VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py@ 78407

Last change on this file since 78407 was 78407, checked in by vboxsync, 6 years ago

HostServices/SharedOpenGL: Avoid assertion trying to allocate 0 bytes in a debug build (seen with OpenGL extension viewer on a Windows guest)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.7 KB
Line 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6from __future__ import print_function
7import sys
8
9import apiutil
10
11
12apiutil.CopyrightC()
13
14print("""#include "cr_spu.h"
15#include "chromium.h"
16#include "cr_error.h"
17#include "cr_mem.h"
18#include "cr_net.h"
19#include "server_dispatch.h"
20#include "server.h"
21""")
22
23from get_sizes import *;
24
25
26funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
27types = [ 'GLint', 'GLfloat', 'GLdouble', 'GLboolean' ]
28
29for index in range(len(funcs)):
30 func_name = funcs[index]
31 params = apiutil.Parameters(func_name)
32 print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params)))
33 print('{')
34 print('\t%s *get_values;' % types[index])
35 print('\tint tablesize;')
36 print("""
37 #ifdef CR_ARB_texture_compression
38 if (GL_COMPRESSED_TEXTURE_FORMATS_ARB == pname)
39 {
40 GLint numtexfmts = 0;
41 cr_server.head_spu->dispatch_table.GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numtexfmts);
42 tablesize = numtexfmts * sizeof(%s);
43 }
44 else
45 #endif
46 {
47 tablesize = __numValues( pname ) * sizeof(%s);
48 }
49 """ % (types[index], types[index]))
50 print('\t(void) params;')
51 print('\tif (tablesize == 0)')
52 print('\t{')
53 print('\t\tcrServerReturnValue(NULL, 0);')
54 print('\t\treturn;')
55 print('\t}')
56 print('\tget_values = (%s *) crAlloc( tablesize );' % types[index])
57 print('\tcr_server.head_spu->dispatch_table.%s( pname, get_values );' % func_name)
58 print("""
59 if (GL_TEXTURE_BINDING_1D==pname
60 || GL_TEXTURE_BINDING_2D==pname
61 || GL_TEXTURE_BINDING_3D==pname
62 || GL_TEXTURE_BINDING_RECTANGLE_ARB==pname
63 || GL_TEXTURE_BINDING_CUBE_MAP_ARB==pname)
64 {
65 GLuint texid;
66 CRASSERT(tablesize/sizeof(%s)==1);
67 texid = (GLuint) *get_values;
68 *get_values = (%s) crStateTextureHWIDtoID(&cr_server.StateTracker, texid);
69 }
70 else if (GL_CURRENT_PROGRAM==pname)
71 {
72 GLuint programid;
73 CRASSERT(tablesize/sizeof(%s)==1);
74 programid = (GLuint) *get_values;
75 *get_values = (%s) crStateGLSLProgramHWIDtoID(&cr_server.StateTracker, programid);
76 }
77 else if (GL_FRAMEBUFFER_BINDING_EXT==pname
78 ||GL_READ_FRAMEBUFFER_BINDING==pname)
79 {
80 GLuint fboid;
81 CRASSERT(tablesize/sizeof(%s)==1);
82 fboid = (GLuint) *get_values;
83 if (crServerIsRedirectedToFBO()
84 && (fboid==cr_server.curClient->currentMural->aidFBOs[0]
85 || fboid==cr_server.curClient->currentMural->aidFBOs[1]))
86 {
87 fboid = 0;
88 }
89 else
90 {
91 fboid = crStateFBOHWIDtoID(&cr_server.StateTracker, fboid);
92 }
93 *get_values = (%s) fboid;
94 }
95 else if (GL_READ_BUFFER==pname)
96 {
97 if (crServerIsRedirectedToFBO()
98 && CR_SERVER_FBO_FOR_IDX(cr_server.curClient->currentMural, cr_server.curClient->currentMural->iCurReadBuffer)
99 && !crStateGetCurrent(&cr_server.StateTracker)->framebufferobject.readFB)
100 {
101 *get_values = (%s) crStateGetCurrent(&cr_server.StateTracker)->buffer.readBuffer;
102 Assert(crStateGetCurrent(&cr_server.StateTracker)->buffer.readBuffer == GL_BACK || crStateGetCurrent(&cr_server.StateTracker)->buffer.readBuffer == GL_FRONT);
103 }
104 }
105 else if (GL_DRAW_BUFFER==pname)
106 {
107 if (crServerIsRedirectedToFBO()
108 && CR_SERVER_FBO_FOR_IDX(cr_server.curClient->currentMural, cr_server.curClient->currentMural->iCurDrawBuffer)
109 && !crStateGetCurrent(&cr_server.StateTracker)->framebufferobject.drawFB)
110 {
111 *get_values = (%s) crStateGetCurrent(&cr_server.StateTracker)->buffer.drawBuffer;
112 Assert(crStateGetCurrent(&cr_server.StateTracker)->buffer.drawBuffer == GL_BACK || crStateGetCurrent(&cr_server.StateTracker)->buffer.drawBuffer == GL_FRONT);
113 }
114 }
115 else if (GL_RENDERBUFFER_BINDING_EXT==pname)
116 {
117 GLuint rbid;
118 CRASSERT(tablesize/sizeof(%s)==1);
119 rbid = (GLuint) *get_values;
120 *get_values = (%s) crStateRBOHWIDtoID(&cr_server.StateTracker, rbid);
121 }
122 else if (GL_ARRAY_BUFFER_BINDING_ARB==pname
123 || GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB==pname
124 || GL_VERTEX_ARRAY_BUFFER_BINDING_ARB==pname
125 || GL_NORMAL_ARRAY_BUFFER_BINDING_ARB==pname
126 || GL_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
127 || GL_INDEX_ARRAY_BUFFER_BINDING_ARB==pname
128 || GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB==pname
129 || GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB==pname
130 || GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
131 || GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB==pname
132 || GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB==pname)
133 {
134 GLuint bufid;
135 CRASSERT(tablesize/sizeof(%s)==1);
136 bufid = (GLuint) *get_values;
137 *get_values = (%s) crStateBufferHWIDtoID(&cr_server.StateTracker, bufid);
138 }
139 else if (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS==pname)
140 {
141 if (CR_MAX_TEXTURE_UNITS < (GLuint)*get_values)
142 {
143 *get_values = (%s)CR_MAX_TEXTURE_UNITS;
144 }
145 }
146 else if (GL_MAX_VERTEX_ATTRIBS_ARB==pname)
147 {
148 if (CR_MAX_VERTEX_ATTRIBS < (GLuint)*get_values)
149 {
150 *get_values = (%s)CR_MAX_VERTEX_ATTRIBS;
151 }
152 }
153 """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index]))
154 print('\tcrServerReturnValue( get_values, tablesize );')
155 print('\tcrFree(get_values);')
156 print('}\n')
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette