summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2019-07-25 14:06:53 +0200
committerErik Faye-Lund <erik.faye-lund@collabora.com>2019-10-28 08:51:45 +0000
commit8edd357795bf71c98bca73de34d962ddbaacccc4 (patch)
tree5aca0577e747cee01dae035c41bd55c01a98ad06
parent80673264cbb8acea304d112b9526b161c91a580b (diff)
zink: request ucp-lowering
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r--src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c90
-rw-r--r--src/gallium/drivers/zink/zink_screen.c4
2 files changed, 71 insertions, 23 deletions
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 8534ed1300a..f7a7024212c 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -176,6 +176,17 @@ get_glsl_type(struct ntv_context *ctx, const struct glsl_type *type)
get_glsl_basetype(ctx, glsl_get_base_type(type)),
glsl_get_vector_elements(type));
+ if (glsl_type_is_array(type)) {
+ SpvId ret = spirv_builder_type_array(&ctx->builder,
+ get_glsl_type(ctx, glsl_get_array_element(type)),
+ spirv_builder_const_uint(&ctx->builder, 32, glsl_get_length(type)));
+ uint32_t stride = glsl_get_explicit_stride(type);
+ if (stride)
+ spirv_builder_emit_array_stride(&ctx->builder, ret, stride);
+ return ret;
+ }
+
+
unreachable("we shouldn't get here, I think...");
}
@@ -259,6 +270,11 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var)
spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointSize);
break;
+ case VARYING_SLOT_CLIP_DIST0:
+ assert(glsl_type_is_array(var->type));
+ spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInClipDistance);
+ break;
+
default:
unreachable("unknown varying slot");
}
@@ -382,10 +398,13 @@ emit_ubo(struct ntv_context *ctx, struct nir_variable *var)
static void
emit_uniform(struct ntv_context *ctx, struct nir_variable *var)
{
- if (glsl_type_is_sampler(var->type))
- emit_sampler(ctx, var);
- else if (var->interface_type)
+ if (var->data.mode == nir_var_mem_ubo)
emit_ubo(ctx, var);
+ else {
+ assert(var->data.mode == nir_var_uniform);
+ if (glsl_type_is_sampler(var->type))
+ emit_sampler(ctx, var);
+ }
}
static SpvId
@@ -984,12 +1003,10 @@ emit_discard(struct ntv_context *ctx, nir_intrinsic_instr *intr)
static void
emit_load_deref(struct ntv_context *ctx, nir_intrinsic_instr *intr)
{
- nir_variable *var = nir_intrinsic_get_var(intr, 0);
- struct hash_entry *he = _mesa_hash_table_search(ctx->vars, var);
- assert(he);
- SpvId ptr = (SpvId)(intptr_t)he->data;
+ /* uint is a bit of a lie here; it's really just a pointer */
+ SpvId ptr = get_src_uint(ctx, intr->src);
- // SpvId ptr = get_src_uint(ctx, intr->src); /* uint is a bit of a lie here; it's really just a pointer */
+ nir_variable *var = nir_intrinsic_get_var(intr, 0);
SpvId result = spirv_builder_emit_load(&ctx->builder,
get_glsl_type(ctx, var->type),
ptr);
@@ -1002,14 +1019,13 @@ emit_load_deref(struct ntv_context *ctx, nir_intrinsic_instr *intr)
static void
emit_store_deref(struct ntv_context *ctx, nir_intrinsic_instr *intr)
{
- nir_variable *var = nir_intrinsic_get_var(intr, 0);
- struct hash_entry *he = _mesa_hash_table_search(ctx->vars, var);
- assert(he);
- SpvId ptr = (SpvId)(intptr_t)he->data;
- // SpvId ptr = get_src_uint(ctx, &intr->src[0]); /* uint is a bit of a lie here; it's really just a pointer */
-
+ /* uint is a bit of a lie here; it's really just a pointer */
+ SpvId ptr = get_src_uint(ctx, &intr->src[0]);
SpvId src = get_src_uint(ctx, &intr->src[1]);
- SpvId result = emit_unop(ctx, SpvOpBitcast, get_glsl_type(ctx, var->type),
+
+ nir_variable *var = nir_intrinsic_get_var(intr, 0);
+ SpvId result = emit_unop(ctx, SpvOpBitcast,
+ get_glsl_type(ctx, glsl_without_array(var->type)),
src);
spirv_builder_emit_store(&ctx->builder, ptr, result);
}
@@ -1212,12 +1228,25 @@ emit_jump(struct ntv_context *ctx, nir_jump_instr *jump)
}
static void
-emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
+emit_deref_var(struct ntv_context *ctx, nir_deref_instr *deref)
{
assert(deref->deref_type == nir_deref_type_var);
+ struct hash_entry *he = _mesa_hash_table_search(ctx->vars, deref->var);
+ assert(he);
+ SpvId result = (SpvId)(intptr_t)he->data;
+ /* uint is a bit of a lie here, it's really just an opaque type */
+ store_dest_uint(ctx, &deref->dest, result);
+}
+
+static void
+emit_deref_array(struct ntv_context *ctx, nir_deref_instr *deref)
+{
+ assert(deref->deref_type == nir_deref_type_array);
+ nir_variable *var = nir_deref_instr_get_variable(deref);
+
SpvStorageClass storage_class;
- switch (deref->var->data.mode) {
+ switch (var->data.mode) {
case nir_var_shader_in:
storage_class = SpvStorageClassInput;
break;
@@ -1230,8 +1259,7 @@ emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
unreachable("Unsupported nir_variable_mode\n");
}
- struct hash_entry *he = _mesa_hash_table_search(ctx->vars, deref->var);
- assert(he);
+ SpvId index = get_src_uint(ctx, &deref->arr.index);
SpvId ptr_type = spirv_builder_type_pointer(&ctx->builder,
storage_class,
@@ -1239,13 +1267,30 @@ emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
SpvId result = spirv_builder_emit_access_chain(&ctx->builder,
ptr_type,
- (SpvId)(intptr_t)he->data,
- NULL, 0);
+ get_src_uint(ctx, &deref->parent),
+ &index, 1);
/* uint is a bit of a lie here, it's really just an opaque type */
store_dest_uint(ctx, &deref->dest, result);
}
static void
+emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
+{
+ switch (deref->deref_type) {
+ case nir_deref_type_var:
+ emit_deref_var(ctx, deref);
+ break;
+
+ case nir_deref_type_array:
+ emit_deref_array(ctx, deref);
+ break;
+
+ default:
+ unreachable("unexpected deref_type");
+ }
+}
+
+static void
emit_block(struct ntv_context *ctx, struct nir_block *block)
{
start_block(ctx, block_label(ctx, block));
@@ -1279,8 +1324,7 @@ emit_block(struct ntv_context *ctx, struct nir_block *block)
unreachable("nir_instr_type_parallel_copy not supported");
break;
case nir_instr_type_deref:
- /* these are handled in emit_{load,store}_deref */
- /* emit_deref(ctx, nir_instr_as_deref(instr)); */
+ emit_deref(ctx, nir_instr_as_deref(instr));
break;
}
}
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 06215132ca9..db9f9d3a9a2 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -276,8 +276,12 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
return 1;
+ case PIPE_CAP_NIR_COMPACT_ARRAYS:
+ return 1;
+
case PIPE_CAP_FLATSHADE:
case PIPE_CAP_ALPHA_TEST:
+ case PIPE_CAP_CLIP_PLANES:
return 0;
default: