⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r300_emit.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/*Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.The Weather Channel (TM) funded Tungsten Graphics to develop theinitial release of the Radeon 8500 driver under the XFree86 license.This notice must be preserved.Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice (including thenext paragraph) shall be included in all copies or substantialportions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//** * \file * * \author Keith Whitwell <keith@tungstengraphics.com> */#include "glheader.h"#include "mtypes.h"#include "colormac.h"#include "imports.h"#include "macros.h"#include "image.h"#include "swrast_setup/swrast_setup.h"#include "math/m_translate.h"#include "tnl/tnl.h"#include "tnl/t_context.h"#include "r300_context.h"#include "radeon_ioctl.h"#include "r300_state.h"#include "r300_emit.h"#include "r300_ioctl.h"#ifdef USER_BUFFERS#include "r300_mem.h"#endif#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \    SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \    SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \    SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \    SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \    SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE#error Cannot change these!#endif#define DEBUG_ALL DEBUG_VERTS#if defined(USE_X86_ASM)#define COPY_DWORDS( dst, src, nr )					\do {									\	int __tmp;							\	__asm__ __volatile__( "rep ; movsl"				\			      : "=%c" (__tmp), "=D" (dst), "=S" (__tmp)	\			      : "0" (nr),				\			        "D" ((long)dst),			\			        "S" ((long)src) );			\} while (0)#else#define COPY_DWORDS( dst, src, nr )		\do {						\   int j;					\   for ( j = 0 ; j < nr ; j++ )			\      dst[j] = ((int *)src)[j];			\   dst += nr;					\} while (0)#endifstatic void r300EmitVec4(GLcontext * ctx, struct r300_dma_region *rvb,			 GLvoid * data, int stride, int count){	int i;	int *out = (int *)(rvb->address + rvb->start);	if (RADEON_DEBUG & DEBUG_VERTS)		fprintf(stderr, "%s count %d stride %d out %p data %p\n",			__FUNCTION__, count, stride, (void *)out, (void *)data);	if (stride == 4)		COPY_DWORDS(out, data, count);	else		for (i = 0; i < count; i++) {			out[0] = *(int *)data;			out++;			data += stride;		}}static void r300EmitVec8(GLcontext * ctx, struct r300_dma_region *rvb,			 GLvoid * data, int stride, int count){	int i;	int *out = (int *)(rvb->address + rvb->start);	if (RADEON_DEBUG & DEBUG_VERTS)		fprintf(stderr, "%s count %d stride %d out %p data %p\n",			__FUNCTION__, count, stride, (void *)out, (void *)data);	if (stride == 8)		COPY_DWORDS(out, data, count * 2);	else		for (i = 0; i < count; i++) {			out[0] = *(int *)data;			out[1] = *(int *)(data + 4);			out += 2;			data += stride;		}}static void r300EmitVec12(GLcontext * ctx, struct r300_dma_region *rvb,			  GLvoid * data, int stride, int count){	int i;	int *out = (int *)(rvb->address + rvb->start);	if (RADEON_DEBUG & DEBUG_VERTS)		fprintf(stderr, "%s count %d stride %d out %p data %p\n",			__FUNCTION__, count, stride, (void *)out, (void *)data);	if (stride == 12)		COPY_DWORDS(out, data, count * 3);	else		for (i = 0; i < count; i++) {			out[0] = *(int *)data;			out[1] = *(int *)(data + 4);			out[2] = *(int *)(data + 8);			out += 3;			data += stride;		}}static void r300EmitVec16(GLcontext * ctx, struct r300_dma_region *rvb,			  GLvoid * data, int stride, int count){	int i;	int *out = (int *)(rvb->address + rvb->start);	if (RADEON_DEBUG & DEBUG_VERTS)		fprintf(stderr, "%s count %d stride %d out %p data %p\n",			__FUNCTION__, count, stride, (void *)out, (void *)data);	if (stride == 16)		COPY_DWORDS(out, data, count * 4);	else		for (i = 0; i < count; i++) {			out[0] = *(int *)data;			out[1] = *(int *)(data + 4);			out[2] = *(int *)(data + 8);			out[3] = *(int *)(data + 12);			out += 4;			data += stride;		}}static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,			GLvoid * data, int size, int stride, int count){	r300ContextPtr rmesa = R300_CONTEXT(ctx);	if (stride == 0) {		r300AllocDmaRegion(rmesa, rvb, size * 4, 4);		count = 1;		rvb->aos_offset = GET_START(rvb);		rvb->aos_stride = 0;	} else {		r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4);		rvb->aos_offset = GET_START(rvb);		rvb->aos_stride = size;	}	switch (size) {	case 1:		r300EmitVec4(ctx, rvb, data, stride, count);		break;	case 2:		r300EmitVec8(ctx, rvb, data, stride, count);		break;	case 3:		r300EmitVec12(ctx, rvb, data, stride, count);		break;	case 4:		r300EmitVec16(ctx, rvb, data, stride, count);		break;	default:		assert(0);		break;	}}#define DW_SIZE(x) ((inputs[tab[(x)]] << R300_DST_VEC_LOC_SHIFT) |	\		    (attribptr[tab[(x)]]->size - 1) << R300_DATA_TYPE_0_SHIFT)GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,				 int *inputs, GLint * tab, GLuint nr){	GLuint i, dw;	/* type, inputs, stop bit, size */	for (i = 0; i < nr; i += 2) {		/* make sure input is valid, would lockup the gpu */		assert(inputs[tab[i]] != -1);		dw = (R300_SIGNED | DW_SIZE(i));		if (i + 1 == nr) {			dw |= R300_LAST_VEC << R300_DATA_TYPE_0_SHIFT;		} else {			assert(inputs[tab[i + 1]] != -1);			dw |= (R300_SIGNED |			       DW_SIZE(i + 1)) << R300_DATA_TYPE_1_SHIFT;			if (i + 2 == nr) {				dw |= R300_LAST_VEC << R300_DATA_TYPE_1_SHIFT;			}		}		dst[i >> 1] = dw;	}	return (nr + 1) >> 1;}static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]){	return (swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) |	    (swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) |	    (swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) |	    (swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT);}GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr){	GLuint i, dw;	for (i = 0; i < nr; i += 2) {		dw = (r300VAPInputRoute1Swizzle(swizzle[i]) |		      ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y |			R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT)) << R300_SWIZZLE0_SHIFT;		if (i + 1 < nr) {			dw |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) |			       ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y |				 R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT)) << R300_SWIZZLE1_SHIFT;		}		dst[i >> 1] = dw;	}	return (nr + 1) >> 1;}GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead){	/* No idea what this value means. I have seen other values written to	 * this register... */	return 0x5555;}GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead){	r300ContextPtr rmesa = R300_CONTEXT(ctx);	GLuint i, vic_1 = 0;	if (InputsRead & (1 << VERT_ATTRIB_POS))		vic_1 |= R300_INPUT_CNTL_POS;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -