diff options
author | Mike Blumenkrantz <[email protected]> | 2020-06-11 15:22:53 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-15 15:36:06 +0000 |
commit | f90bc6daa973b3d762d87254bf4cbe2a71475fda (patch) | |
tree | 17bf00fcd33ebfd6d047d204c85ac87afc81071a /src/gallium | |
parent | 9b6a8d17424ac5fa11ccf44c02da2a237088cb76 (diff) |
zink: handle more glsl->spirv builtin translation
this should be all of them, though the check for vertex shader stage needs
to be changed to !fragment stage at some point
Reviewed-by: Erik Faye-Lund <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5432>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 36 |
1 files changed, 22 insertions, 14 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 12f82b4e6e0..881103c1432 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 @@ -220,6 +220,12 @@ get_glsl_type(struct ntv_context *ctx, const struct glsl_type *type) unreachable("we shouldn't get here, I think..."); } +#define HANDLE_EMIT_BUILTIN(SLOT, BUILTIN) \ + case VARYING_SLOT_##SLOT: \ + spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltIn##BUILTIN); \ + break + + static void emit_input(struct ntv_context *ctx, struct nir_variable *var) { @@ -247,13 +253,14 @@ emit_input(struct ntv_context *ctx, struct nir_variable *var) var->data.location); } else { switch (var->data.location) { - case VARYING_SLOT_POS: - spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInFragCoord); - break; - - case VARYING_SLOT_PNTC: - spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointCoord); - break; + HANDLE_EMIT_BUILTIN(POS, FragCoord); + HANDLE_EMIT_BUILTIN(PNTC, PointCoord); + HANDLE_EMIT_BUILTIN(LAYER, Layer); + HANDLE_EMIT_BUILTIN(PRIMITIVE_ID, PrimitiveId); + HANDLE_EMIT_BUILTIN(CLIP_DIST0, ClipDistance); + HANDLE_EMIT_BUILTIN(CULL_DIST0, CullDistance); + HANDLE_EMIT_BUILTIN(VIEWPORT, ViewportIndex); + HANDLE_EMIT_BUILTIN(FACE, FrontFacing); default: debug_printf("unknown varying slot: %s\n", gl_varying_slot_name(var->data.location)); @@ -305,13 +312,14 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var) var->data.location); } else { switch (var->data.location) { - case VARYING_SLOT_POS: - spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPosition); - break; - - case VARYING_SLOT_PSIZ: - spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInPointSize); - break; + HANDLE_EMIT_BUILTIN(POS, Position); + HANDLE_EMIT_BUILTIN(PSIZ, PointSize); + HANDLE_EMIT_BUILTIN(LAYER, Layer); + HANDLE_EMIT_BUILTIN(PRIMITIVE_ID, PrimitiveId); + HANDLE_EMIT_BUILTIN(CULL_DIST0, CullDistance); + HANDLE_EMIT_BUILTIN(VIEWPORT, ViewportIndex); + HANDLE_EMIT_BUILTIN(TESS_LEVEL_OUTER, TessLevelOuter); + HANDLE_EMIT_BUILTIN(TESS_LEVEL_INNER, TessLevelInner); case VARYING_SLOT_CLIP_DIST0: assert(glsl_type_is_array(var->type)); |