nir: Move zero_initialize_shared_memory into common shader_info

Move it out the "cs" sub-struct, since the bit will be used for other
shader stages in the future.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11225>
This commit is contained in:
Caio Marcelo de Oliveira Filho
2021-05-05 09:34:46 -07:00
parent 7b13c1461d
commit b5f6fc442c
4 changed files with 8 additions and 5 deletions

View File

@@ -648,7 +648,7 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
} }
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset); NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset);
if (nir->info.cs.zero_initialize_shared_memory && nir->info.shared_size > 0) { if (nir->info.zero_initialize_shared_memory && nir->info.shared_size > 0) {
const unsigned chunk_size = 16; /* max single store size */ const unsigned chunk_size = 16; /* max single store size */
const unsigned shared_size = ALIGN(nir->info.shared_size, chunk_size); const unsigned shared_size = ALIGN(nir->info.shared_size, chunk_size);
NIR_PASS_V(nir, nir_zero_initialize_shared_memory, shared_size, chunk_size); NIR_PASS_V(nir, nir_zero_initialize_shared_memory, shared_size, chunk_size);

View File

@@ -254,6 +254,11 @@ typedef struct shader_info {
*/ */
bool shared_memory_explicit_layout:1; bool shared_memory_explicit_layout:1;
/**
* Used for VK_KHR_zero_initialize_workgroup_memory.
*/
bool zero_initialize_shared_memory:1;
union { union {
struct { struct {
/* Which inputs are doubles */ /* Which inputs are doubles */
@@ -396,8 +401,6 @@ typedef struct shader_info {
*/ */
enum gl_derivative_group derivative_group:2; enum gl_derivative_group derivative_group:2;
bool zero_initialize_shared_memory;
/** /**
* pointer size is: * pointer size is:
* AddressingModelLogical: 0 (default) * AddressingModelLogical: 0 (default)

View File

@@ -1960,7 +1960,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
"as initializer, but have %u instead", "as initializer, but have %u instead",
vtn_id_for_value(b, val), vtn_id_for_value(b, val),
vtn_id_for_value(b, initializer)); vtn_id_for_value(b, initializer));
b->shader->info.cs.zero_initialize_shared_memory = true; b->shader->info.zero_initialize_shared_memory = true;
break; break;
case SpvStorageClassUniformConstant: case SpvStorageClassUniformConstant:

View File

@@ -1808,7 +1808,7 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
NIR_PASS_V(stage.nir, nir_lower_explicit_io, NIR_PASS_V(stage.nir, nir_lower_explicit_io,
nir_var_mem_shared, nir_address_format_32bit_offset); nir_var_mem_shared, nir_address_format_32bit_offset);
if (stage.nir->info.cs.zero_initialize_shared_memory && if (stage.nir->info.zero_initialize_shared_memory &&
stage.nir->info.shared_size > 0) { stage.nir->info.shared_size > 0) {
/* The effective Shared Local Memory size is at least 1024 bytes and /* The effective Shared Local Memory size is at least 1024 bytes and
* is always rounded to a power of two, so it is OK to align the size * is always rounded to a power of two, so it is OK to align the size