[Mesa-dev] [RFC PATCH 31/56] glsl: Add builtin uniforms for default inner/outer tess levels
Chris Forbes
chrisf at ijw.co.nz
Sat Sep 20 18:41:11 PDT 2014
If the hardware needs to always have a control shader present if
and evaluation shader is present, then the control shader will need
these values.
---
src/glsl/builtin_variables.cpp | 14 ++++++++++++++
src/mesa/program/prog_statevars.c | 24 ++++++++++++++++++++++++
src/mesa/program/prog_statevars.h | 3 +++
3 files changed, 41 insertions(+)
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 97ef68c..0909818 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -33,6 +33,14 @@ static const struct gl_builtin_uniform_element gl_NumSamples_elements[] = {
{NULL, {STATE_NUM_SAMPLES, 0, 0}, SWIZZLE_XXXX}
};
+static const struct gl_builtin_uniform_element gl_DefaultTessLevelOuterMESA_elements[] = {
+ {NULL, {STATE_INTERNAL, STATE_DEFAULT_TESS_LEVEL_OUTER, 0, 0}, SWIZZLE_XXXX}
+};
+
+static const struct gl_builtin_uniform_element gl_DefaultTessLevelInnerMESA_elements[] = {
+ {NULL, {STATE_INTERNAL, STATE_DEFAULT_TESS_LEVEL_INNER, 0, 0}, SWIZZLE_XXXX}
+};
+
static const struct gl_builtin_uniform_element gl_DepthRange_elements[] = {
{"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX},
{"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY},
@@ -280,6 +288,9 @@ static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
STATEVAR(gl_CurrentAttribVertMESA),
STATEVAR(gl_CurrentAttribFragMESA),
+ STATEVAR(gl_DefaultTessLevelOuterMESA),
+ STATEVAR(gl_DefaultTessLevelInnerMESA),
+
{NULL, NULL, 0}
};
@@ -743,6 +754,9 @@ builtin_variable_generator::generate_uniforms()
add_uniform(array(vec4_t, VERT_ATTRIB_MAX), "gl_CurrentAttribVertMESA");
add_uniform(array(vec4_t, VARYING_SLOT_MAX), "gl_CurrentAttribFragMESA");
+ add_uniform(array(float_t, 4), "gl_DefaultTessLevelOuterMESA");
+ add_uniform(array(float_t, 2), "gl_DefaultTessLevelInnerMESA");
+
if (compatibility) {
add_uniform(mat4_t, "gl_ModelViewMatrix");
add_uniform(mat4_t, "gl_ProjectionMatrix");
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index be5ddb1..785257b 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -593,6 +593,20 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
}
return;
+ case STATE_DEFAULT_TESS_LEVEL_OUTER:
+ value[0] = ctx->TessCtrlProgram.patch_default_outer_level[state[2]];
+ value[1] = 0.0F;
+ value[2] = 0.0F;
+ value[3] = 0.0F;
+ return;
+
+ case STATE_DEFAULT_TESS_LEVEL_INNER:
+ value[0] = ctx->TessCtrlProgram.patch_default_inner_level[state[2]];
+ value[1] = 0.0F;
+ value[2] = 0.0F;
+ value[3] = 0.0F;
+ return;
+
/* XXX: make sure new tokens added here are also handled in the
* _mesa_program_state_flags() switch, below.
*/
@@ -703,6 +717,10 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
case STATE_FB_WPOS_Y_TRANSFORM:
return _NEW_BUFFERS;
+ case STATE_DEFAULT_TESS_LEVEL_OUTER:
+ case STATE_DEFAULT_TESS_LEVEL_INNER:
+ return _NEW_PROGRAM;
+
default:
/* unknown state indexes are silently ignored and
* no flag set, since it is handled by the driver.
@@ -909,6 +927,12 @@ append_token(char *dst, gl_state_index k)
case STATE_FB_WPOS_Y_TRANSFORM:
append(dst, "FbWposYTransform");
break;
+ case STATE_DEFAULT_TESS_LEVEL_OUTER:
+ append(dst, "DefaultTessLevelOuter");
+ break;
+ case STATE_DEFAULT_TESS_LEVEL_INNER:
+ append(dst, "DefaultTessLevelInner");
+ break;
default:
/* probably STATE_INTERNAL_DRIVER+i (driver private state) */
append(dst, "driverState");
diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h
index 6333e63..7240398 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -128,6 +128,9 @@ typedef enum gl_state_index_ {
STATE_PT_BIAS, /**< Pixel transfer RGBA bias */
STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */
STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */
+
+ STATE_DEFAULT_TESS_LEVEL_OUTER,
+ STATE_DEFAULT_TESS_LEVEL_INNER,
STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */
} gl_state_index;
--
2.1.0
More information about the mesa-dev
mailing list