mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
zink: correctly handle ARB_arrays_of_arrays in ntv for samplers
this extension allows for array nesting with no clear limitations, so we need to ensure that we use the "unrolled" array size in a couple places in order to correctly bind and access these types of arrays in shaders fixes spec@arb_separate_shader_objects@active sampler conflict and others Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6981>
This commit is contained in:
parent
18fd6274b2
commit
7767c3dae3
2 changed files with 23 additions and 12 deletions
|
|
@ -536,7 +536,11 @@ emit_sampler(struct ntv_context *ctx, struct nir_variable *var)
|
|||
sampled_type);
|
||||
|
||||
if (glsl_type_is_array(var->type)) {
|
||||
for (int i = 0; i < glsl_get_length(var->type); ++i) {
|
||||
/* ARB_arrays_of_arrays from GLSL 1.30 allows nesting of arrays, so we just
|
||||
* use the total array size if we encounter a nested array
|
||||
*/
|
||||
unsigned size = glsl_get_aoa_size(var->type);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
SpvId var_id = spirv_builder_emit_var(&ctx->builder, pointer_type,
|
||||
SpvStorageClassUniformConstant);
|
||||
|
||||
|
|
|
|||
|
|
@ -289,9 +289,24 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
ret->num_bindings++;
|
||||
} else {
|
||||
assert(var->data.mode == nir_var_uniform);
|
||||
if (glsl_type_is_array(var->type) &&
|
||||
glsl_type_is_sampler(glsl_get_array_element(var->type))) {
|
||||
for (int i = 0; i < glsl_get_length(var->type); ++i) {
|
||||
if (glsl_type_is_sampler(var->type)) {
|
||||
int binding = zink_binding(nir->info.stage,
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
var->data.binding);
|
||||
ret->bindings[ret->num_bindings].index = var->data.binding;
|
||||
ret->bindings[ret->num_bindings].binding = binding;
|
||||
ret->bindings[ret->num_bindings].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
ret->num_bindings++;
|
||||
} else if (glsl_type_is_array(var->type)) {
|
||||
/* need to unroll possible arrays of arrays before checking type
|
||||
* in order to handle ARB_arrays_of_arrays extension
|
||||
*/
|
||||
const struct glsl_type *type = glsl_without_array(var->type);
|
||||
if (!glsl_type_is_sampler(type))
|
||||
continue;
|
||||
|
||||
unsigned size = glsl_get_aoa_size(var->type);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
int binding = zink_binding(nir->info.stage,
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
var->data.binding + i);
|
||||
|
|
@ -300,14 +315,6 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
ret->bindings[ret->num_bindings].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
ret->num_bindings++;
|
||||
}
|
||||
} else if (glsl_type_is_sampler(var->type)) {
|
||||
int binding = zink_binding(nir->info.stage,
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
var->data.binding);
|
||||
ret->bindings[ret->num_bindings].index = var->data.binding;
|
||||
ret->bindings[ret->num_bindings].binding = binding;
|
||||
ret->bindings[ret->num_bindings].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
ret->num_bindings++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue