Changeset 27091 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Mar 5, 2010 2:13:31 PM (15 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py
r20467 r27091 612 612 'GLsizeiptrARB': 4, # XXX or 8 bytes? 613 613 'GLhandleARB': 4, 614 'GLcharARB': 1 614 'GLcharARB': 1, 615 'uintptr_t': 4 615 616 } 616 617 -
trunk/src/VBox/GuestHost/OpenGL/include/cr_extstring.h
r22284 r27091 94 94 "GL_ARB_vertex_buffer_object " 95 95 #endif 96 #ifdef CR_ARB_pixel_buffer_object 97 "GL_ARB_pixel_buffer_object " 98 #endif 96 99 #ifdef CR_ARB_vertex_program 97 100 "GL_ARB_vertex_program " -
trunk/src/VBox/GuestHost/OpenGL/include/cr_protocol.h
r23399 r27091 16 16 /*For now guest is allowed to connect host opengl service if protocol version matches exactly*/ 17 17 /*Note: that after any change to this file, or glapi_parser\apispec.txt version should be changed*/ 18 #define CR_PROTOCOL_VERSION_MAJOR 518 #define CR_PROTOCOL_VERSION_MAJOR 6 19 19 #define CR_PROTOCOL_VERSION_MINOR 1 20 20 -
trunk/src/VBox/GuestHost/OpenGL/include/cr_version.h
r22284 r27091 122 122 #define CR_EXT_compiled_vertex_array 1 123 123 124 #define CR_ARB_pixel_buffer_object 1 125 124 126 #endif /* CR_VERSION_H */ -
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
r23123 r27091 19 19 CRbitvalue arrayBinding[CR_MAX_BITARRAY]; 20 20 CRbitvalue elementsBinding[CR_MAX_BITARRAY]; 21 CRbitvalue packBinding[CR_MAX_BITARRAY]; 22 CRbitvalue unpackBinding[CR_MAX_BITARRAY]; 21 23 } CRBufferObjectBits; 22 24 … … 34 36 GLvoid *pointer; /* only valid while buffer is mapped */ 35 37 GLvoid *data; /* the buffer data, if retainBufferData is true */ 38 GLboolean bResyncOnRead; /* buffer data could be changed on server side, 39 so we need to resync every time guest wants to read from it*/ 36 40 CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */ 37 41 GLintptrARB dirtyStart, dirtyLength; /* dirty region */ … … 42 46 CRBufferObject *arrayBuffer; 43 47 CRBufferObject *elementsBuffer; 48 CRBufferObject *packBuffer; 49 CRBufferObject *unpackBuffer; 44 50 45 51 CRBufferObject *nullBuffer; /* name = 0 */ … … 50 56 } CRBufferObjectState; 51 57 58 DECLEXPORT(CRBufferObject *) crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b); 59 DECLEXPORT(GLboolean) crStateIsBufferBound(GLenum target); 52 60 53 61 #ifdef __cplusplus -
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h
r26407 r27091 228 228 GLboolean ARB_transpose_matrix; 229 229 GLboolean ARB_vertex_buffer_object; 230 GLboolean ARB_pixel_buffer_object; 230 231 GLboolean ARB_vertex_program; 231 232 GLboolean ARB_window_pos; -
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
r25154 r27091 22 22 */ 23 23 #define CR_STATE_NO_TEXTURE_IMAGE_STORE 24 25 #if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE) 26 #error CR_ARB_pixel_buffer_object not supported without CR_STATE_NO_TEXTURE_IMAGE_STORE 27 #endif 24 28 25 29 #define CR_MAX_MIPMAP_LEVELS 20 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_pixelmap.c
r27073 r27091 7 7 #include "packer.h" 8 8 #include "cr_mem.h" 9 #include "cr_glstate.h" 9 10 10 11 static unsigned char * __gl_HandlePixelMapData(GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values) 11 12 { 13 int nodata = (values == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 12 14 int packet_length = 13 15 sizeof( map ) + 14 sizeof( mapsize ) + 15 mapsize*size_of_value; 16 unsigned char *data_ptr = (unsigned char *) crPackAlloc( packet_length ); 16 sizeof( mapsize ) + sizeof(int) + sizeof(uintptr_t); 17 unsigned char *data_ptr; 18 19 if (!nodata) 20 { 21 packet_length += mapsize*size_of_value; 22 } 23 24 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 17 25 18 26 WRITE_DATA( 0, GLenum, map ); 19 27 WRITE_DATA( 4, GLsizei, mapsize ); 20 crMemcpy( data_ptr + 8, values, mapsize*size_of_value ); 28 WRITE_DATA( 8, int, nodata); 29 WRITE_DATA( 12, uintptr_t, (uintptr_t)values); 30 31 if (!nodata) 32 { 33 crMemcpy( data_ptr + 16, values, mapsize*size_of_value ); 34 } 35 21 36 return data_ptr; 22 37 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_pixels.c
r21854 r27091 12 12 13 13 14 void PACK_APIENTRY crPackDrawPixels( 15 16 17 14 void PACK_APIENTRY crPackDrawPixels(GLsizei width, GLsizei height, 15 GLenum format, GLenum type, 16 const GLvoid *pixels, 17 const CRPixelPackState *unpackstate ) 18 18 { 19 19 unsigned char *data_ptr; 20 20 int packet_length, imagesize; 21 22 if (pixels == NULL) 23 { 24 return; 25 } 26 27 #if 0 28 /* WHAT IS THIS FOR? Disabled by Brian on 3 Dec 2003 */ 29 if (type == GL_BITMAP) 30 { 31 crPackBitmap( width, height, 0, 0, 0, 0, 32 (const GLubyte *) pixels, unpackstate ); 33 } 34 #endif 21 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 35 22 36 23 packet_length = … … 38 25 sizeof( height ) + 39 26 sizeof( format ) + 40 sizeof( type ); 41 42 imagesize = crImageSize( format, type, width, height ); 43 44 if (imagesize<=0) 45 { 46 crDebug("crPackDrawPixels: 0 image size, ignoring"); 47 return; 48 } 49 50 packet_length += imagesize; 27 sizeof( type ) + sizeof(int) + sizeof(uintptr_t); 28 29 if (!noimagedata) 30 { 31 imagesize = crImageSize( format, type, width, height ); 32 33 if (imagesize<=0) 34 { 35 crDebug("crPackDrawPixels: 0 image size, ignoring"); 36 return; 37 } 38 packet_length += imagesize; 39 } 51 40 52 41 data_ptr = (unsigned char *) crPackAlloc( packet_length ); … … 55 44 WRITE_DATA( 8, GLenum, format ); 56 45 WRITE_DATA( 12, GLenum, type ); 57 58 crPixelCopy2D( width, height, 59 (void *) (data_ptr + 16), format, type, NULL, /* dst */ 60 pixels, format, type, unpackstate ); /* src */ 46 WRITE_DATA( 16, GLint, noimagedata ); 47 WRITE_DATA( 20, uintptr_t, (uintptr_t) pixels ); 48 49 if (!noimagedata) 50 { 51 crPixelCopy2D(width, height, 52 (void *) (data_ptr + 24), format, type, NULL, /* dst */ 53 pixels, format, type, unpackstate); /* src */ 54 } 61 55 62 56 crHugePacket( CR_DRAWPIXELS_OPCODE, data_ptr ); … … 64 58 } 65 59 66 void PACK_APIENTRY crPackReadPixels( 67 68 69 70 60 void PACK_APIENTRY crPackReadPixels(GLint x, GLint y, GLsizei width, 61 GLsizei height, GLenum format, 62 GLenum type, GLvoid *pixels, 63 const CRPixelPackState *packstate, 64 int *writeback) 71 65 { 72 66 GET_PACKER_CONTEXT(pc); … … 115 109 #define CEIL8(N) (((N) + 7) & ~0x7) 116 110 117 void PACK_APIENTRY crPackBitmap( 118 GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,119 const GLubyte *bitmap, const CRPixelPackState *unpack )120 { 121 const int isnull = (bitmap == NULL);111 void PACK_APIENTRY crPackBitmap(GLsizei width, GLsizei height, 112 GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, 113 const GLubyte *bitmap, const CRPixelPackState *unpack ) 114 { 115 const int noimagedata = (bitmap == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 122 116 unsigned char *data_ptr; 123 117 int data_length = 0; … … 130 124 sizeof( xmove ) + 131 125 sizeof( ymove ) + 132 sizeof( GLuint ) ;133 134 if ( bitmap)126 sizeof( GLuint ) + sizeof(uintptr_t); 127 128 if (!noimagedata) 135 129 { 136 130 data_length = CEIL8(width) * height / 8; 137 131 packet_length += data_length; 138 139 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 140 destBitmap = data_ptr + 28; 141 142 crBitmapCopy(width, height, destBitmap, bitmap, unpack); 143 /* 144 crMemcpy(destBitmap, bitmap, data_length); 145 */ 146 } 147 else { 148 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 149 } 132 } 133 134 data_ptr = (unsigned char *) crPackAlloc( packet_length ); 150 135 151 136 WRITE_DATA( 0, GLsizei, width ); … … 155 140 WRITE_DATA( 16, GLfloat, xmove ); 156 141 WRITE_DATA( 20, GLfloat, ymove ); 157 WRITE_DATA( 24, GLuint, isnull ); 142 WRITE_DATA( 24, GLuint, noimagedata ); 143 WRITE_DATA( 28, uintptr_t, (uintptr_t) bitmap); 144 145 crBitmapCopy(width, height, (GLubyte *)(data_ptr + 32), bitmap, unpack); 158 146 159 147 crHugePacket( CR_BITMAP_OPCODE, data_ptr ); -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_stipple.c
r15532 r27091 8 8 #include "cr_opcodes.h" 9 9 #include "cr_mem.h" 10 10 #include "cr_glstate.h" 11 11 12 12 void PACK_APIENTRY crPackPolygonStipple( const GLubyte *mask ) 13 13 { 14 GET_PACKER_CONTEXT(pc); 15 unsigned char *data_ptr; 16 int packet_length = 32*32/8; 17 GET_BUFFERED_POINTER(pc, packet_length ); 18 crMemcpy( data_ptr, mask, 32*32/8 ); 19 WRITE_OPCODE( pc, CR_POLYGONSTIPPLE_OPCODE ); 14 GET_PACKER_CONTEXT(pc); 15 unsigned char *data_ptr; 16 int nodata = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 17 int packet_length = sizeof(int); 18 19 if (nodata) 20 packet_length += sizeof(uintptr_t); 21 else 22 packet_length += 32*32/8; 23 24 GET_BUFFERED_POINTER(pc, packet_length ); 25 WRITE_DATA_AI(int, nodata); 26 if (nodata) 27 { 28 WRITE_DATA_AI(uintptr_t, (uintptr_t)mask); 29 } 30 else 31 { 32 crMemcpy( data_ptr, mask, 32*32/8 ); 33 } 34 WRITE_OPCODE( pc, CR_POLYGONSTIPPLE_OPCODE ); 20 35 } -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_texture.c
r21843 r27091 10 10 #include "cr_string.h" 11 11 #include "cr_version.h" 12 #include "cr_glstate.h" 12 13 13 14 void PACK_APIENTRY 14 15 crPackTexImage1D(GLenum target, GLint level, 15 16 17 18 { 19 unsigned char *data_ptr; 20 int packet_length; 21 int isnull = (pixels == NULL);16 GLint internalformat, GLsizei width, GLint border, 17 GLenum format, GLenum type, const GLvoid * pixels, 18 const CRPixelPackState * unpackstate) 19 { 20 unsigned char *data_ptr; 21 int packet_length; 22 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 22 23 23 24 packet_length = … … 26 27 sizeof(internalformat) + 27 28 sizeof(width) + 28 sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) ;29 30 if ( pixels)29 sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(uintptr_t); 30 31 if (!noimagedata) 31 32 { 32 33 packet_length += crImageSize(format, type, width, 1); … … 41 42 WRITE_DATA(20, GLenum, format); 42 43 WRITE_DATA(24, GLenum, type); 43 WRITE_DATA(28, int, isnull); 44 45 if (pixels) 46 { 47 crPixelCopy1D((void *) (data_ptr + 32), format, type, 48 pixels, format, type, width, unpackstate); 44 WRITE_DATA(28, int, noimagedata); 45 WRITE_DATA(32, uintptr_t, (uintptr_t) pixels); 46 47 if (!noimagedata) 48 { 49 crPixelCopy1D((void *) (data_ptr + 36), format, type, 50 pixels, format, type, width, unpackstate); 49 51 } 50 52 … … 55 57 void PACK_APIENTRY 56 58 crPackTexImage2D(GLenum target, GLint level, 57 58 59 60 { 61 unsigned char *data_ptr; 62 int packet_length; 63 const int isnull = (pixels == NULL);59 GLint internalformat, GLsizei width, GLsizei height, 60 GLint border, GLenum format, GLenum type, 61 const GLvoid * pixels, const CRPixelPackState * unpackstate) 62 { 63 unsigned char *data_ptr; 64 int packet_length; 65 const int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 64 66 const int is_distrib = ((type == GL_TRUE) || (type == GL_FALSE)); 65 67 int distrib_buf_len = 0; … … 71 73 sizeof(width) + 72 74 sizeof(height) + 73 sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) ;74 75 if ( pixels)75 sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(uintptr_t); 76 77 if (!noimagedata) 76 78 { 77 79 if (is_distrib) … … 102 104 WRITE_DATA(24, GLenum, format); 103 105 WRITE_DATA(28, GLenum, type); 104 WRITE_DATA(32, int, isnull); 105 106 if (pixels) 106 WRITE_DATA(32, int, noimagedata); 107 WRITE_DATA(36, uintptr_t, (uintptr_t) pixels); 108 109 if (!noimagedata) 107 110 { 108 111 if (is_distrib) 109 112 { 110 crMemcpy((void *) (data_ptr + 36), pixels, distrib_buf_len);113 crMemcpy((void *) (data_ptr + 40), pixels, distrib_buf_len); 111 114 } 112 115 else 113 116 { 114 117 crPixelCopy2D(width, height, 115 (void *) (data_ptr + 36), /* dest image addr */118 (void *) (data_ptr + 40), /* dest image addr */ 116 119 format, type, /* dest image format/type */ 117 120 NULL, /* dst packing (use default params) */ … … 127 130 128 131 #if defined( GL_EXT_texture3D ) 129 void PACK_APIENTRY crPackTexImage3DEXT(GLenum target, GLint level, 130 GLenum internalformat, 131 GLsizei width, GLsizei height, GLsizei depth, GLint border, 132 GLenum format, GLenum type, const GLvoid *pixels, 133 const CRPixelPackState *unpackstate ) 134 { 135 unsigned char *data_ptr; 136 int packet_length; 137 int isnull = (pixels == NULL); 132 void PACK_APIENTRY 133 crPackTexImage3DEXT(GLenum target, GLint level, 134 GLenum internalformat, 135 GLsizei width, GLsizei height, GLsizei depth, GLint border, 136 GLenum format, GLenum type, const GLvoid *pixels, 137 const CRPixelPackState *unpackstate ) 138 { 139 unsigned char *data_ptr; 140 int packet_length; 141 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 138 142 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; 139 143 int distrib_buf_len = 0; … … 150 154 sizeof( format ) + 151 155 sizeof( type ) + 152 sizeof( int ) ;153 154 if ( pixels)156 sizeof( int ) + sizeof(uintptr_t); 157 158 if (!noimagedata) 155 159 { 156 160 if ( is_distrib ) … … 177 181 WRITE_DATA( 28, GLenum, format ); 178 182 WRITE_DATA( 32, GLenum, type ); 179 WRITE_DATA( 36, int, isnull ); 180 181 if (pixels) 183 WRITE_DATA( 36, int, noimagedata ); 184 WRITE_DATA( 40, uintptr_t, (uintptr_t) pixels); 185 186 if (!noimagedata) 182 187 { 183 188 if ( is_distrib ) 184 189 { 185 crMemcpy( (void*)(data_ptr + 4 0), pixels, distrib_buf_len ) ;190 crMemcpy( (void*)(data_ptr + 44), pixels, distrib_buf_len ) ; 186 191 } 187 192 else 188 193 { 189 194 crPixelCopy3D( width, height, depth, 190 (void *)(data_ptr + 4 0), format, type, NULL,195 (void *)(data_ptr + 44), format, type, NULL, 191 196 pixels, format, type, unpackstate ); 192 197 } … … 199 204 200 205 #ifdef CR_OPENGL_VERSION_1_2 201 void PACK_APIENTRY crPackTexImage3D(GLenum target, GLint level, 202 GLint internalformat, 203 GLsizei width, GLsizei height, 204 GLsizei depth, GLint border, 205 GLenum format, GLenum type, 206 const GLvoid *pixels, 207 const CRPixelPackState *unpackstate ) 208 { 209 unsigned char *data_ptr; 210 int packet_length; 211 int isnull = (pixels == NULL); 206 void PACK_APIENTRY 207 crPackTexImage3D(GLenum target, GLint level, 208 GLint internalformat, 209 GLsizei width, GLsizei height, 210 GLsizei depth, GLint border, 211 GLenum format, GLenum type, 212 const GLvoid *pixels, 213 const CRPixelPackState *unpackstate ) 214 { 215 unsigned char *data_ptr; 216 int packet_length; 217 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 212 218 int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; 213 219 int distrib_buf_len = 0; … … 224 230 sizeof( format ) + 225 231 sizeof( type ) + 226 sizeof( int ) ;227 228 if ( pixels)232 sizeof( int ) + sizeof(uintptr_t); 233 234 if (!noimagedata) 229 235 { 230 236 if ( is_distrib ) … … 251 257 WRITE_DATA( 28, GLenum, format ); 252 258 WRITE_DATA( 32, GLenum, type ); 253 WRITE_DATA( 36, int, isnull ); 254 255 if (pixels) 259 WRITE_DATA( 36, int, noimagedata ); 260 WRITE_DATA( 40, uintptr_t, (uintptr_t) pixels); 261 262 if (!noimagedata) 256 263 { 257 264 if ( is_distrib ) 258 265 { 259 crMemcpy( (void*)(data_ptr + 4 0), pixels, distrib_buf_len ) ;266 crMemcpy( (void*)(data_ptr + 44), pixels, distrib_buf_len ) ; 260 267 } 261 268 else 262 269 { 263 270 crPixelCopy3D( width, height, depth, 264 (void *)(data_ptr + 4 0), format, type, NULL,271 (void *)(data_ptr + 44), format, type, NULL, 265 272 pixels, format, type, unpackstate ); 266 273 } … … 536 543 void PACK_APIENTRY 537 544 crPackTexSubImage3D(GLenum target, GLint level, 538 GLint xoffset, GLint yoffset, GLint zoffset, 539 GLsizei width, GLsizei height, GLsizei depth, 540 GLenum format, GLenum type, const GLvoid * pixels, 541 const CRPixelPackState * unpackstate) 542 { 543 unsigned char *data_ptr; 544 int packet_length; 545 GLint xoffset, GLint yoffset, GLint zoffset, 546 GLsizei width, GLsizei height, GLsizei depth, 547 GLenum format, GLenum type, const GLvoid * pixels, 548 const CRPixelPackState * unpackstate) 549 { 550 unsigned char *data_ptr; 551 int packet_length; 552 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 545 553 546 554 packet_length = … … 554 562 sizeof(depth) + 555 563 sizeof(format) + 556 sizeof(type) + crTextureSize(format, type, width, height, depth); 564 sizeof(type) + sizeof(int) + sizeof(uintptr_t); 565 566 if (!noimagedata) 567 { 568 packet_length += crTextureSize(format, type, width, height, depth); 569 } 557 570 558 571 data_ptr = (unsigned char *) crPackAlloc(packet_length); … … 567 580 WRITE_DATA(32, GLenum, format); 568 581 WRITE_DATA(36, GLenum, type); 569 570 crPixelCopy3D(width, height, depth, (GLvoid *) (data_ptr + 40), format, type, NULL, /* dst */ 571 pixels, format, type, unpackstate); /* src */ 582 WRITE_DATA(40, GLint, noimagedata); 583 WRITE_DATA(44, uintptr_t, (uintptr_t) pixels); 584 585 if (!noimagedata) 586 { 587 crPixelCopy3D(width, height, depth, (GLvoid *) (data_ptr + 48), format, type, NULL, /* dst */ 588 pixels, format, type, unpackstate); /* src */ 589 } 572 590 573 591 crHugePacket(CR_TEXSUBIMAGE3D_OPCODE, data_ptr); … … 578 596 void PACK_APIENTRY 579 597 crPackTexSubImage2D(GLenum target, GLint level, 580 GLint xoffset, GLint yoffset, GLsizei width, 581 GLsizei height, GLenum format, GLenum type, 582 const GLvoid * pixels, 583 const CRPixelPackState * unpackstate) 584 { 585 unsigned char *data_ptr; 586 int packet_length; 598 GLint xoffset, GLint yoffset, GLsizei width, 599 GLsizei height, GLenum format, GLenum type, 600 const GLvoid * pixels, 601 const CRPixelPackState * unpackstate) 602 { 603 unsigned char *data_ptr; 604 int packet_length; 605 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 587 606 588 607 packet_length = … … 593 612 sizeof(width) + 594 613 sizeof(height) + 595 sizeof(format) + sizeof(type) + crImageSize(format, type, width, height); 614 sizeof(format) + sizeof(type) + sizeof(int) + sizeof(uintptr_t); 615 616 if (!noimagedata) 617 { 618 packet_length += crImageSize(format, type, width, height); 619 } 596 620 597 621 data_ptr = (unsigned char *) crPackAlloc(packet_length); … … 604 628 WRITE_DATA(24, GLenum, format); 605 629 WRITE_DATA(28, GLenum, type); 606 607 crPixelCopy2D(width, height, (GLvoid *) (data_ptr + 32), format, type, NULL, /* dst */ 608 pixels, format, type, unpackstate); /* src */ 630 WRITE_DATA(32, GLint, noimagedata); 631 WRITE_DATA(36, uintptr_t, (uintptr_t) pixels); 632 633 if (!noimagedata) 634 { 635 crPixelCopy2D(width, height, (GLvoid *) (data_ptr + 40), format, type, NULL, /* dst */ 636 pixels, format, type, unpackstate); /* src */ 637 } 609 638 610 639 crHugePacket(CR_TEXSUBIMAGE2D_OPCODE, data_ptr); … … 620 649 unsigned char *data_ptr; 621 650 int packet_length; 651 int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 622 652 623 653 packet_length = … … 626 656 sizeof(xoffset) + 627 657 sizeof(width) + 628 sizeof(format) + sizeof(type) + crImageSize(format, type, width, 1); 658 sizeof(format) + sizeof(type) + sizeof(int) + sizeof(uintptr_t); 659 660 if (!noimagedata) 661 { 662 packet_length += crImageSize(format, type, width, 1); 663 } 629 664 630 665 data_ptr = (unsigned char *) crPackAlloc(packet_length); … … 635 670 WRITE_DATA(16, GLenum, format); 636 671 WRITE_DATA(20, GLenum, type); 637 638 crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type, 639 pixels, format, type, width, unpackstate); 672 WRITE_DATA(24, GLint, noimagedata); 673 WRITE_DATA(28, uintptr_t, (uintptr_t) pixels); 674 675 if (!noimagedata) 676 { 677 crPixelCopy1D((GLvoid *) (data_ptr + 32), format, type, 678 pixels, format, type, width, unpackstate); 679 } 640 680 641 681 crHugePacket(CR_TEXSUBIMAGE1D_OPCODE, data_ptr); … … 679 719 unsigned char *data_ptr; 680 720 int packet_length; 681 int isnull = (data == NULL);721 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 682 722 683 723 /* All extended opcodes have their first 8 bytes predefined: … … 693 733 sizeof( border ) + 694 734 sizeof( imagesize ) + 695 sizeof( int ) ; /* isnull */696 697 if ( data)735 sizeof( int ) + sizeof(uintptr_t); 736 737 if (!noimagedata) 698 738 { 699 739 packet_length += imagesize; … … 709 749 WRITE_DATA( 20, GLint, border ); 710 750 WRITE_DATA( 24, GLsizei, imagesize ); 711 WRITE_DATA( 28, int, isnull ); 712 713 if (data) { 714 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); 751 WRITE_DATA( 28, int, noimagedata ); 752 WRITE_DATA( 32, uintptr_t, (uintptr_t) data); 753 754 if (!noimagedata) { 755 crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); 715 756 } 716 757 … … 723 764 unsigned char *data_ptr; 724 765 int packet_length; 725 int isnull = (data == NULL);766 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 726 767 727 768 /* All extended opcodes have their first 8 bytes predefined: … … 738 779 sizeof( border ) + 739 780 sizeof( imagesize ) + 740 sizeof( int ) ; /* isnull */741 742 if ( data)781 sizeof( int ) + sizeof(uintptr_t); 782 783 if (!noimagedata) 743 784 { 744 785 packet_length += imagesize; … … 756 797 WRITE_DATA( 24, GLint, border ); 757 798 WRITE_DATA( 28, GLsizei, imagesize ); 758 WRITE_DATA( 32, int, isnull ); 759 760 if (data) { 761 crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); 799 WRITE_DATA( 32, int, noimagedata ); 800 WRITE_DATA( 36, uintptr_t, (uintptr_t) data); 801 802 if (!noimagedata) { 803 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); 762 804 } 763 805 … … 770 812 unsigned char *data_ptr; 771 813 int packet_length; 772 int isnull = (data == NULL);814 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 773 815 774 816 /* All extended opcodes have their first 8 bytes predefined: … … 786 828 sizeof( border ) + 787 829 sizeof( imagesize ) + 788 sizeof( int ) ; /* isnull */789 790 if ( data)830 sizeof( int ) + sizeof(uintptr_t); 831 832 if (!noimagedata) 791 833 { 792 834 packet_length += imagesize; … … 803 845 WRITE_DATA( 28, GLint, border ); 804 846 WRITE_DATA( 32, GLsizei, imagesize ); 805 WRITE_DATA( 36, int, isnull ); 806 807 if (data) { 808 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); 847 WRITE_DATA( 36, int, noimagedata ); 848 WRITE_DATA( 40, uintptr_t, (uintptr_t) data); 849 850 if (!noimagedata) { 851 crMemcpy( (void *)(data_ptr + 44), (void *)data, imagesize); 809 852 } 810 853 … … 817 860 unsigned char *data_ptr; 818 861 int packet_length; 819 int isnull = (data == NULL);862 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 820 863 821 864 /* All extended opcodes have their first 8 bytes predefined: … … 831 874 sizeof( format ) + 832 875 sizeof( imagesize ) + 833 sizeof( int ) ; /* isnull */834 835 if ( data)876 sizeof( int ) + sizeof(uintptr_t); 877 878 if (!noimagedata) 836 879 { 837 880 packet_length += imagesize; … … 846 889 WRITE_DATA( 20, GLenum, format ); 847 890 WRITE_DATA( 24, GLsizei, imagesize ); 848 WRITE_DATA( 28, int, isnull ); 849 850 if (data) { 851 crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); 891 WRITE_DATA( 28, int, noimagedata ); 892 WRITE_DATA( 32, uintptr_t, (uintptr_t) data); 893 894 if (!noimagedata) { 895 crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); 852 896 } 853 897 … … 860 904 unsigned char *data_ptr; 861 905 int packet_length; 862 int isnull = (data == NULL);906 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 863 907 864 908 /* All extended opcodes have their first 8 bytes predefined: … … 876 920 sizeof( format ) + 877 921 sizeof( imagesize ) + 878 sizeof( int ) ; /* isnull */879 880 if ( data)922 sizeof( int ) + sizeof(uintptr_t); 923 924 if (!noimagedata) 881 925 { 882 926 packet_length += imagesize; … … 893 937 WRITE_DATA( 28, GLenum, format ); 894 938 WRITE_DATA( 32, GLsizei, imagesize ); 895 WRITE_DATA( 36, int, isnull ); 896 897 if (data) { 898 crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); 939 WRITE_DATA( 36, int, noimagedata ); 940 WRITE_DATA( 40, uintptr_t, (uintptr_t) data); 941 942 if (!noimagedata) { 943 crMemcpy( (void *)(data_ptr + 44), (void *)data, imagesize); 899 944 } 900 945 … … 907 952 unsigned char *data_ptr; 908 953 int packet_length; 909 int isnull = (data == NULL);954 int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 910 955 911 956 /* All extended opcodes have their first 8 bytes predefined: … … 925 970 sizeof( format ) + 926 971 sizeof( imagesize ) + 927 sizeof( int ) ; /* isnull */928 929 if ( data)972 sizeof( int ) + sizeof(uintptr_t); 973 974 if (!noimagedata) 930 975 { 931 976 packet_length += imagesize; … … 944 989 WRITE_DATA( 36, GLenum, format ); 945 990 WRITE_DATA( 40, GLsizei, imagesize ); 946 WRITE_DATA( 44, int, isnull ); 947 948 if (data) { 949 crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize); 991 WRITE_DATA( 44, int, noimagedata ); 992 WRITE_DATA( 48, uintptr_t, (uintptr_t) data); 993 994 if (!noimagedata) { 995 crMemcpy( (void *)(data_ptr + 52), (void *)data, imagesize); 950 996 } 951 997 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
r25303 r27091 21 21 b->usage = GL_STATIC_DRAW_ARB; 22 22 b->access = GL_READ_WRITE_ARB; 23 b->bResyncOnRead = GL_FALSE; 23 24 } 24 25 return b; 25 26 } 26 27 28 GLboolean crStateIsBufferBound(GLenum target) 29 { 30 CRContext *g = GetCurrentContext(); 31 CRBufferObjectState *b = &(g->bufferobject); 32 33 switch (target) 34 { 35 case GL_ARRAY_BUFFER_ARB: 36 return b->arrayBuffer->name!=0; 37 case GL_ELEMENT_ARRAY_BUFFER_ARB: 38 return b->elementsBuffer->name!=0; 39 #ifdef CR_ARB_pixel_buffer_object 40 case GL_PIXEL_PACK_BUFFER_ARB: 41 return b->packBuffer->name!=0; 42 case GL_PIXEL_UNPACK_BUFFER_ARB: 43 return b->unpackBuffer->name!=0; 44 #endif 45 default: 46 return GL_FALSE; 47 } 48 } 49 50 CRBufferObject *crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b) 51 { 52 switch (target) 53 { 54 case GL_ARRAY_BUFFER_ARB: 55 return b->arrayBuffer; 56 case GL_ELEMENT_ARRAY_BUFFER_ARB: 57 return b->elementsBuffer; 58 #ifdef CR_ARB_pixel_buffer_object 59 case GL_PIXEL_PACK_BUFFER_ARB: 60 return b->packBuffer; 61 case GL_PIXEL_UNPACK_BUFFER_ARB: 62 return b->unpackBuffer; 63 #endif 64 default: 65 return NULL; 66 } 67 } 27 68 28 69 void crStateBufferObjectInit (CRContext *ctx) … … 46 87 b->elementsBuffer = b->nullBuffer; 47 88 b->nullBuffer->refCount = 3; 89 #ifdef CR_ARB_pixel_buffer_object 90 b->packBuffer = b->nullBuffer; 91 b->unpackBuffer = b->nullBuffer; 92 b->nullBuffer->refCount += 2; 93 #endif 48 94 49 95 b->buffers = crAllocHashtable(); … … 92 138 FLUSH(); 93 139 94 if (target == GL_ARRAY_BUFFER_ARB) { 95 oldObj = b->arrayBuffer; 96 } 97 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 98 oldObj = b->elementsBuffer; 99 } 100 else { 101 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 102 "glBindBufferARB(target)"); 140 oldObj = crStateGetBoundBufferObject(target, b); 141 if (!oldObj) 142 { 143 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)"); 103 144 return; 104 145 } … … 122 163 oldObj->refCount--; 123 164 124 if (target == GL_ARRAY_BUFFER_ARB) { 125 b->arrayBuffer = newObj; 126 DIRTY(bb->dirty, g->neg_bitid); 127 DIRTY(bb->arrayBinding, g->neg_bitid); 128 } 129 else { 130 CRASSERT(target == GL_ELEMENT_ARRAY_BUFFER_ARB); 131 b->elementsBuffer = newObj; 132 DIRTY(bb->dirty, g->neg_bitid); 133 DIRTY(bb->elementsBinding, g->neg_bitid); 165 switch (target) 166 { 167 case GL_ARRAY_BUFFER_ARB: 168 b->arrayBuffer = newObj; 169 DIRTY(bb->dirty, g->neg_bitid); 170 DIRTY(bb->arrayBinding, g->neg_bitid); 171 break; 172 case GL_ELEMENT_ARRAY_BUFFER_ARB: 173 b->elementsBuffer = newObj; 174 DIRTY(bb->dirty, g->neg_bitid); 175 DIRTY(bb->elementsBinding, g->neg_bitid); 176 break; 177 #ifdef CR_ARB_pixel_buffer_object 178 case GL_PIXEL_PACK_BUFFER_ARB: 179 b->packBuffer = newObj; 180 DIRTY(bb->dirty, g->neg_bitid); 181 DIRTY(bb->packBinding, g->neg_bitid); 182 break; 183 case GL_PIXEL_UNPACK_BUFFER_ARB: 184 b->unpackBuffer = newObj; 185 DIRTY(bb->dirty, g->neg_bitid); 186 DIRTY(bb->unpackBinding, g->neg_bitid); 187 break; 188 #endif 189 default: /*can't get here*/ 190 CRASSERT(false); 191 return; 134 192 } 135 193 … … 139 197 crHashtableDelete(b->buffers, (unsigned long) oldObj->name, crStateFreeBufferObject); 140 198 } 199 200 #ifdef IN_GUEST 201 if (target == GL_PIXEL_PACK_BUFFER_ARB) 202 { 203 newObj->bResyncOnRead = GL_TRUE; 204 } 205 #endif 141 206 } 142 207 … … 169 234 crHashtableSearch(b->buffers, buffers[i]); 170 235 if (obj) { 171 if (obj == b->arrayBuffer) { 236 if (obj == b->arrayBuffer) 237 { 172 238 b->arrayBuffer = b->nullBuffer; 173 239 b->arrayBuffer->refCount++; 174 240 DIRTY(bb->dirty, g->neg_bitid); 175 241 DIRTY(bb->arrayBinding, g->neg_bitid); 176 } 177 if (obj == b->elementsBuffer) { 242 } 243 else if (obj == b->elementsBuffer) 244 { 178 245 b->elementsBuffer = b->nullBuffer; 179 246 b->elementsBuffer->refCount++; … … 181 248 DIRTY(bb->elementsBinding, g->neg_bitid); 182 249 } 250 #ifdef CR_ARB_pixel_buffer_object 251 else if (obj == b->packBuffer) 252 { 253 b->packBuffer = b->nullBuffer; 254 b->packBuffer->refCount++; 255 DIRTY(bb->dirty, g->neg_bitid); 256 DIRTY(bb->packBinding, g->neg_bitid); 257 } 258 else if (obj == b->unpackBuffer) 259 { 260 b->unpackBuffer = b->nullBuffer; 261 b->unpackBuffer->refCount++; 262 DIRTY(bb->dirty, g->neg_bitid); 263 DIRTY(bb->unpackBinding, g->neg_bitid); 264 } 265 #endif 183 266 /* @todo check bindings with the vertex arrays */ 184 267 … … 285 368 } 286 369 287 if (target == GL_ARRAY_BUFFER_ARB) { 288 obj = b->arrayBuffer; 289 } 290 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 291 obj = b->elementsBuffer; 292 } 293 else { 294 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 295 "glBufferDataARB(target)"); 370 obj = crStateGetBoundBufferObject(target, b); 371 if (!obj) 372 { 373 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)"); 296 374 return; 297 375 } … … 352 430 } 353 431 354 if (target == GL_ARRAY_BUFFER_ARB) { 355 obj = b->arrayBuffer; 356 } 357 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 358 obj = b->elementsBuffer; 359 } 360 else { 361 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 362 "glBufferSubDataARB(target)"); 432 obj = crStateGetBoundBufferObject(target, b); 433 if (!obj) 434 { 435 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)"); 363 436 return; 364 437 } … … 411 484 } 412 485 413 if (target == GL_ARRAY_BUFFER_ARB) { 414 obj = b->arrayBuffer; 415 } 416 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 417 obj = b->elementsBuffer; 418 } 419 else { 420 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 421 "glGetBufferSubDataARB(target)"); 486 obj = crStateGetBoundBufferObject(target, b); 487 if (!obj) 488 { 489 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)"); 422 490 return; 423 491 } … … 462 530 } 463 531 464 if (target == GL_ARRAY_BUFFER_ARB) { 465 obj = b->arrayBuffer; 466 } 467 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 468 obj = b->elementsBuffer; 469 } 470 else { 471 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 472 "glMapBufferARB(target)"); 532 obj = crStateGetBoundBufferObject(target, b); 533 if (!obj) 534 { 535 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)"); 473 536 return NULL; 474 537 } … … 515 578 } 516 579 517 if (target == GL_ARRAY_BUFFER_ARB) { 518 obj = b->arrayBuffer; 519 } 520 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 521 obj = b->elementsBuffer; 522 } 523 else { 524 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 525 "glUnmapBufferARB(target)"); 580 obj = crStateGetBoundBufferObject(target, b); 581 if (!obj) 582 { 583 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)"); 526 584 return GL_FALSE; 527 585 } … … 566 624 } 567 625 568 if (target == GL_ARRAY_BUFFER_ARB) { 569 obj = b->arrayBuffer; 570 } 571 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 572 obj = b->elementsBuffer; 573 } 574 else { 575 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 576 "glGetBufferParameterivARB(target)"); 626 obj = crStateGetBoundBufferObject(target, b); 627 if (!obj) 628 { 629 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)"); 577 630 return; 578 631 } … … 614 667 } 615 668 616 if (target == GL_ARRAY_BUFFER_ARB) { 617 obj = b->arrayBuffer; 618 } 619 else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { 620 obj = b->elementsBuffer; 621 } 622 else { 623 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 624 "glGetBufferPointervARB(target)"); 669 obj = crStateGetBoundBufferObject(target, b); 670 if (!obj) 671 { 672 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)"); 625 673 return; 626 674 } 627 675 628 676 if (pname != GL_BUFFER_MAP_POINTER_ARB) { 629 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 630 "glGetBufferPointervARB(pname)"); 677 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); 631 678 return; 632 679 } … … 672 719 } 673 720 674 675 void crStateBufferObjectDiff(CRBufferObjectBits *bb, CRbitvalue *bitID,676 CRContext *fromCtx, CRContext *toCtx)721 static crStateBufferObjectIntCmp(CRBufferObjectBits *bb, CRbitvalue *bitID, 722 CRContext *fromCtx, CRContext *toCtx, 723 GLboolean bSwitch) 677 724 { 678 725 CRBufferObjectState *from = &(fromCtx->bufferobject); 679 726 const CRBufferObjectState *to = &(toCtx->bufferobject); 680 727 681 if (!HaveBufferObjectExtension()) 682 return; 683 684 /* ARRAY_BUFFER binding */ 685 if (CHECKDIRTY(bb->arrayBinding, bitID)) { 686 if (from->arrayBuffer != to->arrayBuffer) { 728 /* ARRAY_BUFFER */ 729 if (CHECKDIRTY(bb->arrayBinding, bitID)) 730 { 731 if (from->arrayBuffer != to->arrayBuffer) 732 { 687 733 GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->name : 0; 688 734 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); 689 CLEARDIRTY2(bb->arrayBinding, bitID); 690 from->arrayBuffer = to->arrayBuffer; 691 } 692 } 693 694 if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID)) { 735 if (bSwitch) 736 { 737 FILLDIRTY(bb->arrayBinding); 738 } 739 else 740 { 741 CLEARDIRTY2(bb->arrayBinding, bitID); 742 from->arrayBuffer = to->arrayBuffer; 743 } 744 } 745 if (bSwitch) CLEARDIRTY2(bb->arrayBinding, bitID); 746 } 747 748 if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID)) 749 { 695 750 /* update array buffer data */ 696 751 CRBufferObject *bufObj = to->arrayBuffer; 697 752 CRASSERT(bufObj); 698 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { 753 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 754 { 699 755 /* update whole buffer */ 700 756 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size, 701 bufObj->data, bufObj->usage); 702 } 703 else { 757 bufObj->data, bufObj->usage); 758 } 759 else 760 { 704 761 /* update sub buffer */ 705 762 diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 706 bufObj->dirtyStart, 707 bufObj->dirtyLength, 708 (char *) bufObj->data 709 + bufObj->dirtyStart); 710 } 763 bufObj->dirtyStart, bufObj->dirtyLength, 764 (char *) bufObj->data + bufObj->dirtyStart); 765 } 766 if (bSwitch) FILLDIRTY(bufObj->dirty); 711 767 CLEARDIRTY2(bufObj->dirty, bitID); 712 #if 0 713 bufObj->dirtyStart = 0; 714 bufObj->dirtyLength = 0; 715 #endif 716 } 717 718 /* ELEMENTS_BUFFER binding */ 719 if (CHECKDIRTY(bb->elementsBinding, bitID)) { 720 if (from->elementsBuffer != to->elementsBuffer) { 768 } 769 770 /* ELEMENTS_BUFFER */ 771 if (CHECKDIRTY(bb->elementsBinding, bitID)) 772 { 773 if (from->elementsBuffer != to->elementsBuffer) 774 { 721 775 GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->name : 0; 722 776 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID); 723 CLEARDIRTY2(bb->elementsBinding, bitID); 724 from->elementsBuffer = to->elementsBuffer; 725 } 726 } 727 728 if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID)) { 729 /* update element buffer data */ 777 if (bSwitch) 778 { 779 FILLDIRTY(bb->elementsBinding); 780 } 781 else 782 { 783 CLEARDIRTY2(bb->elementsBinding, bitID); 784 from->elementsBuffer = to->elementsBuffer; 785 } 786 } 787 if (bSwitch) CLEARDIRTY2(bb->elementsBinding, bitID); 788 } 789 790 if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID)) 791 { 792 /* update array buffer data */ 730 793 CRBufferObject *bufObj = to->elementsBuffer; 731 794 CRASSERT(bufObj); 732 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { 795 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 796 { 733 797 /* update whole buffer */ 734 798 diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size, 735 bufObj->data, bufObj->usage); 736 } 737 else { 799 bufObj->data, bufObj->usage); 800 } 801 else 802 { 738 803 /* update sub buffer */ 739 804 diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 740 bufObj->dirtyStart, 741 bufObj->dirtyLength, 742 (char *) bufObj->data 743 + bufObj->dirtyStart); 744 } 805 bufObj->dirtyStart, bufObj->dirtyLength, 806 (char *) bufObj->data + bufObj->dirtyStart); 807 } 808 if (bSwitch) FILLDIRTY(bufObj->dirty); 745 809 CLEARDIRTY2(bufObj->dirty, bitID); 746 #if 0 747 bufObj->dirtyStart = 0; 748 bufObj->dirtyLength = 0; 749 #endif 750 } 810 } 811 812 #ifdef CR_ARB_pixel_buffer_object 813 /* PIXEL_PACK_BUFFER */ 814 if (CHECKDIRTY(bb->packBinding, bitID)) 815 { 816 if (from->packBuffer != to->packBuffer) 817 { 818 GLuint bufferID = to->packBuffer ? to->packBuffer->name : 0; 819 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID); 820 if (bSwitch) 821 { 822 FILLDIRTY(bb->packBinding); 823 } 824 else 825 { 826 CLEARDIRTY2(bb->packBinding, bitID); 827 from->packBuffer = to->packBuffer; 828 } 829 } 830 if (bSwitch) CLEARDIRTY2(bb->packBinding, bitID); 831 } 832 833 if (to->packBuffer && CHECKDIRTY(to->packBuffer->dirty, bitID)) 834 { 835 /* update array buffer data */ 836 CRBufferObject *bufObj = to->packBuffer; 837 CRASSERT(bufObj); 838 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 839 { 840 /* update whole buffer */ 841 diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size, 842 bufObj->data, bufObj->usage); 843 } 844 else 845 { 846 /* update sub buffer */ 847 diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB, 848 bufObj->dirtyStart, bufObj->dirtyLength, 849 (char *) bufObj->data + bufObj->dirtyStart); 850 } 851 if (bSwitch) FILLDIRTY(bufObj->dirty); 852 CLEARDIRTY2(bufObj->dirty, bitID); 853 } 854 855 /* PIXEL_UNPACK_BUFFER */ 856 if (CHECKDIRTY(bb->unpackBinding, bitID)) 857 { 858 if (from->unpackBuffer != to->unpackBuffer) 859 { 860 GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->name : 0; 861 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID); 862 if (bSwitch) 863 { 864 FILLDIRTY(bb->unpackBinding); 865 } 866 else 867 { 868 CLEARDIRTY2(bb->unpackBinding, bitID); 869 from->unpackBuffer = to->unpackBuffer; 870 } 871 } 872 if (bSwitch) CLEARDIRTY2(bb->unpackBinding, bitID); 873 } 874 875 if (to->unpackBuffer && CHECKDIRTY(to->unpackBuffer->dirty, bitID)) 876 { 877 /* update array buffer data */ 878 CRBufferObject *bufObj = to->unpackBuffer; 879 CRASSERT(bufObj); 880 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 881 { 882 /* update whole buffer */ 883 diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size, 884 bufObj->data, bufObj->usage); 885 } 886 else 887 { 888 /* update sub buffer */ 889 diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 890 bufObj->dirtyStart, bufObj->dirtyLength, 891 (char *) bufObj->data + bufObj->dirtyStart); 892 } 893 if (bSwitch) FILLDIRTY(bufObj->dirty); 894 CLEARDIRTY2(bufObj->dirty, bitID); 895 } 896 #endif /*ifdef CR_ARB_pixel_buffer_object*/ 897 } 898 899 void crStateBufferObjectDiff(CRBufferObjectBits *bb, CRbitvalue *bitID, 900 CRContext *fromCtx, CRContext *toCtx) 901 { 902 CRBufferObjectState *from = &(fromCtx->bufferobject); 903 const CRBufferObjectState *to = &(toCtx->bufferobject); 904 905 if (!HaveBufferObjectExtension()) 906 return; 907 908 crStateBufferObjectIntCmp(bb, bitID, fromCtx, toCtx, GL_FALSE); 751 909 } 752 910 … … 758 916 if (pBufferObj->data) 759 917 { 918 /*@todo http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt 919 "While it is entirely legal to create a buffer object by binding 920 it to GL_ARRAY_BUFFER and loading it with data, then using it 921 with the GL_PIXEL_UNPACK_BUFFER_ARB or GL_PIXEL_PACK_BUFFER_ARB 922 binding, such behavior is liable to confuse the driver and may 923 hurt performance." 924 */ 760 925 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->name); 761 926 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage); … … 868 1033 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->name); 869 1034 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->name); 870 } 871 872 /* ARRAY_BUFFER binding */ 873 if (CHECKDIRTY(bb->arrayBinding, bitID)) { 874 if (from->arrayBuffer != to->arrayBuffer) { 875 GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->name : 0; 876 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); 877 FILLDIRTY(bb->arrayBinding); 878 } 879 CLEARDIRTY2(bb->arrayBinding, bitID); 880 } 881 882 if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID)) { 883 /* update array buffer data */ 884 CRBufferObject *bufObj = to->arrayBuffer; 885 CRASSERT(bufObj); 886 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { 887 /* update whole buffer */ 888 diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size, 889 bufObj->data, bufObj->usage); 890 } 891 else { 892 /* update sub buffer */ 893 diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 894 bufObj->dirtyStart, 895 bufObj->dirtyLength, 896 (char *) bufObj->data 897 + bufObj->dirtyStart); 898 } 899 FILLDIRTY(bufObj->dirty); 900 CLEARDIRTY2(bufObj->dirty, bitID); 901 #if 0 902 bufObj->dirtyStart = 0; 903 bufObj->dirtyLength = 0; 1035 #ifdef CR_ARB_pixel_buffer_object 1036 diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->name); 1037 diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->name); 904 1038 #endif 905 1039 } 906 907 /* ELEMENTS_BUFFER binding */ 908 if (CHECKDIRTY(bb->elementsBinding, bitID)) { 909 if (from->elementsBuffer != to->elementsBuffer) { 910 GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->name : 0; 911 diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID); 912 FILLDIRTY(bb->elementsBinding); 913 } 914 CLEARDIRTY2(bb->elementsBinding, bitID); 915 } 916 917 if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID)) { 918 /* update element buffer data */ 919 CRBufferObject *bufObj = to->elementsBuffer; 920 CRASSERT(bufObj); 921 if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) { 922 /* update whole buffer */ 923 diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size, 924 bufObj->data, bufObj->usage); 925 } 926 else { 927 /* update sub buffer */ 928 diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 929 bufObj->dirtyStart, 930 bufObj->dirtyLength, 931 (char *) bufObj->data 932 + bufObj->dirtyStart); 933 } 934 FILLDIRTY(bufObj->dirty); 935 CLEARDIRTY2(bufObj->dirty, bitID); 936 #if 0 937 bufObj->dirtyStart = 0; 938 bufObj->dirtyLength = 0; 939 #endif 940 } 941 } 942 943 1040 else 1041 { 1042 crStateBufferObjectIntCmp(bb, bitID, fromCtx, toCtx, GL_TRUE); 1043 } 1044 } 1045 1046 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_get.txt
r15532 r27091 129 129 # GL_ARB_point_sprite 130 130 GLboolean GL_POINT_SPRITE_ARB GL_ARB_point_sprite g->point.pointSprite 131 132 # GL_ARB_vertex_buffer_object 133 GLuint GL_ARRAY_BUFFER_BINDING_ARB GL_ARB_vertex_buffer_object g->bufferobject.arrayBuffer->name 134 GLuint GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_ARB_vertex_buffer_object g->bufferobject.elementsBuffer->name 135 136 # GL_ARB_pixel_buffer_object 137 GLuint GL_PIXEL_PACK_BUFFER_BINDING_ARB GL_ARB_pixel_buffer_object g->bufferobject.packBuffer->name 138 GLuint GL_PIXEL_UNPACK_BUFFER_BINDING_ARB GL_ARB_pixel_buffer_object g->bufferobject.unpackBuffer->name -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c
r16574 r27091 300 300 if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_buffer_object")) 301 301 extensions->ARB_vertex_buffer_object = GL_TRUE; 302 303 if (hasExtension((const char*)limits->extensions, "GL_ARB_pixel_buffer_object")) 304 extensions->ARB_pixel_buffer_object = GL_TRUE; 302 305 303 306 if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_program")) -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c
r27072 r27091 208 208 CRPixelBits *pb = &(sb->pixel); 209 209 GLint i; 210 GLboolean unpackbuffer = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); 210 211 211 212 if (g->current.inBeginEnd) { … … 228 229 case GL_PIXEL_MAP_S_TO_S: 229 230 p->mapStoSsize = mapsize; 230 for (i=0;i<mapsize;i++) { 231 p->mapStoS[i] = (GLint) values[i]; 232 } 231 if (!unpackbuffer) 232 for (i=0;i<mapsize;i++) { 233 p->mapStoS[i] = (GLint) values[i]; 234 } 233 235 break; 234 236 case GL_PIXEL_MAP_I_TO_I: 235 237 p->mapItoIsize = mapsize; 238 if (!unpackbuffer) 236 239 for (i=0;i<mapsize;i++) { 237 240 p->mapItoI[i] = (GLint) values[i]; … … 240 243 case GL_PIXEL_MAP_I_TO_R: 241 244 p->mapItoRsize = mapsize; 242 for (i=0;i<mapsize;i++) { 243 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 244 p->mapItoR[i] = val; 245 } 245 if (!unpackbuffer) 246 for (i=0;i<mapsize;i++) { 247 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 248 p->mapItoR[i] = val; 249 } 246 250 break; 247 251 case GL_PIXEL_MAP_I_TO_G: 248 252 p->mapItoGsize = mapsize; 249 for (i=0;i<mapsize;i++) { 250 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 251 p->mapItoG[i] = val; 252 } 253 if (!unpackbuffer) 254 for (i=0;i<mapsize;i++) { 255 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 256 p->mapItoG[i] = val; 257 } 253 258 break; 254 259 case GL_PIXEL_MAP_I_TO_B: 255 260 p->mapItoBsize = mapsize; 256 for (i=0;i<mapsize;i++) { 257 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 258 p->mapItoB[i] = val; 259 } 261 if (!unpackbuffer) 262 for (i=0;i<mapsize;i++) { 263 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 264 p->mapItoB[i] = val; 265 } 260 266 break; 261 267 case GL_PIXEL_MAP_I_TO_A: 262 268 p->mapItoAsize = mapsize; 263 for (i=0;i<mapsize;i++) { 264 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 265 p->mapItoA[i] = val; 266 } 269 if (!unpackbuffer) 270 for (i=0;i<mapsize;i++) { 271 GLfloat val = CLAMP( values[i], 0.0F, 1.0F ); 272 p->mapItoA[i] = val; 273 } 267 274 break; 268 275 case GL_PIXEL_MAP_R_TO_R: 269 276 p->mapRtoRsize = mapsize; 270 for (i=0;i<mapsize;i++) { 271 p->mapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F ); 272 } 277 if (!unpackbuffer) 278 for (i=0;i<mapsize;i++) { 279 p->mapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F ); 280 } 273 281 break; 274 282 case GL_PIXEL_MAP_G_TO_G: 275 283 p->mapGtoGsize = mapsize; 276 for (i=0;i<mapsize;i++) { 277 p->mapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F ); 278 } 284 if (!unpackbuffer) 285 for (i=0;i<mapsize;i++) { 286 p->mapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F ); 287 } 279 288 break; 280 289 case GL_PIXEL_MAP_B_TO_B: 281 290 p->mapBtoBsize = mapsize; 282 for (i=0;i<mapsize;i++) { 283 p->mapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F ); 284 } 291 if (!unpackbuffer) 292 for (i=0;i<mapsize;i++) { 293 p->mapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F ); 294 } 285 295 break; 286 296 case GL_PIXEL_MAP_A_TO_A: 287 297 p->mapAtoAsize = mapsize; 288 for (i=0;i<mapsize;i++) { 289 p->mapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F ); 290 } 298 if (!unpackbuffer) 299 for (i=0;i<mapsize;i++) { 300 p->mapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F ); 301 } 291 302 break; 292 303 default: … … 301 312 void STATE_APIENTRY crStatePixelMapuiv (GLenum map, GLint mapsize, const GLuint * values) 302 313 { 303 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; 304 GLint i; 305 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 306 for (i=0;i<mapsize;i++) { 307 fvalues[i] = (GLfloat) values[i]; 308 } 309 } 310 else { 311 for (i=0;i<mapsize;i++) { 312 fvalues[i] = values[i] / 4294967295.0F; 313 } 314 } 315 crStatePixelMapfv(map, mapsize, fvalues); 314 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; 315 GLint i; 316 317 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 318 { 319 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 320 for (i=0;i<mapsize;i++) { 321 fvalues[i] = (GLfloat) values[i]; 322 } 323 } 324 else { 325 for (i=0;i<mapsize;i++) { 326 fvalues[i] = values[i] / 4294967295.0F; 327 } 328 } 329 crStatePixelMapfv(map, mapsize, fvalues); 330 } 331 else 332 { 333 crStatePixelMapfv(map, mapsize, (const GLfloat*) values); 334 } 316 335 } 317 336 318 337 void STATE_APIENTRY crStatePixelMapusv (GLenum map, GLint mapsize, const GLushort * values) 319 338 { 320 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; 321 GLint i; 322 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 323 for (i=0;i<mapsize;i++) { 324 fvalues[i] = (GLfloat) values[i]; 325 } 326 } 327 else { 328 for (i=0;i<mapsize;i++) { 329 fvalues[i] = values[i] / 65535.0F; 330 } 331 } 332 crStatePixelMapfv(map, mapsize, fvalues); 339 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; 340 GLint i; 341 342 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 343 { 344 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 345 for (i=0;i<mapsize;i++) { 346 fvalues[i] = (GLfloat) values[i]; 347 } 348 } 349 else { 350 for (i=0;i<mapsize;i++) { 351 fvalues[i] = values[i] / 65535.0F; 352 } 353 } 354 crStatePixelMapfv(map, mapsize, fvalues); 355 } 356 else 357 { 358 crStatePixelMapfv(map, mapsize, (const GLfloat*) values); 359 } 333 360 } 334 361 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c
r27069 r27091 179 179 FLUSH(); 180 180 181 if (!p )181 if (!p && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 182 182 { 183 183 crStateError(__LINE__, __FILE__, GL_NO_ERROR, … … 186 186 } 187 187 188 crMemcpy((char*)poly->stipple, (char*)p, 128); 188 /*@todo track mask if buffer is bound?*/ 189 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 190 { 191 crMemcpy((char*)poly->stipple, (char*)p, 128); 192 } 189 193 190 194 DIRTY(pb->dirty, g->neg_bitid); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r27034 r27091 1186 1186 rc = SSMR3PutU32(pSSM, pContext->bufferobject.elementsBuffer->name); 1187 1187 AssertRCReturn(rc, rc); 1188 #ifdef CR_ARB_pixel_buffer_object 1189 rc = SSMR3PutU32(pSSM, pContext->bufferobject.packBuffer->name); 1190 AssertRCReturn(rc, rc); 1191 rc = SSMR3PutU32(pSSM, pContext->bufferobject.unpackBuffer->name); 1192 AssertRCReturn(rc, rc); 1193 #endif 1188 1194 /* Save clint pointers and buffer bindings*/ 1189 1195 for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i) … … 1671 1677 AssertRCReturn(rc, rc); 1672 1678 pContext->bufferobject.elementsBuffer = CRS_GET_BO(ui); 1679 #ifdef CR_ARB_pixel_buffer_object 1680 rc = SSMR3GetU32(pSSM, &ui); 1681 AssertRCReturn(rc, rc); 1682 pContext->bufferobject.packBuffer = CRS_GET_BO(ui); 1683 rc = SSMR3GetU32(pSSM, &ui); 1684 AssertRCReturn(rc, rc); 1685 pContext->bufferobject.unpackBuffer = CRS_GET_BO(ui); 1686 #endif 1673 1687 #undef CRS_GET_BO 1674 1688 … … 1952 1966 FILLDIRTY(pBits->bufferobject.arrayBinding); 1953 1967 FILLDIRTY(pBits->bufferobject.elementsBinding); 1968 # ifdef CR_ARB_pixel_buffer_object 1969 FILLDIRTY(pBits->bufferobject.packBinding); 1970 FILLDIRTY(pBits->bufferobject.unpackBinding); 1971 # endif 1954 1972 #endif 1955 1973
Note:
See TracChangeset
for help on using the changeset viewer.