VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/state/cr_program.h@ 73697

Last change on this file since 73697 was 69474, checked in by vboxsync, 7 years ago

*: scm updates - header files should have 'svn:keywords=Id Revision' too (doesn't mean they have to use them).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.8 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 CR_STATE_PROGRAM_H
8#define CR_STATE_PROGRAM_H
9
10#include "cr_hash.h"
11#include "state/cr_statetypes.h"
12#include "state/cr_limits.h"
13
14#include <iprt/cdefs.h>
15
16/*
17 * Dirty bits for per-context program state. Per-program dirty bits
18 * are in the CRProgram structure.
19 */
20typedef struct {
21 CRbitvalue dirty[CR_MAX_BITARRAY];
22 CRbitvalue vpEnable[CR_MAX_BITARRAY];
23 CRbitvalue fpEnable[CR_MAX_BITARRAY];
24 CRbitvalue vpBinding[CR_MAX_BITARRAY];
25 CRbitvalue fpBinding[CR_MAX_BITARRAY];
26 CRbitvalue vertexAttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
27 CRbitvalue map1AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
28 CRbitvalue map2AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
29 /* per-param flags: */
30 CRbitvalue vertexEnvParameter[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY];
31 CRbitvalue fragmentEnvParameter[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY];
32 /* any param flags: */
33 CRbitvalue vertexEnvParameters[CR_MAX_BITARRAY];
34 CRbitvalue fragmentEnvParameters[CR_MAX_BITARRAY];
35 CRbitvalue trackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4][CR_MAX_BITARRAY];
36} CRProgramBits;
37
38
39/*
40 * Fragment programs have named symbols which are defined/declared
41 * within the fragment program that can also be set with the
42 * glProgramNamedParameter4*NV() functions.
43 * We keep a linked list of these CRProgramSymbol structures to implement
44 * a symbol table. A simple linked list is sufficient since a fragment
45 * program typically has just a few symbols.
46 */
47typedef struct CRProgramSymbol {
48 const char *name;
49 GLuint cbName;
50 GLfloat value[4];
51 CRbitvalue dirty[CR_MAX_BITARRAY];
52 struct CRProgramSymbol *next;
53} CRProgramSymbol;
54
55
56/*
57 * A vertex or fragment program.
58 */
59typedef struct {
60 GLenum target;
61 GLuint id;
62 GLboolean isARBprogram; /* to distinguish between NV and ARB programs */
63 const GLubyte *string;
64 GLsizei length;
65 GLboolean resident;
66 GLenum format;
67
68 /* Set with ProgramNamedParameterNV */
69 struct CRProgramSymbol *symbolTable;
70
71 /* Set with ProgramLocalParameterARB: */
72 GLfloat parameters[CR_MAX_PROGRAM_LOCAL_PARAMS][4];
73
74 /* ARB info (this could be impossible to implement without parsing */
75 GLint numInstructions;
76 GLint numTemporaries;
77 GLint numParameters;
78 GLint numAttributes;
79 GLint numAddressRegs;
80 GLint numAluInstructions;
81 GLint numTexInstructions;
82 GLint numTexIndirections;
83
84 CRbitvalue dirtyNamedParams[CR_MAX_BITARRAY];
85 CRbitvalue dirtyParam[CR_MAX_PROGRAM_LOCAL_PARAMS][CR_MAX_BITARRAY];
86 CRbitvalue dirtyParams[CR_MAX_BITARRAY];
87 CRbitvalue dirtyProgram[CR_MAX_BITARRAY];
88} CRProgram;
89
90
91
92typedef struct {
93 CRProgram *currentVertexProgram;
94 CRProgram *currentFragmentProgram;
95 GLint errorPos;
96 const GLubyte *errorString;
97 GLboolean loadedProgram; /* XXX temporary */
98
99 CRProgram *defaultVertexProgram;
100 CRProgram *defaultFragmentProgram;
101
102 /* tracking matrices for vertex programs */
103#ifdef VBOX /* see state_program.c */
104 GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4];
105 GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4];
106#else
107 GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4];
108 GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4];
109#endif
110
111 /* global/env params shared by all programs */
112 GLfloat fragmentParameters[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][4];
113 GLfloat vertexParameters[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][4];
114
115 CRHashTable *programHash; /* XXX belongs in shared state, actually */
116
117 GLuint vpProgramBinding;
118 GLuint fpProgramBinding;
119 GLboolean vpEnabled; /* GL_VERTEX_PROGRAM_NV / ARB*/
120 GLboolean fpEnabled; /* GL_FRAGMENT_PROGRAM_NV */
121 GLboolean fpEnabledARB; /* GL_FRAGMENT_PROGRAM_ARB */
122 GLboolean vpPointSize; /* GL_VERTEX_PROGRAM_NV */
123 GLboolean vpTwoSide; /* GL_VERTEX_PROGRAM_NV */
124
125 /* Indicates that we have to resend program data to GPU on first glMakeCurrent call with owning context */
126 GLboolean bResyncNeeded;
127
128} CRProgramState;
129
130
131
132extern DECLEXPORT(void) crStateProgramInit(CRContext *ctx);
133extern DECLEXPORT(void) crStateProgramDestroy(CRContext *ctx);
134
135extern DECLEXPORT(void) crStateProgramDiff(CRProgramBits *b, CRbitvalue *bitID,
136 CRContext *fromCtx, CRContext *toCtx);
137extern DECLEXPORT(void) crStateProgramSwitch(CRProgramBits *b, CRbitvalue *bitID,
138 CRContext *fromCtx, CRContext *toCtx);
139
140DECLEXPORT(void) crStateDiffAllPrograms(CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate);
141
142#endif /* CR_STATE_PROGRAM_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