aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorKarol Herbst <[email protected]>2019-12-05 11:37:34 +0100
committerKarol Herbst <[email protected]>2019-12-11 23:54:39 +0000
commit2402232c90ef362a6cf14ff1cf5518e6c25bf9f9 (patch)
tree88dc6eef0538c4e25883882365336f96571188be /src/compiler/spirv
parent123f90cf367d3feceea0dbea84b2bdd6be26a146 (diff)
spirv: handle UniformConstant for OpenCL kernels
The caller is responsible for setting up the ubo_addr_format value as contrary to shared and global, it's not controlled by the spirv. Right now clovers implementation of CL constant memory uses a 24/8 bit format to encode the buffer index and offset, but that code is dead as all backends treat constants as global memory to workaround annoying issues within OpenCL. Maybe that will change, maybe not. But just in case somebody wants to look at it, add a toggle for this inside vtn. Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/nir_spirv.h6
-rw-r--r--src/compiler/spirv/spirv_to_nir.c1
-rw-r--r--src/compiler/spirv/vtn_variables.c14
3 files changed, 19 insertions, 2 deletions
diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index d5978a81bb4..81175ebf022 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -83,6 +83,12 @@ struct spirv_to_nir_options {
nir_address_format global_addr_format;
nir_address_format temp_addr_format;
+ /* Whether UniformConstant memory should be treated as normal global memory.
+ * This is usefull for CL 2.0 implementations with fine grain system SVM
+ * support.
+ */
+ bool constant_as_global;
+
struct {
void (*func)(void *private_data,
enum nir_spirv_debug_level level,
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 0c1813b139d..aff11a2d579 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1351,6 +1351,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
case SpvStorageClassFunction:
case SpvStorageClassWorkgroup:
case SpvStorageClassCrossWorkgroup:
+ case SpvStorageClassUniformConstant:
val->type->stride = align(glsl_get_cl_size(val->type->deref->type),
glsl_get_cl_alignment(val->type->deref->type));
break;
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 755d85642a0..d7edabb5656 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1816,8 +1816,18 @@ vtn_storage_class_to_mode(struct vtn_builder *b,
nir_mode = nir_var_mem_global;
break;
case SpvStorageClassUniformConstant:
- mode = vtn_variable_mode_uniform;
- nir_mode = nir_var_uniform;
+ if (b->shader->info.stage == MESA_SHADER_KERNEL) {
+ if (b->options->constant_as_global) {
+ mode = vtn_variable_mode_cross_workgroup;
+ nir_mode = nir_var_mem_global;
+ } else {
+ mode = vtn_variable_mode_ubo;
+ nir_mode = nir_var_mem_ubo;
+ }
+ } else {
+ mode = vtn_variable_mode_uniform;
+ nir_mode = nir_var_uniform;
+ }
break;
case SpvStorageClassPushConstant:
mode = vtn_variable_mode_push_constant;