From 5818d47ae661bfc7121a2e6c80d4e5870cf5fe8c Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 15 Oct 2021 14:15:52 -0500 Subject: [PATCH] spirv: Use texture types for sampled images Instead of using gsamplerND types for sampled images, use the new gtextureND types for sampled images and reserve gsamplerND for combined image+samplers. Combined image+sampler bindings still get a gsamplerND type. Reviewed-by: Jesse Natalie Part-of: --- .../nir/nir_lower_readonly_images_to_tex.c | 14 +++++++------- src/compiler/spirv/spirv_to_nir.c | 9 +++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/compiler/nir/nir_lower_readonly_images_to_tex.c b/src/compiler/nir/nir_lower_readonly_images_to_tex.c index 60b0a3451a8..25ecc707939 100644 --- a/src/compiler/nir/nir_lower_readonly_images_to_tex.c +++ b/src/compiler/nir/nir_lower_readonly_images_to_tex.c @@ -25,16 +25,16 @@ #include "nir_builder.h" static const struct glsl_type * -get_sampler_type_for_image(const struct glsl_type *type) +get_texture_type_for_image(const struct glsl_type *type) { if (glsl_type_is_array(type)) { const struct glsl_type *elem_type = - get_sampler_type_for_image(glsl_get_array_element(type)); + get_texture_type_for_image(glsl_get_array_element(type)); return glsl_array_type(elem_type, glsl_get_length(type), 0 /*explicit size*/); } assert((glsl_type_is_image(type))); - return glsl_sampler_type(glsl_get_sampler_dim(type), false, + return glsl_texture_type(glsl_get_sampler_dim(type), glsl_sampler_type_is_array(type), glsl_get_sampler_result_type(type)); } @@ -45,15 +45,15 @@ replace_image_type_with_sampler(nir_deref_instr *deref) const struct glsl_type *type = deref->type; /* If we've already chased up the deref chain this far from a different intrinsic, we're done */ - if (glsl_type_is_sampler(glsl_without_array(type))) + if (glsl_type_is_texture(glsl_without_array(type))) return; - deref->type = get_sampler_type_for_image(type); + deref->type = get_texture_type_for_image(type); deref->modes = nir_var_uniform; if (deref->deref_type == nir_deref_type_var) { type = deref->var->type; - if (!glsl_type_is_sampler(glsl_without_array(type))) { - deref->var->type = get_sampler_type_for_image(type); + if (!glsl_type_is_texture(glsl_without_array(type))) { + deref->var->type = get_texture_type_for_image(type); deref->var->data.mode = nir_var_uniform; memset(&deref->var->data.sampler, 0, sizeof(deref->var->data.sampler)); } diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index e685704c017..99be91e4d2b 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -950,14 +950,15 @@ vtn_type_get_nir_type(struct vtn_builder *b, struct vtn_type *type, } case vtn_base_type_image: - vtn_assert(glsl_type_is_sampler(type->glsl_image)); + vtn_assert(glsl_type_is_texture(type->glsl_image)); return type->glsl_image; case vtn_base_type_sampler: return glsl_bare_sampler_type(); case vtn_base_type_sampled_image: - return type->image->glsl_image; + return glsl_texture_type_to_sampler(type->image->glsl_image, + false /* is_shadow */); default: return type->type; @@ -1744,7 +1745,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, enum glsl_base_type sampled_base_type = glsl_get_base_type(sampled_type->type); if (sampled == 1) { - val->type->glsl_image = glsl_sampler_type(dim, false, is_array, + val->type->glsl_image = glsl_texture_type(dim, is_array, sampled_base_type); } else if (sampled == 2) { val->type->glsl_image = glsl_image_type(dim, is_array, @@ -5651,7 +5652,7 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, if (glsl_type_is_image(image_type->glsl_image)) { vtn_handle_image(b, opcode, w, count); } else { - vtn_assert(glsl_type_is_sampler(image_type->glsl_image)); + vtn_assert(glsl_type_is_texture(image_type->glsl_image)); vtn_handle_texture(b, opcode, w, count); } break;