VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c@ 78341

最後變更 在這個檔案從78341是 78190,由 vboxsync 提交於 6 年 前

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 7.3 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "state.h"
8#include "state/cr_statetypes.h"
9#include "state/cr_statefuncs.h"
10#include "state_internals.h"
11#include "cr_mem.h"
12
13void
14crStateOcclusionInit(CRContext *ctx)
15{
16 CROcclusionState *o = &ctx->occlusion;
17
18 o->objects = crAllocHashtable();
19 o->currentQueryObject = 0;
20}
21
22
23void
24crStateOcclusionDestroy(CRContext *ctx)
25{
26 CROcclusionState *o = &(ctx->occlusion);
27 crFreeHashtable(o->objects, crFree);
28}
29
30
31static CROcclusionObject *
32NewQueryObject(GLenum target, GLuint id)
33{
34 CROcclusionObject *q = (CROcclusionObject *) crAlloc(sizeof(CROcclusionObject));
35 if (q) {
36 q->target = target;
37 q->name = id;
38 q->passedCounter = 0;
39 q->active = GL_FALSE;
40 }
41 return q;
42}
43
44
45void STATE_APIENTRY
46crStateDeleteQueriesARB(GLsizei n, const GLuint *ids)
47{
48 CRContext *g = GetCurrentContext();
49 CROcclusionState *o = &(g->occlusion);
50 /*CRStateBits *sb = GetCurrentBits();*/
51 /*CROcclusionBits *bb = &(sb->occlusion);*/
52 int i;
53
54 FLUSH();
55
56 if (g->current.inBeginEnd) {
57 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
58 "glDeleteQueriesARB called in Begin/End");
59 return;
60 }
61
62 for (i = 0; i < n; i++) {
63 if (ids[i]) {
64 CROcclusionObject *q = (CROcclusionObject *)
65 crHashtableSearch(o->objects, ids[i]);
66 if (q) {
67 crHashtableDelete(o->objects, ids[i], crFree);
68 }
69 }
70 }
71}
72
73
74void STATE_APIENTRY
75crStateGenQueriesARB(GLsizei n, GLuint * queries)
76{
77 CRContext *g = GetCurrentContext();
78 CROcclusionState *o = &(g->occlusion);
79 GLint start;
80
81 FLUSH();
82
83 if (g->current.inBeginEnd) {
84 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
85 "glGenQueriesARB called in Begin/End");
86 return;
87 }
88
89 if (n < 0) {
90 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
91 "glGenQueriesARB(n < 0)");
92 return;
93 }
94
95 start = crHashtableAllocKeys(o->objects, n);
96 if (start) {
97 GLint i;
98 for (i = 0; i < n; i++)
99 queries[i] = (GLuint) (start + i);
100 }
101 else {
102 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenQueriesARB");
103 }
104}
105
106
107GLboolean STATE_APIENTRY
108crStateIsQueryARB(GLuint id)
109{
110 CRContext *g = GetCurrentContext();
111 CROcclusionState *o = &(g->occlusion);
112
113 FLUSH();
114
115 if (g->current.inBeginEnd) {
116 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
117 "glIsQueryARB called in begin/end");
118 return GL_FALSE;
119 }
120
121 if (id && crHashtableIsKeyUsed(o->objects, id))
122 return GL_TRUE;
123 else
124 return GL_FALSE;
125}
126
127
128void STATE_APIENTRY
129crStateGetQueryivARB(GLenum target, GLenum pname, GLint *params)
130{
131 CRContext *g = GetCurrentContext();
132 CROcclusionState *o = &(g->occlusion);
133 (void)target;
134
135 FLUSH();
136
137 if (g->current.inBeginEnd) {
138 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
139 "glGetGetQueryivARB called in begin/end");
140 return;
141 }
142
143 switch (pname) {
144 case GL_QUERY_COUNTER_BITS_ARB:
145 *params = 8 * sizeof(GLuint);
146 break;
147 case GL_CURRENT_QUERY_ARB:
148 *params = o->currentQueryObject;
149 break;
150 default:
151 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
152 "glGetGetQueryivARB(pname)");
153 return;
154 }
155}
156
157
158void STATE_APIENTRY
159crStateGetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
160{
161 CRContext *g = GetCurrentContext();
162 CROcclusionState *o = &(g->occlusion);
163 CROcclusionObject *q;
164
165 FLUSH();
166
167 if (g->current.inBeginEnd) {
168 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
169 "glGetGetQueryObjectivARB called in begin/end");
170 return;
171 }
172
173 q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
174 if (!q || q->active) {
175 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
176 "glGetQueryObjectivARB");
177 return;
178 }
179
180 switch (pname) {
181 case GL_QUERY_RESULT_ARB:
182 *params = q->passedCounter;
183 break;
184 case GL_QUERY_RESULT_AVAILABLE_ARB:
185 *params = GL_TRUE;
186 break;
187 default:
188 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
189 "glGetQueryObjectivARB(pname)");
190 return;
191 }
192}
193
194
195void STATE_APIENTRY
196crStateGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
197{
198 CRContext *g = GetCurrentContext();
199 CROcclusionState *o = &(g->occlusion);
200 CROcclusionObject *q;
201
202 FLUSH();
203
204 if (g->current.inBeginEnd) {
205 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
206 "glGetGetQueryObjectuivARB called in begin/end");
207 return;
208 }
209
210 q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
211 if (!q || q->active) {
212 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
213 "glGetQueryObjectuivARB");
214 return;
215 }
216
217 switch (pname) {
218 case GL_QUERY_RESULT_ARB:
219 *params = q->passedCounter;
220 break;
221 case GL_QUERY_RESULT_AVAILABLE_ARB:
222 /* XXX revisit when we have a hardware implementation! */
223 *params = GL_TRUE;
224 break;
225 default:
226 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
227 "glGetQueryObjectuivARB(pname)");
228 return;
229 }
230}
231
232
233void STATE_APIENTRY
234crStateBeginQueryARB(GLenum target, GLuint id)
235{
236 CRContext *g = GetCurrentContext();
237 CROcclusionState *o = &(g->occlusion);
238 CROcclusionObject *q;
239
240 FLUSH();
241
242 if (g->current.inBeginEnd) {
243 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
244 "glGetGetQueryObjectuivARB called in begin/end");
245 return;
246 }
247
248 if (target != GL_SAMPLES_PASSED_ARB) {
249 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
250 "glBeginQueryARB(target)");
251 return;
252 }
253
254 if (o->currentQueryObject) {
255 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
256 "glBeginQueryARB(target)");
257 return;
258 }
259
260 q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
261 if (q && q->active) {
262 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBeginQueryARB");
263 return;
264 }
265 else if (!q) {
266 q = NewQueryObject(target, id);
267 if (!q) {
268 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBeginQueryARB");
269 return;
270 }
271 crHashtableAdd(o->objects, id, q);
272 }
273
274 q->active = GL_TRUE;
275 q->passedCounter = 0;
276 q->active = GL_TRUE;
277 q->passedCounter = 0;
278 o->currentQueryObject = id;
279}
280
281
282void STATE_APIENTRY
283crStateEndQueryARB(GLenum target)
284{
285 CRContext *g = GetCurrentContext();
286 CROcclusionState *o = &(g->occlusion);
287 CROcclusionObject *q;
288
289 FLUSH();
290
291 if (g->current.inBeginEnd) {
292 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
293 "glGetGetQueryObjectuivARB called in begin/end");
294 return;
295 }
296
297 if (target != GL_SAMPLES_PASSED_ARB) {
298 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEndQueryARB(target)");
299 return;
300 }
301
302 q = (CROcclusionObject *) crHashtableSearch(o->objects, o->currentQueryObject);
303 if (!q || !q->active) {
304 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
305 "glEndQueryARB with glBeginQueryARB");
306 return;
307 }
308
309 q->passedCounter = 0;
310 q->active = GL_FALSE;
311 o->currentQueryObject = 0;
312}
313
314
315void crStateOcclusionDiff(CROcclusionBits *bb, CRbitvalue *bitID,
316 CRContext *fromCtx, CRContext *toCtx)
317{
318 /* Apparently, no occlusion state differencing needed */
319 (void)bb; (void)bitID; (void)fromCtx; (void)toCtx;
320}
321
322
323/*
324 * XXX this function might need some testing/fixing.
325 */
326void crStateOcclusionSwitch(CROcclusionBits *bb, CRbitvalue *bitID,
327 CRContext *fromCtx, CRContext *toCtx)
328{
329 /* Apparently, no occlusion state switching needed */
330 /* Note: we better not do a switch while we're inside a glBeginQuery/
331 * glEndQuery sequence.
332 */
333 (void)bb; (void)bitID; (void)fromCtx; (void)toCtx;
334 CRASSERT(!fromCtx->occlusion.currentQueryObject);
335}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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