[Mesa-dev] [PATCH 07/11] glsl: add builtin variables for EXT_gpu_shader4

Marek Olšák maraeo at gmail.com
Wed Aug 8 05:42:04 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/compiler/glsl/builtin_variables.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 78fccc4e195..17ee80cd419 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -1002,30 +1002,31 @@ builtin_variable_generator::generate_special_vars()
 
 
 /**
  * Generate variables which only exist in vertex shaders.
  */
 void
 builtin_variable_generator::generate_vs_special_vars()
 {
    ir_variable *var;
 
-   if (state->is_version(130, 300))
+   if (state->is_version(130, 300) || state->EXT_gpu_shader4_enable)
       add_system_value(SYSTEM_VALUE_VERTEX_ID, int_t, "gl_VertexID");
    if (state->is_version(460, 0)) {
       add_system_value(SYSTEM_VALUE_BASE_VERTEX, int_t, "gl_BaseVertex");
       add_system_value(SYSTEM_VALUE_BASE_INSTANCE, int_t, "gl_BaseInstance");
       add_system_value(SYSTEM_VALUE_DRAW_ID, int_t, "gl_DrawID");
    }
    if (state->ARB_draw_instanced_enable)
       add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDARB");
-   if (state->ARB_draw_instanced_enable || state->is_version(140, 300))
+   if (state->ARB_draw_instanced_enable || state->is_version(140, 300) ||
+       state->EXT_gpu_shader4_enable)
       add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceID");
    if (state->ARB_shader_draw_parameters_enable) {
       add_system_value(SYSTEM_VALUE_BASE_VERTEX, int_t, "gl_BaseVertexARB");
       add_system_value(SYSTEM_VALUE_BASE_INSTANCE, int_t, "gl_BaseInstanceARB");
       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) {
       var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
       var->data.interpolation = INTERP_MODE_FLAT;
@@ -1164,21 +1165,21 @@ builtin_variable_generator::generate_fs_special_vars()
       add_input(VARYING_SLOT_POS, vec4_t, "gl_FragCoord");
 
    if (this->state->ctx->Const.GLSLFrontFacingIsSysVal)
       add_system_value(SYSTEM_VALUE_FRONT_FACE, bool_t, "gl_FrontFacing");
    else
       add_input(VARYING_SLOT_FACE, bool_t, "gl_FrontFacing");
 
    if (state->is_version(120, 100))
       add_input(VARYING_SLOT_PNTC, vec2_t, "gl_PointCoord");
 
-   if (state->has_geometry_shader()) {
+   if (state->has_geometry_shader() || state->EXT_gpu_shader4_enable) {
       var = add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
       var->data.interpolation = INTERP_MODE_FLAT;
    }
 
    /* gl_FragColor and gl_FragData were deprecated starting in desktop GLSL
     * 1.30, and were relegated to the compatibility profile in GLSL 4.20.
     * They were removed from GLSL ES 3.00.
     */
    if (compatibility || !state->is_version(420, 300)) {
       add_output(FRAG_RESULT_COLOR, vec4_t, "gl_FragColor");
-- 
2.17.1



More information about the mesa-dev mailing list