mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 02:58:05 +02:00
mesa: glsl: fix/simplify built-in constant lookup
This commit is contained in:
parent
564c97660a
commit
d5835c1d0f
1 changed files with 25 additions and 17 deletions
|
|
@ -37,6 +37,15 @@
|
|||
#include "slang_print.h"
|
||||
|
||||
|
||||
#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
|
||||
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
|
||||
#endif
|
||||
#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
|
||||
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
|
||||
#endif
|
||||
#ifndef GL_MAX_VARYING_VECTORS
|
||||
#define GL_MAX_VARYING_VECTORS 0x8DFC
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -49,25 +58,24 @@ _slang_lookup_constant(const char *name)
|
|||
struct constant_info {
|
||||
const char *Name;
|
||||
const GLenum Token;
|
||||
GLint Divisor;
|
||||
};
|
||||
static const struct constant_info info[] = {
|
||||
{ "gl_MaxClipPlanes", GL_MAX_CLIP_PLANES, 1 },
|
||||
{ "gl_MaxCombinedTextureImageUnits", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 1 },
|
||||
{ "gl_MaxDrawBuffers", GL_MAX_DRAW_BUFFERS, 1 },
|
||||
{ "gl_MaxFragmentUniformComponents", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1 },
|
||||
{ "gl_MaxLights", GL_MAX_LIGHTS, 1 },
|
||||
{ "gl_MaxTextureUnits", GL_MAX_TEXTURE_UNITS, 1 },
|
||||
{ "gl_MaxTextureCoords", GL_MAX_TEXTURE_COORDS, 1 },
|
||||
{ "gl_MaxVertexAttribs", GL_MAX_VERTEX_ATTRIBS, 1 },
|
||||
{ "gl_MaxVertexUniformComponents", GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1 },
|
||||
{ "gl_MaxVaryingFloats", GL_MAX_VARYING_FLOATS, 1 },
|
||||
{ "gl_MaxVertexTextureImageUnits", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 1 },
|
||||
{ "gl_MaxTextureImageUnits", GL_MAX_TEXTURE_IMAGE_UNITS, 1 },
|
||||
{ "gl_MaxClipPlanes", GL_MAX_CLIP_PLANES },
|
||||
{ "gl_MaxCombinedTextureImageUnits", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS },
|
||||
{ "gl_MaxDrawBuffers", GL_MAX_DRAW_BUFFERS },
|
||||
{ "gl_MaxFragmentUniformComponents", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS },
|
||||
{ "gl_MaxLights", GL_MAX_LIGHTS },
|
||||
{ "gl_MaxTextureUnits", GL_MAX_TEXTURE_UNITS },
|
||||
{ "gl_MaxTextureCoords", GL_MAX_TEXTURE_COORDS },
|
||||
{ "gl_MaxVertexAttribs", GL_MAX_VERTEX_ATTRIBS },
|
||||
{ "gl_MaxVertexUniformComponents", GL_MAX_VERTEX_UNIFORM_COMPONENTS },
|
||||
{ "gl_MaxVaryingFloats", GL_MAX_VARYING_FLOATS },
|
||||
{ "gl_MaxVertexTextureImageUnits", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS },
|
||||
{ "gl_MaxTextureImageUnits", GL_MAX_TEXTURE_IMAGE_UNITS },
|
||||
#if FEATURE_es2_glsl
|
||||
{ "gl_MaxVertexUniformVectors", GL_MAX_VERTEX_UNIFORM_COMPONENTS, 4 },
|
||||
{ "gl_MaxVaryingVectors", GL_MAX_VARYING_FLOATS, 4 },
|
||||
{ "gl_MaxFragmentUniformVectors", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 4 },
|
||||
{ "gl_MaxVertexUniformVectors", GL_MAX_VERTEX_UNIFORM_VECTORS },
|
||||
{ "gl_MaxVaryingVectors", GL_MAX_VARYING_VECTORS },
|
||||
{ "gl_MaxFragmentUniformVectors", GL_MAX_FRAGMENT_UNIFORM_VECTORS },
|
||||
#endif
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
|
@ -79,7 +87,7 @@ _slang_lookup_constant(const char *name)
|
|||
GLint value = -1;
|
||||
_mesa_GetIntegerv(info[i].Token, &value);
|
||||
ASSERT(value >= 0); /* sanity check that glGetFloatv worked */
|
||||
return value / info[i].Divisor;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue