diff options
author | Connor Abbott <cwabbott0@gmail.com> | 2024-04-08 06:02:21 -0400 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-04-23 15:22:19 +0000 |
commit | 7a1779edc7fb82c891e584074b95d1a4801c1782 (patch) | |
tree | 38ac23b0163c9ec709a81b88df66d2e11be5664a | |
parent | 56607fafc2c94602c42eaa0505cb9a3b4231c6cc (diff) |
ir3: Don't pack FS inlocs
Thanks to transform feedback, we don't know which varying components
will be used when compiling the FS. The VS could use additional
components for xfb, and packing the inlocs per-component would result in
overlapping varyings. In order to do this properly, we'd need to create
a variant for the FS when used with xfb.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28626>
-rw-r--r-- | src/freedreno/ci/freedreno-a618-fails.txt | 2 | ||||
-rw-r--r-- | src/freedreno/ci/freedreno-a630-fails.txt | 2 | ||||
-rw-r--r-- | src/freedreno/ir3/ir3_compiler_nir.c | 29 |
3 files changed, 28 insertions, 5 deletions
diff --git a/src/freedreno/ci/freedreno-a618-fails.txt b/src/freedreno/ci/freedreno-a618-fails.txt index 30a2e1725ae..13cecb2bde2 100644 --- a/src/freedreno/ci/freedreno-a618-fails.txt +++ b/src/freedreno/ci/freedreno-a618-fails.txt @@ -202,8 +202,6 @@ spec@ext_texture_snorm@fbo-generatemipmap-formats@GL_LUMINANCE16_SNORM NPOT,Fail spec@ext_texture_snorm@multisample-formats 2 gl_ext_texture_snorm,Fail spec@ext_texture_snorm@multisample-formats 4 gl_ext_texture_snorm,Fail -spec@ext_transform_feedback@structs struct-array-elem run,Fail -spec@ext_transform_feedback@structs struct-array-elem run interface,Fail spec@ext_transform_feedback@tessellation triangle_fan flat_first,Fail spec@ext_transform_feedback@tessellation triangle_strip flat_first,Fail spec@glsl-1.30@execution@texelfetch fs sampler3d 1x129x9-98x129x9,Fail diff --git a/src/freedreno/ci/freedreno-a630-fails.txt b/src/freedreno/ci/freedreno-a630-fails.txt index 107cc0faab5..3e780b58464 100644 --- a/src/freedreno/ci/freedreno-a630-fails.txt +++ b/src/freedreno/ci/freedreno-a630-fails.txt @@ -208,8 +208,6 @@ spec@ext_texture_snorm@fbo-generatemipmap-formats@GL_LUMINANCE16_SNORM NPOT,Fail spec@ext_texture_snorm@multisample-formats 2 gl_ext_texture_snorm,Fail spec@ext_texture_snorm@multisample-formats 4 gl_ext_texture_snorm,Fail -spec@ext_transform_feedback@structs struct-array-elem run,Fail -spec@ext_transform_feedback@structs struct-array-elem run interface,Fail spec@ext_transform_feedback@tessellation triangle_fan flat_first,Fail spec@ext_transform_feedback@tessellation triangle_strip flat_first,Fail spec@glsl-1.30@execution@texelfetch fs sampler3d 1x129x9-98x129x9,Fail diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index fe826b789ca..2dac010618c 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -4161,6 +4161,23 @@ setup_input(struct ir3_context *ctx, nir_intrinsic_instr *intr) compile_assert(ctx, ctx->so->type == MESA_SHADER_FRAGMENT || ctx->so->type == MESA_SHADER_VERTEX); + /* for clip+cull distances, unused components can't be eliminated because + * they're read by fixed-function, even if there's a hole. Note that + * clip/cull distance arrays must be declared in the FS, so we can just + * use the NIR clip/cull distances to avoid reading ucp_enables in the + * shader key. + */ + if (ctx->so->type == MESA_SHADER_FRAGMENT && + (slot == VARYING_SLOT_CLIP_DIST0 || + slot == VARYING_SLOT_CLIP_DIST1)) { + unsigned clip_cull_mask = so->clip_mask | so->cull_mask; + + if (slot == VARYING_SLOT_CLIP_DIST0) + compmask = clip_cull_mask & 0xf; + else + compmask = clip_cull_mask >> 4; + } + /* for a4xx+ rasterflat */ if (so->inputs[n].rasterflat && ctx->so->key.rasterflat) coord = NULL; @@ -4185,6 +4202,9 @@ setup_input(struct ir3_context *ctx, nir_intrinsic_instr *intr) if (slot == VARYING_SLOT_PRIMITIVE_ID) so->reads_primid = true; + + so->inputs[n].inloc = 4 * n; + so->varying_in = MAX2(so->varying_in, 4 * n + 4); } else { struct ir3_instruction *input = NULL; @@ -4282,6 +4302,8 @@ pack_inlocs(struct ir3_context *ctx) */ unsigned clip_cull_mask = so->clip_mask | so->cull_mask; + so->varying_in = 0; + for (unsigned i = 0; i < so->inputs_count; i++) { unsigned compmask = 0, maxcomp = 0; @@ -5151,7 +5173,12 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, IR3_PASS(ir, ir3_legalize_relative); IR3_PASS(ir, ir3_lower_subgroups); - if (so->type == MESA_SHADER_FRAGMENT) + /* This isn't valid to do when transform feedback is done in HW, which is + * a4xx onward, because the VS may use components not read by the FS for + * transform feedback. Ideally we'd delete this, but a5xx and earlier seem to + * be broken without it. + */ + if (so->type == MESA_SHADER_FRAGMENT && ctx->compiler->gen < 6) pack_inlocs(ctx); /* |