- Timestamp:
- Oct 26, 2010 11:12:30 AM (14 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL/packer
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c
r15532 r33457 10 10 void PACK_APIENTRY crPackBegin( GLenum mode ) 11 11 { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 12 GET_PACKER_CONTEXT(pc); 13 unsigned char *data_ptr; 14 (void) pc; 15 if (pc->buffer.canBarf) 16 { 17 if (!pc->buffer.holds_BeginEnd) 18 pc->Flush( pc->flush_arg ); 19 pc->buffer.in_BeginEnd = 1; 20 pc->buffer.holds_BeginEnd = 1; 21 } 22 GET_BUFFERED_POINTER( pc, 4 ); 23 pc->current.begin_data = data_ptr; 24 pc->current.begin_op = pc->buffer.opcode_current; 25 pc->current.attribsUsedMask = 0; 26 WRITE_DATA( 0, GLenum, mode ); 27 WRITE_OPCODE( pc, CR_BEGIN_OPCODE ); 28 28 } 29 29 30 30 void PACK_APIENTRY crPackBeginSWAP( GLenum mode ) 31 31 { 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 32 GET_PACKER_CONTEXT(pc); 33 unsigned char *data_ptr; 34 (void) pc; 35 if (pc->buffer.canBarf) 36 { 37 if (!pc->buffer.holds_BeginEnd) 38 pc->Flush( pc->flush_arg ); 39 pc->buffer.in_BeginEnd = 1; 40 pc->buffer.holds_BeginEnd = 1; 41 } 42 GET_BUFFERED_POINTER( pc, 4 ); 43 pc->current.begin_data = data_ptr; 44 pc->current.begin_op = pc->buffer.opcode_current; 45 pc->current.attribsUsedMask = 0; 46 WRITE_DATA( 0, GLenum, SWAP32(mode) ); 47 WRITE_OPCODE( pc, CR_BEGIN_OPCODE ); 48 48 } 49 49 50 50 void PACK_APIENTRY crPackEnd( void ) 51 51 { 52 53 54 55 56 57 52 GET_PACKER_CONTEXT(pc); 53 unsigned char *data_ptr; 54 (void) pc; 55 GET_BUFFERED_POINTER_NO_ARGS( pc ); 56 WRITE_OPCODE( pc, CR_END_OPCODE ); 57 pc->buffer.in_BeginEnd = 0; 58 58 } 59 59 60 60 void PACK_APIENTRY crPackEndSWAP( void ) 61 61 { 62 63 64 65 66 67 62 GET_PACKER_CONTEXT(pc); 63 unsigned char *data_ptr; 64 (void) pc; 65 GET_BUFFERED_POINTER_NO_ARGS( pc ); 66 WRITE_OPCODE( pc, CR_END_OPCODE ); 67 pc->buffer.in_BeginEnd = 0; 68 68 } 69 69 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c
r15532 r33457 11 11 void PACK_APIENTRY crPackBoundsInfoCR( const CRrecti *bounds, const GLbyte *payload, GLint len, GLint num_opcodes ) 12 12 { 13 14 15 13 GET_PACKER_CONTEXT(pc); 14 /* Don't get the buffered_ptr here because we've already 15 * verified that there's enough space for everything. */ 16 16 17 18 19 17 unsigned char *data_ptr = pc->buffer.data_current; 18 int len_aligned = ( len + 0x3 ) & ~0x3; 19 int total_len = 24 + len_aligned; 20 20 21 22 23 24 25 26 21 WRITE_DATA( 0, int, total_len ); 22 WRITE_DATA( 4, int, bounds->x1 ); 23 WRITE_DATA( 8, int, bounds->y1 ); 24 WRITE_DATA( 12, int, bounds->x2 ); 25 WRITE_DATA( 16, int, bounds->y2 ); 26 WRITE_DATA( 20, int, num_opcodes ); 27 27 28 29 28 /* skip the BOUNDSINFO */ 29 data_ptr += 24; 30 30 31 32 33 34 35 36 37 38 31 /* put in padding opcodes (deliberately bogus) */ 32 switch ( len_aligned - len ) 33 { 34 case 3: *data_ptr++ = 0xff; /* FALLTHROUGH */ 35 case 2: *data_ptr++ = 0xff; /* FALLTHROUGH */ 36 case 1: *data_ptr++ = 0xff; /* FALLTHROUGH */ 37 default: break; 38 } 39 39 40 40 crMemcpy( data_ptr, payload, len ); 41 41 42 43 42 WRITE_OPCODE( pc, CR_BOUNDSINFOCR_OPCODE ); 43 pc->buffer.data_current += 24 + len_aligned; 44 44 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_clipplane.c
r15532 r33457 10 10 void PACK_APIENTRY crPackClipPlane( GLenum plane, const GLdouble *equation ) 11 11 { 12 13 14 15 16 17 18 19 20 21 12 GET_PACKER_CONTEXT(pc); 13 unsigned char *data_ptr; 14 int packet_length = sizeof( plane ) + 4*sizeof(*equation); 15 GET_BUFFERED_POINTER(pc, packet_length ); 16 WRITE_DATA( 0, GLenum, plane ); 17 WRITE_DOUBLE( 4, equation[0] ); 18 WRITE_DOUBLE( 12, equation[1] ); 19 WRITE_DOUBLE( 20, equation[2] ); 20 WRITE_DOUBLE( 28, equation[3] ); 21 WRITE_OPCODE( pc, CR_CLIPPLANE_OPCODE ); 22 22 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_error.c
r15532 r33457 17 17 void crPackErrorFunction( CRPackContext *pc, CRPackErrorHandlerFunc function ) 18 18 { 19 19 pc->Error = function; 20 20 } 21 21 … … 27 27 void __PackError( int line, const char *file, GLenum error, const char *info) 28 28 { 29 29 GET_PACKER_CONTEXT(pc); 30 30 31 32 31 if (pc->Error) 32 pc->Error( line, file, error, info ); 33 33 34 35 36 34 if (crGetenv("CR_DEBUG")) 35 { 36 char *glerr; 37 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 38 switch (error) { 39 case GL_NO_ERROR: 40 glerr = "GL_NO_ERROR"; 41 break; 42 case GL_INVALID_VALUE: 43 glerr = "GL_INVALID_VALUE"; 44 break; 45 case GL_INVALID_ENUM: 46 glerr = "GL_INVALID_ENUM"; 47 break; 48 case GL_INVALID_OPERATION: 49 glerr = "GL_INVALID_OPERATION"; 50 break; 51 case GL_STACK_OVERFLOW: 52 glerr = "GL_STACK_OVERFLOW"; 53 break; 54 case GL_STACK_UNDERFLOW: 55 glerr = "GL_STACK_UNDERFLOW"; 56 break; 57 case GL_OUT_OF_MEMORY: 58 glerr = "GL_OUT_OF_MEMORY"; 59 break; 60 case GL_TABLE_TOO_LARGE: 61 glerr = "GL_TABLE_TOO_LARGE"; 62 break; 63 default: 64 glerr = "unknown"; 65 break; 66 } 67 67 68 69 70 68 crWarning( "GL error in packer: %s, line %d: %s: %s", 69 file, line, glerr, info ); 70 } 71 71 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_extensions.c
r15532 r33457 11 11 int __packTexParameterNumParams( GLenum param ) 12 12 { 13 14 13 switch( param ) 14 { 15 15 #ifdef CR_EXT_texture_filter_anisotropic 16 17 16 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 17 return 1; 18 18 #endif 19 20 21 22 19 default: 20 break; 21 } 22 return 0; 23 23 } 24 24 25 25 int __packFogParamsLength( GLenum param ) 26 26 { 27 27 static int one_param = sizeof( GLfloat ); 28 28 (void) one_param; 29 30 29 switch( param ) 30 { 31 31 #ifdef CR_NV_fog_distance 32 33 32 case GL_FOG_DISTANCE_MODE_NV: 33 return one_param; 34 34 #endif 35 36 37 38 35 default: 36 break; 37 } 38 return 0; 39 39 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c
r15532 r33457 10 10 void PACK_APIENTRY crPackFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) 11 11 { 12 13 14 12 (void) size; 13 (void) type; 14 (void) buffer; 15 15 16 17 16 crWarning("Packer wont pass FeedbackBuffer()\n"); 17 crWarning("Try using the feedbackspu\n"); 18 18 } 19 19 20 20 void PACK_APIENTRY crPackFeedbackBufferSWAP( GLsizei size, GLenum type, GLfloat *buffer ) 21 21 { 22 23 24 22 (void) size; 23 (void) type; 24 (void) buffer; 25 25 26 27 26 crWarning("Packer wont pass FeedbackBuffer()\n"); 27 crWarning("Try using the feedbackspu\n"); 28 28 } 29 29 30 30 void PACK_APIENTRY crPackSelectBuffer( GLsizei size, GLuint *buffer ) 31 31 { 32 33 32 (void) size; 33 (void) buffer; 34 34 35 36 35 crWarning("Packer wont pass SelectBuffer()\n"); 36 crWarning("Try using the feedbackspu\n"); 37 37 } 38 38 39 39 void PACK_APIENTRY crPackSelectBufferSWAP( GLsizei size, GLuint *buffer ) 40 40 { 41 42 41 (void) size; 42 (void) buffer; 43 43 44 45 44 crWarning("Packer wont pass SelectBuffer()\n"); 45 crWarning("Try using the feedbackspu\n"); 46 46 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_fence.c
r15532 r33457 10 10 crPackDeleteFencesNV(GLsizei n, const GLuint * fences) 11 11 { 12 13 12 unsigned char *data_ptr; 13 int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences); 14 14 15 16 15 if( !fences ) 16 return; 17 17 18 19 20 21 22 23 18 data_ptr = (unsigned char *) crPackAlloc(packet_length); 19 WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE); 20 WRITE_DATA(4, GLsizei, n); 21 crMemcpy(data_ptr + 8, fences, n * sizeof(*fences)); 22 crHugePacket(CR_EXTEND_OPCODE, data_ptr); 23 crPackFree(data_ptr); 24 24 } 25 25 26 26 void PACK_APIENTRY crPackDeleteFencesNVSWAP( GLsizei n, const GLuint *fences ) 27 27 { 28 29 30 28 unsigned char *data_ptr; 29 int i; 30 int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences); 31 31 32 33 32 if( !fences ) 33 return; 34 34 35 36 37 38 39 40 41 42 43 35 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 36 WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE); 37 WRITE_DATA(4, GLsizei, n); 38 for (i = 0 ; i < n ; i++) 39 { 40 WRITE_DATA(i*sizeof(GLuint) + 8, GLuint, SWAP32(fences[i])); 41 } 42 crHugePacket(CR_EXTEND_OPCODE, data_ptr); 43 crPackFree(data_ptr); 44 44 } 45 45 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_fog.c
r15532 r33457 10 10 static GLboolean __handleFogData( GLenum pname, const GLfloat *params ) 11 11 { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 12 GET_PACKER_CONTEXT(pc); 13 int params_length = 0; 14 int packet_length = sizeof( int ) + sizeof( pname ); 15 unsigned char *data_ptr; 16 switch( pname ) 17 { 18 case GL_FOG_MODE: 19 case GL_FOG_DENSITY: 20 case GL_FOG_START: 21 case GL_FOG_END: 22 case GL_FOG_INDEX: 23 params_length = sizeof( *params ); 24 break; 25 case GL_FOG_COLOR: 26 params_length = 4*sizeof( *params ); 27 break; 28 default: 29 params_length = __packFogParamsLength( pname ); 30 if (!params_length) 31 { 32 char msg[100]; 33 sprintf(msg, "Invalid pname in Fog: %d", (int) pname ); 34 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); 35 return GL_FALSE; 36 } 37 break; 38 } 39 packet_length += params_length; 40 40 41 42 43 44 45 46 47 48 49 50 51 41 GET_BUFFERED_POINTER(pc, packet_length ); 42 WRITE_DATA( 0, int, packet_length ); 43 WRITE_DATA( 4, GLenum, pname ); 44 WRITE_DATA( 8, GLfloat, params[0] ); 45 if (packet_length > 12) 46 { 47 WRITE_DATA( 12, GLfloat, params[1] ); 48 WRITE_DATA( 16, GLfloat, params[2] ); 49 WRITE_DATA( 20, GLfloat, params[3] ); 50 } 51 return GL_TRUE; 52 52 } 53 53 54 54 void PACK_APIENTRY crPackFogfv(GLenum pname, const GLfloat *params) 55 55 { 56 57 58 56 GET_PACKER_CONTEXT(pc); 57 if (__handleFogData( pname, params )) 58 WRITE_OPCODE( pc, CR_FOGFV_OPCODE ); 59 59 } 60 60 61 61 void PACK_APIENTRY crPackFogiv(GLenum pname, const GLint *params) 62 62 { 63 64 65 66 63 GET_PACKER_CONTEXT(pc); 64 /* floats and ints are the same size, so the packing should be the same */ 65 if (__handleFogData( pname, (const GLfloat *) params )) 66 WRITE_OPCODE( pc, CR_FOGIV_OPCODE ); 67 67 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_lights.c
r15532 r33457 10 10 static GLboolean __handleLightData( GLenum light, GLenum pname, const GLfloat *params ) 11 11 { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 12 GET_PACKER_CONTEXT(pc); 13 unsigned int packet_length = sizeof( int ) + sizeof( light ) + sizeof( pname ); 14 unsigned int params_length = 0; 15 unsigned char *data_ptr; 16 switch( pname ) 17 { 18 case GL_AMBIENT: 19 case GL_DIFFUSE: 20 case GL_SPECULAR: 21 case GL_POSITION: 22 params_length = 4*sizeof( *params ); 23 break; 24 case GL_SPOT_DIRECTION: 25 params_length = 3*sizeof( *params ); 26 break; 27 case GL_SPOT_EXPONENT: 28 case GL_SPOT_CUTOFF: 29 case GL_CONSTANT_ATTENUATION: 30 case GL_LINEAR_ATTENUATION: 31 case GL_QUADRATIC_ATTENUATION: 32 params_length = sizeof( *params ); 33 break; 34 default: 35 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 36 "crPackLight(bad pname)" ); 37 return GL_FALSE; 38 } 39 packet_length += params_length; 40 GET_BUFFERED_POINTER(pc, packet_length ); 41 WRITE_DATA( 0, int, packet_length ); 42 WRITE_DATA( sizeof( int ) + 0, GLenum, light ); 43 WRITE_DATA( sizeof( int ) + 4, GLenum, pname ); 44 WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] ); 45 if (params_length > sizeof( *params )) 46 { 47 WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] ); 48 WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] ); 49 } 50 if (params_length > 3*sizeof( *params )) 51 { 52 WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] ); 53 } 54 return GL_TRUE; 55 55 } 56 56 57 57 void PACK_APIENTRY crPackLightfv (GLenum light, GLenum pname, const GLfloat *params) 58 58 { 59 60 61 59 GET_PACKER_CONTEXT(pc); 60 if (__handleLightData( light, pname, params )) 61 WRITE_OPCODE( pc, CR_LIGHTFV_OPCODE ); 62 62 } 63 63 64 64 void PACK_APIENTRY crPackLightiv (GLenum light, GLenum pname, const GLint *params) 65 65 { 66 67 68 69 66 /* floats and ints are the same size, so the packing should be the same */ 67 GET_PACKER_CONTEXT(pc); 68 if (__handleLightData( light, pname, (const GLfloat *) params )) 69 WRITE_OPCODE( pc, CR_LIGHTIV_OPCODE ); 70 70 } 71 71 72 72 static GLboolean __handleLightModelData( GLenum pname, const GLfloat *params ) 73 73 { 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 74 GET_PACKER_CONTEXT(pc); 75 unsigned int packet_length = sizeof( int ) + sizeof( pname ); 76 unsigned int params_length = 0; 77 unsigned char *data_ptr; 78 switch( pname ) 79 { 80 case GL_LIGHT_MODEL_AMBIENT: 81 params_length = 4*sizeof( *params ); 82 break; 83 case GL_LIGHT_MODEL_TWO_SIDE: 84 case GL_LIGHT_MODEL_LOCAL_VIEWER: 85 params_length = sizeof( *params ); 86 break; 87 default: 88 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 89 "crPackLightModel(bad pname)" ); 90 return GL_FALSE; 91 } 92 packet_length += params_length; 93 GET_BUFFERED_POINTER(pc, packet_length ); 94 WRITE_DATA( 0, int, packet_length ); 95 WRITE_DATA( sizeof( int ) + 0, GLenum, pname ); 96 WRITE_DATA( sizeof( int ) + 4, GLfloat, params[0] ); 97 if (params_length > sizeof( *params )) 98 { 99 WRITE_DATA( sizeof( int ) + 8, GLfloat, params[1] ); 100 WRITE_DATA( sizeof( int ) + 12, GLfloat, params[2] ); 101 WRITE_DATA( sizeof( int ) + 16, GLfloat, params[3] ); 102 } 103 return GL_TRUE; 104 104 } 105 105 106 106 void PACK_APIENTRY crPackLightModelfv (GLenum pname, const GLfloat *params) 107 107 { 108 109 110 108 GET_PACKER_CONTEXT(pc); 109 if (__handleLightModelData( pname, params )) 110 WRITE_OPCODE( pc, CR_LIGHTMODELFV_OPCODE ); 111 111 } 112 112 113 113 void PACK_APIENTRY crPackLightModeliv (GLenum pname, const GLint *params) 114 114 { 115 116 117 118 115 /* floats and ints are the same size, so the packing should be the same */ 116 GET_PACKER_CONTEXT(pc); 117 if (__handleLightModelData( pname, (const GLfloat *) params )) 118 WRITE_OPCODE( pc, CR_LIGHTMODELIV_OPCODE ); 119 119 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_lists.c
r15532 r33457 11 11 static int __gl_CallListsNumBytes( GLenum type ) 12 12 { 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 13 switch( type ) 14 { 15 case GL_BYTE: 16 case GL_UNSIGNED_BYTE: 17 case GL_2_BYTES: 18 return 1; 19 case GL_SHORT: 20 case GL_UNSIGNED_SHORT: 21 case GL_3_BYTES: 22 return 2; 23 case GL_INT: 24 case GL_UNSIGNED_INT: 25 case GL_FLOAT: 26 case GL_4_BYTES: 27 return 4; 28 default: 29 return -1; 30 } 31 31 } 32 32 33 33 void PACK_APIENTRY crPackCallLists(GLint n, GLenum type, 34 34 const GLvoid *lists ) 35 35 { 36 37 36 unsigned char *data_ptr; 37 int packet_length; 38 38 39 40 41 42 43 44 45 39 int num_bytes = __gl_CallListsNumBytes( type ) * n; 40 if (num_bytes < 0) 41 { 42 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 43 "crPackCallLists(bad type)" ); 44 return; 45 } 46 46 47 48 49 50 47 packet_length = 48 sizeof( n ) + 49 sizeof( type ) + 50 num_bytes; 51 51 52 53 54 55 52 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 53 WRITE_DATA( 0, GLint, n ); 54 WRITE_DATA( 4, GLenum, type ); 55 crMemcpy( data_ptr + 8, lists, num_bytes ); 56 56 57 57 crHugePacket( CR_CALLLISTS_OPCODE, data_ptr ); 58 58 crPackFree( data_ptr ); 59 59 } … … 63 63 void PACK_APIENTRY crPackNewList( GLuint list, GLenum mode ) 64 64 { 65 66 67 68 69 70 71 72 73 74 75 65 GET_PACKER_CONTEXT(pc); 66 unsigned char *data_ptr; 67 (void) pc; 68 GET_BUFFERED_POINTER( pc, 16 ); 69 WRITE_DATA( 0, GLint, 16 ); 70 WRITE_DATA( 4, GLenum, CR_NEWLIST_EXTEND_OPCODE ); 71 WRITE_DATA( 8, GLuint, list ); 72 WRITE_DATA( 12, GLenum, mode ); 73 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 74 pc->buffer.in_List = GL_TRUE; 75 pc->buffer.holds_List = GL_TRUE; 76 76 } 77 77 78 78 void PACK_APIENTRY crPackEndList( void ) 79 79 { 80 81 82 83 84 85 86 80 GET_PACKER_CONTEXT(pc); 81 unsigned char *data_ptr; 82 GET_BUFFERED_POINTER( pc, 8 ); 83 WRITE_DATA( 0, GLint, 8 ); 84 WRITE_DATA( 4, GLenum, CR_ENDLIST_EXTEND_OPCODE ); 85 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 86 pc->buffer.in_List = GL_FALSE; 87 87 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_map.c
r15532 r33457 16 16 static int __gl_Map2NumComponents( GLenum target ) 17 17 { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 18 switch( target ) 19 { 20 case GL_MAP2_VERTEX_3: 21 case GL_MAP2_NORMAL: 22 case GL_MAP2_TEXTURE_COORD_3: 23 return 3; 24 case GL_MAP2_VERTEX_4: 25 case GL_MAP2_COLOR_4: 26 case GL_MAP2_TEXTURE_COORD_4: 27 case GL_MAP1_VERTEX_ATTRIB0_4_NV: 28 case GL_MAP1_VERTEX_ATTRIB1_4_NV: 29 case GL_MAP1_VERTEX_ATTRIB2_4_NV: 30 case GL_MAP1_VERTEX_ATTRIB3_4_NV: 31 case GL_MAP1_VERTEX_ATTRIB4_4_NV: 32 case GL_MAP1_VERTEX_ATTRIB5_4_NV: 33 case GL_MAP1_VERTEX_ATTRIB6_4_NV: 34 case GL_MAP1_VERTEX_ATTRIB7_4_NV: 35 case GL_MAP1_VERTEX_ATTRIB8_4_NV: 36 case GL_MAP1_VERTEX_ATTRIB9_4_NV: 37 case GL_MAP1_VERTEX_ATTRIB10_4_NV: 38 case GL_MAP1_VERTEX_ATTRIB11_4_NV: 39 case GL_MAP1_VERTEX_ATTRIB12_4_NV: 40 case GL_MAP1_VERTEX_ATTRIB13_4_NV: 41 case GL_MAP1_VERTEX_ATTRIB14_4_NV: 42 case GL_MAP1_VERTEX_ATTRIB15_4_NV: 43 case GL_MAP2_VERTEX_ATTRIB0_4_NV: 44 case GL_MAP2_VERTEX_ATTRIB1_4_NV: 45 case GL_MAP2_VERTEX_ATTRIB2_4_NV: 46 case GL_MAP2_VERTEX_ATTRIB3_4_NV: 47 case GL_MAP2_VERTEX_ATTRIB4_4_NV: 48 case GL_MAP2_VERTEX_ATTRIB5_4_NV: 49 case GL_MAP2_VERTEX_ATTRIB6_4_NV: 50 case GL_MAP2_VERTEX_ATTRIB7_4_NV: 51 case GL_MAP2_VERTEX_ATTRIB8_4_NV: 52 case GL_MAP2_VERTEX_ATTRIB9_4_NV: 53 case GL_MAP2_VERTEX_ATTRIB10_4_NV: 54 case GL_MAP2_VERTEX_ATTRIB11_4_NV: 55 case GL_MAP2_VERTEX_ATTRIB12_4_NV: 56 case GL_MAP2_VERTEX_ATTRIB13_4_NV: 57 case GL_MAP2_VERTEX_ATTRIB14_4_NV: 58 case GL_MAP2_VERTEX_ATTRIB15_4_NV: 59 return 4; 60 case GL_MAP2_INDEX: 61 case GL_MAP2_TEXTURE_COORD_1: 62 return 1; 63 case GL_MAP2_TEXTURE_COORD_2: 64 return 2; 65 default: 66 return -1; 67 } 68 68 } 69 69 70 70 static int __gl_Map1NumComponents( GLenum target ) 71 71 { 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 72 switch( target ) 73 { 74 case GL_MAP1_VERTEX_3: 75 case GL_MAP1_NORMAL: 76 case GL_MAP1_TEXTURE_COORD_3: 77 return 3; 78 case GL_MAP1_VERTEX_4: 79 case GL_MAP1_COLOR_4: 80 case GL_MAP1_TEXTURE_COORD_4: 81 return 4; 82 case GL_MAP1_INDEX: 83 case GL_MAP1_TEXTURE_COORD_1: 84 return 1; 85 case GL_MAP1_TEXTURE_COORD_2: 86 return 2; 87 default: 88 return -1; 89 } 90 90 } 91 91 92 92 void PACK_APIENTRY crPackMap2d(GLenum target, GLdouble u1, 93 94 95 { 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 93 GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, 94 GLint vstride, GLint vorder, const GLdouble *points) 95 { 96 unsigned char *data_ptr; 97 int u,v; 98 GLdouble *dest_data, *src_data; 99 int packet_length = 100 sizeof( target ) + 101 sizeof( u1 ) + 102 sizeof( u2 ) + 103 sizeof( uorder ) + 104 sizeof( ustride ) + 105 sizeof( v1 ) + 106 sizeof( v2 ) + 107 sizeof( vorder ) + 108 sizeof( vstride ); 109 110 int num_components = __gl_Map2NumComponents( target ); 111 if (num_components < 0) 112 { 113 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 114 "crPackMap2d(bad target)" ); 115 return; 116 } 117 118 packet_length += num_components*uorder*vorder*sizeof( *points ); 119 120 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 121 122 WRITE_DATA( 0, GLenum, target ); 123 WRITE_DOUBLE( 4, u1 ); 124 WRITE_DOUBLE( 12, u2 ); 125 WRITE_DATA( 20, GLint, num_components ); 126 WRITE_DATA( 24, GLint, uorder ); 127 WRITE_DOUBLE( 28, v1 ); 128 WRITE_DOUBLE( 36, v2 ); 129 WRITE_DATA( 44, GLint, num_components*uorder ); 130 WRITE_DATA( 48, GLint, vorder ); 131 132 dest_data = (GLdouble *) (data_ptr + 52); 133 src_data = (GLdouble *) points; 134 for (v = 0 ; v < vorder ; v++) 135 { 136 for (u = 0 ; u < uorder ; u++) 137 { 138 crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); 139 dest_data += num_components; 140 src_data += ustride; 141 } 142 src_data += vstride - ustride*uorder; 143 } 144 145 crHugePacket( CR_MAP2D_OPCODE, data_ptr ); 146 146 crPackFree( data_ptr ); 147 147 } 148 148 149 149 void PACK_APIENTRY crPackMap2f(GLenum target, GLfloat u1, 150 151 152 { 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 150 GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, 151 GLint vstride, GLint vorder, const GLfloat *points) 152 { 153 unsigned char *data_ptr; 154 int u,v; 155 GLfloat *dest_data, *src_data; 156 int packet_length = 157 sizeof( target ) + 158 sizeof( u1 ) + 159 sizeof( u2 ) + 160 sizeof( uorder ) + 161 sizeof( ustride ) + 162 sizeof( v1 ) + 163 sizeof( v2 ) + 164 sizeof( vorder ) + 165 sizeof( vstride ); 166 167 int num_components = __gl_Map2NumComponents( target ); 168 if (num_components < 0) 169 { 170 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 171 "crPackMap2f(bad target)" ); 172 return; 173 } 174 175 packet_length += num_components*uorder*vorder*sizeof( *points ); 176 177 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 178 179 WRITE_DATA( 0, GLenum, target ); 180 WRITE_DATA( 4, GLfloat, u1 ); 181 WRITE_DATA( 8, GLfloat, u2 ); 182 WRITE_DATA( 12, GLint, num_components ); 183 WRITE_DATA( 16, GLint, uorder ); 184 WRITE_DATA( 20, GLfloat, v1 ); 185 WRITE_DATA( 24, GLfloat, v2 ); 186 WRITE_DATA( 28, GLint, num_components*uorder ); 187 WRITE_DATA( 32, GLint, vorder ); 188 189 dest_data = (GLfloat *) (data_ptr + 36); 190 src_data = (GLfloat *) points; 191 for (v = 0 ; v < vorder ; v++) 192 { 193 for (u = 0 ; u < uorder ; u++) 194 { 195 crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); 196 dest_data += num_components; 197 src_data += ustride; 198 } 199 src_data += vstride - ustride*uorder; 200 } 201 202 crHugePacket( CR_MAP2F_OPCODE, data_ptr ); 203 203 crPackFree( data_ptr ); 204 204 } 205 205 206 206 void PACK_APIENTRY crPackMap1d( GLenum target, GLdouble u1, 207 208 { 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 207 GLdouble u2, GLint stride, GLint order, const GLdouble *points ) 208 { 209 unsigned char *data_ptr; 210 int packet_length = 211 sizeof( target ) + 212 sizeof( u1 ) + 213 sizeof( u2 ) + 214 sizeof( stride ) + 215 sizeof( order ); 216 217 int num_components = __gl_Map1NumComponents( target ); 218 GLdouble *src_data, *dest_data; 219 int u; 220 221 if (num_components < 0) 222 { 223 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 224 "crPackMap1d(bad target)" ); 225 return; 226 } 227 228 packet_length += num_components * order * sizeof( *points ); 229 230 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 231 232 WRITE_DATA( 0, GLenum, target ); 233 WRITE_DOUBLE( 4, u1 ); 234 WRITE_DOUBLE( 12, u2 ); 235 WRITE_DATA( 20, GLint, num_components ); 236 WRITE_DATA( 24, GLint, order ); 237 238 dest_data = (GLdouble *) (data_ptr + 28); 239 src_data = (GLdouble *) points; 240 for (u = 0 ; u < order ; u++) 241 { 242 crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); 243 dest_data += num_components; 244 src_data += stride; 245 } 246 247 crHugePacket( CR_MAP1D_OPCODE, data_ptr ); 248 248 crPackFree( data_ptr ); 249 249 } 250 250 251 251 void PACK_APIENTRY crPackMap1f( GLenum target, GLfloat u1, 252 253 { 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 crPackFree( data_ptr ); 294 } 252 GLfloat u2, GLint stride, GLint order, const GLfloat *points ) 253 { 254 unsigned char *data_ptr; 255 int packet_length = 256 sizeof( target ) + 257 sizeof( u1 ) + 258 sizeof( u2 ) + 259 sizeof( stride ) + 260 sizeof( order ); 261 262 int num_components = __gl_Map1NumComponents( target ); 263 GLfloat *src_data, *dest_data; 264 int u; 265 266 if (num_components < 0) 267 { 268 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 269 "crPackMap1f(bad target)" ); 270 return; 271 } 272 273 packet_length += num_components * order * sizeof( *points ); 274 275 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 276 277 WRITE_DATA( 0, GLenum, target ); 278 WRITE_DATA( 4, GLfloat, u1 ); 279 WRITE_DATA( 8, GLfloat, u2 ); 280 WRITE_DATA( 12, GLint, num_components ); 281 WRITE_DATA( 16, GLint, order ); 282 283 dest_data = (GLfloat *) (data_ptr + 20); 284 src_data = (GLfloat *) points; 285 for (u = 0 ; u < order ; u++) 286 { 287 crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); 288 dest_data += num_components; 289 src_data += stride; 290 } 291 292 crHugePacket( CR_MAP1F_OPCODE, data_ptr ); 293 crPackFree( data_ptr ); 294 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_materials.c
r15532 r33457 10 10 static void __handleMaterialData( GLenum face, GLenum pname, const GLfloat *params ) 11 11 { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 12 GET_PACKER_CONTEXT(pc); 13 unsigned int packet_length = sizeof( int ) + sizeof( face ) + sizeof( pname ); 14 unsigned int params_length = 0; 15 unsigned char *data_ptr; 16 switch( pname ) 17 { 18 case GL_AMBIENT: 19 case GL_DIFFUSE: 20 case GL_SPECULAR: 21 case GL_EMISSION: 22 case GL_AMBIENT_AND_DIFFUSE: 23 params_length = 4*sizeof( *params ); 24 break; 25 case GL_COLOR_INDEXES: 26 params_length = 3*sizeof( *params ); 27 break; 28 case GL_SHININESS: 29 params_length = sizeof( *params ); 30 break; 31 default: 32 __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterial(pname)"); 33 return; 34 } 35 packet_length += params_length; 36 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 37 GET_BUFFERED_POINTER(pc, packet_length ); 38 WRITE_DATA( 0, int, packet_length ); 39 WRITE_DATA( sizeof( int ) + 0, GLenum, face ); 40 WRITE_DATA( sizeof( int ) + 4, GLenum, pname ); 41 WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] ); 42 if (params_length > sizeof( *params )) 43 { 44 WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] ); 45 WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] ); 46 } 47 if (packet_length > 3*sizeof( *params ) ) 48 { 49 WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] ); 50 } 51 51 } 52 52 53 53 void PACK_APIENTRY crPackMaterialfv(GLenum face, GLenum pname, const GLfloat *params) 54 54 { 55 56 57 55 GET_PACKER_CONTEXT(pc); 56 __handleMaterialData( face, pname, params ); 57 WRITE_OPCODE( pc, CR_MATERIALFV_OPCODE ); 58 58 } 59 59 60 60 void PACK_APIENTRY crPackMaterialiv(GLenum face, GLenum pname, const GLint *params) 61 61 { 62 63 64 65 62 /* floats and ints are the same size, so the packing should be the same */ 63 GET_PACKER_CONTEXT(pc); 64 __handleMaterialData( face, pname, (const GLfloat *) params ); 65 WRITE_OPCODE( pc, CR_MATERIALIV_OPCODE ); 66 66 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c
r15532 r33457 10 10 void PACK_APIENTRY crPackMultMatrixd( const GLdouble *m ) 11 11 { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 12 GET_PACKER_CONTEXT(pc); 13 unsigned char *data_ptr; 14 int packet_length = 16*sizeof( *m ); 15 GET_BUFFERED_POINTER(pc, packet_length ); 16 WRITE_DOUBLE( 0*sizeof(double), m[ 0] ); 17 WRITE_DOUBLE( 1*sizeof(double), m[ 1] ); 18 WRITE_DOUBLE( 2*sizeof(double), m[ 2] ); 19 WRITE_DOUBLE( 3*sizeof(double), m[ 3] ); 20 WRITE_DOUBLE( 4*sizeof(double), m[ 4] ); 21 WRITE_DOUBLE( 5*sizeof(double), m[ 5] ); 22 WRITE_DOUBLE( 6*sizeof(double), m[ 6] ); 23 WRITE_DOUBLE( 7*sizeof(double), m[ 7] ); 24 WRITE_DOUBLE( 8*sizeof(double), m[ 8] ); 25 WRITE_DOUBLE( 9*sizeof(double), m[ 9] ); 26 WRITE_DOUBLE( 10*sizeof(double), m[10] ); 27 WRITE_DOUBLE( 11*sizeof(double), m[11] ); 28 WRITE_DOUBLE( 12*sizeof(double), m[12] ); 29 WRITE_DOUBLE( 13*sizeof(double), m[13] ); 30 WRITE_DOUBLE( 14*sizeof(double), m[14] ); 31 WRITE_DOUBLE( 15*sizeof(double), m[15] ); 32 WRITE_OPCODE( pc, CR_MULTMATRIXD_OPCODE ); 33 33 } 34 34 35 35 void PACK_APIENTRY crPackMultMatrixf( const GLfloat *m ) 36 36 { 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 37 GET_PACKER_CONTEXT(pc); 38 unsigned char *data_ptr; 39 int packet_length = 16*sizeof( *m ); 40 GET_BUFFERED_POINTER(pc, packet_length ); 41 WRITE_DATA( 0*sizeof(GLfloat), GLfloat, m[ 0] ); 42 WRITE_DATA( 1*sizeof(GLfloat), GLfloat, m[ 1] ); 43 WRITE_DATA( 2*sizeof(GLfloat), GLfloat, m[ 2] ); 44 WRITE_DATA( 3*sizeof(GLfloat), GLfloat, m[ 3] ); 45 WRITE_DATA( 4*sizeof(GLfloat), GLfloat, m[ 4] ); 46 WRITE_DATA( 5*sizeof(GLfloat), GLfloat, m[ 5] ); 47 WRITE_DATA( 6*sizeof(GLfloat), GLfloat, m[ 6] ); 48 WRITE_DATA( 7*sizeof(GLfloat), GLfloat, m[ 7] ); 49 WRITE_DATA( 8*sizeof(GLfloat), GLfloat, m[ 8] ); 50 WRITE_DATA( 9*sizeof(GLfloat), GLfloat, m[ 9] ); 51 WRITE_DATA( 10*sizeof(GLfloat), GLfloat, m[10] ); 52 WRITE_DATA( 11*sizeof(GLfloat), GLfloat, m[11] ); 53 WRITE_DATA( 12*sizeof(GLfloat), GLfloat, m[12] ); 54 WRITE_DATA( 13*sizeof(GLfloat), GLfloat, m[13] ); 55 WRITE_DATA( 14*sizeof(GLfloat), GLfloat, m[14] ); 56 WRITE_DATA( 15*sizeof(GLfloat), GLfloat, m[15] ); 57 WRITE_OPCODE( pc, CR_MULTMATRIXF_OPCODE ); 58 58 } 59 59 60 60 void PACK_APIENTRY crPackLoadMatrixd( const GLdouble *m ) 61 61 { 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 62 GET_PACKER_CONTEXT(pc); 63 unsigned char *data_ptr; 64 int packet_length = 16*sizeof( *m ); 65 GET_BUFFERED_POINTER(pc, packet_length ); 66 WRITE_DOUBLE( 0*sizeof(double), m[ 0] ); 67 WRITE_DOUBLE( 1*sizeof(double), m[ 1] ); 68 WRITE_DOUBLE( 2*sizeof(double), m[ 2] ); 69 WRITE_DOUBLE( 3*sizeof(double), m[ 3] ); 70 WRITE_DOUBLE( 4*sizeof(double), m[ 4] ); 71 WRITE_DOUBLE( 5*sizeof(double), m[ 5] ); 72 WRITE_DOUBLE( 6*sizeof(double), m[ 6] ); 73 WRITE_DOUBLE( 7*sizeof(double), m[ 7] ); 74 WRITE_DOUBLE( 8*sizeof(double), m[ 8] ); 75 WRITE_DOUBLE( 9*sizeof(double), m[ 9] ); 76 WRITE_DOUBLE( 10*sizeof(double), m[10] ); 77 WRITE_DOUBLE( 11*sizeof(double), m[11] ); 78 WRITE_DOUBLE( 12*sizeof(double), m[12] ); 79 WRITE_DOUBLE( 13*sizeof(double), m[13] ); 80 WRITE_DOUBLE( 14*sizeof(double), m[14] ); 81 WRITE_DOUBLE( 15*sizeof(double), m[15] ); 82 WRITE_OPCODE( pc, CR_LOADMATRIXD_OPCODE ); 83 83 } 84 84 85 85 void PACK_APIENTRY crPackLoadMatrixf( const GLfloat *m ) 86 86 { 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 87 GET_PACKER_CONTEXT(pc); 88 unsigned char *data_ptr; 89 int packet_length = 16*sizeof( *m ); 90 GET_BUFFERED_POINTER(pc, packet_length ); 91 WRITE_DATA( 0*sizeof(GLfloat), GLfloat, m[ 0] ); 92 WRITE_DATA( 1*sizeof(GLfloat), GLfloat, m[ 1] ); 93 WRITE_DATA( 2*sizeof(GLfloat), GLfloat, m[ 2] ); 94 WRITE_DATA( 3*sizeof(GLfloat), GLfloat, m[ 3] ); 95 WRITE_DATA( 4*sizeof(GLfloat), GLfloat, m[ 4] ); 96 WRITE_DATA( 5*sizeof(GLfloat), GLfloat, m[ 5] ); 97 WRITE_DATA( 6*sizeof(GLfloat), GLfloat, m[ 6] ); 98 WRITE_DATA( 7*sizeof(GLfloat), GLfloat, m[ 7] ); 99 WRITE_DATA( 8*sizeof(GLfloat), GLfloat, m[ 8] ); 100 WRITE_DATA( 9*sizeof(GLfloat), GLfloat, m[ 9] ); 101 WRITE_DATA( 10*sizeof(GLfloat), GLfloat, m[10] ); 102 WRITE_DATA( 11*sizeof(GLfloat), GLfloat, m[11] ); 103 WRITE_DATA( 12*sizeof(GLfloat), GLfloat, m[12] ); 104 WRITE_DATA( 13*sizeof(GLfloat), GLfloat, m[13] ); 105 WRITE_DATA( 14*sizeof(GLfloat), GLfloat, m[14] ); 106 WRITE_DATA( 15*sizeof(GLfloat), GLfloat, m[15] ); 107 WRITE_OPCODE( pc, CR_LOADMATRIXF_OPCODE ); 108 108 } 109 109 110 110 void PACK_APIENTRY crPackMultTransposeMatrixdARB( const GLdouble *m ) 111 111 { 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 112 GET_PACKER_CONTEXT(pc); 113 unsigned char *data_ptr; 114 int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum); 115 GET_BUFFERED_POINTER(pc, packet_length ); 116 WRITE_DATA( 0, GLint, packet_length ); 117 WRITE_DATA( 4, GLenum, CR_MULTTRANSPOSEMATRIXDARB_EXTEND_OPCODE ); 118 WRITE_DOUBLE( 8 + 0*sizeof(double), m[ 0] ); 119 WRITE_DOUBLE( 8 + 1*sizeof(double), m[ 1] ); 120 WRITE_DOUBLE( 8 + 2*sizeof(double), m[ 2] ); 121 WRITE_DOUBLE( 8 + 3*sizeof(double), m[ 3] ); 122 WRITE_DOUBLE( 8 + 4*sizeof(double), m[ 4] ); 123 WRITE_DOUBLE( 8 + 5*sizeof(double), m[ 5] ); 124 WRITE_DOUBLE( 8 + 6*sizeof(double), m[ 6] ); 125 WRITE_DOUBLE( 8 + 7*sizeof(double), m[ 7] ); 126 WRITE_DOUBLE( 8 + 8*sizeof(double), m[ 8] ); 127 WRITE_DOUBLE( 8 + 9*sizeof(double), m[ 9] ); 128 WRITE_DOUBLE( 8 + 10*sizeof(double), m[10] ); 129 WRITE_DOUBLE( 8 + 11*sizeof(double), m[11] ); 130 WRITE_DOUBLE( 8 + 12*sizeof(double), m[12] ); 131 WRITE_DOUBLE( 8 + 13*sizeof(double), m[13] ); 132 WRITE_DOUBLE( 8 + 14*sizeof(double), m[14] ); 133 WRITE_DOUBLE( 8 + 15*sizeof(double), m[15] ); 134 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 135 135 } 136 136 137 137 void PACK_APIENTRY crPackMultTransposeMatrixfARB( const GLfloat *m ) 138 138 { 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 139 GET_PACKER_CONTEXT(pc); 140 unsigned char *data_ptr; 141 int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum); 142 GET_BUFFERED_POINTER(pc, packet_length ); 143 WRITE_DATA( 0, GLint, packet_length ); 144 WRITE_DATA( 4, GLenum, CR_MULTTRANSPOSEMATRIXFARB_EXTEND_OPCODE ); 145 WRITE_DATA( 8 + 0*sizeof(GLfloat), GLfloat, m[ 0] ); 146 WRITE_DATA( 8 + 1*sizeof(GLfloat), GLfloat, m[ 1] ); 147 WRITE_DATA( 8 + 2*sizeof(GLfloat), GLfloat, m[ 2] ); 148 WRITE_DATA( 8 + 3*sizeof(GLfloat), GLfloat, m[ 3] ); 149 WRITE_DATA( 8 + 4*sizeof(GLfloat), GLfloat, m[ 4] ); 150 WRITE_DATA( 8 + 5*sizeof(GLfloat), GLfloat, m[ 5] ); 151 WRITE_DATA( 8 + 6*sizeof(GLfloat), GLfloat, m[ 6] ); 152 WRITE_DATA( 8 + 7*sizeof(GLfloat), GLfloat, m[ 7] ); 153 WRITE_DATA( 8 + 8*sizeof(GLfloat), GLfloat, m[ 8] ); 154 WRITE_DATA( 8 + 9*sizeof(GLfloat), GLfloat, m[ 9] ); 155 WRITE_DATA( 8 + 10*sizeof(GLfloat), GLfloat, m[10] ); 156 WRITE_DATA( 8 + 11*sizeof(GLfloat), GLfloat, m[11] ); 157 WRITE_DATA( 8 + 12*sizeof(GLfloat), GLfloat, m[12] ); 158 WRITE_DATA( 8 + 13*sizeof(GLfloat), GLfloat, m[13] ); 159 WRITE_DATA( 8 + 14*sizeof(GLfloat), GLfloat, m[14] ); 160 WRITE_DATA( 8 + 15*sizeof(GLfloat), GLfloat, m[15] ); 161 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 162 162 } 163 163 164 164 void PACK_APIENTRY crPackLoadTransposeMatrixdARB( const GLdouble *m ) 165 165 { 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 166 GET_PACKER_CONTEXT(pc); 167 unsigned char *data_ptr; 168 int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum); 169 GET_BUFFERED_POINTER(pc, packet_length ); 170 WRITE_DATA( 0, GLint, packet_length ); 171 WRITE_DATA( 4, GLenum, CR_LOADTRANSPOSEMATRIXDARB_EXTEND_OPCODE ); 172 WRITE_DOUBLE( 8 + 0*sizeof(double), m[ 0] ); 173 WRITE_DOUBLE( 8 + 1*sizeof(double), m[ 1] ); 174 WRITE_DOUBLE( 8 + 2*sizeof(double), m[ 2] ); 175 WRITE_DOUBLE( 8 + 3*sizeof(double), m[ 3] ); 176 WRITE_DOUBLE( 8 + 4*sizeof(double), m[ 4] ); 177 WRITE_DOUBLE( 8 + 5*sizeof(double), m[ 5] ); 178 WRITE_DOUBLE( 8 + 6*sizeof(double), m[ 6] ); 179 WRITE_DOUBLE( 8 + 7*sizeof(double), m[ 7] ); 180 WRITE_DOUBLE( 8 + 8*sizeof(double), m[ 8] ); 181 WRITE_DOUBLE( 8 + 9*sizeof(double), m[ 9] ); 182 WRITE_DOUBLE( 8 + 10*sizeof(double), m[10] ); 183 WRITE_DOUBLE( 8 + 11*sizeof(double), m[11] ); 184 WRITE_DOUBLE( 8 + 12*sizeof(double), m[12] ); 185 WRITE_DOUBLE( 8 + 13*sizeof(double), m[13] ); 186 WRITE_DOUBLE( 8 + 14*sizeof(double), m[14] ); 187 WRITE_DOUBLE( 8 + 15*sizeof(double), m[15] ); 188 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 189 189 } 190 190 191 191 void PACK_APIENTRY crPackLoadTransposeMatrixfARB( const GLfloat *m ) 192 192 { 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 } 193 GET_PACKER_CONTEXT(pc); 194 unsigned char *data_ptr; 195 int packet_length = 16*sizeof( *m ) + sizeof(GLint) + sizeof(GLenum); 196 GET_BUFFERED_POINTER(pc, packet_length ); 197 WRITE_DATA( 0, GLint, packet_length ); 198 WRITE_DATA( 4, GLenum, CR_LOADTRANSPOSEMATRIXFARB_EXTEND_OPCODE ); 199 WRITE_DATA( 8 + 0*sizeof(GLfloat), GLfloat, m[ 0] ); 200 WRITE_DATA( 8 + 1*sizeof(GLfloat), GLfloat, m[ 1] ); 201 WRITE_DATA( 8 + 2*sizeof(GLfloat), GLfloat, m[ 2] ); 202 WRITE_DATA( 8 + 3*sizeof(GLfloat), GLfloat, m[ 3] ); 203 WRITE_DATA( 8 + 4*sizeof(GLfloat), GLfloat, m[ 4] ); 204 WRITE_DATA( 8 + 5*sizeof(GLfloat), GLfloat, m[ 5] ); 205 WRITE_DATA( 8 + 6*sizeof(GLfloat), GLfloat, m[ 6] ); 206 WRITE_DATA( 8 + 7*sizeof(GLfloat), GLfloat, m[ 7] ); 207 WRITE_DATA( 8 + 8*sizeof(GLfloat), GLfloat, m[ 8] ); 208 WRITE_DATA( 8 + 9*sizeof(GLfloat), GLfloat, m[ 9] ); 209 WRITE_DATA( 8 + 10*sizeof(GLfloat), GLfloat, m[10] ); 210 WRITE_DATA( 8 + 11*sizeof(GLfloat), GLfloat, m[11] ); 211 WRITE_DATA( 8 + 12*sizeof(GLfloat), GLfloat, m[12] ); 212 WRITE_DATA( 8 + 13*sizeof(GLfloat), GLfloat, m[13] ); 213 WRITE_DATA( 8 + 14*sizeof(GLfloat), GLfloat, m[14] ); 214 WRITE_DATA( 8 + 15*sizeof(GLfloat), GLfloat, m[15] ); 215 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 216 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_misc.c
r21845 r33457 10 10 void PACK_APIENTRY crPackChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values) 11 11 { 12 13 14 15 16 17 12 GET_PACKER_CONTEXT(pc); 13 unsigned int header_length = 2 * sizeof(int) + sizeof(target) + sizeof(type) + sizeof(count); 14 unsigned int packet_length; 15 unsigned int params_length = 0; 16 unsigned char *data_ptr; 17 int i, pos; 18 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 19 switch (type) { 20 case GL_BYTE: 21 case GL_UNSIGNED_BYTE: 22 params_length = sizeof(GLbyte) * count; 23 break; 24 case GL_SHORT: 25 case GL_UNSIGNED_SHORT: 26 params_length = sizeof(GLshort) * count; 27 break; 28 case GL_INT: 29 case GL_UNSIGNED_INT: 30 params_length = sizeof(GLint) * count; 31 break; 32 case GL_FLOAT: 33 params_length = sizeof(GLfloat) * count; 34 break; 35 35 #if 0 36 37 38 36 case GL_DOUBLE: 37 params_length = sizeof(GLdouble) * count; 38 break; 39 39 #endif 40 41 42 43 44 40 default: 41 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 42 "crPackChromiumParametervCR(bad type)" ); 43 return; 44 } 45 45 46 46 packet_length = header_length + params_length; 47 47 48 49 50 51 52 53 54 48 GET_BUFFERED_POINTER(pc, packet_length ); 49 WRITE_DATA( 0, GLint, packet_length ); 50 WRITE_DATA( 4, GLenum, CR_CHROMIUMPARAMETERVCR_EXTEND_OPCODE ); 51 WRITE_DATA( 8, GLenum, target ); 52 WRITE_DATA( 12, GLenum, type ); 53 WRITE_DATA( 16, GLsizei, count ); 54 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 55 55 56 56 pos = header_length; 57 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 58 switch (type) { 59 case GL_BYTE: 60 case GL_UNSIGNED_BYTE: 61 for (i = 0; i < count; i++, pos += sizeof(GLbyte)) { 62 WRITE_DATA( pos, GLbyte, ((GLbyte *) values)[i]); 63 } 64 break; 65 case GL_SHORT: 66 case GL_UNSIGNED_SHORT: 67 for (i = 0; i < count; i++, pos += sizeof(GLshort)) { 68 WRITE_DATA( pos, GLshort, ((GLshort *) values)[i]); 69 } 70 break; 71 case GL_INT: 72 case GL_UNSIGNED_INT: 73 for (i = 0; i < count; i++, pos += sizeof(GLint)) { 74 WRITE_DATA( pos, GLint, ((GLint *) values)[i]); 75 } 76 break; 77 case GL_FLOAT: 78 for (i = 0; i < count; i++, pos += sizeof(GLfloat)) { 79 WRITE_DATA( pos, GLfloat, ((GLfloat *) values)[i]); 80 } 81 break; 82 82 #if 0 83 84 85 86 87 83 case GL_DOUBLE: 84 for (i = 0; i < count; i++) { 85 WRITE_foo_DATA( sizeof(int) + 12, GLdouble, ((GLdouble *) values)[i]); 86 } 87 break; 88 88 #endif 89 90 91 92 93 89 default: 90 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 91 "crPackChromiumParametervCR(bad type)" ); 92 return; 93 } 94 94 } 95 95 … … 98 98 unsigned char *data_ptr; 99 99 int packet_length = sizeof(GLenum)+sizeof(n)+n*sizeof(*ids); 100 100 GET_PACKER_CONTEXT(pc); 101 101 if (!ids) return; 102 102 data_ptr = (unsigned char *) crPackAlloc(packet_length); -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_pica.c
r15532 r33457 10 10 11 11 void PACK_APIENTRY crPackPicaListCompositors(const PICAuint *config, 12 13 12 PICAint *numResults, 13 PICAcompItem *results, PICAerror *return_value, int* writeback ) 14 14 { 15 15 crWarning("You can't really pack PICA calls!"); … … 21 21 } 22 22 void PACK_APIENTRY crPackPicaListCompositorsSWAP(const PICAuint *config, 23 24 23 PICAint *numResults, 24 PICAcompItem *results, PICAerror *return_value, int* writeback ) 25 25 { 26 26 crWarning("You can't really pack PICA calls!"); … … 32 32 } 33 33 void PACK_APIENTRY crPackPicaGetCompositorParamiv(PICAcompID compositor, 34 35 34 PICAparam pname, 35 PICAint *params, PICAerror *return_value, int* writeback ) 36 36 { 37 37 … … 44 44 } 45 45 void PACK_APIENTRY crPackPicaGetCompositorParamivSWAP(PICAcompID compositor, 46 47 46 PICAparam pname, 47 PICAint *params, PICAerror *return_value, int* writeback ) 48 48 { 49 49 … … 56 56 } 57 57 void PACK_APIENTRY crPackPicaGetCompositorParamfv(PICAcompID compositor, 58 59 58 PICAparam pname, 59 PICAfloat *params, PICAerror *return_value, int* writeback ) 60 60 { 61 61 … … 68 68 } 69 69 void PACK_APIENTRY crPackPicaGetCompositorParamfvSWAP(PICAcompID compositor, 70 71 70 PICAparam pname, 71 PICAfloat *params, PICAerror *return_value, int* writeback ) 72 72 { 73 73 … … 80 80 } 81 81 void PACK_APIENTRY crPackPicaGetCompositorParamcv(PICAcompID compositor, 82 83 82 PICAparam pname, 83 PICAchar **params, PICAerror *return_value, int* writeback ) 84 84 { 85 85 … … 92 92 } 93 93 void PACK_APIENTRY crPackPicaGetCompositorParamcvSWAP(PICAcompID compositor, 94 95 94 PICAparam pname, 95 PICAchar **params, PICAerror *return_value, int* writeback ) 96 96 { 97 97 … … 104 104 } 105 105 void PACK_APIENTRY crPackPicaListNodes(PICAcompID compositor, 106 107 106 PICAint *num, 107 PICAnodeItem *results, PICAerror *return_value, int* writeback ) 108 108 { 109 109 … … 116 116 } 117 117 void PACK_APIENTRY crPackPicaListNodesSWAP(PICAcompID compositor, 118 119 118 PICAint *num, 119 PICAnodeItem *results, PICAerror *return_value, int* writeback ) 120 120 { 121 121 … … 129 129 130 130 void PACK_APIENTRY crPackPicaCreateContext(const PICAuint *config, 131 132 131 const PICAnodeID *nodes, 132 PICAuint numNodes, PICAcontextID *return_value, int* writeback ) 133 133 { 134 134 … … 141 141 } 142 142 void PACK_APIENTRY crPackPicaCreateContextSWAP(const PICAuint *config, 143 144 143 const PICAnodeID *nodes, 144 PICAuint numNodes, PICAcontextID *return_value, int* writeback ) 145 145 { 146 146 … … 170 170 171 171 void PACK_APIENTRY crPackPicaSetContextParami(PICAcontextID ctx, 172 173 172 PICAparam pname, 173 PICAint param, PICAerror *return_value, int* writeback ) 174 174 { 175 175 … … 182 182 } 183 183 void PACK_APIENTRY crPackPicaSetContextParamiSWAP(PICAcontextID ctx, 184 185 184 PICAparam pname, 185 PICAint param, PICAerror *return_value, int* writeback ) 186 186 { 187 187 … … 194 194 } 195 195 void PACK_APIENTRY crPackPicaSetContextParamiv(PICAcontextID ctx, 196 197 196 PICAparam pname, 197 const PICAint *param, PICAerror *return_value, int* writeback ) 198 198 { 199 199 … … 206 206 } 207 207 void PACK_APIENTRY crPackPicaSetContextParamivSWAP(PICAcontextID ctx, 208 209 208 PICAparam pname, 209 const PICAint *param, PICAerror *return_value, int* writeback ) 210 210 { 211 211 … … 218 218 } 219 219 void PACK_APIENTRY crPackPicaSetContextParamf(PICAcontextID ctx, 220 221 220 PICAparam pname, 221 PICAfloat param, PICAerror *return_value, int* writeback ) 222 222 { 223 223 … … 230 230 } 231 231 void PACK_APIENTRY crPackPicaSetContextParamfSWAP(PICAcontextID ctx, 232 233 232 PICAparam pname, 233 PICAfloat param, PICAerror *return_value, int* writeback ) 234 234 { 235 235 … … 242 242 } 243 243 void PACK_APIENTRY crPackPicaSetContextParamfv(PICAcontextID ctx, 244 245 244 PICAparam pname, 245 const PICAfloat *param, PICAerror *return_value, int* writeback ) 246 246 { 247 247 … … 254 254 } 255 255 void PACK_APIENTRY crPackPicaSetContextParamfvSWAP(PICAcontextID ctx, 256 257 256 PICAparam pname, 257 const PICAfloat *param, PICAerror *return_value, int* writeback ) 258 258 { 259 259 … … 266 266 } 267 267 void PACK_APIENTRY crPackPicaSetContextParamv(PICAcontextID ctx, 268 269 268 PICAparam pname, 269 const PICAvoid *param, PICAerror *return_value, int* writeback ) 270 270 { 271 271 … … 278 278 } 279 279 void PACK_APIENTRY crPackPicaSetContextParamvSWAP(PICAcontextID ctx, 280 281 280 PICAparam pname, 281 const PICAvoid *param, PICAerror *return_value, int* writeback ) 282 282 { 283 283 … … 291 291 292 292 void PACK_APIENTRY crPackPicaGetContextParamiv(PICAcontextID ctx, 293 294 293 PICAparam pname, 294 PICAint *param, PICAerror *return_value, int* writeback ) 295 295 { 296 296 … … 304 304 305 305 void PACK_APIENTRY crPackPicaGetContextParamivSWAP(PICAcontextID ctx, 306 307 306 PICAparam pname, 307 PICAint *param, PICAerror *return_value, int* writeback ) 308 308 { 309 309 … … 316 316 } 317 317 void PACK_APIENTRY crPackPicaGetContextParamfv(PICAcontextID ctx, 318 319 318 PICAparam pname, 319 PICAfloat *param, PICAerror *return_value, int* writeback ) 320 320 { 321 321 … … 328 328 } 329 329 void PACK_APIENTRY crPackPicaGetContextParamfvSWAP(PICAcontextID ctx, 330 331 330 PICAparam pname, 331 PICAfloat *param, PICAerror *return_value, int* writeback ) 332 332 { 333 333 … … 340 340 } 341 341 void PACK_APIENTRY crPackPicaGetContextParamcv(PICAcontextID ctx, 342 343 342 PICAparam pname, 343 PICAchar **param, PICAerror *return_value, int* writeback ) 344 344 { 345 345 … … 352 352 } 353 353 void PACK_APIENTRY crPackPicaGetContextParamcvSWAP(PICAcontextID ctx, 354 355 354 PICAparam pname, 355 PICAchar **param, PICAerror *return_value, int* writeback ) 356 356 { 357 357 … … 364 364 } 365 365 void PACK_APIENTRY crPackPicaGetContextParamv(PICAcontextID ctx, 366 367 366 PICAparam pname, 367 PICAvoid *param, PICAerror *return_value, int* writeback ) 368 368 { 369 369 … … 376 376 } 377 377 void PACK_APIENTRY crPackPicaGetContextParamvSWAP(PICAcontextID ctx, 378 379 378 PICAparam pname, 379 PICAvoid *param, PICAerror *return_value, int* writeback ) 380 380 { 381 381 … … 389 389 390 390 void PACK_APIENTRY crPackPicaBindLocalContext(PICAcontextID globalCtx, 391 391 PICAnodeID node, PICAcontextID *return_value, int* writeback ) 392 392 { 393 393 … … 400 400 401 401 void PACK_APIENTRY crPackPicaBindLocalContextSWAP(PICAcontextID globalCtx, 402 402 PICAnodeID node, PICAcontextID *return_value, int* writeback ) 403 403 { 404 404 … … 427 427 428 428 void PACK_APIENTRY crPackPicaStartFrame(PICAcontextID lctx, 429 430 431 432 433 434 429 const PICAframeID *frameID, 430 PICAuint numLocalFramelets, 431 PICAuint numOrders, 432 const PICAuint *orderList, 433 const PICArect *srcRectList, 434 const PICApoint *dstList, PICAerror *return_value, int* writeback ) 435 435 { 436 436 … … 448 448 449 449 void PACK_APIENTRY crPackPicaStartFrameSWAP(PICAcontextID lctx, 450 451 452 453 454 455 450 const PICAframeID *frameID, 451 PICAuint numLocalFramelets, 452 PICAuint numOrders, 453 const PICAuint *orderList, 454 const PICArect *srcRectList, 455 const PICApoint *dstList, PICAerror *return_value, int* writeback ) 456 456 { 457 457 … … 484 484 } 485 485 void PACK_APIENTRY crPackPicaCancelFrame(PICAcontextID ctx, 486 486 PICAframeID frameID, PICAerror *return_value, int* writeback ) 487 487 { 488 488 … … 494 494 } 495 495 void PACK_APIENTRY crPackPicaCancelFrameSWAP(PICAcontextID ctx, 496 496 PICAframeID frameID, PICAerror *return_value, int* writeback ) 497 497 { 498 498 … … 504 504 } 505 505 void PACK_APIENTRY crPackPicaQueryFrame(PICAcontextID ctx, 506 507 508 506 PICAframeID frameID, 507 PICAnodeID nodeID, 508 PICAfloat timeout, PICAstatus *return_value, int* writeback ) 509 509 { 510 510 … … 518 518 } 519 519 void PACK_APIENTRY crPackPicaQueryFrameSWAP(PICAcontextID ctx, 520 521 522 520 PICAframeID frameID, 521 PICAnodeID nodeID, 522 PICAfloat timeout, PICAstatus *return_value, int* writeback ) 523 523 { 524 524 … … 532 532 } 533 533 void PACK_APIENTRY crPackPicaAddGfxFramelet(PICAcontextID lctx, 534 535 536 537 534 const PICArect *srcRect, 535 const PICApoint *dstPos, 536 PICAuint order, 537 PICAint iVolatile, PICAerror *return_value, int* writeback ) 538 538 { 539 539 … … 548 548 } 549 549 void PACK_APIENTRY crPackPicaAddGfxFrameletSWAP(PICAcontextID lctx, 550 551 552 553 550 const PICArect *srcRect, 551 const PICApoint *dstPos, 552 PICAuint order, 553 PICAint iVolatile, PICAerror *return_value, int* writeback ) 554 554 { 555 555 … … 564 564 } 565 565 void PACK_APIENTRY crPackPicaAddMemFramelet(PICAcontextID lctx, 566 567 568 569 570 571 572 566 const PICAvoid *colorBuffer, 567 const PICAvoid *depthBuffer, 568 PICAuint span_x, 569 const PICArect *srcRect, 570 const PICApoint *dstPos, 571 PICAuint order, 572 PICAint iVolatile, PICAerror *return_value, int* writeback ) 573 573 { 574 574 … … 586 586 } 587 587 void PACK_APIENTRY crPackPicaAddMemFrameletSWAP(PICAcontextID lctx, 588 589 590 591 592 593 594 595 596 588 const PICAvoid *colorBuffer, 589 const PICAvoid *depthBuffer, 590 PICAuint span_x, 591 const PICArect *srcRect, 592 const PICApoint *dstPos, 593 PICAuint order, 594 PICAint iVolatile, 595 PICAerror *return_value, 596 int* writeback ) 597 597 { 598 598 … … 610 610 } 611 611 void PACK_APIENTRY crPackPicaReadFrame(PICAcontextID lctx, 612 613 614 615 616 617 618 612 PICAframeID frameID, 613 PICAuint format, 614 PICAvoid *colorbuffer, 615 PICAvoid *depthbuffer, 616 const PICArect *rect, 617 PICAerror *return_value, 618 int* writeback ) 619 619 { 620 620 … … 630 630 } 631 631 void PACK_APIENTRY crPackPicaReadFrameSWAP(PICAcontextID lctx, 632 633 634 635 636 637 638 632 PICAframeID frameID, 633 PICAuint format, 634 PICAvoid *colorbuffer, 635 PICAvoid *depthbuffer, 636 const PICArect *rect, 637 PICAerror *return_value, 638 int* writeback ) 639 639 { 640 640 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_point.c
r15532 r33457 13 13 static GLboolean __handlePointDataf( GLenum pname, const GLfloat *params ) 14 14 { 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 }35 36 37 15 GET_PACKER_CONTEXT(pc); 16 int params_length = 0; 17 int packet_length = 2 * sizeof( int ) + sizeof( pname ); 18 unsigned char *data_ptr; 19 switch( pname ) 20 { 21 case GL_POINT_SIZE_MIN_ARB: 22 case GL_POINT_SIZE_MAX_ARB: 23 case GL_POINT_FADE_THRESHOLD_SIZE_ARB: 24 params_length = sizeof( *params ); 25 break; 26 case GL_POINT_DISTANCE_ATTENUATION_ARB: 27 params_length = 3 * sizeof( *params ); 28 break; 29 default: 30 { 31 char msg[100]; 32 sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname ); 33 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); 34 } 35 return GL_FALSE; 36 } 37 packet_length += params_length; 38 38 39 40 41 42 43 44 45 46 47 48 49 39 GET_BUFFERED_POINTER(pc, packet_length ); 40 WRITE_DATA( 0, GLint, packet_length ); 41 WRITE_DATA( 4, GLenum, CR_POINTPARAMETERFVARB_EXTEND_OPCODE ); 42 WRITE_DATA( 8, GLenum, pname ); 43 WRITE_DATA( 12, GLfloat, params[0] ); 44 if (packet_length > 16) 45 { 46 WRITE_DATA( 16, GLfloat, params[1] ); 47 WRITE_DATA( 20, GLfloat, params[2] ); 48 } 49 return GL_TRUE; 50 50 } 51 51 52 52 void PACK_APIENTRY crPackPointParameterfvARB(GLenum pname, const GLfloat *params) 53 53 { 54 55 56 54 GET_PACKER_CONTEXT(pc); 55 if (__handlePointDataf( pname, params )) 56 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 57 57 } 58 58 … … 61 61 static GLboolean __handlePointDatai( GLenum pname, const GLint *params ) 62 62 { 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 63 GET_PACKER_CONTEXT(pc); 64 int params_length = 0; 65 int packet_length = 2 * sizeof( int ) + sizeof( pname ); 66 unsigned char *data_ptr; 67 switch( pname ) 68 { 69 case GL_POINT_SIZE_MIN_ARB: 70 case GL_POINT_SIZE_MAX_ARB: 71 case GL_POINT_FADE_THRESHOLD_SIZE_ARB: 72 params_length = sizeof( *params ); 73 break; 74 case GL_POINT_DISTANCE_ATTENUATION_ARB: 75 params_length = 3 * sizeof( *params ); 76 break; 77 default: 78 { 79 char msg[100]; 80 sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname ); 81 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); 82 } 83 return GL_FALSE; 84 } 85 packet_length += params_length; 86 86 87 88 89 90 91 92 93 94 95 96 97 87 GET_BUFFERED_POINTER(pc, packet_length ); 88 WRITE_DATA( 0, GLint, packet_length ); 89 WRITE_DATA( 4, GLenum, CR_POINTPARAMETERIV_EXTEND_OPCODE ); 90 WRITE_DATA( 8, GLenum, pname ); 91 WRITE_DATA( 12, GLint, params[0] ); 92 if (packet_length > 16) 93 { 94 WRITE_DATA( 16, GLint, params[1] ); 95 WRITE_DATA( 20, GLint, params[2] ); 96 } 97 return GL_TRUE; 98 98 } 99 99 100 100 void PACK_APIENTRY crPackPointParameteriv(GLenum pname, const GLint *params) 101 101 { 102 103 104 102 GET_PACKER_CONTEXT(pc); 103 if (__handlePointDatai( pname, params )) 104 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 105 105 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_program.c
r31474 r33457 17 17 void PACK_APIENTRY crPackProgramParameters4dvNV (GLenum target, GLuint index, GLuint num, const GLdouble * params) 18 18 { 19 20 21 22 23 24 25 26 27 28 29 30 19 GET_PACKER_CONTEXT(pc); 20 unsigned char *data_ptr; 21 int packet_length = sizeof(int) + sizeof(target) + sizeof(index) + sizeof(num) + num * 4 * sizeof(GLdouble); 22 23 GET_BUFFERED_POINTER(pc, packet_length); 24 WRITE_DATA(0, int, packet_length); 25 WRITE_DATA(sizeof(int) + 0, GLenum, target); 26 WRITE_DATA(sizeof(int) + 4, GLuint, index); 27 WRITE_DATA(sizeof(int) + 8, GLuint, num); 28 crMemcpy(data_ptr + sizeof(int) + 12, params, num * 4 * sizeof(GLdouble)); 29 30 WRITE_OPCODE(pc, CR_PROGRAMPARAMETERS4DVNV_EXTEND_OPCODE); 31 31 } 32 32 … … 34 34 void PACK_APIENTRY crPackProgramParameters4fvNV (GLenum target, GLuint index, GLuint num, const GLfloat * params) 35 35 { 36 37 38 39 40 41 42 43 44 45 46 47 36 GET_PACKER_CONTEXT(pc); 37 unsigned char *data_ptr; 38 int packet_length = sizeof(int) + sizeof(target) + sizeof(index) + sizeof(num) + num * 4 * sizeof(GLfloat); 39 40 GET_BUFFERED_POINTER(pc, packet_length); 41 WRITE_DATA(0, int, packet_length); 42 WRITE_DATA(sizeof(int) + 0, GLenum, target); 43 WRITE_DATA(sizeof(int) + 4, GLuint, index); 44 WRITE_DATA(sizeof(int) + 8, GLuint, num); 45 crMemcpy(data_ptr + sizeof(int) + 12, params, num * 4 * sizeof(GLfloat)); 46 47 WRITE_OPCODE(pc, CR_PROGRAMPARAMETERS4FVNV_EXTEND_OPCODE); 48 48 } 49 49 … … 51 51 void PACK_APIENTRY crPackVertexAttribs1dvNV( GLuint index, GLsizei n, const GLdouble *v ) 52 52 { 53 54 55 56 53 GLint i; 54 /* reverse order so we hit index 0 last (provoking glVertex) */ 55 for (i = n - 1; i >= 0; i--) 56 crPackVertexAttrib1dvARB(index + i, v + i); 57 57 } 58 58 … … 60 60 void PACK_APIENTRY crPackVertexAttribs1fvNV( GLuint index, GLsizei n, const GLfloat *v ) 61 61 { 62 63 64 65 62 GLint i; 63 /* reverse order so we hit index 0 last (provoking glVertex) */ 64 for (i = n - 1; i >= 0; i--) 65 crPackVertexAttrib1fvARB(index + i, v + i); 66 66 } 67 67 … … 69 69 void PACK_APIENTRY crPackVertexAttribs1svNV( GLuint index, GLsizei n, const GLshort *v ) 70 70 { 71 72 73 74 71 GLint i; 72 /* reverse order so we hit index 0 last (provoking glVertex) */ 73 for (i = n - 1; i >= 0; i--) 74 crPackVertexAttrib1svARB(index + i, v + i); 75 75 } 76 76 … … 78 78 void PACK_APIENTRY crPackVertexAttribs2dvNV( GLuint index, GLsizei n, const GLdouble *v ) 79 79 { 80 81 82 83 80 GLint i; 81 /* reverse order so we hit index 0 last (provoking glVertex) */ 82 for (i = n - 1; i >= 0; i--) 83 crPackVertexAttrib2dvARB(index + i, v + 2 * i); 84 84 } 85 85 86 86 void PACK_APIENTRY crPackVertexAttribs2fvNV( GLuint index, GLsizei n, const GLfloat *v ) 87 87 { 88 89 90 91 88 GLint i; 89 /* reverse order so we hit index 0 last (provoking glVertex) */ 90 for (i = n - 1; i >= 0; i--) 91 crPackVertexAttrib2fvARB(index + i, v + 2 * i); 92 92 } 93 93 94 94 void PACK_APIENTRY crPackVertexAttribs2svNV( GLuint index, GLsizei n, const GLshort *v ) 95 95 { 96 97 98 99 96 GLint i; 97 /* reverse order so we hit index 0 last (provoking glVertex) */ 98 for (i = n - 1; i >= 0; i--) 99 crPackVertexAttrib2svARB(index + i, v + 2 * i); 100 100 } 101 101 102 102 void PACK_APIENTRY crPackVertexAttribs3dvNV( GLuint index, GLsizei n, const GLdouble *v ) 103 103 { 104 105 106 107 104 GLint i; 105 /* reverse order so we hit index 0 last (provoking glVertex) */ 106 for (i = n - 1; i >= 0; i--) 107 crPackVertexAttrib3dvARB(index + i, v + 3 * i); 108 108 } 109 109 110 110 void PACK_APIENTRY crPackVertexAttribs3fvNV( GLuint index, GLsizei n, const GLfloat *v ) 111 111 { 112 113 114 115 112 GLint i; 113 /* reverse order so we hit index 0 last (provoking glVertex) */ 114 for (i = n - 1; i >= 0; i--) 115 crPackVertexAttrib3fvARB(index + i, v + 3 * i); 116 116 } 117 117 118 118 void PACK_APIENTRY crPackVertexAttribs3svNV( GLuint index, GLsizei n, const GLshort *v ) 119 119 { 120 121 122 123 120 GLint i; 121 /* reverse order so we hit index 0 last (provoking glVertex) */ 122 for (i = n - 1; i >= 0; i--) 123 crPackVertexAttrib3svARB(index + i, v + 3 * i); 124 124 } 125 125 126 126 void PACK_APIENTRY crPackVertexAttribs4dvNV( GLuint index, GLsizei n, const GLdouble *v ) 127 127 { 128 129 130 131 128 GLint i; 129 /* reverse order so we hit index 0 last (provoking glVertex) */ 130 for (i = n - 1; i >= 0; i--) 131 crPackVertexAttrib4dvARB(index + i, v + 4 * i); 132 132 } 133 133 134 134 void PACK_APIENTRY crPackVertexAttribs4fvNV( GLuint index, GLsizei n, const GLfloat *v ) 135 135 { 136 137 138 139 136 GLint i; 137 /* reverse order so we hit index 0 last (provoking glVertex) */ 138 for (i = n - 1; i >= 0; i--) 139 crPackVertexAttrib4fvARB(index + i, v + 4 * i); 140 140 } 141 141 142 142 void PACK_APIENTRY crPackVertexAttribs4svNV( GLuint index, GLsizei n, const GLshort *v ) 143 143 { 144 145 146 147 144 GLint i; 145 /* reverse order so we hit index 0 last (provoking glVertex) */ 146 for (i = n - 1; i >= 0; i--) 147 crPackVertexAttrib4svARB(index + i, v + 4 * i); 148 148 } 149 149 150 150 void PACK_APIENTRY crPackVertexAttribs4ubvNV( GLuint index, GLsizei n, const GLubyte *v ) 151 151 { 152 153 154 155 152 GLint i; 153 /* reverse order so we hit index 0 last (provoking glVertex) */ 154 for (i = n - 1; i >= 0; i--) 155 crPackVertexAttrib4ubvARB(index + i, v + 4 * i); 156 156 } 157 157 … … 159 159 void PACK_APIENTRY crPackExecuteProgramNV( GLenum target, GLuint id, const GLfloat *params ) 160 160 { 161 162 163 164 165 166 167 168 169 170 171 172 173 174 161 const int packet_length = 32; 162 unsigned char *data_ptr; 163 GET_PACKER_CONTEXT(pc); 164 165 GET_BUFFERED_POINTER(pc, packet_length); 166 WRITE_DATA(0, int, packet_length); 167 WRITE_DATA(4, GLenum, CR_EXECUTEPROGRAMNV_EXTEND_OPCODE); 168 WRITE_DATA(8, GLenum, target); 169 WRITE_DATA(12, GLuint, id); 170 WRITE_DATA(16, GLfloat, params[0] ); 171 WRITE_DATA(20, GLfloat, params[1] ); 172 WRITE_DATA(24, GLfloat, params[2] ); 173 WRITE_DATA(28, GLfloat, params[3] ); 174 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 175 175 } 176 176 177 177 void PACK_APIENTRY crPackLoadProgramNV( GLenum target, GLuint id, GLsizei len, const GLubyte *program ) 178 178 { 179 180 181 182 183 184 185 186 187 188 189 190 179 const int packet_length = 20 + len; 180 unsigned char *data_ptr; 181 GET_PACKER_CONTEXT(pc); 182 183 GET_BUFFERED_POINTER(pc, packet_length); 184 WRITE_DATA(0, int, packet_length); 185 WRITE_DATA(4, GLenum, CR_LOADPROGRAMNV_EXTEND_OPCODE); 186 WRITE_DATA(8, GLenum, target); 187 WRITE_DATA(12, GLuint, id); 188 WRITE_DATA(16, GLsizei, len ); 189 crMemcpy( (void *) (data_ptr + 20), program, len ); 190 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 191 191 } 192 192 193 193 void PACK_APIENTRY crPackRequestResidentProgramsNV( GLsizei n, const GLuint *ids ) 194 194 { 195 196 197 198 199 195 GET_PACKER_CONTEXT(pc); 196 (void) pc; 197 (void) n; 198 (void) ids; 199 /* We're no-op'ing this function for now. */ 200 200 } 201 201 … … 203 203 void PACK_APIENTRY crPackProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) 204 204 { 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 205 GET_PACKER_CONTEXT(pc); 206 unsigned char *data_ptr; 207 int packet_length = 32 + len; 208 209 GET_BUFFERED_POINTER(pc, packet_length); 210 WRITE_DATA(0, GLint, packet_length); 211 WRITE_DATA(4, GLenum, CR_PROGRAMNAMEDPARAMETER4FNV_EXTEND_OPCODE); 212 WRITE_DATA(8, GLuint, id); 213 WRITE_DATA(12, GLsizei, len); 214 WRITE_DATA(16, GLfloat, x); 215 WRITE_DATA(20, GLfloat, y); 216 WRITE_DATA(24, GLfloat, z); 217 WRITE_DATA(28, GLfloat, w); 218 crMemcpy( (void *) (data_ptr + 32), name, len ); 219 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 220 220 } 221 221 222 222 void PACK_APIENTRY crPackProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w) 223 223 { 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 224 GET_PACKER_CONTEXT(pc); 225 unsigned char *data_ptr; 226 int packet_length = 48 + len; 227 228 GET_BUFFERED_POINTER(pc, packet_length); 229 WRITE_DATA(0, GLint, packet_length); 230 WRITE_DATA(4, GLenum, CR_PROGRAMNAMEDPARAMETER4DNV_EXTEND_OPCODE); 231 WRITE_DATA(8, GLenum, id); 232 WRITE_DATA(12, GLuint, len); 233 WRITE_DOUBLE(16, x); 234 WRITE_DOUBLE(24, y); 235 WRITE_DOUBLE(32, z); 236 WRITE_DOUBLE(40, w); 237 crMemcpy( (void *) (data_ptr + 48), name, len ); 238 239 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 240 240 } 241 241 242 242 void PACK_APIENTRY crPackProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v) 243 243 { 244 244 crPackProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); 245 245 } 246 246 247 247 void PACK_APIENTRY crPackProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v) 248 248 { 249 249 crPackProgramNamedParameter4dNV(id, len, name, v[0], v[1], v[2], v[3]); 250 250 } 251 251 … … 253 253 void PACK_APIENTRY 254 254 crPackAreProgramsResidentNV(GLsizei n, const GLuint * programs, 255 256 257 { 258 259 260 261 262 263 264 packet_length = sizeof(int) +/* packet length */265 sizeof(GLenum) +/* extend opcode */266 sizeof(n) +/* num programs */267 n * sizeof(*programs) +/* programs */268 269 270 271 272 273 274 275 WRITE_NETWORK_POINTER(12 + n * sizeof(*programs),(void *) residences);276 277 255 GLboolean *residences, GLboolean *return_val, 256 int *writeback) 257 { 258 GET_PACKER_CONTEXT(pc); 259 unsigned char *data_ptr; 260 int packet_length; 261 262 (void) return_val; /* Caller must compute this from residences!!! */ 263 264 packet_length = sizeof(int) + /* packet length */ 265 sizeof(GLenum) + /* extend opcode */ 266 sizeof(n) + /* num programs */ 267 n * sizeof(*programs) + /* programs */ 268 8 + 8; 269 270 GET_BUFFERED_POINTER(pc, packet_length); 271 WRITE_DATA(0, int, packet_length); 272 WRITE_DATA(4, GLenum, CR_AREPROGRAMSRESIDENTNV_EXTEND_OPCODE); 273 WRITE_DATA(8, GLsizei, n); 274 crMemcpy(data_ptr + 12, programs, n * sizeof(*programs)); 275 WRITE_NETWORK_POINTER(12 + n * sizeof(*programs), (void *) residences); 276 WRITE_NETWORK_POINTER(20 + n * sizeof(*programs), (void *) writeback); 277 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 278 278 } 279 279 … … 281 281 void PACK_APIENTRY crPackGetProgramNamedParameterfvNV( GLuint id, GLsizei len, const GLubyte *name, GLfloat *params, int *writeback ) 282 282 { 283 284 285 286 287 288 289 290 291 292 293 294 283 int packet_length = 32 + len; 284 GET_PACKER_CONTEXT(pc); 285 unsigned char *data_ptr; 286 GET_BUFFERED_POINTER( pc, packet_length ); 287 WRITE_DATA( 0, GLint, packet_length ); 288 WRITE_DATA( 4, GLenum, CR_GETPROGRAMNAMEDPARAMETERFVNV_EXTEND_OPCODE ); 289 WRITE_DATA( 8, GLuint, id ); 290 WRITE_DATA( 12, GLsizei, len ); 291 crMemcpy(data_ptr + 16, name, len); 292 WRITE_NETWORK_POINTER( 16 + len, (void *) params ); 293 WRITE_NETWORK_POINTER( 16 + len + 8, (void *) writeback ); 294 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 295 295 } 296 296 297 297 void PACK_APIENTRY crPackGetProgramNamedParameterdvNV( GLuint id, GLsizei len, const GLubyte *name, GLdouble *params, int *writeback ) 298 298 { 299 300 301 302 303 304 305 306 307 308 309 310 299 int packet_length = 32 + len; 300 GET_PACKER_CONTEXT(pc); 301 unsigned char *data_ptr; 302 GET_BUFFERED_POINTER( pc, packet_length ); 303 WRITE_DATA( 0, GLint, packet_length ); 304 WRITE_DATA( 4, GLenum, CR_GETPROGRAMNAMEDPARAMETERDVNV_EXTEND_OPCODE ); 305 WRITE_DATA( 8, GLuint, id ); 306 WRITE_DATA( 12, GLsizei, len ); 307 crMemcpy(data_ptr + 16, name, len); 308 WRITE_NETWORK_POINTER( 16 + len, (void *) params ); 309 WRITE_NETWORK_POINTER( 16 + len + 8, (void *) writeback ); 310 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 311 311 } 312 312 … … 314 314 void PACK_APIENTRY crPackDeleteProgramsARB( GLsizei n, const GLuint *ids ) 315 315 { 316 317 318 319 320 321 322 323 324 325 326 327 316 unsigned char *data_ptr; 317 int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*ids); 318 319 if (!ids) 320 return; 321 322 data_ptr = (unsigned char *) crPackAlloc(packet_length); 323 WRITE_DATA( 0, GLenum, CR_DELETEPROGRAMSARB_EXTEND_OPCODE ); 324 WRITE_DATA( 4, GLsizei, n ); 325 crMemcpy( data_ptr + 8, ids, n * sizeof(*ids) ); 326 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 327 crPackFree( data_ptr ); 328 328 } 329 329 … … 331 331 void PACK_APIENTRY crPackProgramStringARB( GLenum target, GLenum format, GLsizei len, const void *string ) 332 332 { 333 334 335 336 337 338 339 340 341 342 343 344 333 const int packet_length = 20 + len; 334 unsigned char *data_ptr; 335 GET_PACKER_CONTEXT(pc); 336 337 GET_BUFFERED_POINTER(pc, packet_length); 338 WRITE_DATA(0, int, packet_length); 339 WRITE_DATA(4, GLenum, CR_PROGRAMSTRINGARB_EXTEND_OPCODE); 340 WRITE_DATA(8, GLenum, target); 341 WRITE_DATA(12, GLuint, format); 342 WRITE_DATA(16, GLsizei, len ); 343 crMemcpy( (void *) (data_ptr + 20), string, len ); 344 WRITE_OPCODE(pc, CR_EXTEND_OPCODE); 345 345 } 346 346 … … 353 353 void PACK_APIENTRY crPackVertexAttrib4NbvARB( GLuint index, const GLbyte *v ) 354 354 { 355 356 357 358 359 360 361 362 363 364 365 355 GET_PACKER_CONTEXT(pc); 356 unsigned char *data_ptr; 357 GET_BUFFERED_POINTER( pc, 8 ); 358 pc->current.c.vertexAttrib.b4[index] = data_ptr + 12; 359 pc->current.attribsUsedMask |= (1 << index); 360 WRITE_DATA( 0, GLuint, index ); 361 WRITE_DATA( 4, GLbyte, v[0] ); 362 WRITE_DATA( 5, GLbyte, v[1] ); 363 WRITE_DATA( 6, GLbyte, v[2] ); 364 WRITE_DATA( 7, GLbyte, v[3] ); 365 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NBVARB_OPCODE ); 366 366 } 367 367 368 368 void PACK_APIENTRY crPackVertexAttrib4NivARB( GLuint index, const GLint *v ) 369 369 { 370 371 372 373 374 375 376 377 378 379 380 370 GET_PACKER_CONTEXT(pc); 371 unsigned char *data_ptr; 372 GET_BUFFERED_POINTER( pc, 20 ); 373 pc->current.c.vertexAttrib.i4[index] = data_ptr + 12; 374 pc->current.attribsUsedMask |= (1 << index); 375 WRITE_DATA( 0, GLuint, index ); 376 WRITE_DATA( 4, GLint, v[0] ); 377 WRITE_DATA( 8, GLint, v[1] ); 378 WRITE_DATA( 12, GLint, v[2] ); 379 WRITE_DATA( 16, GLint, v[3] ); 380 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NIVARB_OPCODE ); 381 381 } 382 382 383 383 void PACK_APIENTRY crPackVertexAttrib4NsvARB( GLuint index, const GLshort *v ) 384 384 { 385 386 387 388 389 390 391 392 393 394 395 385 GET_PACKER_CONTEXT(pc); 386 unsigned char *data_ptr; 387 GET_BUFFERED_POINTER( pc, 12 ); 388 pc->current.c.vertexAttrib.s4[index] = data_ptr + 12; 389 pc->current.attribsUsedMask |= (1 << index); 390 WRITE_DATA( 0, GLuint, index ); 391 WRITE_DATA( 4, GLshort, v[0] ); 392 WRITE_DATA( 6, GLshort, v[1] ); 393 WRITE_DATA( 8, GLshort, v[2] ); 394 WRITE_DATA( 10, GLshort, v[3] ); 395 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NSVARB_OPCODE ); 396 396 } 397 397 398 398 void PACK_APIENTRY crPackVertexAttrib4NubvARB(GLuint index, const GLubyte * v) 399 399 { 400 401 402 403 404 405 406 407 408 409 410 400 GET_PACKER_CONTEXT(pc); 401 unsigned char *data_ptr; 402 GET_BUFFERED_POINTER( pc, 8 ); 403 pc->current.c.vertexAttrib.ub4[index] = data_ptr + 12; 404 pc->current.attribsUsedMask |= (1 << index); 405 WRITE_DATA( 0, GLuint, index ); 406 WRITE_DATA( 4, GLubyte, v[0] ); 407 WRITE_DATA( 5, GLubyte, v[1] ); 408 WRITE_DATA( 6, GLubyte, v[2] ); 409 WRITE_DATA( 7, GLubyte, v[3] ); 410 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUBVARB_OPCODE ); 411 411 } 412 412 413 413 void PACK_APIENTRY crPackVertexAttrib4NuivARB(GLuint index, const GLuint * v) 414 414 { 415 416 417 418 419 420 421 422 423 424 425 415 GET_PACKER_CONTEXT(pc); 416 unsigned char *data_ptr; 417 GET_BUFFERED_POINTER( pc, 20 ); 418 pc->current.c.vertexAttrib.ui4[index] = data_ptr + 12; 419 pc->current.attribsUsedMask |= (1 << index); 420 WRITE_DATA( 0, GLuint, index ); 421 WRITE_DATA( 4, GLuint, v[0] ); 422 WRITE_DATA( 8, GLuint, v[1] ); 423 WRITE_DATA( 12, GLuint, v[2] ); 424 WRITE_DATA( 16, GLuint, v[3] ); 425 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUIVARB_OPCODE ); 426 426 } 427 427 428 428 void PACK_APIENTRY crPackVertexAttrib4NusvARB(GLuint index, const GLushort * v) 429 429 { 430 431 432 433 434 435 436 437 438 439 440 430 GET_PACKER_CONTEXT(pc); 431 unsigned char *data_ptr; 432 GET_BUFFERED_POINTER( pc, 12 ); 433 pc->current.c.vertexAttrib.s4[index] = data_ptr + 12; 434 pc->current.attribsUsedMask |= (1 << index); 435 WRITE_DATA( 0, GLuint, index ); 436 WRITE_DATA( 4, GLushort, v[0] ); 437 WRITE_DATA( 6, GLushort, v[1] ); 438 WRITE_DATA( 8, GLushort, v[2] ); 439 WRITE_DATA( 10, GLushort, v[3] ); 440 WRITE_OPCODE( pc, CR_VERTEXATTRIB4NUSVARB_OPCODE ); 441 441 } 442 442 443 443 void PACK_APIENTRY crPackVertexAttrib4bvARB(GLuint index, const GLbyte * v) 444 444 { 445 446 447 448 449 450 451 452 453 454 455 445 GET_PACKER_CONTEXT(pc); 446 unsigned char *data_ptr; 447 GET_BUFFERED_POINTER( pc, 8 ); 448 pc->current.c.vertexAttrib.b4[index] = data_ptr + 12; 449 pc->current.attribsUsedMask |= (1 << index); 450 WRITE_DATA( 0, GLuint, index ); 451 WRITE_DATA( 4, GLbyte, v[0] ); 452 WRITE_DATA( 5, GLbyte, v[1] ); 453 WRITE_DATA( 6, GLbyte, v[2] ); 454 WRITE_DATA( 7, GLbyte, v[3] ); 455 WRITE_OPCODE( pc, CR_VERTEXATTRIB4BVARB_OPCODE ); 456 456 } 457 457 458 458 void PACK_APIENTRY crPackVertexAttrib4ivARB(GLuint index, const GLint * v) 459 459 { 460 461 462 463 464 465 466 467 468 469 470 460 GET_PACKER_CONTEXT(pc); 461 unsigned char *data_ptr; 462 GET_BUFFERED_POINTER( pc, 20 ); 463 pc->current.c.vertexAttrib.i4[index] = data_ptr + 12; 464 pc->current.attribsUsedMask |= (1 << index); 465 WRITE_DATA( 0, GLuint, index ); 466 WRITE_DATA( 4, GLint, v[0] ); 467 WRITE_DATA( 8, GLint, v[1] ); 468 WRITE_DATA( 12, GLint, v[2] ); 469 WRITE_DATA( 16, GLint, v[3] ); 470 WRITE_OPCODE( pc, CR_VERTEXATTRIB4IVARB_OPCODE ); 471 471 } 472 472 473 473 void PACK_APIENTRY crPackVertexAttrib4uivARB(GLuint index, const GLuint * v) 474 474 { 475 476 477 478 479 480 481 482 483 484 485 475 GET_PACKER_CONTEXT(pc); 476 unsigned char *data_ptr; 477 GET_BUFFERED_POINTER( pc, 20 ); 478 pc->current.c.vertexAttrib.ui4[index] = data_ptr + 12; 479 pc->current.attribsUsedMask |= (1 << index); 480 WRITE_DATA( 0, GLuint, index ); 481 WRITE_DATA( 4, GLuint, v[0] ); 482 WRITE_DATA( 8, GLuint, v[1] ); 483 WRITE_DATA( 12, GLuint, v[2] ); 484 WRITE_DATA( 16, GLuint, v[3] ); 485 WRITE_OPCODE( pc, CR_VERTEXATTRIB4UIVARB_OPCODE ); 486 486 } 487 487 488 488 void PACK_APIENTRY crPackVertexAttrib4usvARB(GLuint index, const GLushort * v) 489 489 { 490 491 492 493 494 495 496 497 498 499 500 490 GET_PACKER_CONTEXT(pc); 491 unsigned char *data_ptr; 492 GET_BUFFERED_POINTER( pc, 12 ); 493 pc->current.c.vertexAttrib.s4[index] = data_ptr + 12; 494 pc->current.attribsUsedMask |= (1 << index); 495 WRITE_DATA( 0, GLuint, index ); 496 WRITE_DATA( 4, GLushort, v[0] ); 497 WRITE_DATA( 6, GLushort, v[1] ); 498 WRITE_DATA( 8, GLushort, v[2] ); 499 WRITE_DATA( 10, GLushort, v[3] ); 500 WRITE_OPCODE( pc, CR_VERTEXATTRIB4USVARB_OPCODE ); 501 501 } 502 502 … … 504 504 void PACK_APIENTRY crPackVertexAttrib4ubvARB(GLuint index, const GLubyte * v) 505 505 { 506 507 508 509 510 511 512 513 514 515 516 517 } 518 506 GET_PACKER_CONTEXT(pc); 507 unsigned char *data_ptr; 508 GET_BUFFERED_POINTER( pc, 8 ); 509 pc->current.c.vertexAttrib.ub4[index] = data_ptr + 12; 510 pc->current.attribsUsedMask |= (1 << index); 511 WRITE_DATA( 0, GLuint, index ); 512 WRITE_DATA( 4, GLubyte, v[0] ); 513 WRITE_DATA( 5, GLubyte, v[1] ); 514 WRITE_DATA( 6, GLubyte, v[2] ); 515 WRITE_DATA( 7, GLubyte, v[3] ); 516 WRITE_OPCODE( pc, CR_VERTEXATTRIB4UBVARB_OPCODE ); 517 } 518 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c
r15532 r33457 10 10 static GLboolean __handleCombinerParameterData( GLenum pname, const GLfloat *params, GLenum extended_opcode ) 11 11 { 12 13 14 15 12 GET_PACKER_CONTEXT(pc); 13 unsigned int params_length = 0; 14 unsigned int packet_length = sizeof( int ) + sizeof( extended_opcode ) + sizeof( pname ); 15 unsigned char *data_ptr; 16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 17 switch( pname ) 18 { 19 case GL_CONSTANT_COLOR0_NV: 20 case GL_CONSTANT_COLOR1_NV: 21 params_length = 4 * sizeof( *params ); 22 break; 23 case GL_NUM_GENERAL_COMBINERS_NV: 24 case GL_COLOR_SUM_CLAMP_NV: 25 params_length = sizeof( *params ); 26 break; 27 default: 28 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 29 "crPackCombinerParameter(bad pname)" ); 30 CRASSERT(0); 31 return GL_FALSE; 32 } 33 packet_length += params_length; 34 GET_BUFFERED_POINTER(pc, packet_length ); 35 WRITE_DATA( 0, int, packet_length ); 36 WRITE_DATA( sizeof( int ) + 0, GLenum, extended_opcode ); 37 WRITE_DATA( sizeof( int ) + 4, GLenum, pname ); 38 WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] ); 39 if (params_length > sizeof( *params )) 40 { 41 WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] ); 42 WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] ); 43 WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] ); 44 CRASSERT(packet_length == sizeof(int) + 20 + 4); 45 } 46 return GL_TRUE; 47 47 } 48 48 49 49 void PACK_APIENTRY crPackCombinerParameterfvNV( GLenum pname, const GLfloat *params ) 50 50 { 51 52 53 51 GET_PACKER_CONTEXT(pc); 52 if (__handleCombinerParameterData( pname, params, CR_COMBINERPARAMETERFVNV_EXTEND_OPCODE )) 53 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 54 54 } 55 55 56 56 void PACK_APIENTRY crPackCombinerParameterivNV( GLenum pname, const GLint *params ) 57 57 { 58 59 60 61 58 /* floats and ints are the same size, so the packing should be the same */ 59 GET_PACKER_CONTEXT(pc); 60 if (__handleCombinerParameterData( pname, (const GLfloat *) params, CR_COMBINERPARAMETERIVNV_EXTEND_OPCODE )) 61 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 62 62 } 63 63 64 64 void PACK_APIENTRY crPackCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params ) 65 65 { 66 67 66 GET_PACKER_CONTEXT(pc); 67 unsigned char *data_ptr; 68 68 69 70 71 72 73 74 75 76 77 78 69 GET_BUFFERED_POINTER(pc, 32 ); 70 WRITE_DATA( 0, GLint, 32 ); 71 WRITE_DATA( 4, GLenum, CR_COMBINERSTAGEPARAMETERFVNV_EXTEND_OPCODE ); 72 WRITE_DATA( 8, GLenum, stage ); 73 WRITE_DATA( 12, GLenum, pname ); 74 WRITE_DATA( 16, GLfloat, params[0] ); 75 WRITE_DATA( 20, GLfloat, params[1] ); 76 WRITE_DATA( 24, GLfloat, params[2] ); 77 WRITE_DATA( 28, GLfloat, params[3] ); 78 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 79 79 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c
r15532 r33457 11 11 static int __gl_CallListsNumBytes( GLenum type ) 12 12 { 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 13 switch( type ) 14 { 15 case GL_BYTE: 16 case GL_UNSIGNED_BYTE: 17 case GL_2_BYTES: 18 return 1; 19 case GL_SHORT: 20 case GL_UNSIGNED_SHORT: 21 case GL_3_BYTES: 22 return 2; 23 case GL_INT: 24 case GL_UNSIGNED_INT: 25 case GL_FLOAT: 26 case GL_4_BYTES: 27 return 4; 28 default: 29 return -1; 30 } 31 31 } 32 32 33 33 void PACK_APIENTRY crPackCallListsSWAP(GLint n, GLenum type, 34 34 const GLvoid *lists ) 35 35 { 36 37 38 39 40 36 unsigned char *data_ptr; 37 int packet_length; 38 GLshort *shortPtr; 39 GLint *intPtr; 40 int i; 41 41 42 43 42 int bytesPerList = __gl_CallListsNumBytes( type ); 43 int numBytes = bytesPerList * n; 44 44 45 46 47 48 49 50 45 if (numBytes < 0) 46 { 47 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 48 "crPackCallLists(bad type)" ); 49 return; 50 } 51 51 52 53 54 52 packet_length = sizeof( n ) + 53 sizeof( type ) + 54 numBytes; 55 55 56 57 58 56 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 57 WRITE_DATA( 0, GLint, SWAP32(n) ); 58 WRITE_DATA( 4, GLenum, SWAP32(type) ); 59 59 60 61 62 60 crMemcpy( data_ptr + 8, lists, numBytes ); 61 shortPtr = (GLshort *) (data_ptr + 8); 62 intPtr = (GLint *) (data_ptr + 8); 63 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 64 if (bytesPerList > 1) 65 { 66 for ( i = 0 ; i < n ; i++) 67 { 68 switch( bytesPerList ) 69 { 70 case 2: 71 *shortPtr = SWAP16(*shortPtr); 72 shortPtr+=1; 73 break; 74 case 4: 75 *intPtr = SWAP32(*intPtr); 76 intPtr+=1; 77 break; 78 } 79 } 80 } 81 81 82 83 82 crHugePacket( CR_CALLLISTS_OPCODE, data_ptr ); 83 crPackFree( data_ptr ); 84 84 } 85 85 … … 87 87 void PACK_APIENTRY crPackNewListSWAP( GLuint list, GLenum mode ) 88 88 { 89 90 91 92 93 94 95 96 97 98 99 89 GET_PACKER_CONTEXT(pc); 90 unsigned char *data_ptr; 91 (void) pc; 92 GET_BUFFERED_POINTER( pc, 16 ); 93 WRITE_DATA( 0, GLint, SWAP32(16) ); 94 WRITE_DATA( 4, GLenum, SWAP32(CR_NEWLIST_EXTEND_OPCODE) ); 95 WRITE_DATA( 8, GLuint, SWAP32(list) ); 96 WRITE_DATA( 12, GLenum, SWAP32(mode) ); 97 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 98 pc->buffer.in_List = GL_TRUE; 99 pc->buffer.holds_List = GL_TRUE; 100 100 } 101 101 … … 103 103 void PACK_APIENTRY crPackEndListSWAP( void ) 104 104 { 105 106 107 108 109 110 111 112 105 GET_PACKER_CONTEXT(pc); 106 unsigned char *data_ptr; 107 (void) pc; 108 GET_BUFFERED_POINTER( pc, 8 ); 109 WRITE_DATA( 0, GLint, SWAP32(8) ); 110 WRITE_DATA( 4, GLenum, SWAP32(CR_ENDLIST_EXTEND_OPCODE) ); 111 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 112 pc->buffer.in_List = GL_FALSE; 113 113 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c
r15532 r33457 16 16 static int __gl_Map2NumComponents( GLenum target ) 17 17 { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 18 switch( target ) 19 { 20 case GL_MAP2_VERTEX_3: 21 case GL_MAP2_NORMAL: 22 case GL_MAP2_TEXTURE_COORD_3: 23 return 3; 24 case GL_MAP2_VERTEX_4: 25 case GL_MAP2_COLOR_4: 26 case GL_MAP2_TEXTURE_COORD_4: 27 return 4; 28 case GL_MAP2_INDEX: 29 case GL_MAP2_TEXTURE_COORD_1: 30 return 1; 31 case GL_MAP2_TEXTURE_COORD_2: 32 return 2; 33 default: 34 return -1; 35 } 36 36 } 37 37 38 38 static int __gl_Map1NumComponents( GLenum target ) 39 39 { 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 40 switch( target ) 41 { 42 case GL_MAP1_VERTEX_3: 43 case GL_MAP1_NORMAL: 44 case GL_MAP1_TEXTURE_COORD_3: 45 return 3; 46 case GL_MAP1_VERTEX_4: 47 case GL_MAP1_COLOR_4: 48 case GL_MAP1_TEXTURE_COORD_4: 49 return 4; 50 case GL_MAP1_INDEX: 51 case GL_MAP1_TEXTURE_COORD_1: 52 return 1; 53 case GL_MAP1_TEXTURE_COORD_2: 54 return 2; 55 default: 56 return -1; 57 } 58 58 } 59 59 60 60 void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1, 61 62 63 { 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 61 GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, 62 GLint vstride, GLint vorder, const GLdouble *points) 63 { 64 unsigned char *data_ptr; 65 int u,v; 66 int comp; 67 GLdouble *dest_data, *src_data; 68 int packet_length = 69 sizeof( target ) + 70 sizeof( u1 ) + 71 sizeof( u2 ) + 72 sizeof( uorder ) + 73 sizeof( ustride ) + 74 sizeof( v1 ) + 75 sizeof( v2 ) + 76 sizeof( vorder ) + 77 sizeof( vstride ); 78 79 int num_components = __gl_Map2NumComponents( target ); 80 if (num_components < 0) 81 { 82 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 83 "crPackMap2d(bad target)" ); 84 return; 85 } 86 87 packet_length += num_components*uorder*vorder*sizeof( *points ); 88 89 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 90 91 WRITE_DATA( 0, GLenum, SWAP32(target) ); 92 WRITE_SWAPPED_DOUBLE( 4, u1 ); 93 WRITE_SWAPPED_DOUBLE( 12, u2 ); 94 WRITE_DATA( 20, GLint, SWAP32(num_components) ); 95 WRITE_DATA( 24, GLint, SWAP32(uorder) ); 96 WRITE_SWAPPED_DOUBLE( 28, v1 ); 97 WRITE_SWAPPED_DOUBLE( 36, v2 ); 98 WRITE_DATA( 44, GLint, SWAP32(num_components*uorder) ); 99 WRITE_DATA( 48, GLint, SWAP32(vorder) ); 100 101 dest_data = (GLdouble *) (data_ptr + 52); 102 src_data = (GLdouble *) points; 103 for (v = 0 ; v < vorder ; v++) 104 { 105 for (u = 0 ; u < uorder ; u++) 106 { 107 for (comp = 0 ; comp < num_components ; comp++) 108 { 109 WRITE_SWAPPED_DOUBLE( ((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp) ); 110 } 111 dest_data += num_components; 112 src_data += ustride; 113 } 114 src_data += vstride - ustride*uorder; 115 } 116 117 crHugePacket( CR_MAP2D_OPCODE, data_ptr ); 118 crPackFree( data_ptr ); 119 119 } 120 120 121 121 void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1, 122 123 124 { 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 122 GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, 123 GLint vstride, GLint vorder, const GLfloat *points) 124 { 125 unsigned char *data_ptr; 126 int u,v; 127 int comp; 128 GLfloat *dest_data, *src_data; 129 int packet_length = 130 sizeof( target ) + 131 sizeof( u1 ) + 132 sizeof( u2 ) + 133 sizeof( uorder ) + 134 sizeof( ustride ) + 135 sizeof( v1 ) + 136 sizeof( v2 ) + 137 sizeof( vorder ) + 138 sizeof( vstride ); 139 140 int num_components = __gl_Map2NumComponents( target ); 141 if (num_components < 0) 142 { 143 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 144 "crPackMap2f(bad target)" ); 145 return; 146 } 147 148 packet_length += num_components*uorder*vorder*sizeof( *points ); 149 150 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 151 152 WRITE_DATA( 0, GLenum, SWAP32(target) ); 153 WRITE_DATA( 4, GLuint, SWAPFLOAT(u1) ); 154 WRITE_DATA( 8, GLuint, SWAPFLOAT(u2) ); 155 WRITE_DATA( 12, GLint, SWAP32(num_components) ); 156 WRITE_DATA( 16, GLint, SWAP32(uorder) ); 157 WRITE_DATA( 20, GLuint, SWAPFLOAT(v1) ); 158 WRITE_DATA( 24, GLuint, SWAPFLOAT(v2) ); 159 WRITE_DATA( 28, GLint, SWAP32(num_components*uorder) ); 160 WRITE_DATA( 32, GLint, SWAP32(vorder) ); 161 162 dest_data = (GLfloat *) (data_ptr + 36); 163 src_data = (GLfloat *) points; 164 for (v = 0 ; v < vorder ; v++) 165 { 166 for (u = 0 ; u < uorder ; u++) 167 { 168 for (comp = 0 ; comp < num_components ; comp++) 169 { 170 WRITE_DATA( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT( *(src_data + comp) ) ); 171 } 172 dest_data += num_components; 173 src_data += ustride; 174 } 175 src_data += vstride - ustride*uorder; 176 } 177 178 crHugePacket( CR_MAP2F_OPCODE, data_ptr ); 179 crPackFree( data_ptr ); 180 180 } 181 181 182 182 void PACK_APIENTRY crPackMap1dSWAP( GLenum target, GLdouble u1, 183 184 { 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 183 GLdouble u2, GLint stride, GLint order, const GLdouble *points ) 184 { 185 unsigned char *data_ptr; 186 int packet_length = 187 sizeof( target ) + 188 sizeof( u1 ) + 189 sizeof( u2 ) + 190 sizeof( stride ) + 191 sizeof( order ); 192 193 int num_components = __gl_Map1NumComponents( target ); 194 GLdouble *src_data, *dest_data; 195 int u; 196 int comp; 197 198 if (num_components < 0) 199 { 200 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 201 "crPackMap1d(bad target)" ); 202 return; 203 } 204 205 packet_length += num_components * order * sizeof( *points ); 206 207 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 208 209 WRITE_DATA( 0, GLenum, SWAP32(target) ); 210 WRITE_SWAPPED_DOUBLE( 4, u1 ); 211 WRITE_SWAPPED_DOUBLE( 12, u2 ); 212 WRITE_DATA( 20, GLint, SWAP32(num_components) ); 213 WRITE_DATA( 24, GLint, SWAP32(order) ); 214 215 dest_data = (GLdouble *) (data_ptr + 28); 216 src_data = (GLdouble *) points; 217 for (u = 0 ; u < order ; u++) 218 { 219 for (comp = 0 ; comp < num_components ; comp++) 220 { 221 WRITE_SWAPPED_DOUBLE( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, *(src_data + comp) ); 222 } 223 dest_data += num_components; 224 src_data += stride; 225 } 226 227 crHugePacket( CR_MAP1D_OPCODE, data_ptr ); 228 crPackFree( data_ptr ); 229 229 } 230 230 231 231 void PACK_APIENTRY crPackMap1fSWAP( GLenum target, GLfloat u1, 232 233 { 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 } 232 GLfloat u2, GLint stride, GLint order, const GLfloat *points ) 233 { 234 unsigned char *data_ptr; 235 int packet_length = 236 sizeof( target ) + 237 sizeof( u1 ) + 238 sizeof( u2 ) + 239 sizeof( stride ) + 240 sizeof( order ); 241 242 int num_components = __gl_Map1NumComponents( target ); 243 GLfloat *src_data, *dest_data; 244 int u; 245 int comp; 246 247 if (num_components < 0) 248 { 249 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 250 "crPackMap1f(bad target)" ); 251 return; 252 } 253 254 packet_length += num_components * order * sizeof( *points ); 255 256 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 257 258 WRITE_DATA( 0, GLenum, SWAP32(target) ); 259 WRITE_DATA( 4, GLuint, SWAPFLOAT(u1) ); 260 WRITE_DATA( 8, GLuint, SWAPFLOAT(u2) ); 261 WRITE_DATA( 12, GLint, SWAP32(num_components) ); 262 WRITE_DATA( 16, GLint, SWAP32(order) ); 263 264 dest_data = (GLfloat *) (data_ptr + 20); 265 src_data = (GLfloat *) points; 266 for (u = 0 ; u < order ; u++) 267 { 268 for (comp = 0 ; comp < num_components ; comp++) 269 { 270 WRITE_DATA( (unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT( *(src_data + comp) ) ); 271 } 272 dest_data += num_components; 273 src_data += stride; 274 } 275 276 crHugePacket( CR_MAP1F_OPCODE, data_ptr ); 277 crPackFree( data_ptr ); 278 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c
r15532 r33457 9 9 static unsigned char * __gl_HandlePixelMapData( GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values ) 10 10 { 11 11 int i; 12 12 13 14 15 16 17 13 int packet_length = 14 sizeof( map ) + 15 sizeof( mapsize ) + 16 mapsize*size_of_value; 17 unsigned char *data_ptr = (unsigned char *) crPackAlloc( packet_length ); 18 18 19 20 19 WRITE_DATA( 0, GLenum, SWAP32(map) ); 20 WRITE_DATA( 4, GLsizei, SWAP32(mapsize) ); 21 21 22 23 24 25 26 27 28 29 30 31 32 33 34 22 for (i = 0 ; i < mapsize ; i++) 23 { 24 switch( size_of_value ) 25 { 26 case 2: 27 WRITE_DATA( 8 + i*sizeof(GLshort), GLshort, SWAP16(*((GLshort *)values + i) )); 28 break; 29 case 4: 30 WRITE_DATA( 8 + i*sizeof(GLint), GLint, SWAP32(*((GLint *)values + i) )); 31 break; 32 } 33 } 34 return data_ptr; 35 35 } 36 36 37 37 void PACK_APIENTRY crPackPixelMapfvSWAP(GLenum map, GLsizei mapsize, 38 38 const GLfloat *values ) 39 39 { 40 40 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); 41 41 42 43 42 crHugePacket( CR_PIXELMAPFV_OPCODE, data_ptr ); 43 crPackFree( data_ptr ); 44 44 } 45 45 46 46 void PACK_APIENTRY crPackPixelMapuivSWAP(GLenum map, GLsizei mapsize, 47 47 const GLuint *values ) 48 48 { 49 49 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); 50 50 51 52 51 crHugePacket( CR_PIXELMAPUIV_OPCODE, data_ptr ); 52 crPackFree( data_ptr ); 53 53 } 54 54 55 55 void PACK_APIENTRY crPackPixelMapusvSWAP(GLenum map, GLsizei mapsize, 56 56 const GLushort *values ) 57 57 { 58 58 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); 59 59 60 61 60 crHugePacket( CR_PIXELMAPUSV_OPCODE, data_ptr ); 61 crPackFree( data_ptr ); 62 62 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c
r15532 r33457 12 12 13 13 void PACK_APIENTRY crPackTexImage1DSWAP(GLenum target, GLint level, 14 15 16 { 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 14 GLint internalformat, GLsizei width, GLint border, GLenum format, 15 GLenum type, const GLvoid *pixels, const CRPixelPackState *unpackstate ) 16 { 17 unsigned char *data_ptr; 18 int packet_length; 19 int isnull = (pixels == NULL); 20 21 packet_length = 22 sizeof( target ) + 23 sizeof( level ) + 24 sizeof( internalformat ) + 25 sizeof( width ) + 26 sizeof( border ) + 27 sizeof( format ) + 28 sizeof( type ) + 29 sizeof( int ); 30 31 if (pixels) 32 { 33 packet_length += crImageSize( format, type, width, 1 ); 34 } 35 36 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 37 WRITE_DATA( 0, GLenum, SWAP32(target) ); 38 WRITE_DATA( 4, GLint, SWAP32(level) ); 39 WRITE_DATA( 8, GLint, SWAP32(internalformat) ); 40 WRITE_DATA( 12, GLsizei, SWAP32(width) ); 41 WRITE_DATA( 16, GLint, SWAP32(border) ); 42 WRITE_DATA( 20, GLenum, SWAP32(format) ); 43 WRITE_DATA( 24, GLenum, SWAP32(type) ); 44 WRITE_DATA( 28, int, SWAP32(isnull) ); 45 46 if (pixels) { 47 CRPixelPackState tmpUnpackState = *unpackstate; 48 /* flip application-requested swapBytes state */ 49 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 50 51 crPixelCopy1D( (void *)(data_ptr + 32), format, type, 52 pixels, format, type, width, &tmpUnpackState ); 53 } 54 55 crHugePacket( CR_TEXIMAGE1D_OPCODE, data_ptr ); 56 crPackFree( data_ptr ); 57 57 } 58 58 59 59 void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level, 60 61 62 63 { 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 60 GLint internalformat, GLsizei width, GLsizei height, GLint border, 61 GLenum format, GLenum type, const GLvoid *pixels, 62 const CRPixelPackState *unpackstate ) 63 { 64 unsigned char *data_ptr; 65 int packet_length; 66 int isnull = (pixels == NULL); 67 68 packet_length = 69 sizeof( target ) + 70 sizeof( level ) + 71 sizeof( internalformat ) + 72 sizeof( width ) + 73 sizeof( height ) + 74 sizeof( border ) + 75 sizeof( format ) + 76 sizeof( type ) + 77 sizeof( int ); 78 79 if (pixels) 80 { 81 packet_length += crImageSize( format, type, width, height ); 82 } 83 84 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 85 WRITE_DATA( 0, GLenum, SWAP32(target) ); 86 WRITE_DATA( 4, GLint, SWAP32(level) ); 87 WRITE_DATA( 8, GLint, SWAP32(internalformat) ); 88 WRITE_DATA( 12, GLsizei, SWAP32(width) ); 89 WRITE_DATA( 16, GLsizei, SWAP32(height) ); 90 WRITE_DATA( 20, GLint, SWAP32(border) ); 91 WRITE_DATA( 24, GLenum, SWAP32(format) ); 92 WRITE_DATA( 28, GLenum, SWAP32(type) ); 93 WRITE_DATA( 32, int, SWAP32(isnull) ); 94 95 if (pixels) 96 { 97 CRPixelPackState tmpUnpackState = *unpackstate; 98 /* flip application-requested swapBytes state */ 99 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 100 101 crPixelCopy2D( width, height, 102 (void *)(data_ptr + 36), format, type, NULL, /* dst */ 103 pixels, format, type, &tmpUnpackState ); /* src */ 104 } 105 106 crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr ); 107 crPackFree( data_ptr ); 108 108 } 109 109 110 110 #if defined( GL_EXT_texture3D ) 111 111 void PACK_APIENTRY crPackTexImage3DEXTSWAP(GLenum target, GLint level, 112 112 GLenum internalformat, 113 113 GLsizei width, GLsizei height, GLsizei depth, GLint border, 114 114 GLenum format, GLenum type, const GLvoid *pixels, 115 115 const CRPixelPackState *unpackstate ) 116 116 { 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 117 unsigned char *data_ptr; 118 int packet_length; 119 int isnull = (pixels == NULL); 120 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; 121 int distrib_buf_len = 0; 122 int tex_size = 0; 123 124 packet_length = 125 sizeof( target ) + 126 sizeof( level ) + 127 sizeof( internalformat ) + 128 sizeof( width ) + 129 sizeof( height ) + 130 sizeof( depth ) + 131 sizeof( border ) + 132 sizeof( format ) + 133 sizeof( type ) + 134 sizeof( int ); 135 136 if (pixels) 137 { 138 if ( is_distrib ) 139 { 140 distrib_buf_len = crStrlen( pixels ) + 1 + 141 ( (type == GL_TRUE) ? width*height*3 : 0 ) ; 142 packet_length += distrib_buf_len ; 143 } 144 else 145 { 146 tex_size = crTextureSize( format, type, width, height, depth ); 147 packet_length += tex_size; 148 } 149 } 150 151 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 152 WRITE_DATA( 0, GLenum, SWAP32( target ) ); 153 WRITE_DATA( 4, GLint, SWAP32( level ) ); 154 WRITE_DATA( 8, GLint, SWAP32( internalformat ) ); 155 WRITE_DATA( 12, GLsizei, SWAP32( width ) ); 156 WRITE_DATA( 16, GLsizei, SWAP32( height ) ); 157 WRITE_DATA( 20, GLsizei, SWAP32( depth ) ); 158 WRITE_DATA( 24, GLint, SWAP32( border ) ); 159 WRITE_DATA( 28, GLenum, SWAP32( format ) ); 160 WRITE_DATA( 32, GLenum, SWAP32( type ) ); 161 WRITE_DATA( 36, int, SWAP32( isnull ) ); 162 163 if (pixels) 164 { 165 if ( is_distrib ) 166 { 167 crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ; 168 } 169 else 170 { 171 CRPixelPackState tmpUnpackState = *unpackstate; 172 /* flip application-requested swapBytes state */ 173 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 174 175 crPixelCopy3D( width, height, depth, 176 (void *)(data_ptr + 40), format, type, NULL, 177 pixels, format, type, &tmpUnpackState ); 178 } 179 } 180 181 crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr ); 182 crPackFree( data_ptr ); 183 183 } 184 184 #endif /* GL_EXT_texture3D */ … … 186 186 #ifdef CR_OPENGL_VERSION_1_2 187 187 void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level, 188 189 190 191 192 193 194 { 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 188 GLint internalformat, 189 GLsizei width, GLsizei height, 190 GLsizei depth, GLint border, 191 GLenum format, GLenum type, 192 const GLvoid *pixels, 193 const CRPixelPackState *unpackstate ) 194 { 195 unsigned char *data_ptr; 196 int packet_length; 197 int isnull = (pixels == NULL); 198 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; 199 int distrib_buf_len = 0; 200 int tex_size = 0; 201 202 packet_length = 203 sizeof( target ) + 204 sizeof( level ) + 205 sizeof( internalformat ) + 206 sizeof( width ) + 207 sizeof( height ) + 208 sizeof( depth ) + 209 sizeof( border ) + 210 sizeof( format ) + 211 sizeof( type ) + 212 sizeof( int ); 213 214 if (pixels) 215 { 216 if ( is_distrib ) 217 { 218 distrib_buf_len = crStrlen( pixels ) + 1 + 219 ( (type == GL_TRUE) ? width*height*3 : 0 ) ; 220 packet_length += distrib_buf_len ; 221 } 222 else 223 { 224 tex_size = crTextureSize( format, type, width, height, depth ); 225 packet_length += tex_size; 226 } 227 } 228 229 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 230 WRITE_DATA( 0, GLenum, SWAP32( target ) ); 231 WRITE_DATA( 4, GLint, SWAP32( level ) ); 232 WRITE_DATA( 8, GLint, SWAP32( internalformat ) ); 233 WRITE_DATA( 12, GLsizei, SWAP32( width ) ); 234 WRITE_DATA( 16, GLsizei, SWAP32( height ) ); 235 WRITE_DATA( 20, GLsizei, SWAP32( depth ) ); 236 WRITE_DATA( 24, GLint, SWAP32( border ) ); 237 WRITE_DATA( 28, GLenum, SWAP32( format ) ); 238 WRITE_DATA( 32, GLenum, SWAP32( type ) ); 239 WRITE_DATA( 36, int, SWAP32( isnull ) ); 240 241 if (pixels) 242 { 243 if ( is_distrib ) 244 { 245 crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ; 246 } 247 else 248 { 249 CRPixelPackState tmpUnpackState = *unpackstate; 250 /* flip application-requested swapBytes state */ 251 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 252 253 crPixelCopy3D( width, height, depth, 254 (void *)(data_ptr + 40), format, type, NULL, 255 pixels, format, type, &tmpUnpackState ); 256 } 257 } 258 259 crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr ); 260 crPackFree( data_ptr ); 261 261 } 262 262 #endif /* CR_OPENGL_VERSION_1_2 */ … … 265 265 void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures ) 266 266 { 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 267 unsigned char *data_ptr; 268 int i; 269 270 int packet_length = 271 sizeof( n ) + 272 n*sizeof( *textures ); 273 274 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 275 WRITE_DATA( 0, GLsizei, SWAP32(n) ); 276 277 for ( i = 0 ; i < n ; i++) 278 { 279 WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) ); 280 } 281 crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr ); 282 crPackFree( data_ptr ); 283 283 } 284 284 285 285 static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params ) 286 286 { 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 287 GET_PACKER_CONTEXT(pc); 288 unsigned char *data_ptr; 289 int num_params; 290 int i; 291 292 int packet_length = 293 sizeof( int ) + 294 sizeof( target ) + 295 sizeof( pname ); 296 297 num_params = 1; 298 if ( pname == GL_TEXTURE_ENV_COLOR ) 299 { 300 num_params = 4; 301 } 302 303 packet_length += num_params*sizeof(*params); 304 305 GET_BUFFERED_POINTER(pc, packet_length ); 306 WRITE_DATA( 0, int, SWAP32(packet_length) ); 307 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) ); 308 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); 309 for ( i = 0 ; i < num_params ; i++) 310 { 311 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) ); 312 } 313 313 } 314 314 315 315 316 316 void PACK_APIENTRY crPackTexEnvfvSWAP( GLenum target, GLenum pname, 317 318 { 319 320 321 317 const GLfloat *params ) 318 { 319 GET_PACKER_CONTEXT(pc); 320 __handleTexEnvData( target, pname, params ); 321 WRITE_OPCODE( pc, CR_TEXENVFV_OPCODE ); 322 322 } 323 323 324 324 void PACK_APIENTRY crPackTexEnvivSWAP( GLenum target, GLenum pname, 325 326 { 327 328 329 330 325 const GLint *params ) 326 { 327 /* floats and ints are the same size, so the packing should be the same */ 328 GET_PACKER_CONTEXT(pc); 329 __handleTexEnvData( target, pname, (const GLfloat *) params ); 330 WRITE_OPCODE( pc, CR_TEXENVIV_OPCODE ); 331 331 } 332 332 333 333 void PACK_APIENTRY crPackTexEnviSWAP( GLenum target, GLenum pname, GLint param ) 334 334 { 335 335 crPackTexEnvivSWAP( target, pname, ¶m ); 336 336 } 337 337 338 338 void PACK_APIENTRY crPackTexEnvfSWAP( GLenum target, GLenum pname, GLfloat param ) 339 339 { 340 340 crPackTexEnvfvSWAP( target, pname, ¶m ); 341 341 } 342 342 343 343 void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n, 344 345 { 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 344 const GLuint *textures, const GLclampf *priorities ) 345 { 346 unsigned char *data_ptr; 347 int packet_length = 348 sizeof( n ) + 349 n*sizeof( *textures ) + 350 n*sizeof( *priorities ); 351 int i; 352 353 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 354 WRITE_DATA( 0, GLsizei, SWAP32(n) ); 355 for ( i = 0 ; i < n ; i++) 356 { 357 WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i])); 358 } 359 for ( i = 0 ; i < n ; i++) 360 { 361 WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ), 362 GLuint, SWAPFLOAT(priorities[i])); 363 } 364 365 crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr ); 366 crPackFree( data_ptr ); 367 367 } 368 368 369 369 static void __handleTexGenData( GLenum coord, GLenum pname, 370 371 { 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 370 int sizeof_param, const GLvoid *params ) 371 { 372 GET_PACKER_CONTEXT(pc); 373 unsigned char *data_ptr; 374 int packet_length = sizeof( int ) + sizeof( coord ) + sizeof( pname ); 375 int num_params = 1; 376 int i; 377 if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE) 378 { 379 num_params = 4; 380 } 381 packet_length += num_params * sizeof_param; 382 383 GET_BUFFERED_POINTER(pc, packet_length ); 384 WRITE_DATA( 0, int, SWAP32(packet_length) ); 385 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(coord) ); 386 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); 387 for ( i = 0 ; i < num_params ; i++) 388 { 389 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLint, SWAP32(((GLint *)params)[i]) ); 390 } 391 391 } 392 392 393 393 void PACK_APIENTRY crPackTexGendvSWAP( GLenum coord, GLenum pname, 394 395 { 396 397 398 394 const GLdouble *params ) 395 { 396 GET_PACKER_CONTEXT(pc); 397 __handleTexGenData( coord, pname, sizeof( *params ), params ); 398 WRITE_OPCODE( pc, CR_TEXGENDV_OPCODE ); 399 399 } 400 400 401 401 void PACK_APIENTRY crPackTexGenfvSWAP( GLenum coord, GLenum pname, 402 403 { 404 405 406 402 const GLfloat *params ) 403 { 404 GET_PACKER_CONTEXT(pc); 405 __handleTexGenData( coord, pname, sizeof( *params ), params ); 406 WRITE_OPCODE( pc, CR_TEXGENFV_OPCODE ); 407 407 } 408 408 409 409 void PACK_APIENTRY crPackTexGenivSWAP( GLenum coord, GLenum pname, 410 411 { 412 413 414 410 const GLint *params ) 411 { 412 GET_PACKER_CONTEXT(pc); 413 __handleTexGenData( coord, pname, sizeof( *params ), params ); 414 WRITE_OPCODE( pc, CR_TEXGENIV_OPCODE ); 415 415 } 416 416 417 417 void PACK_APIENTRY crPackTexGendSWAP( GLenum coord, GLenum pname, GLdouble param ) 418 418 { 419 419 crPackTexGendvSWAP( coord, pname, ¶m ); 420 420 } 421 421 422 422 void PACK_APIENTRY crPackTexGenfSWAP( GLenum coord, GLenum pname, GLfloat param ) 423 423 { 424 424 crPackTexGenfvSWAP( coord, pname, ¶m ); 425 425 } 426 426 427 427 void PACK_APIENTRY crPackTexGeniSWAP( GLenum coord, GLenum pname, GLint param ) 428 428 { 429 429 crPackTexGenivSWAP( coord, pname, ¶m ); 430 430 } 431 431 432 432 static GLboolean __handleTexParameterData( GLenum target, GLenum pname, const GLfloat *params ) 433 433 { 434 435 436 437 438 439 440 441 442 443 444 445 446 447 434 GET_PACKER_CONTEXT(pc); 435 unsigned char *data_ptr; 436 int packet_length = sizeof( int ) + sizeof( target ) + sizeof( pname ); 437 int num_params = 0; 438 int i; 439 440 switch( pname ) 441 { 442 443 case GL_TEXTURE_MIN_FILTER: 444 case GL_TEXTURE_MAG_FILTER: 445 case GL_TEXTURE_WRAP_R: 446 case GL_TEXTURE_WRAP_S: 447 case GL_TEXTURE_WRAP_T: 448 448 #ifdef GL_TEXTURE_PRIORITY 449 449 case GL_TEXTURE_PRIORITY: 450 450 #endif 451 452 453 454 455 456 457 458 459 460 461 462 463 464 451 num_params = 1; 452 break; 453 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 454 num_params = 1; 455 break; 456 case GL_TEXTURE_MIN_LOD: 457 case GL_TEXTURE_MAX_LOD: 458 case GL_TEXTURE_BASE_LEVEL: 459 case GL_TEXTURE_MAX_LEVEL: 460 num_params = 1; 461 break; 462 case GL_TEXTURE_BORDER_COLOR: 463 num_params = 4; 464 break; 465 465 #ifdef CR_ARB_shadow 466 467 468 469 466 case GL_TEXTURE_COMPARE_MODE_ARB: 467 case GL_TEXTURE_COMPARE_FUNC_ARB: 468 num_params = 1; 469 break; 470 470 #endif 471 471 #ifdef CR_ARB_shadow_ambient 472 473 474 472 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 473 num_params = 1; 474 break; 475 475 #endif 476 476 #ifdef CR_ARB_depth_texture 477 478 479 477 case GL_DEPTH_TEXTURE_MODE_ARB: 478 num_params = 1; 479 break; 480 480 #endif 481 481 #ifdef CR_SGIS_generate_mipmap 482 483 484 482 case GL_GENERATE_MIPMAP_SGIS: 483 num_params = 1; 484 break; 485 485 #endif 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 486 default: 487 num_params = __packTexParameterNumParams( pname ); 488 if (!num_params) 489 { 490 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 491 "crPackTexParameter(bad pname)" ); 492 return GL_FALSE; 493 } 494 } 495 packet_length += num_params * sizeof(*params); 496 497 GET_BUFFERED_POINTER(pc, packet_length ); 498 WRITE_DATA( 0, int, SWAP32(packet_length) ); 499 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) ); 500 WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); 501 for ( i = 0 ; i < num_params ; i++) 502 { 503 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT(params[i]) ); 504 } 505 return GL_TRUE; 506 506 } 507 507 508 508 void PACK_APIENTRY crPackTexParameterfvSWAP( GLenum target, GLenum pname, 509 510 { 511 512 513 509 const GLfloat *params ) 510 { 511 GET_PACKER_CONTEXT(pc); 512 if (__handleTexParameterData( target, pname, params )) 513 WRITE_OPCODE( pc, CR_TEXPARAMETERFV_OPCODE ); 514 514 } 515 515 516 516 void PACK_APIENTRY crPackTexParameterivSWAP( GLenum target, GLenum pname, 517 518 { 519 520 521 517 const GLint *params ) 518 { 519 GET_PACKER_CONTEXT(pc); 520 if (__handleTexParameterData( target, pname, (GLfloat *) params )) 521 WRITE_OPCODE( pc, CR_TEXPARAMETERIV_OPCODE ); 522 522 } 523 523 524 524 void PACK_APIENTRY crPackTexParameterfSWAP( GLenum target, GLenum pname, GLfloat param ) 525 525 { 526 526 crPackTexParameterfvSWAP( target, pname, ¶m ); 527 527 } 528 528 529 529 void PACK_APIENTRY crPackTexParameteriSWAP( GLenum target, GLenum pname, GLint param ) 530 530 { 531 531 crPackTexParameterivSWAP( target, pname, ¶m ); 532 532 } 533 533 … … 546 546 sizeof( xoffset ) + 547 547 sizeof( yoffset ) + 548 548 sizeof( zoffset ) + 549 549 sizeof( width ) + 550 550 sizeof( height ) + 551 551 sizeof( depth ) + 552 552 sizeof( format ) + 553 553 sizeof( type ) + … … 559 559 WRITE_DATA( 8, GLint, SWAP32(xoffset) ); 560 560 WRITE_DATA( 12, GLint, SWAP32(yoffset) ); 561 561 WRITE_DATA( 16, GLint, SWAP32(zoffset) ); 562 562 WRITE_DATA( 20, GLsizei, SWAP32(width) ); 563 563 WRITE_DATA( 24, GLsizei, SWAP32(height) ); 564 564 WRITE_DATA( 28, GLsizei, SWAP32(depth) ); 565 565 WRITE_DATA( 32, GLenum, SWAP32(format) ); 566 566 WRITE_DATA( 36, GLenum, SWAP32(type) ); … … 576 576 577 577 void PACK_APIENTRY crPackTexSubImage2DSWAP (GLenum target, GLint level, 578 579 580 581 { 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 578 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, 579 GLenum format, GLenum type, const GLvoid *pixels, 580 const CRPixelPackState *unpackstate ) 581 { 582 unsigned char *data_ptr; 583 int packet_length; 584 585 CRPixelPackState tmpUnpackState = *unpackstate; 586 587 packet_length = 588 sizeof( target ) + 589 sizeof( level ) + 590 sizeof( xoffset ) + 591 sizeof( yoffset ) + 592 sizeof( width ) + 593 sizeof( height ) + 594 sizeof( format ) + 595 sizeof( type ) + 596 crImageSize( format, type, width, height ); 597 598 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 599 WRITE_DATA( 0, GLenum, SWAP32(target) ); 600 WRITE_DATA( 4, GLint, SWAP32(level) ); 601 WRITE_DATA( 8, GLint, SWAP32(xoffset) ); 602 WRITE_DATA( 12, GLint, SWAP32(yoffset) ); 603 WRITE_DATA( 16, GLsizei, SWAP32(width) ); 604 WRITE_DATA( 20, GLsizei, SWAP32(height) ); 605 WRITE_DATA( 24, GLenum, SWAP32(format) ); 606 WRITE_DATA( 28, GLenum, SWAP32(type) ); 607 608 /* flip application-requested swapBytes state */ 609 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 610 611 crPixelCopy2D( width, height, 612 (GLvoid *) (data_ptr + 32), format, type, NULL, /* dst */ 613 pixels, format, type, &tmpUnpackState ); /* src */ 614 615 crHugePacket( CR_TEXSUBIMAGE2D_OPCODE, data_ptr ); 616 crPackFree( data_ptr ); 617 617 } 618 618 619 619 void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level, 620 621 622 { 623 624 620 GLint xoffset, GLsizei width, GLenum format, GLenum type, 621 const GLvoid *pixels, const CRPixelPackState *unpackstate ) 622 { 623 unsigned char *data_ptr; 624 int packet_length; 625 625 CRPixelPackState tmpUnpackState = *unpackstate; 626 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 627 packet_length = 628 sizeof( target ) + 629 sizeof( level ) + 630 sizeof( xoffset ) + 631 sizeof( width ) + 632 sizeof( format ) + 633 sizeof( type ) + 634 crImageSize( format, type, width, 1 ); 635 636 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 637 WRITE_DATA( 0, GLenum, SWAP32(target) ); 638 WRITE_DATA( 4, GLint, SWAP32(level) ); 639 WRITE_DATA( 8, GLint, SWAP32(xoffset) ); 640 WRITE_DATA( 12, GLsizei, SWAP32(width) ); 641 WRITE_DATA( 16, GLenum, SWAP32(format) ); 642 WRITE_DATA( 20, GLenum, SWAP32(type) ); 643 644 /* flip application-requested swapBytes state */ 645 tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; 646 647 crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type, 648 pixels, format, type, width, &tmpUnpackState ); 649 650 crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr ); 651 crPackFree( data_ptr ); 652 652 } 653 653 654 654 void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback ) 655 655 { 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 656 GET_PACKER_CONTEXT(pc); 657 unsigned char *data_ptr; 658 int packet_length; 659 int i; 660 661 packet_length = 662 sizeof( int ) + /* packet length */ 663 sizeof( GLenum ) + /* extend-o opcode */ 664 sizeof( n ) + /* num_textures */ 665 n*sizeof( *textures ) + /* textures */ 666 8 + 8 + 8; /* return pointers */ 667 668 GET_BUFFERED_POINTER(pc, packet_length); 669 WRITE_DATA( 0, int, SWAP32(packet_length) ); 670 WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) ); 671 WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) ); 672 for (i = 0 ; i < n ; i++) 673 { 674 WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) ); 675 } 676 WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences ); 677 WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val ); 678 WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback ); 679 WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); 680 680 } 681 681 … … 687 687 void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data ) 688 688 { 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 689 unsigned char *data_ptr; 690 int packet_length; 691 int isnull = (data == NULL); 692 693 /* All extended opcodes have their first 8 bytes predefined: 694 * the first four indicate the packet size, and the next four 695 * indicate the actual extended opcode. 696 */ 697 packet_length = 698 sizeof( GLenum) + /* extended opcode */ 699 sizeof( target ) + 700 sizeof( level ) + 701 sizeof( internalformat ) + 702 sizeof( width ) + 703 sizeof( border ) + 704 sizeof( imagesize ) + 705 sizeof( int ); 706 707 if (data) 708 { 709 packet_length += imagesize; 710 } 711 712 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 713 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) ); 714 WRITE_DATA( 4, GLenum, SWAP32(target) ); 715 WRITE_DATA( 8, GLint, SWAP32(level) ); 716 WRITE_DATA( 12, GLint, SWAP32(internalformat) ); 717 WRITE_DATA( 16, GLsizei, SWAP32(width) ); 718 WRITE_DATA( 20, GLint, SWAP32(border) ); 719 WRITE_DATA( 24, GLsizei, SWAP32(imagesize) ); 720 WRITE_DATA( 28, int, SWAP32(isnull) ); 721 722 if (data) { 723 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); 724 } 725 726 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 727 crPackFree( data_ptr ); 728 728 } 729 729 730 730 void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data ) 731 731 { 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 732 unsigned char *data_ptr; 733 int packet_length; 734 int isnull = (data == NULL); 735 736 /* All extended opcodes have their first 8 bytes predefined: 737 * the first four indicate the packet size, and the next four 738 * indicate the actual extended opcode. 739 */ 740 packet_length = 741 sizeof( GLenum) + /* extended opcode */ 742 sizeof( target ) + 743 sizeof( level ) + 744 sizeof( internalformat ) + 745 sizeof( width ) + 746 sizeof( height ) + 747 sizeof( border ) + 748 sizeof( imagesize ) + 749 sizeof( int ); /* isnull */ 750 751 if (data) 752 { 753 packet_length += imagesize; 754 } 755 756 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 757 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) ); 758 WRITE_DATA( 4, GLenum, SWAP32(target) ); 759 WRITE_DATA( 8, GLint, SWAP32(level) ); 760 WRITE_DATA( 12, GLint, SWAP32(internalformat) ); 761 WRITE_DATA( 16, GLsizei, SWAP32(width) ); 762 WRITE_DATA( 20, GLsizei, SWAP32(height) ); 763 WRITE_DATA( 24, GLint, SWAP32(border) ); 764 WRITE_DATA( 28, GLsizei, SWAP32(imagesize) ); 765 WRITE_DATA( 32, int, SWAP32(isnull) ); 766 767 if (data) { 768 crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); 769 } 770 771 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 772 crPackFree( data_ptr ); 773 773 } 774 774 775 775 void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data ) 776 776 { 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 777 unsigned char *data_ptr; 778 int packet_length; 779 int isnull = (data == NULL); 780 781 /* All extended opcodes have their first 8 bytes predefined: 782 * the first four indicate the packet size, and the next four 783 * indicate the actual extended opcode. 784 */ 785 packet_length = 786 sizeof( GLenum) + /* extended opcode */ 787 sizeof( target ) + 788 sizeof( level ) + 789 sizeof( internalformat ) + 790 sizeof( width ) + 791 sizeof( height ) + 792 sizeof( depth ) + 793 sizeof( border ) + 794 sizeof( imagesize ) + 795 sizeof( int ); /* isnull */ 796 797 if (data) 798 { 799 packet_length += imagesize; 800 } 801 802 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 803 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) ); 804 WRITE_DATA( 4, GLenum, SWAP32(target) ); 805 WRITE_DATA( 8, GLint, SWAP32(level) ); 806 WRITE_DATA( 12, GLint, SWAP32(internalformat) ); 807 WRITE_DATA( 16, GLsizei, SWAP32(width) ); 808 WRITE_DATA( 20, GLsizei, SWAP32(height) ); 809 WRITE_DATA( 24, GLsizei, SWAP32(depth) ); 810 WRITE_DATA( 28, GLint, SWAP32(border) ); 811 WRITE_DATA( 32, GLsizei, SWAP32(imagesize) ); 812 WRITE_DATA( 36, int, SWAP32(isnull) ); 813 814 if (data) { 815 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); 816 } 817 818 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 819 crPackFree( data_ptr ); 820 820 } 821 821 822 822 void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data ) 823 823 { 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 824 unsigned char *data_ptr; 825 int packet_length; 826 int isnull = (data == NULL); 827 828 /* All extended opcodes have their first 8 bytes predefined: 829 * the first four indicate the packet size, and the next four 830 * indicate the actual extended opcode. 831 */ 832 packet_length = 833 sizeof( GLenum) + /* extended opcode */ 834 sizeof( target ) + 835 sizeof( level ) + 836 sizeof( xoffset ) + 837 sizeof( width ) + 838 sizeof( format ) + 839 sizeof( imagesize ) + 840 sizeof( int ); /* isnull */ 841 842 if (data) 843 { 844 packet_length += imagesize; 845 } 846 847 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 848 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) ); 849 WRITE_DATA( 4, GLenum, SWAP32(target) ); 850 WRITE_DATA( 8, GLint, SWAP32(level) ); 851 WRITE_DATA( 12, GLint, SWAP32(xoffset) ); 852 WRITE_DATA( 16, GLsizei, SWAP32(width) ); 853 WRITE_DATA( 20, GLenum, SWAP32(format) ); 854 WRITE_DATA( 24, GLsizei, SWAP32(imagesize) ); 855 WRITE_DATA( 28, int, SWAP32(isnull) ); 856 857 if (data) { 858 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); 859 } 860 861 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 862 crPackFree( data_ptr ); 863 863 } 864 864 865 865 void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data ) 866 866 { 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 867 unsigned char *data_ptr; 868 int packet_length; 869 int isnull = (data == NULL); 870 871 /* All extended opcodes have their first 8 bytes predefined: 872 * the first four indicate the packet size, and the next four 873 * indicate the actual extended opcode. 874 */ 875 packet_length = 876 sizeof( GLenum) + /* extended opcode */ 877 sizeof( target ) + 878 sizeof( level ) + 879 sizeof( xoffset ) + 880 sizeof( yoffset ) + 881 sizeof( width ) + 882 sizeof( height ) + 883 sizeof( format ) + 884 sizeof( imagesize ) + 885 sizeof( int ); /* isnull */ 886 887 if (data) 888 { 889 packet_length += imagesize; 890 } 891 892 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 893 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) ); 894 WRITE_DATA( 4, GLenum, SWAP32(target) ); 895 WRITE_DATA( 8, GLint, SWAP32(level) ); 896 WRITE_DATA( 12, GLint, SWAP32(xoffset) ); 897 WRITE_DATA( 16, GLint, SWAP32(yoffset) ); 898 WRITE_DATA( 20, GLsizei, SWAP32(width) ); 899 WRITE_DATA( 24, GLsizei, SWAP32(height) ); 900 WRITE_DATA( 28, GLenum, SWAP32(format) ); 901 WRITE_DATA( 32, GLsizei, SWAP32(imagesize) ); 902 WRITE_DATA( 36, int, SWAP32(isnull) ); 903 904 if (data) { 905 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); 906 } 907 908 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 909 crPackFree( data_ptr ); 910 910 } 911 911 912 912 void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data ) 913 913 { 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 914 unsigned char *data_ptr; 915 int packet_length; 916 int isnull = (data == NULL); 917 918 /* All extended opcodes have their first 8 bytes predefined: 919 * the first four indicate the packet size, and the next four 920 * indicate the actual extended opcode. 921 */ 922 packet_length = 923 sizeof( GLenum) + /* extended opcode */ 924 sizeof( target ) + 925 sizeof( level ) + 926 sizeof( xoffset ) + 927 sizeof( yoffset ) + 928 sizeof( zoffset ) + 929 sizeof( width ) + 930 sizeof( height ) + 931 sizeof( depth ) + 932 sizeof( format ) + 933 sizeof( imagesize ) + 934 sizeof( int ); /* isnull */ 935 936 if (data) 937 { 938 packet_length += imagesize; 939 } 940 941 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 942 WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) ); 943 WRITE_DATA( 4, GLenum, SWAP32(target) ); 944 WRITE_DATA( 8, GLint, SWAP32(level) ); 945 WRITE_DATA( 12, GLint, SWAP32(xoffset) ); 946 WRITE_DATA( 16, GLint, SWAP32(yoffset) ); 947 WRITE_DATA( 20, GLint, SWAP32(zoffset) ); 948 WRITE_DATA( 24, GLsizei, SWAP32(width) ); 949 WRITE_DATA( 28, GLsizei, SWAP32(height) ); 950 WRITE_DATA( 32, GLsizei, SWAP32(depth) ); 951 WRITE_DATA( 36, GLenum, SWAP32(format) ); 952 WRITE_DATA( 40, GLsizei, SWAP32(imagesize) ); 953 WRITE_DATA( 44, int, SWAP32(isnull) ); 954 955 if (data) { 956 crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize); 957 } 958 959 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 960 crPackFree( data_ptr ); 961 961 } 962 962 963 963 void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback ) 964 964 { 965 966 967 968 969 970 971 972 } 965 GET_PACKER_CONTEXT(pc); 966 crError ( "GetCompressedTexImageARB needs to be special cased!"); 967 (void) pc; 968 (void) target; 969 (void) level; 970 (void) img; 971 (void) writeback; 972 }
Note:
See TracChangeset
for help on using the changeset viewer.