vk: Use binding instead of index in uniform layout qualifiers
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 19 May 2015 19:42:21 +0000 (12:42 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 19 May 2015 19:44:22 +0000 (12:44 -0700)
This more closely matches what the Vulkan docs say to do.

src/glsl/ast_to_hir.cpp
src/glsl/ast_type.cpp
src/glsl/glsl_parser.yy
src/vulkan/meta.c
src/vulkan/vk.c

index 8713cd85f0a1516ea0d300f89860895953c2d78a..cd6a068e97d87743e35929d05789a214e7a47d87 100644 (file)
@@ -2647,14 +2647,14 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
    }
 
    if (qual->flags.q.vk_set) {
-      if (!qual->flags.q.explicit_index)
+      if (!qual->flags.q.explicit_binding)
          _mesa_glsl_error(loc, state,
-                          "Vulkan descriptor set layout requires both group and index "
-                          "qualifiers");
+                          "Vulkan descriptor set layout requires both set "
+                          "and binding qualifiers");
 
       var->data.vk_set = true;
       var->data.set = qual->set;
-      var->data.index = qual->index;
+      var->data.binding = qual->binding;
    } else if (qual->flags.q.explicit_location) {
       validate_explicit_location(qual, var, state, loc);
    } else if (qual->flags.q.explicit_index) {
@@ -5794,7 +5794,7 @@ ast_interface_block::hir(exec_list *instructions,
 
          var->data.vk_set = this->layout.flags.q.vk_set;
          var->data.set = this->layout.set;
-         var->data.index = this->layout.index;
+         var->data.binding = this->layout.binding;
 
          state->symbols->add_variable(var);
          instructions->push_tail(var);
@@ -5870,7 +5870,7 @@ ast_interface_block::hir(exec_list *instructions,
 
          var->data.vk_set = this->layout.flags.q.vk_set;
          var->data.set = this->layout.set;
-         var->data.index = this->layout.index;
+         var->data.binding = this->layout.binding;
 
          state->symbols->add_variable(var);
          instructions->push_tail(var);
index a988fd5879258a5fc42f5b30794919e3068c07b9..5eb2913d6b70f7be38d0f31aa330b5c9715f710e 100644 (file)
@@ -254,7 +254,7 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
 
    if (q.flags.q.vk_set) {
       this->set = q.set;
-      this->index = q.index;
+      this->binding = q.binding;
    }
 
    return true;
index 41106060e5e1d4b535da6ebd9aeb8c0d9bd05436..05fa4ea9ac571ff252a2af781e69f0b1de5ccb76 100644 (file)
@@ -1424,9 +1424,7 @@ layout_qualifier_id:
          }
       }
 
-      if ((state->ARB_shading_language_420pack_enable ||
-           state->has_atomic_counters()) &&
-          match_layout_qualifier("binding", $1, state) == 0) {
+      if (match_layout_qualifier("binding", $1, state) == 0) {
          $$.flags.q.explicit_binding = 1;
          $$.binding = $3;
       }
index 1aad8d91df9875c2b45d4ab7177748d526e872ae..7be8a5116557662f282b716f24c1a4b5587bf081 100644 (file)
@@ -307,7 +307,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
    VkShader fs = GLSL_VK_SHADER(device, FRAGMENT,
       out vec4 f_color;
       in vec4 v_tex_coord;
-      layout(set = 0, index = 0) uniform sampler2D u_tex;
+      layout(set = 0, binding = 0) uniform sampler2D u_tex;
       void main()
       {
          f_color = texture2D(u_tex, v_tex_coord.xy);
index 59c4bd35669d1fa403a4731f9b899c84e3a6d811..bc78b558d562c5170df9fd164baf5300b2a58c92 100644 (file)
@@ -103,13 +103,13 @@ create_pipeline(VkDevice device, VkPipeline *pipeline,
    static const char vs_source[] = GLSL(
       layout(location = 0) in vec4 a_position;
       layout(location = 1) in vec4 a_color;
-      layout(set = 0, index = 0) uniform block1 {
+      layout(set = 0, binding = 0) uniform block1 {
          vec4 color;
       } u1;
-      layout(set = 0, index = 1) uniform block2 {
+      layout(set = 0, binding = 1) uniform block2 {
          vec4 color;
       } u2;
-      layout(set = 1, index = 0) uniform block3 {
+      layout(set = 1, binding = 0) uniform block3 {
          vec4 color;
       } u3;
       out vec4 v_color;
@@ -122,7 +122,7 @@ create_pipeline(VkDevice device, VkPipeline *pipeline,
    static const char fs_source[] = GLSL(
       out vec4 f_color;
       in vec4 v_color;
-      layout(set = 0, index = 0) uniform sampler2D tex;
+      layout(set = 0, binding = 0) uniform sampler2D tex;
       void main()
       {
          f_color = v_color + texture2D(tex, vec2(0.1, 0.1));