VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state.h@ 39507

Last change on this file since 39507 was 39507, checked in by vboxsync, 13 years ago

crOpenGL: fix destroyed context refference in TLS

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 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 */
6
7#ifndef STATE_H
8#define STATE_H
9
10#include "cr_glstate.h"
11#ifdef CHROMIUM_THREADSAFE
12#include "cr_threads.h"
13#include <iprt/asm.h>
14#endif
15
16typedef struct _crCheckIDHWID {
17 GLuint id, hwid;
18} crCheckIDHWID_t;
19
20extern SPUDispatchTable diff_api;
21extern CRStateBits *__currentBits;
22
23#define GetCurrentBits() __currentBits
24
25#ifdef CHROMIUM_THREADSAFE
26extern CRtsd __contextTSD;
27#define GetCurrentContext() (CRContext *) crGetTSD(&__contextTSD)
28
29/* NOTE: below ref & SetCurrentContext stuff is supposed to be used only internally!!
30 * it is placed here only to simplify things since some code besides state_init.c
31 * (i.e. state_glsl.c) is using it */
32void crStateFreeContext(CRContext *ctx);
33#define CRCONTEXT_ADDREF(_ctx) do { \
34 int cRefs = ASMAtomicIncS32(&((CRContext*)(_ctx))->cRefs); \
35 CRASSERT(cRefs > 1); \
36 } while (0)
37#define CRCONTEXT_RELEASE(_ctx) do { \
38 int cRefs = ASMAtomicDecS32(&((CRContext*)(_ctx))->cRefs); \
39 CRASSERT(cRefs >= 0); \
40 if (!cRefs) { \
41 crStateFreeContext((_ctx)); \
42 } \
43 } while (0)
44#define SetCurrentContext(_ctx) do { \
45 CRContext * oldCur = GetCurrentContext(); \
46 if (oldCur != (_ctx)) { \
47 if (oldCur) { \
48 CRCONTEXT_RELEASE(oldCur); \
49 } \
50 if ((_ctx)) { \
51 CRCONTEXT_ADDREF(_ctx); \
52 } \
53 crSetTSD(&__contextTSD, _ctx); \
54 } \
55 } while (0)
56#else
57extern CRContext *__currentContext;
58#define GetCurrentContext() __currentContext
59#endif
60
61extern void crStateTextureInitTextureObj (CRContext *ctx, CRTextureObj *tobj, GLuint name, GLenum target);
62extern void crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat );
63
64/* Normally these functions would have been in cr_bufferobject.h but
65 * that led to a number of issues.
66 */
67void crStateBufferObjectInit(CRContext *ctx);
68
69void crStateBufferObjectDestroy (CRContext *ctx);
70
71void crStateBufferObjectDiff(CRBufferObjectBits *bb, CRbitvalue *bitID,
72 CRContext *fromCtx, CRContext *toCtx);
73
74void crStateBufferObjectSwitch(CRBufferObjectBits *bb, CRbitvalue *bitID,
75 CRContext *fromCtx, CRContext *toCtx);
76
77/* These would normally be in cr_client.h */
78
79void crStateClientDiff(CRClientBits *cb, CRbitvalue *bitID, CRContext *from, CRContext *to);
80
81void crStateClientSwitch(CRClientBits *cb, CRbitvalue *bitID, CRContext *from, CRContext *to);
82
83void crStateGetTextureObjectAndImage(CRContext *g, GLenum texTarget, GLint level,
84 CRTextureObj **obj, CRTextureLevel **img);
85
86void crStateFreeBufferObject(void *data);
87void crStateFreeFBO(void *data);
88void crStateFreeRBO(void *data);
89#endif
Note: See TracBrowser for help on using the repository browser.

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