nir/spirv: improve parsing of the memory model
v2: add some vtn_fail_ifs Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -243,6 +243,15 @@ typedef struct shader_info {
|
|||||||
* Size of shared variables accessed by the compute shader.
|
* Size of shared variables accessed by the compute shader.
|
||||||
*/
|
*/
|
||||||
unsigned shared_size;
|
unsigned shared_size;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pointer size is:
|
||||||
|
* AddressingModelLogical: 0 (default)
|
||||||
|
* AddressingModelPhysical32: 32
|
||||||
|
* AddressingModelPhysical64: 64
|
||||||
|
*/
|
||||||
|
unsigned ptr_size;
|
||||||
} cs;
|
} cs;
|
||||||
|
|
||||||
/* Applies to both TCS and TES. */
|
/* Applies to both TCS and TES. */
|
||||||
|
@@ -3732,12 +3732,38 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvOpMemoryModel:
|
case SpvOpMemoryModel:
|
||||||
vtn_assert(w[1] == SpvAddressingModelLogical ||
|
switch (w[1]) {
|
||||||
(b->options &&
|
case SpvAddressingModelPhysical32:
|
||||||
b->options->caps.physical_storage_buffer_address &&
|
vtn_fail_if(b->shader->info.stage != MESA_SHADER_KERNEL,
|
||||||
w[1] == SpvAddressingModelPhysicalStorageBuffer64EXT));
|
"AddressingModelPhysical32 only supported for kernels");
|
||||||
|
b->shader->info.cs.ptr_size = 32;
|
||||||
|
b->physical_ptrs = true;
|
||||||
|
break;
|
||||||
|
case SpvAddressingModelPhysical64:
|
||||||
|
vtn_fail_if(b->shader->info.stage != MESA_SHADER_KERNEL,
|
||||||
|
"AddressingModelPhysical64 only supported for kernels");
|
||||||
|
b->shader->info.cs.ptr_size = 64;
|
||||||
|
b->physical_ptrs = true;
|
||||||
|
break;
|
||||||
|
case SpvAddressingModelLogical:
|
||||||
|
vtn_fail_if(b->shader->info.stage >= MESA_SHADER_STAGES,
|
||||||
|
"AddressingModelLogical only supported for shaders");
|
||||||
|
b->shader->info.cs.ptr_size = 0;
|
||||||
|
b->physical_ptrs = false;
|
||||||
|
break;
|
||||||
|
case SpvAddressingModelPhysicalStorageBuffer64EXT:
|
||||||
|
vtn_fail_if(!b->options ||
|
||||||
|
!b->options->caps.physical_storage_buffer_address,
|
||||||
|
"AddressingModelPhysicalStorageBuffer64EXT not supported");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
vtn_fail("Unknown addressing model");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
vtn_assert(w[2] == SpvMemoryModelSimple ||
|
vtn_assert(w[2] == SpvMemoryModelSimple ||
|
||||||
w[2] == SpvMemoryModelGLSL450);
|
w[2] == SpvMemoryModelGLSL450 ||
|
||||||
|
w[2] == SpvMemoryModelOpenCL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvOpEntryPoint:
|
case SpvOpEntryPoint:
|
||||||
@@ -4440,6 +4466,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
/* Skip the SPIR-V header, handled at vtn_create_builder */
|
/* Skip the SPIR-V header, handled at vtn_create_builder */
|
||||||
words+= 5;
|
words+= 5;
|
||||||
|
|
||||||
|
b->shader = nir_shader_create(b, stage, nir_options, NULL);
|
||||||
|
|
||||||
/* Handle all the preamble instructions */
|
/* Handle all the preamble instructions */
|
||||||
words = vtn_foreach_instruction(b, words, word_end,
|
words = vtn_foreach_instruction(b, words, word_end,
|
||||||
vtn_handle_preamble_instruction);
|
vtn_handle_preamble_instruction);
|
||||||
@@ -4450,8 +4478,6 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->shader = nir_shader_create(b, stage, nir_options, NULL);
|
|
||||||
|
|
||||||
/* Set shader info defaults */
|
/* Set shader info defaults */
|
||||||
b->shader->info.gs.invocations = 1;
|
b->shader->info.gs.invocations = 1;
|
||||||
|
|
||||||
|
@@ -613,6 +613,9 @@ struct vtn_builder {
|
|||||||
|
|
||||||
/* false by default, set to true by the ContractionOff execution mode */
|
/* false by default, set to true by the ContractionOff execution mode */
|
||||||
bool exact;
|
bool exact;
|
||||||
|
|
||||||
|
/* when a physical memory model is choosen */
|
||||||
|
bool physical_ptrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
nir_ssa_def *
|
nir_ssa_def *
|
||||||
|
Reference in New Issue
Block a user