VirtualBox

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

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

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: cr_glsl.h 78375 2019-05-03 21:51:02Z vboxsync $ */
2
3/** @file
4 * VBox crOpenGL: GLSL related state info
5 */
6
7/*
8 * Copyright (C) 2009-2019 Oracle Corporation
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
19#ifndef CR_STATE_GLSL_H
20#define CR_STATE_GLSL_H
21
22#include "cr_hash.h"
23#include "state/cr_statetypes.h"
24#include "state/cr_statefuncs.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/* We can't go the "easy" way of just extracting all the required data when taking snapshots.
31 Shader objects might be modified *after* program linkage and wouldn't affect program until it's relinked.
32 So we have to keep track of shaders statuses right before each program was linked as well as their "current" status.
33*/
34
35/*@todo: check rare case when successfully linked and active program is relinked with failure*/
36
37typedef struct {
38 GLuint id, hwid;
39 GLenum type; /*GL_VERTEX_SHADER or GL_FRAGMENT_SHADER*/
40 GLchar* source; /*NULL after context loading unless in program's "active" hash*/
41 GLboolean compiled, deleted;
42 GLuint refCount; /*valid only for shaders in CRGLSLState's hash*/
43} CRGLSLShader;
44
45typedef struct {
46 GLchar* name;
47 GLuint index;
48} CRGLSLAttrib;
49
50/*Note: active state will hold copies of shaders while current state references shaders in the CRGLSLState hashtable*/
51/*@todo: probably don't need a hashtable here*/
52typedef struct {
53 CRHashTable *attachedShaders;
54 CRGLSLAttrib *pAttribs; /*several names could be bound to the same index*/
55 GLuint cAttribs;
56} CRGLSLProgramState;
57
58typedef struct{
59 GLchar *name;
60 GLenum type;
61 GLvoid *data;
62#ifdef IN_GUEST
63 GLint location;
64#endif
65} CRGLSLUniform;
66
67typedef struct {
68 GLuint id, hwid;
69 GLboolean validated, linked, deleted;
70 CRGLSLProgramState activeState, currentState;
71 CRGLSLUniform *pUniforms;
72 GLuint cUniforms;
73#ifdef IN_GUEST
74 CRGLSLAttrib *pAttribs;
75 GLuint cAttribs;
76 GLboolean bUniformsSynced; /*uniforms info is updated since last link program call.*/
77 GLboolean bAttribsSynced; /*attribs info is updated since last link program call.*/
78#endif
79} CRGLSLProgram;
80
81typedef struct {
82 CRHashTable *shaders;
83 CRHashTable *programs;
84
85 CRGLSLProgram *activeProgram;
86
87 /* Indicates that we have to resend GLSL data to GPU on first glMakeCurrent call with owning context */
88 GLboolean bResyncNeeded;
89} CRGLSLState;
90
91DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx);
92DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx);
93DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to);
94
95DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(PCRStateTracker pState, GLuint id);
96DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(PCRStateTracker pState, GLuint id);
97DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(PCRStateTracker pState, GLuint hwid);
98DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(PCRStateTracker pState, GLuint hwid);
99
100DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(PCRStateTracker pState, GLenum type);
101DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(PCRStateTracker pState, GLenum type);
102
103DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(PCRStateTracker pState, GLuint id, GLenum type);
104DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(PCRStateTracker pState, GLuint id);
105DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB(PCRStateTracker pState, VBoxGLhandleARB obj );
106
107DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(PCRStateTracker pState, GLuint program);
108DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramAttribsCached(PCRStateTracker pState, GLuint program);
109
110#ifdef IN_GUEST
111DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(PCRStateTracker pState, GLuint program, GLsizei cbData, GLvoid *pData);
112DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(PCRStateTracker pState, GLuint program, GLsizei cbData, GLvoid *pData);
113#else
114DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(PCRStateTracker pState, GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
115DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(PCRStateTracker pState, GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
116#endif
117
118#ifdef __cplusplus
119}
120#endif
121
122#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