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 <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13389>
This commit is contained in:
Jason Ekstrand 2021-10-15 14:15:52 -05:00 committed by Marge Bot
parent 99cda38c81
commit 5818d47ae6
2 changed files with 12 additions and 11 deletions

View file

@ -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));
}

View file

@ -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;