VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h@ 27069

Last change on this file since 27069 was 23433, checked in by vboxsync, 15 years ago

crOpenGL: fix snapshots for array uniforms

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: cr_glsl.h 23433 2009-09-30 11:38:45Z vboxsync $ */
2
3/** @file
4 * VBox crOpenGL: GLSL related state info
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef CR_STATE_GLSL_H
24#define CR_STATE_GLSL_H
25
26#include "cr_hash.h"
27#include "state/cr_statetypes.h"
28#include "state/cr_statefuncs.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/* We can't go the "easy" way of just extracting all the required data when taking snapshots.
35 Shader objects might be modified *after* program linkage and wouldn't affect program untill it's relinked.
36 So we have to keep track of shaders statuses right before each program was linked as well as their "current" status.
37*/
38
39/*@todo: check rare case when successfully linked and active program is relinked with failure*/
40
41typedef struct {
42 GLuint id, hwid;
43 GLenum type; /*GL_VERTEX_SHADER or GL_FRAGMENT_SHADER*/
44 GLchar* source; /*NULL after context loading unless in program's "active" hash*/
45 GLboolean compiled, deleted;
46 GLuint refCount; /*valid only for shaders in CRGLSLState's hash*/
47} CRGLSLShader;
48
49typedef struct {
50 GLchar* name;
51 GLuint index;
52} CRGLSLAttrib;
53
54/*Note: active state will hold copies of shaders while current state references shaders in the CRGLSLState hashtable*/
55/*@todo: probably don't need a hashtable here*/
56typedef struct {
57 CRHashTable *attachedShaders;
58 CRGLSLAttrib *pAttribs; /*several names could be bound to the same index*/
59 GLuint cAttribs;
60} CRGLSLProgramState;
61
62typedef struct{
63 GLchar *name;
64 GLenum type;
65 GLvoid *data;
66#ifdef IN_GUEST
67 GLint location;
68#endif
69} CRGLSLUniform;
70
71typedef struct {
72 GLuint id, hwid;
73 GLboolean validated, linked, deleted;
74 CRGLSLProgramState activeState, currentState;
75 CRGLSLUniform *pUniforms;
76 GLuint cUniforms;
77#ifdef IN_GUEST
78 GLboolean bUniformsSynced; /*uniforms info is updated since last link program call.*/
79#endif
80} CRGLSLProgram;
81
82typedef struct {
83 CRHashTable *shaders;
84 CRHashTable *programs;
85
86 CRGLSLProgram *activeProgram;
87
88 /* Indicates that we have to resend GLSL data to GPU on first glMakeCurrent call with owning context */
89 GLboolean bResyncNeeded;
90} CRGLSLState;
91
92DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx);
93DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx);
94DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to);
95
96DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(GLuint id);
97DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(GLuint id);
98DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(GLuint hwid);
99DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(GLuint hwid);
100
101DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(GLenum type);
102DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type);
103
104DECLEXPORT(void) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type);
105DECLEXPORT(void) STATE_APIENTRY crStateCreateProgram(GLuint id);
106
107DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program);
108
109#ifdef IN_GUEST
110DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei cbData, GLvoid *pData);
111#else
112DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
113#endif
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* CR_STATE_GLSL_H */
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