Mesa (master): st/nir: Fix the st->pbo.use_gs case.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 4 18:16:06 UTC 2020
Module: Mesa
Branch: master
Commit: 9143c08125a33af56d4f05fd5161a572c0c6b4ac
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9143c08125a33af56d4f05fd5161a572c0c6b4ac
Author: Eric Anholt <eric at anholt.net>
Date: Mon Oct 26 12:11:40 2020 -0700
st/nir: Fix the st->pbo.use_gs case.
This case hadn't been ported to NIR before, and I missed that when
removing the TGSI path and replacing it with NIR -> NTT for TGSI drivers.
This caused breakage in nv50 on piglit's pbo-teximage.
In the process, the !use_gs gets its layer output fixed to be an int
instead of a vec4, which I suspect would fix validation in that path.
Fixes: 57effa342b75 ("st/mesa: Drop the TGSI paths for PBOs and use nir-to-tgsi if needed.")
Closes: #3680
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7320>
---
src/mesa/state_tracker/st_pbo.c | 47 +++++++++++++++++++++++++++++++++++------
1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 2f609c14320..2d86c359f7a 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -292,13 +292,48 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
void *
st_pbo_create_vs(struct st_context *st)
{
- unsigned inputs[] = { VERT_ATTRIB_POS, SYSTEM_VALUE_INSTANCE_ID, };
- unsigned outputs[] = { VARYING_SLOT_POS, VARYING_SLOT_LAYER };
+ const struct glsl_type *vec4 = glsl_vec4_type();
+ const nir_shader_compiler_options *options =
+ st_get_nir_compiler_options(st, MESA_SHADER_VERTEX);
+
+ nir_builder b;
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, options);
+
+ nir_variable *in_pos = nir_variable_create(b.shader, nir_var_shader_in,
+ vec4, "in_pos");
+ in_pos->data.location = VERT_ATTRIB_POS;
+
+ nir_variable *out_pos = nir_variable_create(b.shader, nir_var_shader_out,
+ vec4, "out_pos");
+ out_pos->data.location = VARYING_SLOT_POS;
+ out_pos->data.interpolation = INTERP_MODE_NONE;
+
+ nir_copy_var(&b, out_pos, in_pos);
+
+ if (st->pbo.layers) {
+ nir_variable *instance_id = nir_variable_create(b.shader,
+ nir_var_system_value,
+ glsl_int_type(),
+ "instance_id");
+ instance_id->data.location = SYSTEM_VALUE_INSTANCE_ID;
+
+ if (st->pbo.use_gs) {
+ unsigned swiz_x[4] = {0, 0, 0, 0};
+ nir_store_var(&b, out_pos,
+ nir_swizzle(&b, nir_i2f32(&b, nir_load_var(&b, instance_id)), swiz_x, 4),
+ (1 << 2));
+ } else {
+ nir_variable *out_layer = nir_variable_create(b.shader,
+ nir_var_shader_out,
+ glsl_int_type(),
+ "out_layer");
+ out_layer->data.location = VARYING_SLOT_LAYER;
+ out_layer->data.interpolation = INTERP_MODE_NONE;
+ nir_copy_var(&b, out_layer, instance_id);
+ }
+ }
- return st_nir_make_passthrough_shader(st, "st/pbo VS",
- MESA_SHADER_VERTEX,
- st->pbo.layers ? 2 : 1,
- inputs, outputs, NULL, (1 << 1));
+ return st_nir_finish_builtin_shader(st, b.shader, "st/pbo VS");
}
void *
More information about the mesa-commit
mailing list