aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/builtin_variables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/glsl/builtin_variables.cpp')
-rw-r--r--src/compiler/glsl/builtin_variables.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 6f960837321..e305ab9b9b8 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -1097,15 +1097,32 @@ builtin_variable_generator::generate_vs_special_vars()
add_system_value(SYSTEM_VALUE_DRAW_ID, int_t, "gl_DrawIDARB");
}
if (state->AMD_vertex_shader_layer_enable ||
- state->ARB_shader_viewport_layer_array_enable) {
+ state->ARB_shader_viewport_layer_array_enable ||
+ state->NV_viewport_array2_enable) {
var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
var->data.interpolation = INTERP_MODE_FLAT;
}
if (state->AMD_vertex_shader_viewport_index_enable ||
- state->ARB_shader_viewport_layer_array_enable) {
+ state->ARB_shader_viewport_layer_array_enable ||
+ state->NV_viewport_array2_enable) {
var = add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
var->data.interpolation = INTERP_MODE_FLAT;
}
+ if (state->NV_viewport_array2_enable) {
+ /* From the NV_viewport_array2 specification:
+ *
+ * "The variable gl_ViewportMask[] is available as an output variable
+ * in the VTG languages. The array has ceil(v/32) elements where v is
+ * the maximum number of viewports supported by the implementation."
+ *
+ * Since no drivers expose more than 16 viewports, we can simply set the
+ * array size to 1 rather than computing it and dealing with varying
+ * slot complication.
+ */
+ var = add_output(VARYING_SLOT_VIEWPORT_MASK, array(int_t, 1),
+ "gl_ViewportMask");
+ var->data.interpolation = INTERP_MODE_FLAT;
+ }
if (compatibility) {
add_input(VERT_ATTRIB_POS, vec4_t, "gl_Vertex");
add_input(VERT_ATTRIB_NORMAL, vec3_t, "gl_Normal");
@@ -1155,6 +1172,17 @@ builtin_variable_generator::generate_tcs_special_vars()
add_output(bbox_slot, array(vec4_t, 2), GLSL_PRECISION_HIGH,
"gl_BoundingBox")->data.patch = 1;
}
+
+ /* NOTE: These are completely pointless. Writing these will never go
+ * anywhere. But the specs demands it. So we add them with a slot of -1,
+ * which makes the data go nowhere.
+ */
+ if (state->NV_viewport_array2_enable) {
+ add_output(-1, int_t, "gl_Layer");
+ add_output(-1, int_t, "gl_ViewportIndex");
+ add_output(-1, array(int_t, 1), "gl_ViewportMask");
+ }
+
}
@@ -1183,12 +1211,18 @@ builtin_variable_generator::generate_tes_special_vars()
add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
GLSL_PRECISION_HIGH, "gl_TessLevelInner");
}
- if (state->ARB_shader_viewport_layer_array_enable) {
+ if (state->ARB_shader_viewport_layer_array_enable ||
+ state->NV_viewport_array2_enable) {
var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
var->data.interpolation = INTERP_MODE_FLAT;
var = add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
var->data.interpolation = INTERP_MODE_FLAT;
}
+ if (state->NV_viewport_array2_enable) {
+ var = add_output(VARYING_SLOT_VIEWPORT_MASK, array(int_t, 1),
+ "gl_ViewportMask");
+ var->data.interpolation = INTERP_MODE_FLAT;
+ }
}
@@ -1208,6 +1242,11 @@ builtin_variable_generator::generate_gs_special_vars()
"gl_ViewportIndex");
var->data.interpolation = INTERP_MODE_FLAT;
}
+ if (state->NV_viewport_array2_enable) {
+ var = add_output(VARYING_SLOT_VIEWPORT_MASK, array(int_t, 1),
+ "gl_ViewportMask");
+ var->data.interpolation = INTERP_MODE_FLAT;
+ }
if (state->is_version(400, 320) || state->ARB_gpu_shader5_enable ||
state->OES_geometry_shader_enable || state->EXT_geometry_shader_enable) {
add_system_value(SYSTEM_VALUE_INVOCATION_ID, int_t, GLSL_PRECISION_HIGH,