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

📄 radeon_maos_arrays.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos_arrays.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ *//**************************************************************************Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and                     Tungsten Graphics Inc., Cedar Park, Texas.All Rights Reserved.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.**************************************************************************//* * Authors: *   Keith Whitwell <keith@tungstengraphics.com> */#include "glheader.h"#include "imports.h"#include "mtypes.h"#include "macros.h"#include "swrast_setup/swrast_setup.h"#include "math/m_translate.h"#include "tnl/tnl.h"#include "tnl/t_context.h"#include "radeon_context.h"#include "radeon_ioctl.h"#include "radeon_state.h"#include "radeon_swtcl.h"#include "radeon_maos.h"#include "radeon_tcl.h"#if 0/* Usage: *   - from radeon_tcl_render *   - call radeonEmitArrays to ensure uptodate arrays in dma *   - emit primitives (new type?) which reference the data *       -- need to use elts for lineloop, quads, quadstrip/flat *       -- other primitives are all well-formed (need tristrip-1,fake-poly) * */static void emit_ubyte_rgba3( GLcontext *ctx,		       struct radeon_dma_region *rvb,		       char *data,		       int stride,		       int count ){   int i;   radeon_color_t *out = (radeon_color_t *)(rvb->start + rvb->address);   if (RADEON_DEBUG & DEBUG_VERTS)      fprintf(stderr, "%s count %d stride %d out %p\n",	      __FUNCTION__, count, stride, (void *)out);   for (i = 0; i < count; i++) {      out->red   = *data;      out->green = *(data+1);      out->blue  = *(data+2);      out->alpha = 0xFF;      out++;      data += stride;   }}static void emit_ubyte_rgba4( GLcontext *ctx,			      struct radeon_dma_region *rvb,			      char *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\n",	      __FUNCTION__, count, stride);   if (stride == 4)       COPY_DWORDS( out, data, count );   else      for (i = 0; i < count; i++) {	 *out++ = LE32_TO_CPU(*(int *)data);	 data += stride;      }}static void emit_ubyte_rgba( GLcontext *ctx,			     struct radeon_dma_region *rvb,			     char *data,			     int size,			     int stride,			     int count ){   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);   if (RADEON_DEBUG & DEBUG_VERTS)      fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);   assert (!rvb->buf);   if (stride == 0) {      radeonAllocDmaRegion( rmesa, rvb, 4, 4 );      count = 1;      rvb->aos_start = GET_START(rvb);      rvb->aos_stride = 0;      rvb->aos_size = 1;   }   else {      radeonAllocDmaRegion( rmesa, rvb, 4 * count, 4 );	/* alignment? */      rvb->aos_start = GET_START(rvb);      rvb->aos_stride = 1;      rvb->aos_size = 1;   }   /* Emit the data    */   switch (size) {   case 3:      emit_ubyte_rgba3( ctx, rvb, data, stride, count );      break;   case 4:      emit_ubyte_rgba4( ctx, rvb, data, stride, count );      break;   default:      assert(0);      exit(1);      break;   }}#endif#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 emit_vecfog( GLcontext *ctx,			 struct radeon_dma_region *rvb,			 char *data,			 int stride,			 int count ){   int i;   GLfloat *out;   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);   if (RADEON_DEBUG & DEBUG_VERTS)      fprintf(stderr, "%s count %d stride %d\n",	      __FUNCTION__, count, stride);   assert (!rvb->buf);   if (stride == 0) {      radeonAllocDmaRegion( rmesa, rvb, 4, 4 );      count = 1;      rvb->aos_start = GET_START(rvb);      rvb->aos_stride = 0;      rvb->aos_size = 1;   }   else {      radeonAllocDmaRegion( rmesa, rvb, count * 4, 4 );	/* alignment? */      rvb->aos_start = GET_START(rvb);      rvb->aos_stride = 1;      rvb->aos_size = 1;   }   /* Emit the data    */   out = (GLfloat *)(rvb->address + rvb->start);   for (i = 0; i < count; i++) {      out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );      out++;      data += stride;   }}static void emit_vec4( GLcontext *ctx,		       struct radeon_dma_region *rvb,		       char *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\n",	      __FUNCTION__, count, stride);   if (stride == 4)      COPY_DWORDS( out, data, count );   else      for (i = 0; i < count; i++) {	 out[0] = *(int *)data;	 out++;	 data += stride;      }}static void emit_vec8( GLcontext *ctx,		       struct radeon_dma_region *rvb,		       char *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\n",	      __FUNCTION__, count, stride);   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 emit_vec12( GLcontext *ctx,		       struct radeon_dma_region *rvb,		       char *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 emit_vec16( GLcontext *ctx,			struct radeon_dma_region *rvb,			char *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\n",	      __FUNCTION__, count, stride);   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 emit_vector( GLcontext *ctx,			 struct radeon_dma_region *rvb,			 char *data,			 int size,			 int stride,			 int count ){   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);   if (RADEON_DEBUG & DEBUG_VERTS)      fprintf(stderr, "%s count %d size %d stride %d\n",	      __FUNCTION__, count, size, stride);   assert (!rvb->buf);   if (stride == 0) {

⌨️ 快捷键说明

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