mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 09:18:04 +02:00
spirv: Use STACK_ARRAY instead of NIR_VLA
The number of fields comes from the shader, so it could be a value large enough that using alloca would be problematic. Fixes:2a023f30a6("nir/spirv: Add basic support for types") Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Reviewed-by: Ryan Neph <ryanneph@google.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> (cherry picked from commit3da828d2dd) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
parent
5048a2ed1c
commit
978fd42b4b
2 changed files with 18 additions and 11 deletions
|
|
@ -4554,7 +4554,7 @@
|
|||
"description": "spirv: Use STACK_ARRAY instead of NIR_VLA",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "2a023f30a644821550e0d529078a05af12188fcb",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "glsl_types.h"
|
||||
#include "vtn_private.h"
|
||||
#include "nir/nir_vla.h"
|
||||
#include "nir/nir_control_flow.h"
|
||||
#include "nir/nir_constant_expressions.h"
|
||||
#include "nir/nir_deref.h"
|
||||
|
|
@ -42,6 +41,7 @@
|
|||
#include "util/mesa-blake3.h"
|
||||
#include "util/bfloat.h"
|
||||
#include "util/float8.h"
|
||||
#include "util/stack_array.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -1404,7 +1404,7 @@ vtn_type_get_nir_type(struct vtn_builder *b, struct vtn_type *type,
|
|||
case vtn_base_type_struct: {
|
||||
bool need_new_struct = false;
|
||||
const uint32_t num_fields = type->length;
|
||||
NIR_VLA(struct glsl_struct_field, fields, num_fields);
|
||||
STACK_ARRAY(struct glsl_struct_field, fields, num_fields);
|
||||
for (unsigned i = 0; i < num_fields; i++) {
|
||||
fields[i] = *glsl_get_struct_field_data(type->type, i);
|
||||
const struct glsl_type *field_nir_type =
|
||||
|
|
@ -1414,20 +1414,25 @@ vtn_type_get_nir_type(struct vtn_builder *b, struct vtn_type *type,
|
|||
need_new_struct = true;
|
||||
}
|
||||
}
|
||||
|
||||
const struct glsl_type *result;
|
||||
if (need_new_struct) {
|
||||
if (glsl_type_is_interface(type->type)) {
|
||||
return glsl_interface_type(fields, num_fields,
|
||||
/* packing */ 0, false,
|
||||
glsl_get_type_name(type->type));
|
||||
result = glsl_interface_type(fields, num_fields,
|
||||
/* packing */ 0, false,
|
||||
glsl_get_type_name(type->type));
|
||||
} else {
|
||||
return glsl_struct_type(fields, num_fields,
|
||||
glsl_get_type_name(type->type),
|
||||
glsl_struct_type_is_packed(type->type));
|
||||
result = glsl_struct_type(fields, num_fields,
|
||||
glsl_get_type_name(type->type),
|
||||
glsl_struct_type_is_packed(type->type));
|
||||
}
|
||||
} else {
|
||||
/* No changes, just pass it on */
|
||||
return type->type;
|
||||
result = type->type;
|
||||
}
|
||||
|
||||
STACK_ARRAY_FINISH(fields);
|
||||
return result;
|
||||
}
|
||||
|
||||
case vtn_base_type_image:
|
||||
|
|
@ -2073,7 +2078,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||
val->type->offsets = vtn_alloc_array(b, unsigned, num_fields);
|
||||
val->type->packed = false;
|
||||
|
||||
NIR_VLA(struct glsl_struct_field, fields, count);
|
||||
STACK_ARRAY(struct glsl_struct_field, fields, count);
|
||||
for (unsigned i = 0; i < num_fields; i++) {
|
||||
val->type->members[i] = vtn_get_type(b, w[i + 2]);
|
||||
const char *name = NULL;
|
||||
|
|
@ -2129,6 +2134,8 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||
name ? name : "struct",
|
||||
val->type->packed);
|
||||
}
|
||||
|
||||
STACK_ARRAY_FINISH(fields);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue