From: Jason Ekstrand Date: Tue, 19 May 2015 19:42:21 +0000 (-0700) Subject: vk: Use binding instead of index in uniform layout qualifiers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=edff0761881fd833297a6295cb7c9050e1a26eba;p=mesa.git vk: Use binding instead of index in uniform layout qualifiers This more closely matches what the Vulkan docs say to do. --- diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 8713cd85f0a..cd6a068e97d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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); diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index a988fd58792..5eb2913d6b7 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -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; diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 41106060e5e..05fa4ea9ac5 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -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; } diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index 1aad8d91df9..7be8a511655 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -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); diff --git a/src/vulkan/vk.c b/src/vulkan/vk.c index 59c4bd35669..bc78b558d56 100644 --- a/src/vulkan/vk.c +++ b/src/vulkan/vk.c @@ -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));