diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
commit | f8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch) | |
tree | 26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/HostServices/SharedOpenGL/unpacker | |
parent | Initial commit. (diff) | |
download | virtualbox-upstream.tar.xz virtualbox-upstream.zip |
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/HostServices/SharedOpenGL/unpacker')
32 files changed, 3231 insertions, 0 deletions
diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/Makefile.kup b/src/VBox/HostServices/SharedOpenGL/unpacker/Makefile.kup new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/Makefile.kup diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def new file mode 100644 index 00000000..01a07bf2 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def @@ -0,0 +1,11 @@ +; Copyright (c) 2001, Stanford University +; All rights reserved. +; +; See the file LICENSE.txt for information on redistributing this software. +EXPORTS +crUnpack +crUnpackPush +crUnpackPop +crUnpackSetReturnPointer +crUnpackSetWritebackPointer +cr_unpackData diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py new file mode 100755 index 00000000..052fff6c --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py @@ -0,0 +1,394 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys + +import apiutil + + +apiutil.CopyrightC() + +print("""/* DO NOT EDIT! THIS CODE IS AUTOGENERATED BY unpack.py */ + +#include "unpacker.h" +#include "cr_opcodes.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_spu.h" +#include "unpack_extend.h" +#include <stdio.h> +#include <memory.h> + +#include <iprt/cdefs.h> + +DECLEXPORT(const unsigned char *) cr_unpackData = NULL; +DECLEXPORT(const unsigned char *) cr_unpackDataEnd = NULL; +SPUDispatchTable cr_unpackDispatch; + +static void crUnpackExtend(void); +static void crUnpackExtendDbg(void); + +#if 0 //def DEBUG_misha +//# define CR_UNPACK_DEBUG_OPCODES +# define CR_UNPACK_DEBUG_LAST_OPCODES +# define CR_UNPACK_DEBUG_PREV_OPCODES +#endif + +#ifdef CR_UNPACK_DEBUG_PREV_OPCODES +static GLenum g_VBoxDbgCrPrevOpcode = 0; +static GLenum g_VBoxDbgCrPrevExtendOpcode = 0; +#endif +""") + +nodebug_opcodes = [ + "CR_MULTITEXCOORD2FARB_OPCODE", + "CR_VERTEX3F_OPCODE", + "CR_NORMAL3F_OPCODE", + "CR_COLOR4UB_OPCODE", + "CR_LOADIDENTITY_OPCODE", + "CR_MATRIXMODE_OPCODE", + "CR_LOADMATRIXF_OPCODE", + "CR_DISABLE_OPCODE", + "CR_COLOR4F_OPCODE", + "CR_ENABLE_OPCODE", + "CR_BEGIN_OPCODE", + "CR_END_OPCODE", + "CR_SECONDARYCOLOR3FEXT_OPCODE" +] + +nodebug_extopcodes = [ + "CR_ACTIVETEXTUREARB_EXTEND_OPCODE" +] + +# +# Useful functions +# + +def ReadData( offset, arg_type ): + """Emit a READ_DOUBLE or READ_DATA call for pulling a GL function + argument out of the buffer's operand area.""" + if arg_type == "GLdouble" or arg_type == "GLclampd": + retval = "READ_DOUBLE(%d)" % offset + else: + retval = "READ_DATA(%d, %s)" % (offset, arg_type) + return retval + + +def FindReturnPointer( return_type, params ): + """For GL functions that return values (either as the return value or + through a pointer parameter) emit a SET_RETURN_PTR call.""" + arg_len = apiutil.PacketLength( params ) + if (return_type != 'void'): + print('\tSET_RETURN_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length + else: + paramList = [ ('foo', 'void *', 0) ] + print('\tSET_RETURN_PTR(%d);' % (arg_len + 8 - apiutil.PacketLength(paramList))) + + +def FindWritebackPointer( return_type, params ): + """Emit a SET_WRITEBACK_PTR call.""" + arg_len = apiutil.PacketLength( params ) + if return_type != 'void': + paramList = [ ('foo', 'void *', 0) ] + arg_len += apiutil.PacketLength( paramList ) + + print('\tSET_WRITEBACK_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length + + +def MakeNormalCall( return_type, func_name, params, counter_init = 0 ): + counter = counter_init + copy_of_params = params[:] + + for i in range( 0, len(params) ): + (name, type, vecSize) = params[i] + if apiutil.IsPointer(copy_of_params[i][1]): + params[i] = ('NULL', type, vecSize) + copy_of_params[i] = (copy_of_params[i][0], 'void', 0) + if not "get" in apiutil.Properties(func_name): + print('\tcrError( "%s needs to be special cased!" );' % func_name) + else: + print("\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) )) + counter += apiutil.sizeof(copy_of_params[i][1]) + + if ("get" in apiutil.Properties(func_name)): + FindReturnPointer( return_type, params ) + FindWritebackPointer( return_type, params ) + + if return_type != "void": + print("\t(void)", end=" ") + else: + print("\t", end="") + print("cr_unpackDispatch.%s(%s);" % (func_name, apiutil.MakeCallString(params))) + + +def MakeVectorCall( return_type, func_name, arg_type ): + """Convert a call like glVertex3f to glVertex3fv.""" + vec_func = apiutil.VectorFunction(func_name) + params = apiutil.Parameters(vec_func) + assert len(params) == 1 + (arg_name, vecType, vecSize) = params[0] + + if arg_type == "GLdouble" or arg_type == "GLclampd": + print("#ifdef CR_UNALIGNED_ACCESS_OKAY") + print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)) + print("#else") + for index in range(0, vecSize): + print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(" + repr(index * 8) + ");") + if return_type != "void": + print("\t(void) cr_unpackDispatch.%s(" % func_name, end="") + else: + print("\tcr_unpackDispatch.%s(" % func_name, end="") + for index in range(0, vecSize): + print("v" + repr(index), end="") + if index != vecSize - 1: + print(",", end=" ") + print(");") + print("#endif") + else: + print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)) + + + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + + +# +# Generate unpack functions for all the simple functions. +# +for func_name in keys: + if (not "pack" in apiutil.ChromiumProps(func_name) or + apiutil.FindSpecial( "unpacker", func_name )): + continue + + params = apiutil.Parameters(func_name) + return_type = apiutil.ReturnType(func_name) + + print("static void crUnpack%s(void)" % func_name) + print("{") + + vector_func = apiutil.VectorFunction(func_name) + if (vector_func and len(apiutil.Parameters(vector_func)) == 1): + MakeVectorCall( return_type, func_name, params[0][1] ) + else: + MakeNormalCall( return_type, func_name, params ) + packet_length = apiutil.PacketLength( params ) + if packet_length == 0: + print("\tINCR_DATA_PTR_NO_ARGS( );") + else: + print("\tINCR_DATA_PTR(%d);" % packet_length) + print("}\n") + + +# +# Emit some code +# +print(""" +typedef struct __dispatchNode { + const unsigned char *unpackData; + struct __dispatchNode *next; +} DispatchNode; + +static DispatchNode *unpackStack = NULL; + +static SPUDispatchTable *cr_lastDispatch = NULL; + +void crUnpackPush(void) +{ + DispatchNode *node = (DispatchNode*)crAlloc( sizeof( *node ) ); + node->next = unpackStack; + unpackStack = node; + node->unpackData = cr_unpackData; +} + +void crUnpackPop(void) +{ + DispatchNode *node = unpackStack; + + if (!node) + { + crError( "crUnpackPop called with an empty stack!" ); + } + unpackStack = node->next; + cr_unpackData = node->unpackData; + crFree( node ); +} + +CR_UNPACK_BUFFER_TYPE crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes) +{ + const uint8_t *pu8Codes = (const uint8_t *)opcodes; + + uint8_t first; + uint8_t last; + + if (!num_opcodes) + return CR_UNPACK_BUFFER_TYPE_GENERIC; + + first = pu8Codes[0]; + last = pu8Codes[1-(int)num_opcodes]; + + switch (last) + { + case CR_CMDBLOCKFLUSH_OPCODE: + return CR_UNPACK_BUFFER_TYPE_CMDBLOCK_FLUSH; + case CR_CMDBLOCKEND_OPCODE: + return (first == CR_CMDBLOCKBEGIN_OPCODE) ? CR_UNPACK_BUFFER_TYPE_GENERIC : CR_UNPACK_BUFFER_TYPE_CMDBLOCK_END; + default: + return (first != CR_CMDBLOCKBEGIN_OPCODE) ? CR_UNPACK_BUFFER_TYPE_GENERIC : CR_UNPACK_BUFFER_TYPE_CMDBLOCK_BEGIN; + } +} + +void crUnpack( const void *data, const void *data_end, const void *opcodes, + unsigned int num_opcodes, SPUDispatchTable *table ) +{ + unsigned int i; + const unsigned char *unpack_opcodes; + if (table != cr_lastDispatch) + { + crSPUCopyDispatchTable( &cr_unpackDispatch, table ); + cr_lastDispatch = table; + } + + unpack_opcodes = (const unsigned char *)opcodes; + cr_unpackData = (const unsigned char *)data; + cr_unpackDataEnd = (const unsigned char *)data_end; + +#if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES) + crDebug("crUnpack: %d opcodes", num_opcodes); +#endif + + for (i = 0; i < num_opcodes; i++) + { + + CRDBGPTR_CHECKZ(writeback_ptr); + CRDBGPTR_CHECKZ(return_ptr); + + /*crDebug(\"Unpacking opcode \%d\", *unpack_opcodes);*/ +#ifdef CR_UNPACK_DEBUG_PREV_OPCODES + g_VBoxDbgCrPrevOpcode = *unpack_opcodes; +#endif + switch( *unpack_opcodes ) + {""") + +# +# Emit switch cases for all unextended opcodes +# +for func_name in keys: + if "pack" in apiutil.ChromiumProps(func_name): + print('\t\t\tcase %s:' % apiutil.OpcodeName( func_name )) + if not apiutil.OpcodeName(func_name) in nodebug_opcodes: + print(""" +#ifdef CR_UNPACK_DEBUG_LAST_OPCODES + if (i==(num_opcodes-1)) +#endif +#if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES) + crDebug("Unpack: %s"); +#endif """ % apiutil.OpcodeName(func_name)) + print('\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name) + +print(""" + case CR_EXTEND_OPCODE: + #ifdef CR_UNPACK_DEBUG_OPCODES + crUnpackExtendDbg(); + #else + # ifdef CR_UNPACK_DEBUG_LAST_OPCODES + if (i==(num_opcodes-1)) crUnpackExtendDbg(); + else + # endif + crUnpackExtend(); + #endif + break; + case CR_CMDBLOCKBEGIN_OPCODE: + case CR_CMDBLOCKEND_OPCODE: + case CR_CMDBLOCKFLUSH_OPCODE: + case CR_NOP_OPCODE: + INCR_DATA_PTR_NO_ARGS( ); + break; + default: + crError( "Unknown opcode: %d", *unpack_opcodes ); + break; + } + + CRDBGPTR_CHECKZ(writeback_ptr); + CRDBGPTR_CHECKZ(return_ptr); + + unpack_opcodes--; + } +}""") + + +# +# Emit unpack functions for extended opcodes, non-special functions only. +# +for func_name in keys: + if ("extpack" in apiutil.ChromiumProps(func_name) + and not apiutil.FindSpecial("unpacker", func_name)): + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + print('static void crUnpackExtend%s(void)' % func_name) + print('{') + MakeNormalCall( return_type, func_name, params, 8 ) + print('}\n') + +print('static void crUnpackExtend(void)') +print('{') +print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' )) +print('') +print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES') +print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;') +print('#endif') +print('') +print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/') +print('\tswitch( extend_opcode )') +print('\t{') + + +# +# Emit switch statement for extended opcodes +# +for func_name in keys: + if "extpack" in apiutil.ChromiumProps(func_name): + print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )) +# print('\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ))) + print('\t\t\tcrUnpackExtend%s( );' % func_name) + print('\t\t\tbreak;') + +print(""" default: + crError( "Unknown extended opcode: %d", (int) extend_opcode ); + break; + } + INCR_VAR_PTR(); +}""") + +print('static void crUnpackExtendDbg(void)') +print('{') +print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' )) +print('') +print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES') +print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;') +print('#endif') +print('') +print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/') +print('\tswitch( extend_opcode )') +print('\t{') + + +# +# Emit switch statement for extended opcodes +# +for func_name in keys: + if "extpack" in apiutil.ChromiumProps(func_name): + print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )) + if not apiutil.ExtendedOpcodeName(func_name) in nodebug_extopcodes: + print('\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )) + print('\t\t\tcrUnpackExtend%s( );' % func_name) + print('\t\t\tbreak;') + +print(""" default: + crError( "Unknown extended opcode: %d", (int) extend_opcode ); + break; + } + INCR_VAR_PTR(); +}""") diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c new file mode 100644 index 00000000..847bb1ed --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c @@ -0,0 +1,312 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_error.h" +#include "unpack_extend.h" +#include "unpacker.h" +#include "cr_glstate.h" +/** + * \mainpage Unpacker + * + * \section UnpackerIntroduction Introduction + * + * Chromium consists of all the top-level files in the cr + * directory. The unpacker module basically takes care of API dispatch, + * and OpenGL state management. + * + */ + +void crUnpackExtendVertexPointer(void) +{ + GLint size = READ_DATA( 8, GLint ); + GLenum type = READ_DATA( 12, GLenum ); + GLsizei stride = READ_DATA( 16, GLsizei ); + GLintptrARB pointer = (GLintptrARB) READ_DATA( 20, GLuint ); + cr_unpackDispatch.VertexPointer( size, type, stride, (void *) pointer ); +} + +void crUnpackExtendTexCoordPointer(void) +{ + GLint size = READ_DATA( 8, GLint ); + GLenum type = READ_DATA( 12, GLenum ); + GLsizei stride = READ_DATA( 16, GLsizei ); + GLintptrARB pointer = READ_DATA( 20, GLuint ); + cr_unpackDispatch.TexCoordPointer( size, type, stride, (void *) pointer ); +} + +void crUnpackExtendNormalPointer(void) +{ + GLenum type = READ_DATA( 8, GLenum ); + GLsizei stride = READ_DATA( 12, GLsizei ); + GLintptrARB pointer = READ_DATA( 16, GLuint ); + cr_unpackDispatch.NormalPointer( type, stride, (void *) pointer ); +} + +void crUnpackExtendIndexPointer(void) +{ + GLenum type = READ_DATA( 8, GLenum ); + GLsizei stride = READ_DATA( 12, GLsizei ); + GLintptrARB pointer = READ_DATA( 16, GLuint ); + cr_unpackDispatch.IndexPointer( type, stride, (void *) pointer ); +} + +void crUnpackExtendEdgeFlagPointer(void) +{ + GLsizei stride = READ_DATA( 8, GLsizei ); + GLintptrARB pointer = READ_DATA( 12, GLuint ); + cr_unpackDispatch.EdgeFlagPointer( stride, (void *) pointer ); +} + +void crUnpackExtendColorPointer(void) +{ + GLint size = READ_DATA( 8, GLint ); + GLenum type = READ_DATA( 12, GLenum ); + GLsizei stride = READ_DATA( 16, GLsizei ); + GLintptrARB pointer = READ_DATA( 20, GLuint ); + cr_unpackDispatch.ColorPointer( size, type, stride, (void *) pointer ); +} + +void crUnpackExtendFogCoordPointerEXT(void) +{ + GLenum type = READ_DATA( 8, GLenum ); + GLsizei stride = READ_DATA( 12, GLsizei ); + GLintptrARB pointer = READ_DATA( 16, GLuint ); + cr_unpackDispatch.FogCoordPointerEXT( type, stride, (void *) pointer ); +} + +void crUnpackExtendSecondaryColorPointerEXT(void) +{ + GLint size = READ_DATA( 8, GLint ); + GLenum type = READ_DATA( 12, GLenum ); + GLsizei stride = READ_DATA( 16, GLsizei ); + GLintptrARB pointer = READ_DATA( 20, GLuint ); + cr_unpackDispatch.SecondaryColorPointerEXT( size, type, stride, (void *) pointer ); +} + +void crUnpackExtendVertexAttribPointerARB(void) +{ + GLuint index = READ_DATA( 8, GLuint); + GLint size = READ_DATA( 12, GLint ); + GLenum type = READ_DATA( 16, GLenum ); + GLboolean normalized = READ_DATA( 20, GLboolean ); + GLsizei stride = READ_DATA( 24, GLsizei ); + GLintptrARB pointer = READ_DATA( 28, GLuint ); + cr_unpackDispatch.VertexAttribPointerARB( index, size, type, normalized, stride, (void *) pointer ); +} + +void crUnpackExtendVertexAttribPointerNV(void) +{ + GLuint index = READ_DATA( 8, GLuint); + GLint size = READ_DATA( 12, GLint ); + GLenum type = READ_DATA( 16, GLenum ); + GLsizei stride = READ_DATA( 20, GLsizei ); + GLintptrARB pointer = READ_DATA( 24, GLuint ); + cr_unpackDispatch.VertexAttribPointerNV( index, size, type, stride, (void *) pointer ); +} + +void crUnpackExtendInterleavedArrays(void) +{ + GLenum format = READ_DATA( 8, GLenum ); + GLsizei stride = READ_DATA( 12, GLsizei ); + GLintptrARB pointer = READ_DATA( 16, GLuint ); + cr_unpackDispatch.InterleavedArrays( format, stride, (void *) pointer ); +} + +void crUnpackExtendDrawElements(void) +{ + GLenum mode = READ_DATA( 8, GLenum ); + GLsizei count = READ_DATA( 12, GLsizei ); + GLenum type = READ_DATA( 16, GLenum ); + GLintptrARB indices = READ_DATA( 20, GLuint ); + void * indexptr; +#ifdef CR_ARB_vertex_buffer_object + GLboolean hasidxdata = READ_DATA(24, GLint); + indexptr = hasidxdata ? DATA_POINTER(28, void) : (void*)indices; +#else + indexptr = DATA_POINTER(24, void); +#endif + cr_unpackDispatch.DrawElements(mode, count, type, indexptr); +} + +void crUnpackExtendDrawRangeElements(void) +{ + GLenum mode = READ_DATA( 8, GLenum ); + GLuint start = READ_DATA( 12, GLuint ); + GLuint end = READ_DATA( 16, GLuint ); + GLsizei count = READ_DATA( 20, GLsizei ); + GLenum type = READ_DATA( 24, GLenum ); + GLintptrARB indices = READ_DATA( 28, GLuint ); + void * indexptr; +#ifdef CR_ARB_vertex_buffer_object + GLboolean hasidxdata = READ_DATA(32, GLint); + indexptr = hasidxdata ? DATA_POINTER(36, void) : (void*)indices; +#else + indexptr = DATA_POINTER(32, void); +#endif + cr_unpackDispatch.DrawRangeElements(mode, start, end, count, type, indexptr); +} + +void crUnpackMultiDrawArraysEXT(void) +{ + crError( "Can't decode MultiDrawArraysEXT" ); +} + +void crUnpackMultiDrawElementsEXT(void) +{ + crError( "Can't decode MultiDrawElementsEXT" ); +} + +static void crUnpackSetClientPointerByIndex(int index, GLint size, + GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid *pointer, CRClientState *c) +{ + /*crDebug("crUnpackSetClientPointerByIndex: %i(s=%i, t=0x%x, n=%i, str=%i) -> %p", index, size, type, normalized, stride, pointer);*/ + + if (index<7) + { + switch (index) + { + case 0: + cr_unpackDispatch.VertexPointer(size, type, stride, pointer); + break; + case 1: + cr_unpackDispatch.ColorPointer(size, type, stride, pointer); + break; + case 2: + cr_unpackDispatch.FogCoordPointerEXT(type, stride, pointer); + break; + case 3: + cr_unpackDispatch.SecondaryColorPointerEXT(size, type, stride, pointer); + break; + case 4: + cr_unpackDispatch.EdgeFlagPointer(stride, pointer); + break; + case 5: + cr_unpackDispatch.IndexPointer(type, stride, pointer); + break; + case 6: + cr_unpackDispatch.NormalPointer(type, stride, pointer); + break; + } + } + else if (index<(7+CR_MAX_TEXTURE_UNITS)) + { + int curTexUnit = c->curClientTextureUnit; + if ((index-7)!=curTexUnit) + { + cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+index-7); + } + cr_unpackDispatch.TexCoordPointer(size, type, stride, pointer); + if ((index-7)!=curTexUnit) + { + cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+curTexUnit); + } + } + else + { + cr_unpackDispatch.VertexAttribPointerARB(index-7-CR_MAX_TEXTURE_UNITS, + size, type, normalized, stride, pointer); + } +} + +void crUnpackExtendLockArraysEXT(void) +{ + GLint first = READ_DATA(sizeof(int) + 4, GLint); + GLint count = READ_DATA(sizeof(int) + 8, GLint); + int numenabled = READ_DATA(sizeof(int) + 12, int); + + CRContext *g = crStateGetCurrent(); + CRClientState *c = &g->client; + CRClientPointer *cp; + int i, index, offset; + unsigned char *data; + + if (first < 0 || count <= 0 || first >= INT32_MAX - count) + { + crError("crUnpackExtendLockArraysEXT: first(%i) count(%i), parameters out of range", first, count); + return; + } + + if (numenabled <= 0 || numenabled >= CRSTATECLIENT_MAX_VERTEXARRAYS) + { + crError("crUnpackExtendLockArraysEXT: numenabled(%i), parameter out of range", numenabled); + return; + } + + offset = 2 * sizeof(int) + 12; + + /*crDebug("crUnpackExtendLockArraysEXT(%i, %i) ne=%i", first, count, numenabled);*/ + + for (i = 0; i < numenabled; ++i) + { + index = READ_DATA(offset, int); + offset += sizeof(int); + + cp = crStateGetClientPointerByIndex(index, &c->array); + + CRASSERT(cp && cp->enabled && (!cp->buffer || !cp->buffer->id)); + + if (cp && cp->bytesPerIndex > 0) + { + if (first + count >= INT32_MAX / cp->bytesPerIndex) + { + crError("crUnpackExtendLockArraysEXT: first(%i) count(%i) bpi(%i), parameters out of range", first, count, cp->bytesPerIndex); + return; + } + + data = crAlloc((first + count) * cp->bytesPerIndex); + + if (data) + { + crMemcpy(data + first * cp->bytesPerIndex, DATA_POINTER(offset, GLvoid), count * cp->bytesPerIndex); + /*crDebug("crUnpackExtendLockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i", + index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/ + crUnpackSetClientPointerByIndex(index, cp->size, cp->type, cp->normalized, 0, data, c); + /*crDebug("crUnpackExtendLockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i", + index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/ + } + else + { + crError("crUnpackExtendLockArraysEXT: crAlloc failed"); + return; + } + } + else + { + crError("crUnpackExtendLockArraysEXT: wrong CRClientState %i", index); + return; + } + + offset += count * cp->bytesPerIndex; + } + + cr_unpackDispatch.LockArraysEXT(first, count); +} + +void crUnpackExtendUnlockArraysEXT(void) +{ + int i; + CRContext *g = crStateGetCurrent(); + CRClientState *c = &g->client; + CRClientPointer *cp; + + /*crDebug("crUnpackExtendUnlockArraysEXT");*/ + + cr_unpackDispatch.UnlockArraysEXT(); + + for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i) + { + cp = crStateGetClientPointerByIndex(i, &c->array); + if (cp->enabled) + { + /*crDebug("crUnpackExtendUnlockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i", + i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/ + crUnpackSetClientPointerByIndex(i, cp->size, cp->type, cp->normalized, cp->prevStride, cp->prevPtr, c); + /*crDebug("crUnpackExtendUnlockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i", + i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/ + } + } +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.c new file mode 100644 index 00000000..1350a3da --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.c @@ -0,0 +1,27 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "state/cr_statetypes.h" + +void crUnpackBoundsInfoCR( void ) +{ + CRrecti bounds; + GLint len; + GLuint num_opcodes; + GLbyte *payload; + + len = READ_DATA( 0, GLint ); + bounds.x1 = READ_DATA( 4, GLint ); + bounds.y1 = READ_DATA( 8, GLint ); + bounds.x2 = READ_DATA( 12, GLint ); + bounds.y2 = READ_DATA( 16, GLint ); + num_opcodes = READ_DATA( 20, GLuint ); + payload = DATA_POINTER( 24, GLbyte ); + + cr_unpackDispatch.BoundsInfoCR( &bounds, payload, len, num_opcodes ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.c new file mode 100644 index 00000000..2b9ae29c --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.c @@ -0,0 +1,54 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_mem.h" +#include "cr_error.h" + + +void crUnpackExtendGetBufferSubDataARB( void ) +{ + GLenum target = READ_DATA( 8, GLenum ); + GLintptrARB offset = READ_DATA( 12, GLuint ); + GLsizeiptrARB size = READ_DATA( 16, GLuint ); + + SET_RETURN_PTR( 20 ); + SET_WRITEBACK_PTR( 28 ); + + cr_unpackDispatch.GetBufferSubDataARB( target, offset, size, NULL ); +} + + +void crUnpackExtendBufferDataARB( void ) +{ + GLenum target = READ_DATA(sizeof(int) + 4, GLenum); + GLsizeiptrARB size = READ_DATA(sizeof(int) + 8, GLuint); + GLenum usage = READ_DATA(sizeof(int) + 12, GLenum); + GLboolean hasdata = READ_DATA(sizeof(int) + 16, GLint); + GLvoid *data = DATA_POINTER(sizeof(int) + 20, GLvoid); + + cr_unpackDispatch.BufferDataARB(target, size, hasdata ? data:NULL, usage); +} + + +void crUnpackExtendBufferSubDataARB( void ) +{ + GLenum target = READ_DATA( sizeof(int) + 4, GLenum ); + GLintptrARB offset = READ_DATA( sizeof(int) + 8, GLuint ); + GLsizeiptrARB size = READ_DATA( sizeof(int) + 12, GLuint ); + GLvoid *data = DATA_POINTER( sizeof(int) + 16, GLvoid ); + + cr_unpackDispatch.BufferSubDataARB( target, offset, size, data ); +} + + +void crUnpackExtendDeleteBuffersARB(void) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *buffers = DATA_POINTER( 12, GLuint ); + cr_unpackDispatch.DeleteBuffersARB( n, buffers ); +} + diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.c new file mode 100644 index 00000000..7fa87275 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.c @@ -0,0 +1,17 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackCallLists( void ) +{ + GLint n = READ_DATA( sizeof( int ) + 0, GLint ); + GLenum type = READ_DATA( sizeof( int ) + 4, GLenum ); + GLvoid *lists = DATA_POINTER( sizeof( int ) + 8, GLvoid ); + + cr_unpackDispatch.CallLists( n, type, lists ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.c new file mode 100644 index 00000000..462f28e5 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.c @@ -0,0 +1,19 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_mem.h" +#include "unpack_extend.h" + +void crUnpackClipPlane( void ) +{ + GLenum plane = READ_DATA( 0, GLenum ); + GLdouble equation[4]; + crMemcpy( equation, DATA_POINTER( 4, GLdouble ), sizeof(equation) ); + + cr_unpackDispatch.ClipPlane( plane, equation ); + INCR_DATA_PTR( sizeof( GLenum ) + 4*sizeof( GLdouble )); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.c new file mode 100644 index 00000000..bc58dce3 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_mem.h" + +/* XXX duplicated in pack_context.c */ +#define DISPLAY_NAME_LEN 256 + +#define READ_BYTES( dest, offset, len ) \ + crMemcpy( dest, (cr_unpackData + (offset)), len ) + +void crUnpackExtendCreateContext( void ) +{ + char dpyName[DISPLAY_NAME_LEN]; + GLint visBits = READ_DATA( DISPLAY_NAME_LEN + 8, GLint ); + GLint shareCtx = READ_DATA( DISPLAY_NAME_LEN + 12, GLint ); + GLint retVal; + + READ_BYTES( dpyName, 8, DISPLAY_NAME_LEN ); + dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */ + + SET_RETURN_PTR( DISPLAY_NAME_LEN + 16 ); + SET_WRITEBACK_PTR( DISPLAY_NAME_LEN + 24 ); + retVal = cr_unpackDispatch.CreateContext( dpyName, visBits, shareCtx ); + (void) retVal; +} + +void crUnpackExtendWindowCreate(void) +{ + char dpyName[DISPLAY_NAME_LEN]; + GLint visBits = READ_DATA( DISPLAY_NAME_LEN + 8, GLint ); + GLint retVal; + + READ_BYTES( dpyName, 8, DISPLAY_NAME_LEN ); + dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */ + + SET_RETURN_PTR( DISPLAY_NAME_LEN + 12 ); + SET_WRITEBACK_PTR( DISPLAY_NAME_LEN + 20 ); + retVal = cr_unpackDispatch.WindowCreate( dpyName, visBits ); + (void) retVal; +} + diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.c new file mode 100644 index 00000000..e034a28b --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.c @@ -0,0 +1,94 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_error.h" + +#include "state/cr_bufferobject.h" + +void crUnpackDrawPixels( void ) +{ + GLsizei width = READ_DATA( sizeof( int ) + 0, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 4, GLsizei ); + GLenum format = READ_DATA( sizeof( int ) + 8, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 12, GLenum ); + GLint noimagedata = READ_DATA( sizeof( int ) + 16, GLint ); + GLvoid *pixels; + + if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + return; + + if (noimagedata) + pixels = (void*) (uintptr_t) READ_DATA( sizeof( int ) + 20, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 24, GLvoid ); + + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.DrawPixels( width, height, format, type, pixels ); + + INCR_VAR_PTR( ); +} + +void crUnpackBitmap( void ) +{ + GLsizei width = READ_DATA( sizeof( int ) + 0, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 4, GLsizei ); + GLfloat xorig = READ_DATA( sizeof( int ) + 8, GLfloat ); + GLfloat yorig = READ_DATA( sizeof( int ) + 12, GLfloat ); + GLfloat xmove = READ_DATA( sizeof( int ) + 16, GLfloat ); + GLfloat ymove = READ_DATA( sizeof( int ) + 20, GLfloat ); + GLuint noimagedata = READ_DATA( sizeof( int ) + 24, GLuint ); + GLubyte *bitmap; + + if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + return; + + if (noimagedata) + bitmap = (void*) (uintptr_t) READ_DATA(sizeof(int) + 28, GLint); + else + bitmap = DATA_POINTER( sizeof(int) + 32, GLubyte ); + + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.Bitmap( width, height, xorig, yorig, xmove, ymove, bitmap ); + + INCR_VAR_PTR( ); +} + +/* + * ZPixCR - compressed DrawPixels + */ +void crUnpackExtendZPixCR( void ) +{ + GLsizei width = READ_DATA( 8, GLsizei ); + GLsizei height = READ_DATA( 12, GLsizei ); + GLenum format = READ_DATA( 16, GLenum ); + GLenum type = READ_DATA( 20, GLenum ); + GLenum ztype = READ_DATA( 24, GLenum ); + GLint zparm = READ_DATA( 28, GLuint ); + GLint length = READ_DATA( 32, GLint ); + GLvoid *pixels = DATA_POINTER( 36, GLvoid ); + +/*XXX JAG + crDebug("UnpackZPixCR: w = %d, h = %d, len = %d", + width, height, length); +*/ + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.ZPixCR( width, height, format, type, ztype, zparm, length, pixels ); + + /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */ +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py new file mode 100755 index 00000000..d81ff903 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py @@ -0,0 +1,35 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys + +sys.path.append( "../glapi_parser" ) +import apiutil + + +apiutil.CopyrightC() + +print("""/* DO NOT EDIT! THIS CODE IS AUTOGENERATED BY unpack_extend.py */ + +#ifndef UNPACK_EXTEND_H +#define UNPACK_EXTEND_H 1 + +""") + + +# +# Print extern declarations for all special unpacker functions +# +for func_name in apiutil.AllSpecials( "unpacker" ): + if "extpack" in apiutil.ChromiumProps(func_name): + print('extern void crUnpackExtend%s(void);' % func_name) + else: + print('extern void crUnpack%s(void);' % func_name) + +print(""" +#endif +""") + diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.c new file mode 100644 index 00000000..fa616b31 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.c @@ -0,0 +1,10 @@ + +#include "unpacker.h" + +void crUnpackExtendDeleteFencesNV(void) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *fences = DATA_POINTER( 12, GLuint ); + cr_unpackDispatch.DeleteFencesNV( n, fences ); +} + diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.c new file mode 100644 index 00000000..faf09f95 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.c @@ -0,0 +1,25 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackFogfv( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 4, GLfloat ); + + cr_unpackDispatch.Fogfv( pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackFogiv( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint ); + + cr_unpackDispatch.Fogiv( pname, params ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.c new file mode 100644 index 00000000..0bab6d56 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.c @@ -0,0 +1,37 @@ +/* $Id: unpack_framebuffer.c $ */ +/** @file + * VBox OpenGL: EXT_framebuffer_object + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_version.h" + +void crUnpackExtendDeleteFramebuffersEXT(void) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *buffers = DATA_POINTER( 12, GLuint ); + cr_unpackDispatch.DeleteFramebuffersEXT( n, buffers ); +} + +void crUnpackExtendDeleteRenderbuffersEXT(void) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *buffers = DATA_POINTER( 12, GLuint ); + cr_unpackDispatch.DeleteRenderbuffersEXT( n, buffers ); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py new file mode 100755 index 00000000..cb42c22a --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py @@ -0,0 +1,30 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys; +import pickle; +import types; +import string; +import re; + +sys.path.append( "../opengl_stub" ) + +import stub_common; + +parsed_file = open( "../glapi_parser/gl_header.parsed", "rb" ) +gl_mapping = pickle.load( parsed_file ) + +stub_common.CopyrightC() + +print("""#ifndef CR_UNPACKFUNCTIONS_H +#define CR_UNPACKFUNCTIONS_H +""") + +for func_name in sorted(gl_mapping.keys()): + ( return_type, arg_names, arg_types ) = gl_mapping[func_name] + print('void crUnpack%s();' %( func_name )) +print('void crUnpackExtend();') +print('\n#endif /* CR_UNPACKFUNCTIONS_H */') diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.c new file mode 100644 index 00000000..01bd97b3 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.c @@ -0,0 +1,45 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackLightfv( void ) +{ + GLenum light = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.Lightfv( light, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackLightiv( void ) +{ + GLenum light = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.Lightiv( light, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackLightModelfv( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 4, GLfloat ); + + cr_unpackDispatch.LightModelfv( pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackLightModeliv( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint ); + + cr_unpackDispatch.LightModeliv( pname, params ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c new file mode 100644 index 00000000..ac44f856 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c @@ -0,0 +1,138 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "state/cr_limits.h" + + +void crUnpackMap2d(void) +{ + GLenum target = READ_DATA(sizeof(int) + 0, GLenum); + GLdouble u1 = READ_DOUBLE(sizeof(int) + 4); + GLdouble u2 = READ_DOUBLE(sizeof(int) + 12); + GLint ustride = READ_DATA(sizeof(int) + 20, GLint); + GLint uorder = READ_DATA(sizeof(int) + 24, GLint); + GLdouble v1 = READ_DOUBLE(sizeof(int) + 28); + GLdouble v2 = READ_DOUBLE(sizeof(int) + 36); + GLint vstride = READ_DATA(sizeof(int) + 44, GLint); + GLint vorder = READ_DATA(sizeof(int) + 48, GLint); + GLdouble *points = DATA_POINTER(sizeof(int) + 52, GLdouble); + GLint cbMax; + + if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER || + vorder < 1 || vorder > CR_MAX_EVAL_ORDER || + ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(double) / uorder / 8 || + vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(double) / vorder / 8 ) + { + crError("crUnpackMap2d: parameters out of range"); + return; + } + + cbMax = (ustride * uorder + vstride * vorder) * sizeof(double); + if (!DATA_POINTER_CHECK(cbMax)) + { + crError("crUnpackMap2d: parameters out of range"); + return; + } + + cr_unpackDispatch.Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + + INCR_VAR_PTR(); +} + +void crUnpackMap2f(void) +{ + GLenum target = READ_DATA(sizeof(int) + 0, GLenum); + GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat); + GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat); + GLint ustride = READ_DATA(sizeof(int) + 12, GLint); + GLint uorder = READ_DATA(sizeof(int) + 16, GLint); + GLfloat v1 = READ_DATA(sizeof(int) + 20, GLfloat); + GLfloat v2 = READ_DATA(sizeof(int) + 24, GLfloat); + GLint vstride = READ_DATA(sizeof(int) + 28, GLint); + GLint vorder = READ_DATA(sizeof(int) + 32, GLint); + GLfloat *points = DATA_POINTER(sizeof(int) + 36, GLfloat); + GLint cbMax; + + if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER || + vorder < 1 || vorder > CR_MAX_EVAL_ORDER || + ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(float) / uorder / 8 || + vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(float) / vorder / 8) + { + crError("crUnpackMap2d: parameters out of range"); + return; + } + + cbMax = (ustride * uorder + vstride * vorder) * sizeof(float); + if (!DATA_POINTER_CHECK(cbMax)) + { + crError("crUnpackMap2f: parameters out of range"); + return; + } + + cr_unpackDispatch.Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + + INCR_VAR_PTR(); +} + +void crUnpackMap1d(void) +{ + GLenum target = READ_DATA(sizeof(int) + 0, GLenum); + GLdouble u1 = READ_DOUBLE(sizeof(int) + 4); + GLdouble u2 = READ_DOUBLE(sizeof(int) + 12); + GLint stride = READ_DATA(sizeof(int) + 20, GLint); + GLint order = READ_DATA(sizeof(int) + 24, GLint); + GLdouble *points = DATA_POINTER(sizeof(int) + 28, GLdouble); + GLint cbMax; + + if (order < 1 || order > CR_MAX_EVAL_ORDER || + stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(double) / order / 8) + { + crError("crUnpackMap1d: parameters out of range"); + return; + } + + cbMax = stride * order * sizeof(double); + if (!DATA_POINTER_CHECK(cbMax)) + { + crError("crUnpackMap1d: parameters out of range"); + return; + } + + cr_unpackDispatch.Map1d(target, u1, u2, stride, order, points); + + INCR_VAR_PTR(); +} + +void crUnpackMap1f(void) +{ + GLenum target = READ_DATA(sizeof(int) + 0, GLenum); + GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat); + GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat); + GLint stride = READ_DATA(sizeof(int) + 12, GLint); + GLint order = READ_DATA(sizeof(int) + 16, GLint); + GLfloat *points = DATA_POINTER(sizeof(int) + 20, GLfloat); + GLint cbMax; + + if (order < 1 || order > CR_MAX_EVAL_ORDER || + stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(float) / order / 8) + { + crError("crUnpackMap1f: parameters out of range"); + return; + } + + cbMax = stride * order * sizeof(float); + if (!DATA_POINTER_CHECK(cbMax)) + { + crError("crUnpackMap1f: parameters out of range"); + return; + } + + cr_unpackDispatch.Map1f(target, u1, u2, stride, order, points); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.c new file mode 100644 index 00000000..f5c03991 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.c @@ -0,0 +1,27 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackMaterialfv( void ) +{ + GLenum face = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.Materialfv( face, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackMaterialiv( void ) +{ + GLenum face = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.Materialiv( face, pname, params ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.c new file mode 100644 index 00000000..a36db771 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.c @@ -0,0 +1,72 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_mem.h" + +void crUnpackMultMatrixd( void ) +{ + GLdouble m[16]; + crMemcpy( m, DATA_POINTER( 0, GLdouble ), sizeof(m) ); + + cr_unpackDispatch.MultMatrixd( m ); + INCR_DATA_PTR( 16*sizeof( GLdouble ) ); +} + +void crUnpackMultMatrixf( void ) +{ + GLfloat *m = DATA_POINTER( 0, GLfloat ); + + cr_unpackDispatch.MultMatrixf( m ); + INCR_DATA_PTR( 16*sizeof( GLfloat ) ); +} + +void crUnpackLoadMatrixd( void ) +{ + GLdouble m[16]; + crMemcpy( m, DATA_POINTER( 0, GLdouble ), sizeof(m) ); + + cr_unpackDispatch.LoadMatrixd( m ); + INCR_DATA_PTR( 16*sizeof( GLdouble ) ); +} + +void crUnpackLoadMatrixf( void ) +{ + GLfloat *m = DATA_POINTER( 0, GLfloat ); + + cr_unpackDispatch.LoadMatrixf( m ); + INCR_DATA_PTR( 16*sizeof( GLfloat ) ); +} + +void crUnpackExtendMultTransposeMatrixdARB( void ) +{ + GLdouble m[16]; + crMemcpy( m, DATA_POINTER( 8, GLdouble ), sizeof(m) ); + + cr_unpackDispatch.MultTransposeMatrixdARB( m ); +} + +void crUnpackExtendMultTransposeMatrixfARB( void ) +{ + GLfloat *m = DATA_POINTER( 8, GLfloat ); + + cr_unpackDispatch.MultTransposeMatrixfARB( m ); +} + +void crUnpackExtendLoadTransposeMatrixdARB( void ) +{ + GLdouble m[16]; + crMemcpy( m, DATA_POINTER( 8, GLdouble ), sizeof(m) ); + + cr_unpackDispatch.LoadTransposeMatrixdARB( m ); +} + +void crUnpackExtendLoadTransposeMatrixfARB( void ) +{ + GLfloat *m = DATA_POINTER( 8, GLfloat ); + + cr_unpackDispatch.LoadTransposeMatrixfARB( m ); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.c new file mode 100644 index 00000000..daf2b839 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.c @@ -0,0 +1,87 @@ +/* + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackExtendChromiumParametervCR( void ) +{ + GLenum target = READ_DATA( 8, GLenum ); + GLenum type = READ_DATA( 12, GLenum ); + GLsizei count = READ_DATA( 16, GLsizei ); + GLvoid *values = DATA_POINTER( 20, GLvoid ); + + cr_unpackDispatch.ChromiumParametervCR(target, type, count, values); + + + /* + INCR_VAR_PTR(); + */ +} + +void crUnpackExtendDeleteQueriesARB(void) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *ids = DATA_POINTER(12, GLuint); + cr_unpackDispatch.DeleteQueriesARB(n, ids); +} + +void crUnpackExtendGetPolygonStipple(void) +{ + GLubyte *mask; + + SET_RETURN_PTR( 8 ); + SET_WRITEBACK_PTR( 16 ); + mask = DATA_POINTER(8, GLubyte); + + cr_unpackDispatch.GetPolygonStipple( mask ); +} + +void crUnpackExtendGetPixelMapfv(void) +{ + GLenum map = READ_DATA( 8, GLenum ); + GLfloat *values; + + SET_RETURN_PTR( 12 ); + SET_WRITEBACK_PTR( 20 ); + values = DATA_POINTER(12, GLfloat); + + cr_unpackDispatch.GetPixelMapfv( map, values ); +} + +void crUnpackExtendGetPixelMapuiv(void) +{ + GLenum map = READ_DATA( 8, GLenum ); + GLuint *values; + + SET_RETURN_PTR( 12 ); + SET_WRITEBACK_PTR( 20 ); + values = DATA_POINTER(12, GLuint); + + cr_unpackDispatch.GetPixelMapuiv( map, values ); +} + +void crUnpackExtendGetPixelMapusv(void) +{ + GLenum map = READ_DATA( 8, GLenum ); + GLushort *values; + + SET_RETURN_PTR( 12 ); + SET_WRITEBACK_PTR( 20 ); + values = DATA_POINTER(12, GLushort); + + cr_unpackDispatch.GetPixelMapusv( map, values ); +} + +void crUnpackExtendVBoxTexPresent(void) +{ + GLuint texture = READ_DATA( 8, GLuint ); + GLuint cfg = READ_DATA( 12, GLuint ); + GLint xPos = READ_DATA( 16, GLint ); + GLint yPos = READ_DATA( 20, GLint ); + GLint cRects = READ_DATA( 24, GLint ); + GLint *pRects = (GLint *)DATA_POINTER( 28, GLvoid ); + cr_unpackDispatch.VBoxTexPresent( texture, cfg, xPos, yPos, cRects, pRects ); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.c new file mode 100644 index 00000000..9d0eb1a6 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.c @@ -0,0 +1,65 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "state/cr_bufferobject.h" + +void crUnpackPixelMapfv( void ) +{ + GLenum map = READ_DATA( sizeof( int ) + 0, GLenum ); + GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei ); + int nodata = READ_DATA( sizeof(int) + 8, int); + GLfloat *values; + + if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + return; + + if (nodata) + values = (GLfloat*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint); + else + values = DATA_POINTER( sizeof( int ) + 16, GLfloat ); + + cr_unpackDispatch.PixelMapfv( map, mapsize, values ); + INCR_VAR_PTR(); +} + +void crUnpackPixelMapuiv( void ) +{ + GLenum map = READ_DATA( sizeof( int ) + 0, GLenum ); + GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei ); + int nodata = READ_DATA( sizeof(int) + 8, int); + GLuint *values; + + if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + return; + + if (nodata) + values = (GLuint*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint); + else + values = DATA_POINTER( sizeof( int ) + 16, GLuint ); + + cr_unpackDispatch.PixelMapuiv( map, mapsize, values ); + INCR_VAR_PTR(); +} + +void crUnpackPixelMapusv( void ) +{ + GLenum map = READ_DATA( sizeof( int ) + 0, GLenum ); + GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei ); + int nodata = READ_DATA( sizeof(int) + 8, int); + GLushort *values; + + if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + return; + + if (nodata) + values = (GLushort*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint); + else + values = DATA_POINTER( sizeof( int ) + 16, GLushort ); + + cr_unpackDispatch.PixelMapusv( map, mapsize, values ); + INCR_VAR_PTR(); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.c new file mode 100644 index 00000000..1faa0a53 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackExtendPointParameterfvARB( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + cr_unpackDispatch.PointParameterfvARB( pname, params ); +} + +#if 1 +void crUnpackExtendPointParameteriv( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint ); + + cr_unpackDispatch.PointParameteriv( pname, params ); +} +#endif diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c new file mode 100644 index 00000000..346b623c --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c @@ -0,0 +1,386 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_version.h" + + +void crUnpackExtendProgramParameter4dvNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLdouble params[4]; + params[0] = READ_DOUBLE(16); + params[1] = READ_DOUBLE(24); + params[2] = READ_DOUBLE(32); + params[3] = READ_DOUBLE(40); + cr_unpackDispatch.ProgramParameter4dvNV(target, index, params); +} + + +void crUnpackExtendProgramParameter4fvNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLfloat params[4]; + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + cr_unpackDispatch.ProgramParameter4fvNV(target, index, params); +} + + +void crUnpackExtendProgramParameters4dvNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLuint num = READ_DATA(16, GLuint); + GLdouble *params; + + if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLdouble))) + { + crError("crUnpackExtendProgramParameters4dvNV: parameter 'num' is out of range"); + return; + } + + params = (GLdouble *)crAlloc(num * 4 * sizeof(GLdouble)); + + if (params) { + GLuint i; + for (i = 0; i < 4 * num; i++) { + params[i] = READ_DATA(20 + i * sizeof(GLdouble), GLdouble); + } + cr_unpackDispatch.ProgramParameters4dvNV(target, index, num, params); + crFree(params); + } +} + + +void crUnpackExtendProgramParameters4fvNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLuint num = READ_DATA(16, GLuint); + GLfloat *params; + + if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLfloat))) + { + crError("crUnpackExtendProgramParameters4fvNV: parameter 'num' is out of range"); + return; + } + + params = (GLfloat *)crAlloc(num * 4 * sizeof(GLfloat)); + + if (params) { + GLuint i; + for (i = 0; i < 4 * num; i++) { + params[i] = READ_DATA(20 + i * sizeof(GLfloat), GLfloat); + } + cr_unpackDispatch.ProgramParameters4fvNV(target, index, num, params); + crFree(params); + } +} + + +void crUnpackExtendAreProgramsResidentNV(void) +{ + GLsizei n = READ_DATA(8, GLsizei); + const GLuint *programs = DATA_POINTER(12, const GLuint); + + if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(20 + n * sizeof(GLuint))) + { + crError("crUnpackExtendAreProgramsResidentNV: %d is out of range", n); + return; + } + + SET_RETURN_PTR(12 + n * sizeof(GLuint)); + SET_WRITEBACK_PTR(20 + n * sizeof(GLuint)); + (void) cr_unpackDispatch.AreProgramsResidentNV(n, programs, NULL); +} + + +void crUnpackExtendLoadProgramNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint id = READ_DATA(12, GLuint); + GLsizei len = READ_DATA(16, GLsizei); + GLvoid *program = DATA_POINTER(20, GLvoid); + cr_unpackDispatch.LoadProgramNV(target, id, len, program); +} + + +void crUnpackExtendExecuteProgramNV(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint id = READ_DATA(12, GLuint); + GLfloat params[4]; + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + cr_unpackDispatch.ExecuteProgramNV(target, id, params); +} + +void crUnpackExtendRequestResidentProgramsNV(void) +{ + GLsizei n = READ_DATA(8, GLsizei); + crError("RequestResidentProgramsNV needs to be special cased!"); + cr_unpackDispatch.RequestResidentProgramsNV(n, NULL); +} + + +void crUnpackExtendProgramLocalParameter4fvARB(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLfloat params[4]; + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + cr_unpackDispatch.ProgramLocalParameter4fvARB(target, index, params); +} + + +void crUnpackExtendProgramLocalParameter4dvARB(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLdouble params[4]; + params[0] = READ_DOUBLE(16); + params[1] = READ_DOUBLE(24); + params[2] = READ_DOUBLE(32); + params[3] = READ_DOUBLE(40); + cr_unpackDispatch.ProgramLocalParameter4dvARB(target, index, params); +} + + + +void crUnpackExtendProgramNamedParameter4dvNV(void) +{ + GLuint id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + GLdouble params[4]; + GLubyte *name = crAlloc(len); + params[0] = READ_DOUBLE(16); + params[1] = READ_DOUBLE(24); + params[2] = READ_DOUBLE(32); + params[3] = READ_DOUBLE(40); + crMemcpy(name, DATA_POINTER(48, GLubyte), len); + cr_unpackDispatch.ProgramNamedParameter4dvNV(id, len, name, params); +} + +void crUnpackExtendProgramNamedParameter4dNV(void) +{ + GLuint id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + GLdouble params[4]; + GLubyte *name = crAlloc (len); + params[0] = READ_DOUBLE(16); + params[1] = READ_DOUBLE(24); + params[2] = READ_DOUBLE(32); + params[3] = READ_DOUBLE(40); + crMemcpy(name, DATA_POINTER(48, GLubyte), len); + cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]); +} + +void crUnpackExtendProgramNamedParameter4fNV(void) +{ + GLenum id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + GLfloat params[4]; + GLubyte *name = crAlloc(len); + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + crMemcpy(name, DATA_POINTER(32, GLubyte), len); + cr_unpackDispatch.ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]); +} + +void crUnpackExtendProgramNamedParameter4fvNV(void) +{ + GLenum id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + GLfloat params[4]; + GLubyte *name = crAlloc(len); + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + crMemcpy(name, DATA_POINTER(32, GLubyte), len); + cr_unpackDispatch.ProgramNamedParameter4fvNV(id, len, name, params); +} + +void crUnpackExtendGetProgramNamedParameterdvNV(void) +{ + GLuint id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + const GLubyte *name = DATA_POINTER(16, GLubyte); + + if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8)) + { + crError("crUnpackExtendGetProgramNamedParameterdvNV: len %d is out of range", len); + return; + } + + SET_RETURN_PTR(16+len); + SET_WRITEBACK_PTR(16+len+8); + cr_unpackDispatch.GetProgramNamedParameterdvNV(id, len, name, NULL); +} + +void crUnpackExtendGetProgramNamedParameterfvNV(void) +{ + GLuint id = READ_DATA(8, GLuint); + GLsizei len = READ_DATA(12, GLsizei); + const GLubyte *name = DATA_POINTER(16, GLubyte); + + if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8)) + { + crError("crUnpackExtendGetProgramNamedParameterfvNV: len %d is out of range", len); + return; + } + + SET_RETURN_PTR(16+len); + SET_WRITEBACK_PTR(16+len+8); + cr_unpackDispatch.GetProgramNamedParameterfvNV(id, len, name, NULL); +} + +void crUnpackExtendProgramStringARB(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLenum format = READ_DATA(12, GLuint); + GLsizei len = READ_DATA(16, GLsizei); + GLvoid *program = DATA_POINTER(20, GLvoid); + cr_unpackDispatch.ProgramStringARB(target, format, len, program); +} + +void crUnpackExtendGetProgramStringARB(void) +{ +} + +void crUnpackExtendProgramEnvParameter4dvARB(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLdouble params[4]; + params[0] = READ_DOUBLE(16); + params[1] = READ_DOUBLE(24); + params[2] = READ_DOUBLE(32); + params[3] = READ_DOUBLE(40); + cr_unpackDispatch.ProgramEnvParameter4dvARB(target, index, params); +} + +void crUnpackExtendProgramEnvParameter4fvARB(void) +{ + GLenum target = READ_DATA(8, GLenum); + GLuint index = READ_DATA(12, GLuint); + GLfloat params[4]; + params[0] = READ_DATA(16, GLfloat); + params[1] = READ_DATA(20, GLfloat); + params[2] = READ_DATA(24, GLfloat); + params[3] = READ_DATA(28, GLfloat); + cr_unpackDispatch.ProgramEnvParameter4fvARB(target, index, params); +} + +void crUnpackExtendDeleteProgramsARB(void) +{ + GLsizei n = READ_DATA(8, GLsizei); + const GLuint *programs = DATA_POINTER(12, GLuint); + cr_unpackDispatch.DeleteProgramsARB(n, programs); +} + +void crUnpackVertexAttrib4NbvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLbyte *v = DATA_POINTER(4, const GLbyte); + cr_unpackDispatch.VertexAttrib4NbvARB(index, v); + INCR_DATA_PTR(8); +} + +void crUnpackVertexAttrib4NivARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLint *v = DATA_POINTER(4, const GLint); + cr_unpackDispatch.VertexAttrib4NivARB(index, v); + INCR_DATA_PTR(20); +} + +void crUnpackVertexAttrib4NsvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLshort *v = DATA_POINTER(4, const GLshort); + cr_unpackDispatch.VertexAttrib4NsvARB(index, v); + INCR_DATA_PTR(12); +} + +void crUnpackVertexAttrib4NubvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLubyte *v = DATA_POINTER(4, const GLubyte); + cr_unpackDispatch.VertexAttrib4NubvARB(index, v); + INCR_DATA_PTR(8); +} + +void crUnpackVertexAttrib4NuivARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLuint *v = DATA_POINTER(4, const GLuint); + cr_unpackDispatch.VertexAttrib4NuivARB(index, v); + INCR_DATA_PTR(20); +} + +void crUnpackVertexAttrib4NusvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLushort *v = DATA_POINTER(4, const GLushort); + cr_unpackDispatch.VertexAttrib4NusvARB(index, v); + INCR_DATA_PTR(12); +} + +void crUnpackVertexAttrib4bvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLbyte *v = DATA_POINTER(4, const GLbyte); + cr_unpackDispatch.VertexAttrib4bvARB(index, v); + INCR_DATA_PTR(8); +} + +void crUnpackVertexAttrib4ivARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLint *v = DATA_POINTER(4, const GLint); + cr_unpackDispatch.VertexAttrib4ivARB(index, v); + INCR_DATA_PTR(20); +} + +void crUnpackVertexAttrib4ubvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLubyte *v = DATA_POINTER(4, const GLubyte); + cr_unpackDispatch.VertexAttrib4ubvARB(index, v); + INCR_DATA_PTR(8); +} + +void crUnpackVertexAttrib4uivARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLuint *v = DATA_POINTER(4, const GLuint); + cr_unpackDispatch.VertexAttrib4uivARB(index, v); + INCR_DATA_PTR(20); +} + +void crUnpackVertexAttrib4usvARB(void) +{ + GLuint index = READ_DATA(0, GLuint); + const GLushort *v = DATA_POINTER(4, const GLushort); + cr_unpackDispatch.VertexAttrib4usvARB(index, v); + INCR_DATA_PTR(12); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.c new file mode 100644 index 00000000..34b73616 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_pixeldata.h" +#include "cr_mem.h" + +void crUnpackReadPixels( void ) +{ + GLint x = READ_DATA( 0, GLint ); + GLint y = READ_DATA( 4, GLint ); + GLsizei width = READ_DATA( 8, GLsizei ); + GLsizei height = READ_DATA( 12, GLsizei ); + GLenum format = READ_DATA( 16, GLenum ); + GLenum type = READ_DATA( 20, GLenum ); + GLint stride = READ_DATA( 24, GLint ); + GLint alignment = READ_DATA( 28, GLint ); + GLint skipRows = READ_DATA( 32, GLint ); + GLint skipPixels = READ_DATA( 36, GLint ); + GLint bytes_per_row = READ_DATA( 40, GLint ); + GLint rowLength = READ_DATA( 44, GLint ); + GLvoid *pixels; + + /* point <pixels> at the 8-byte network pointer */ + pixels = DATA_POINTER( 48, GLvoid ); + + (void) stride; + (void) bytes_per_row; + (void) alignment; + (void) skipRows; + (void) skipPixels; + (void) rowLength; + + /* we always pack densely on the server side! */ + cr_unpackDispatch.PixelStorei( GL_PACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_PACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_PACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_PACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.ReadPixels( x, y, width, height, format, type, pixels); + + INCR_DATA_PTR(48+sizeof(CRNetworkPointer)); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.c new file mode 100644 index 00000000..9ebd777f --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.c @@ -0,0 +1,35 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackExtendCombinerParameterfvNV( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.CombinerParameterfvNV( pname, params ); + /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */ +} + +void crUnpackExtendCombinerParameterivNV( void ) +{ + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.CombinerParameterivNV( pname, params ); + /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */ +} + +void crUnpackExtendCombinerStageParameterfvNV( void ) +{ + GLenum stage = READ_DATA( sizeof( int ) + 4, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 8, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 12, GLfloat ); + + cr_unpackDispatch.CombinerStageParameterfvNV( stage, pname, params ); + /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */ +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c new file mode 100644 index 00000000..8bc04e2d --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c @@ -0,0 +1,386 @@ +/* $Id: unpack_shaders.c $ */ +/** @file + * VBox OpenGL DRI driver functions + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_version.h" + +void crUnpackExtendBindAttribLocation(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLuint index = READ_DATA(12, GLuint); + const char *name = DATA_POINTER(16, const char); + + cr_unpackDispatch.BindAttribLocation(program, index, name); +} + +void crUnpackExtendShaderSource(void) +{ + GLint *length = NULL; + GLuint shader = READ_DATA(8, GLuint); + GLsizei count = READ_DATA(12, GLsizei); + GLint hasNonLocalLen = READ_DATA(16, GLsizei); + GLint *pLocalLength = DATA_POINTER(20, GLint); + char **ppStrings = NULL; + GLsizei i, j, jUpTo; + int pos, pos_check; + + if (count <= 0 || count >= INT32_MAX / sizeof(char *) / 4) + { + crError("crUnpackExtendShaderSource: count %u is out of range", count); + return; + } + + pos = 20 + count * sizeof(*pLocalLength); + + if (hasNonLocalLen > 0) + { + length = DATA_POINTER(pos, GLint); + pos += count * sizeof(*length); + } + + pos_check = pos; + + if (!DATA_POINTER_CHECK(pos_check)) + { + crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check); + return; + } + + for (i = 0; i < count; ++i) + { + if (pLocalLength[i] <= 0 || pos_check >= INT32_MAX - pLocalLength[i] || !DATA_POINTER_CHECK(pos_check)) + { + crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check); + return; + } + + pos_check += pLocalLength[i]; + } + + ppStrings = crAlloc(count * sizeof(char*)); + if (!ppStrings) return; + + for (i = 0; i < count; ++i) + { + ppStrings[i] = DATA_POINTER(pos, char); + pos += pLocalLength[i]; + if (!length) + { + pLocalLength[i] -= 1; + } + + Assert(pLocalLength[i] > 0); + jUpTo = i == count -1 ? pLocalLength[i] - 1 : pLocalLength[i]; + for (j = 0; j < jUpTo; ++j) + { + char *pString = ppStrings[i]; + + if (pString[j] == '\0') + { + Assert(j == jUpTo - 1); + pString[j] = '\n'; + } + } + } + +// cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength); + cr_unpackDispatch.ShaderSource(shader, 1, (const char**)ppStrings, 0); + + crFree(ppStrings); +} + +void crUnpackExtendUniform1fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLfloat *value = DATA_POINTER(16, const GLfloat); + cr_unpackDispatch.Uniform1fv(location, count, value); +} + +void crUnpackExtendUniform1iv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLint *value = DATA_POINTER(16, const GLint); + cr_unpackDispatch.Uniform1iv(location, count, value); +} + +void crUnpackExtendUniform2fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLfloat *value = DATA_POINTER(16, const GLfloat); + cr_unpackDispatch.Uniform2fv(location, count, value); +} + +void crUnpackExtendUniform2iv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLint *value = DATA_POINTER(16, const GLint); + cr_unpackDispatch.Uniform2iv(location, count, value); +} + +void crUnpackExtendUniform3fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLfloat *value = DATA_POINTER(16, const GLfloat); + cr_unpackDispatch.Uniform3fv(location, count, value); +} + +void crUnpackExtendUniform3iv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLint *value = DATA_POINTER(16, const GLint); + cr_unpackDispatch.Uniform3iv(location, count, value); +} + +void crUnpackExtendUniform4fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLfloat *value = DATA_POINTER(16, const GLfloat); + cr_unpackDispatch.Uniform4fv(location, count, value); +} + +void crUnpackExtendUniform4iv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + const GLint *value = DATA_POINTER(16, const GLint); + cr_unpackDispatch.Uniform4iv(location, count, value); +} + +void crUnpackExtendUniformMatrix2fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix3fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix4fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix2x3fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix2x3fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix3x2fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix3x2fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix2x4fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix2x4fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix4x2fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix4x2fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix3x4fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix3x4fv(location, count, transpose, value); +} + +void crUnpackExtendUniformMatrix4x3fv(void) +{ + GLint location = READ_DATA(8, GLint); + GLsizei count = READ_DATA(12, GLsizei); + GLboolean transpose = READ_DATA(16, GLboolean); + const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat); + cr_unpackDispatch.UniformMatrix4x3fv(location, count, transpose, value); +} + +void crUnpackExtendDrawBuffers(void) +{ + GLsizei n = READ_DATA(8, GLsizei); + const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum); + cr_unpackDispatch.DrawBuffers(n, bufs); +} + +void crUnpackExtendGetActiveAttrib(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLuint index = READ_DATA(12, GLuint); + GLsizei bufSize = READ_DATA(16, GLsizei); + SET_RETURN_PTR(20); + SET_WRITEBACK_PTR(28); + cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL); +} + +void crUnpackExtendGetActiveUniform(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLuint index = READ_DATA(12, GLuint); + GLsizei bufSize = READ_DATA(16, GLsizei); + SET_RETURN_PTR(20); + SET_WRITEBACK_PTR(28); + cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL); +} + +void crUnpackExtendGetAttachedShaders(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLsizei maxCount = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL); +} + +void crUnpackExtendGetAttachedObjectsARB(void) +{ + VBoxGLhandleARB containerObj = READ_DATA(8, VBoxGLhandleARB); + GLsizei maxCount = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL); +} + +void crUnpackExtendGetInfoLogARB(void) +{ + VBoxGLhandleARB obj = READ_DATA(8, VBoxGLhandleARB); + GLsizei maxLength = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL); +} + +void crUnpackExtendGetProgramInfoLog(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLsizei bufSize = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL); +} + +void crUnpackExtendGetShaderInfoLog(void) +{ + GLuint shader = READ_DATA(8, GLuint); + GLsizei bufSize = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL); +} + +void crUnpackExtendGetShaderSource(void) +{ + GLuint shader = READ_DATA(8, GLuint); + GLsizei bufSize = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL); +} + +void crUnpackExtendGetAttribLocation(void) +{ + int packet_length = READ_DATA(0, int); + GLuint program = READ_DATA(8, GLuint); + const char *name = DATA_POINTER(12, const char); + + if (!DATA_POINTER_CHECK(packet_length)) + { + crError("crUnpackExtendGetAttribLocation: packet_length is out of range"); + return; + } + + SET_RETURN_PTR(packet_length-16); + SET_WRITEBACK_PTR(packet_length-8); + cr_unpackDispatch.GetAttribLocation(program, name); +} + +void crUnpackExtendGetUniformLocation(void) +{ + int packet_length = READ_DATA(0, int); + GLuint program = READ_DATA(8, GLuint); + const char *name = DATA_POINTER(12, const char); + + if (!DATA_POINTER_CHECK(packet_length)) + { + crError("crUnpackExtendGetUniformLocation: packet_length is out of range"); + return; + } + + SET_RETURN_PTR(packet_length-16); + SET_WRITEBACK_PTR(packet_length-8); + cr_unpackDispatch.GetUniformLocation(program, name); +} + +void crUnpackExtendGetUniformsLocations(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLsizei maxcbData = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL); +} + +void crUnpackExtendGetAttribsLocations(void) +{ + GLuint program = READ_DATA(8, GLuint); + GLsizei maxcbData = READ_DATA(12, GLsizei); + SET_RETURN_PTR(16); + SET_WRITEBACK_PTR(24); + cr_unpackDispatch.GetAttribsLocations(program, maxcbData, NULL, NULL); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.c new file mode 100644 index 00000000..dcc3ab58 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.c @@ -0,0 +1,27 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" + +void crUnpackPolygonStipple( void ) +{ + int nodata = READ_DATA(0, int); + + if (nodata) + { + crError("crUnpackPolygonStipple: GL_PIXEL_UNPACK_BUFFER is not supported"); + INCR_DATA_PTR(8); + } + else + { + GLubyte *mask; + + mask = DATA_POINTER(4, GLubyte); + cr_unpackDispatch.PolygonStipple(mask); + // Stipple mask consists of 32 * 32 bits + INCR_DATA_PTR(4 + 32 * 32 / 8); + } +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c new file mode 100644 index 00000000..8c757e95 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c @@ -0,0 +1,507 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_version.h" + +#if defined( GL_EXT_texture3D ) +void crUnpackTexImage3DEXT( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLenum internalformat = READ_DATA( sizeof( int ) + 8, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei ); + GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei ); + GLint border = READ_DATA( sizeof( int ) + 24, GLint ); + GLenum format = READ_DATA( sizeof( int ) + 28, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 32, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 36, int ); + GLvoid *pixels; + + /*If there's no imagedata send, it's either that passed pointer was NULL or + there was GL_PIXEL_UNPACK_BUFFER_ARB bound, in both cases 4bytes of passed + pointer would convert to either NULL or offset in the bound buffer. + */ + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+40, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 44, GLvoid ); + + cr_unpackDispatch.TexImage3DEXT(target, level, internalformat, width, + height, depth, border, format, type, + pixels); + INCR_VAR_PTR(); +} +#endif /* GL_EXT_texture3D */ + +#if defined( CR_OPENGL_VERSION_1_2 ) +void crUnpackTexImage3D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei ); + GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei ); + GLint border = READ_DATA( sizeof( int ) + 24, GLint ); + GLenum format = READ_DATA( sizeof( int ) + 28, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 32, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 36, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+40, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 44, GLvoid ); + + cr_unpackDispatch.TexImage3D( target, level, internalformat, width, height, + depth, border, format, type, pixels ); + INCR_VAR_PTR(); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + +void crUnpackTexImage2D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei ); + GLint border = READ_DATA( sizeof( int ) + 20, GLint ); + GLenum format = READ_DATA( sizeof( int ) + 24, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 28, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 32, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+36, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid ); + + cr_unpackDispatch.TexImage2D( target, level, internalformat, width, height, + border, format, type, pixels ); + INCR_VAR_PTR(); +} + +void crUnpackTexImage1D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei ); + GLint border = READ_DATA( sizeof( int ) + 16, GLint ); + GLenum format = READ_DATA( sizeof( int ) + 20, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 24, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 28, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+32, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 36, GLvoid ); + + cr_unpackDispatch.TexImage1D( target, level, internalformat, width, border, + format, type, pixels ); + INCR_VAR_PTR(); +} + +void crUnpackDeleteTextures( void ) +{ + GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei ); + GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint ); + + cr_unpackDispatch.DeleteTextures( n, textures ); + INCR_VAR_PTR(); +} + + +void crUnpackPrioritizeTextures( void ) +{ + GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei ); + GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint ); + GLclampf *priorities = DATA_POINTER( sizeof( int ) + 4 + n*sizeof( GLuint ), + GLclampf ); + + cr_unpackDispatch.PrioritizeTextures( n, textures, priorities ); + INCR_VAR_PTR(); +} + +void crUnpackTexParameterfv( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.TexParameterfv( target, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackTexParameteriv( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.TexParameteriv( target, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackTexParameterf( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat param = READ_DATA( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.TexParameterf( target, pname, param ); + INCR_VAR_PTR(); +} + +void crUnpackTexParameteri( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint param = READ_DATA( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.TexParameteri( target, pname, param ); + INCR_VAR_PTR(); +} + +#if defined(CR_OPENGL_VERSION_1_2) +void crUnpackTexSubImage3D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint ); + GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint ); + GLint zoffset = READ_DATA( sizeof( int ) + 16, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 20, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 24, GLsizei ); + GLsizei depth = READ_DATA( sizeof( int ) + 28, GLsizei ); + GLenum format = READ_DATA( sizeof( int ) + 32, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 36, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 40, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+44, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 48, GLvoid ); + + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.TexSubImage3D(target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels); + INCR_VAR_PTR(); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + +void crUnpackTexSubImage2D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint ); + GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 16, GLsizei ); + GLsizei height = READ_DATA( sizeof( int ) + 20, GLsizei ); + GLenum format = READ_DATA( sizeof( int ) + 24, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 28, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 32, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+36, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid ); + + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.TexSubImage2D( target, level, xoffset, yoffset, width, + height, format, type, pixels ); + INCR_VAR_PTR(); +} + +void crUnpackTexSubImage1D( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( sizeof( int ) + 4, GLint ); + GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint ); + GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei ); + GLenum format = READ_DATA( sizeof( int ) + 16, GLenum ); + GLenum type = READ_DATA( sizeof( int ) + 20, GLenum ); + int noimagedata = READ_DATA( sizeof( int ) + 24, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+28, GLint); + else + pixels = DATA_POINTER( sizeof( int ) + 32, GLvoid ); + + cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + cr_unpackDispatch.TexSubImage1D( target, level, xoffset, width, format, + type, pixels ); + INCR_VAR_PTR(); +} + + +void crUnpackTexEnvfv( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.TexEnvfv( target, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackTexEnviv( void ) +{ + GLenum target = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.TexEnviv( target, pname, params ); + INCR_VAR_PTR(); +} + +#define DATA_POINTER_DOUBLE( offset ) + +void crUnpackTexGendv( void ) +{ + GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLdouble params[4]; + unsigned int n_param = READ_DATA( 0, int ) - ( sizeof(int) + 8 ); + + if (n_param > sizeof(params)) + { + crError("crUnpackTexGendv: n_param=%d, expected <= %d\n", n_param, + (unsigned int)sizeof(params)); + return; + } + + crMemcpy( params, DATA_POINTER( sizeof( int ) + 8, GLdouble ), n_param ); + + cr_unpackDispatch.TexGendv( coord, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackTexGenfv( void ) +{ + GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat ); + + cr_unpackDispatch.TexGenfv( coord, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackTexGeniv( void ) +{ + GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum ); + GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum ); + GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint ); + + cr_unpackDispatch.TexGeniv( coord, pname, params ); + INCR_VAR_PTR(); +} + +void crUnpackExtendAreTexturesResident( void ) +{ + GLsizei n = READ_DATA( 8, GLsizei ); + const GLuint *textures = DATA_POINTER( 12, const GLuint ); + + if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(20 + n * sizeof(GLuint))) + { + crError("crUnpackExtendAreTexturesResident: %d is out of range", n); + return; + } + + SET_RETURN_PTR(12 + n * sizeof(GLuint)); + SET_WRITEBACK_PTR(20 + n * sizeof(GLuint)); + (void) cr_unpackDispatch.AreTexturesResident( n, textures, NULL ); +} + + +void crUnpackExtendCompressedTexImage3DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint ); + GLenum internalformat = READ_DATA( 4 + sizeof(int) + 8, GLenum ); + GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei ); + GLsizei height = READ_DATA( 4 + sizeof(int) + 16, GLsizei ); + GLsizei depth = READ_DATA( 4 + sizeof(int) + 20, GLsizei ); + GLint border = READ_DATA( 4 + sizeof(int) + 24, GLint ); + GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 28, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof(int) + 32, int ); + GLvoid *pixels; + + if( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+36, GLint); + else + pixels = DATA_POINTER( 4 + sizeof(int) + 40, GLvoid ); + + cr_unpackDispatch.CompressedTexImage3DARB(target, level, internalformat, + width, height, depth, border, + imagesize, pixels); +} + + +void crUnpackExtendCompressedTexImage2DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof( int ) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof( int ) + 4, GLint ); + GLenum internalformat = READ_DATA( 4 + sizeof( int ) + 8, GLenum ); + GLsizei width = READ_DATA( 4 + sizeof( int ) + 12, GLsizei ); + GLsizei height = READ_DATA( 4 + sizeof( int ) + 16, GLsizei ); + GLint border = READ_DATA( 4 + sizeof( int ) + 20, GLint ); + GLsizei imagesize = READ_DATA( 4 + sizeof( int ) + 24, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof( int ) + 28, int ); + GLvoid *pixels; + + if ( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+32, GLint); + else + pixels = DATA_POINTER( 4 + sizeof( int ) + 36, GLvoid ); + + cr_unpackDispatch.CompressedTexImage2DARB( target, level, internalformat, + width, height, border, imagesize, + pixels ); +} + + +void crUnpackExtendCompressedTexImage1DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint ); + GLenum internalformat = READ_DATA( 4 + sizeof(int) + 8, GLenum ); + GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei ); + GLint border = READ_DATA( 4 + sizeof(int) + 16, GLint ); + GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 20, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof(int) + 24, int ); + GLvoid *pixels; + + if( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+28, GLint); + else + pixels = DATA_POINTER( 4 + sizeof(int) + 32, GLvoid ); + + cr_unpackDispatch.CompressedTexImage1DARB(target, level, internalformat, + width, border, imagesize, pixels); +} + + +void crUnpackExtendCompressedTexSubImage3DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint ); + GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint ); + GLint yoffset = READ_DATA( 4 + sizeof(int) + 12, GLint ); + GLint zoffset = READ_DATA( 4 + sizeof(int) + 16, GLint ); + GLsizei width = READ_DATA( 4 + sizeof(int) + 20, GLsizei ); + GLsizei height = READ_DATA( 4 + sizeof(int) + 24, GLsizei ); + GLsizei depth = READ_DATA( 4 + sizeof(int) + 28, GLsizei ); + GLenum format = READ_DATA( 4 + sizeof(int) + 32, GLenum ); + GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 36, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof(int) + 40, int ); + GLvoid *pixels; + + if( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+44, GLint); + else + pixels = DATA_POINTER( 4 + sizeof(int) + 48, GLvoid ); + + cr_unpackDispatch.CompressedTexSubImage3DARB(target, level, xoffset, + yoffset, zoffset, width, + height, depth, format, + imagesize, pixels); +} + + +void crUnpackExtendCompressedTexSubImage2DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint ); + GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint ); + GLint yoffset = READ_DATA( 4 + sizeof(int) + 12, GLint ); + GLsizei width = READ_DATA( 4 + sizeof(int) + 16, GLsizei ); + GLsizei height = READ_DATA( 4 + sizeof(int) + 20, GLsizei ); + GLenum format = READ_DATA( 4 + sizeof(int) + 24, GLenum ); + GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 28, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof(int) + 32, int ); + GLvoid *pixels; + + if( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+36, GLint); + else + pixels = DATA_POINTER( 4 + sizeof(int) + 40, GLvoid ); + + cr_unpackDispatch.CompressedTexSubImage2DARB(target, level, xoffset, + yoffset, width, height, + format, imagesize, pixels); +} + + +void crUnpackExtendCompressedTexSubImage1DARB( void ) +{ + GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum ); + GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint ); + GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint ); + GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei ); + GLenum format = READ_DATA( 4 + sizeof(int) + 16, GLenum ); + GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 20, GLsizei ); + int noimagedata = READ_DATA( 4 + sizeof(int) + 24, int ); + GLvoid *pixels; + + if( noimagedata ) + pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+28, GLint); + else + pixels = DATA_POINTER( 4 + sizeof(int) + 32, GLvoid ); + + cr_unpackDispatch.CompressedTexSubImage1DARB(target, level, xoffset, width, + format, imagesize, pixels); +} + +void crUnpackExtendGetTexImage(void) +{ + GLenum target = READ_DATA( 8, GLenum ); + GLint level = READ_DATA( 12, GLint ); + GLenum format = READ_DATA( 16, GLenum ); + GLenum type = READ_DATA( 20, GLenum ); + GLvoid *pixels; + + SET_RETURN_PTR(24); + SET_WRITEBACK_PTR(32); + pixels = DATA_POINTER(24, GLvoid); + + cr_unpackDispatch.GetTexImage(target, level, format, type, pixels); +} + +void crUnpackExtendGetCompressedTexImageARB(void) +{ + GLenum target = READ_DATA( 8, GLenum ); + GLint level = READ_DATA( 12, GLint ); + GLvoid *img; + + SET_RETURN_PTR( 16 ); + SET_WRITEBACK_PTR( 24 ); + img = DATA_POINTER(16, GLvoid); + + cr_unpackDispatch.GetCompressedTexImageARB( target, level, img ); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.c new file mode 100644 index 00000000..ece7c710 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.c @@ -0,0 +1,37 @@ +/* $Id: unpack_visibleregion.c $ */ +/** @file + * VBox Packing VisibleRegion information + */ + +/* + * Copyright (C) 2008-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_version.h" + +void crUnpackExtendWindowVisibleRegion( void ) +{ + GLint window = READ_DATA( 8, GLint ); + GLint cRects = READ_DATA( 12, GLint ); + GLvoid *pRects = DATA_POINTER( 16, GLvoid ); + + if (cRects <= 0 || cRects >= INT32_MAX / sizeof(GLint) / 8 || !DATA_POINTER_CHECK(16 + 4 * cRects * sizeof(GLint))) + { + crError("crUnpackExtendWindowVisibleRegion: parameter 'cRects' is out of range"); + return; + } + + cr_unpackDispatch.WindowVisibleRegion( window, cRects, pRects ); +} diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.c b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.c new file mode 100644 index 00000000..f55a4c37 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.c @@ -0,0 +1,35 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "unpacker.h" +#include "cr_error.h" +#include <stdio.h> + +CRNetworkPointer *return_ptr = NULL, *writeback_ptr = NULL; + +void crUnpackSetReturnPointer( CRNetworkPointer *ret ) +{ + return_ptr = ret; +} + +void crUnpackSetWritebackPointer( CRNetworkPointer *wri ) +{ + writeback_ptr = wri; +} + +void crUnpackExtendWriteback(void) +{ + /* This copies the unpack buffer's CRNetworkPointer to writeback_ptr */ + SET_WRITEBACK_PTR( 8 ); + cr_unpackDispatch.Writeback( NULL ); +} + +#if 0 +void crUnpackWriteback(void) +{ + crError( "crUnpackWriteback should never be called" ); +} +#endif diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker.h b/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker.h new file mode 100644 index 00000000..708a89d0 --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_UNPACKER_H +#define CR_UNPACKER_H + +#ifdef DLLDATA +#undef DLLDATA +#endif +#define DLLDATA(type) DECLEXPORT(type) + +#include "cr_version.h" +#include "cr_unpack.h" +#include "unpack_extend.h" + +#endif /* CR_UNPACKER_H */ diff --git a/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker_special b/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker_special new file mode 100644 index 00000000..ff1cb7ae --- /dev/null +++ b/src/VBox/HostServices/SharedOpenGL/unpacker/unpacker_special @@ -0,0 +1,184 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +# +# Unpack functions which can't be auto-generated +# +Bitmap +CallLists +ClipPlane +ColorPointer +DeleteTextures +DrawElements +DrawRangeElements +DrawPixels +EdgeFlagPointer +Fogfv +Fogiv +IndexPointer +InterleavedArrays +Lightfv +Lightiv +LightModelfv +LightModeliv +LoadMatrixf +LoadMatrixd +Map1d +Map1f +Map2d +Map2f +Materialfv +Materialiv +MultMatrixd +MultMatrixf +NormalPointer +PixelMapfv +PixelMapuiv +PixelMapusv +PolygonStipple +PrioritizeTextures +ReadPixels +TexCoordPointer +TexEnvfv +TexEnviv +TexGendv +TexGenfv +TexGeniv +TexImage1D +TexImage2D +TexImage3D +TexImage3DEXT +TexParameterf +TexParameteri +TexParameterfv +TexParameteriv +TexSubImage1D +TexSubImage2D +TexSubImage3D +VertexPointer +BoundsInfoCR +SecondaryColorPointerEXT +FogCoordPointerEXT +MultiDrawArraysEXT +MultiDrawElementsEXT +VertexAttrib1dvARB +VertexAttrib1fvARB +VertexAttrib1svARB +VertexAttrib2dvARB +VertexAttrib2fvARB +VertexAttrib2svARB +VertexAttrib3dvARB +VertexAttrib3fvARB +VertexAttrib3svARB +VertexAttrib4dvARB +VertexAttrib4fvARB +VertexAttrib4svARB +VertexAttribPointerARB +VertexAttrib4NbvARB +VertexAttrib4NivARB +VertexAttrib4NsvARB +VertexAttrib4NubvARB +VertexAttrib4NuivARB +VertexAttrib4NusvARB +VertexAttrib4bvARB +VertexAttrib4ivARB +VertexAttrib4ubvARB +VertexAttrib4uivARB +VertexAttrib4usvARB +VertexAttribPointerNV +Writeback +CombinerParameterfvNV +CombinerParameterivNV +CombinerStageParameterfvNV +ChromiumParametervCR +CreateContext +WindowCreate +AreTexturesResident +LoadTransposeMatrixfARB +LoadTransposeMatrixdARB +MultTransposeMatrixdARB +MultTransposeMatrixfARB +PointParameteriv +PointParameterfvARB +AreProgramsResidentNV +DeleteProgramsNV +ExecuteProgramNV +GetProgramNamedParameterdvNV +GetProgramNamedParameterfvNV +LoadProgramNV +ProgramLocalParameter4dvARB +ProgramLocalParameter4fvARB +ProgramNamedParameter4dNV +ProgramNamedParameter4dvNV +ProgramNamedParameter4fNV +ProgramNamedParameter4fvNV +ProgramParameter4dvNV +ProgramParameter4fvNV +ProgramParameters4dvNV +ProgramParameters4fvNV +RequestResidentProgramsNV +DeleteProgramsARB +GetProgramStringARB +ProgramEnvParameter4dvARB +ProgramEnvParameter4fvARB +ProgramLocalParameter4dvARB +ProgramLocalParameter4fvARB +ProgramStringARB +BufferDataARB +BufferSubDataARB +GetBufferSubDataARB +DeleteBuffersARB +ZPixCR +CompressedTexImage1DARB +CompressedTexImage2DARB +CompressedTexImage3DARB +CompressedTexSubImage1DARB +CompressedTexSubImage2DARB +CompressedTexSubImage3DARB +DeleteFencesNV +WindowVisibleRegion +BindAttribLocation +ShaderSource +Uniform1fv +Uniform1iv +Uniform2fv +Uniform2iv +Uniform3fv +Uniform3iv +Uniform4fv +Uniform4iv +UniformMatrix2fv +UniformMatrix3fv +UniformMatrix4fv +DrawBuffers +GetActiveAttrib +GetActiveUniform +GetAttachedShaders +GetShaderInfoLog +GetProgramInfoLog +GetShaderSource +GetAttribLocation +GetUniformLocation +GetAttachedObjectsARB +GetInfoLogARB +DeleteQueriesARB +DeleteFramebuffersEXT +DeleteRenderbuffersEXT +LockArraysEXT +UnlockArraysEXT +GetUniformsLocations +GetAttribsLocations +GetTexImage +GetCompressedTexImageARB +GetPolygonStipple +GetPixelMapfv +GetPixelMapuiv +GetPixelMapusv +UniformMatrix2x3fv +UniformMatrix3x2fv +UniformMatrix2x4fv +UniformMatrix4x2fv +UniformMatrix3x4fv +UniformMatrix4x3fv +VBoxTexPresent
\ No newline at end of file |