summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorKarol Herbst <[email protected]>2018-07-19 13:04:14 +0200
committerKarol Herbst <[email protected]>2019-03-05 22:28:29 +0100
commit5f8257fb0b022448eaee7c7d843fcf7309776d83 (patch)
tree47be1fbd3f99a15be5c193de71c673f95a6184bd /src/compiler/spirv
parent5d48359a2c5670d55f24e91229f59efc6368dcba (diff)
nir/spirv: improve parsing of the memory model
v2: add some vtn_fail_ifs Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/spirv_to_nir.c40
-rw-r--r--src/compiler/spirv/vtn_private.h3
2 files changed, 36 insertions, 7 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index de5e6cc8659..08b7ae09d9c 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3732,12 +3732,38 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
break;
case SpvOpMemoryModel:
- vtn_assert(w[1] == SpvAddressingModelLogical ||
- (b->options &&
- b->options->caps.physical_storage_buffer_address &&
- w[1] == SpvAddressingModelPhysicalStorageBuffer64EXT));
+ switch (w[1]) {
+ case SpvAddressingModelPhysical32:
+ vtn_fail_if(b->shader->info.stage != MESA_SHADER_KERNEL,
+ "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 ||
- w[2] == SpvMemoryModelGLSL450);
+ w[2] == SpvMemoryModelGLSL450 ||
+ w[2] == SpvMemoryModelOpenCL);
break;
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 */
words+= 5;
+ b->shader = nir_shader_create(b, stage, nir_options, NULL);
+
/* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end,
vtn_handle_preamble_instruction);
@@ -4450,8 +4478,6 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
return NULL;
}
- b->shader = nir_shader_create(b, stage, nir_options, NULL);
-
/* Set shader info defaults */
b->shader->info.gs.invocations = 1;
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index f3d54051885..330cf47b34a 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -613,6 +613,9 @@ struct vtn_builder {
/* false by default, set to true by the ContractionOff execution mode */
bool exact;
+
+ /* when a physical memory model is choosen */
+ bool physical_ptrs;
};
nir_ssa_def *