diff options
author | Jason Ekstrand <[email protected]> | 2019-01-11 15:02:39 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-01-12 17:55:49 -0600 |
commit | e57e26121a4b0d6fb836e981da039bd1ef0ebf06 (patch) | |
tree | 46ae750b93aa5d1a509cf3e851e3fb8a837f8518 /src/compiler/spirv/vtn_variables.c | |
parent | b57c1ec4219f01bfdb98bcab8fca4c44e87bd1a4 (diff) |
spirv: Contain the GLSLang issue #179 workaround to old GLSLang
Instead of applying the workaround universally, detect semi-old GLSLang
via the generator ID and only enable the workaround on old GLSLang.
This isn't nearly as precise as one would like it to be because the
first GLSLang generator id version bump was on October 7, 2017 which is
about 1.5 years after the bug was fixed. However, it at least lets us
disable it for non-GLSLang and for more modern versions.
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 6036295e61c..6106ff35591 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -544,9 +544,11 @@ repair_atomic_type(const struct glsl_type *type) nir_deref_instr * vtn_pointer_to_deref(struct vtn_builder *b, struct vtn_pointer *ptr) { - /* Do on-the-fly copy propagation for samplers. */ - if (ptr->var && ptr->var->copy_prop_sampler) - return vtn_pointer_to_deref(b, ptr->var->copy_prop_sampler); + if (b->wa_glslang_179) { + /* Do on-the-fly copy propagation for samplers. */ + if (ptr->var && ptr->var->copy_prop_sampler) + return vtn_pointer_to_deref(b, ptr->var->copy_prop_sampler); + } vtn_assert(!vtn_pointer_uses_ssa_offset(b, ptr)); if (!ptr->deref) { @@ -1800,16 +1802,18 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, ptr->type = ptr_type->deref; ptr->ptr_type = ptr_type; - /* To work around https://github.com/KhronosGroup/glslang/issues/179 we - * need to whack the mode because it creates a function parameter with the - * Function storage class even though it's a pointer to a sampler. If we - * don't do this, then NIR won't get rid of the deref_cast for us. - */ - if (ptr->mode == vtn_variable_mode_function && - (ptr->type->base_type == vtn_base_type_sampler || - ptr->type->base_type == vtn_base_type_sampled_image)) { - ptr->mode = vtn_variable_mode_uniform; - nir_mode = nir_var_uniform; + if (b->wa_glslang_179) { + /* To work around https://github.com/KhronosGroup/glslang/issues/179 we + * need to whack the mode because it creates a function parameter with + * the Function storage class even though it's a pointer to a sampler. + * If we don't do this, then NIR won't get rid of the deref_cast for us. + */ + if (ptr->mode == vtn_variable_mode_function && + (ptr->type->base_type == vtn_base_type_sampler || + ptr->type->base_type == vtn_base_type_sampled_image)) { + ptr->mode = vtn_variable_mode_uniform; + nir_mode = nir_var_uniform; + } } if (vtn_pointer_uses_ssa_offset(b, ptr)) { @@ -2266,11 +2270,15 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, vtn_assert_types_equal(b, opcode, dest_val->type->deref, src_val->type); if (glsl_type_is_sampler(dest->type->type)) { - vtn_warn("OpStore of a sampler detected. Doing on-the-fly copy " - "propagation to workaround the problem."); - vtn_assert(dest->var->copy_prop_sampler == NULL); - dest->var->copy_prop_sampler = - vtn_value(b, w[2], vtn_value_type_pointer)->pointer; + if (b->wa_glslang_179) { + vtn_warn("OpStore of a sampler detected. Doing on-the-fly copy " + "propagation to workaround the problem."); + vtn_assert(dest->var->copy_prop_sampler == NULL); + dest->var->copy_prop_sampler = + vtn_value(b, w[2], vtn_value_type_pointer)->pointer; + } else { + vtn_fail("Vulkan does not allow OpStore of a sampler or image."); + } break; } |