From: Jason Ekstrand Date: Thu, 31 Dec 2015 04:54:27 +0000 (-0800) Subject: nir/spirv: Handle push constants after decorations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0bb103d0104da78c31b982e62278c201a416a68b;p=mesa.git nir/spirv: Handle push constants after decorations --- diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c index 7a017ee38a6..8527c8b232f 100644 --- a/src/glsl/nir/spirv/spirv_to_nir.c +++ b/src/glsl/nir/spirv/spirv_to_nir.c @@ -1599,6 +1599,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type; struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_deref); + SpvStorageClass storage_class = w[3]; nir_variable *var = rzalloc(b->shader, nir_variable); @@ -1618,7 +1619,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, if (interface_type) var->interface_type = interface_type->type; - switch ((SpvStorageClass)w[3]) { + switch (storage_class) { case SpvStorageClassUniform: case SpvStorageClassUniformConstant: if (interface_type && interface_type->buffer_block) { @@ -1704,6 +1705,18 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, } } + /* XXX: Work around what appears to be a glslang bug. While the + * SPIR-V spec doesn't say that setting a descriptor set on a push + * constant is invalid, it certainly makes no sense. However, at + * some point, glslang started setting descriptor set 0 on push + * constants for some unknown reason. Hopefully this can be removed + * at some point in the future. + */ + if (storage_class == SpvStorageClassPushConstant) { + var->data.descriptor_set = -1; + var->data.binding = -1; + } + /* Interface block variables aren't actually going to be referenced * by the generated NIR, so we don't put them in the list */