asahi: plumb tri fan flatshading through common
not yet used in the GL driver but we should probably fix that. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:

committed by
Marge Bot

parent
cad60ab4b1
commit
c1d68da5e2
@@ -3335,9 +3335,6 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
||||
|
||||
bool needs_libagx = true /* TODO: Optimize */;
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
NIR_PASS(_, nir, agx_nir_lower_interpolation);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
|
||||
|
||||
if (needs_libagx) {
|
||||
|
@@ -234,6 +234,7 @@ void agx_link_libagx(nir_shader *nir, const nir_shader *libagx);
|
||||
void agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx);
|
||||
bool agx_nir_lower_discard_zs_emit(nir_shader *s);
|
||||
bool agx_nir_lower_sample_mask(nir_shader *s);
|
||||
bool agx_nir_lower_interpolation(nir_shader *s);
|
||||
|
||||
bool agx_nir_lower_cull_distance_fs(struct nir_shader *s,
|
||||
unsigned nr_distances);
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
struct nir_shader;
|
||||
|
||||
bool agx_nir_lower_interpolation(struct nir_shader *s);
|
||||
bool agx_nir_lower_algebraic_late(struct nir_shader *shader);
|
||||
bool agx_nir_fuse_selects(struct nir_shader *shader);
|
||||
bool agx_nir_fuse_algebraic_late(struct nir_shader *shader);
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "agx_nir.h"
|
||||
#include "agx_compile.h"
|
||||
#include "nir.h"
|
||||
#include "nir_builder.h"
|
||||
#include "nir_builder_opcodes.h"
|
||||
@@ -82,8 +82,14 @@ interpolate_at_offset(nir_builder *b, nir_def *cf, nir_def *offset,
|
||||
static nir_def *
|
||||
interpolate_flat(nir_builder *b, nir_def *coefficients)
|
||||
{
|
||||
/* Same value anywhere, so just take the constant (affine) component */
|
||||
return nir_channel(b, coefficients, 2);
|
||||
/* Same value anywhere, so just take the constant (affine) component. For
|
||||
* triangle fans with the first provoking vertex, the CF layout is slightly
|
||||
* different. I am unsure why, but Apple does the same and the bcsel is
|
||||
* required for corrctness.
|
||||
*/
|
||||
return nir_bcsel(b, nir_load_is_first_fan_agx(b),
|
||||
nir_channel(b, coefficients, 1),
|
||||
nir_channel(b, coefficients, 2));
|
||||
}
|
||||
|
||||
static enum glsl_interp_mode
|
||||
|
@@ -198,6 +198,9 @@ lower_intrinsic(nir_builder *b, nir_intrinsic_instr *intr,
|
||||
case nir_intrinsic_load_uvs_index_agx:
|
||||
return load_sysval_root(
|
||||
b, 1, 16, &u->uvs_index[nir_intrinsic_io_semantics(intr).location]);
|
||||
case nir_intrinsic_load_is_first_fan_agx:
|
||||
/* TODO: Plumb this so we can stop using geometry shaders for this case */
|
||||
return nir_imm_false(b);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -1564,6 +1564,10 @@ agx_compile_nir(struct agx_device *dev, nir_shader *nir,
|
||||
.secondary = secondary,
|
||||
};
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
NIR_PASS(_, nir, agx_nir_lower_interpolation);
|
||||
}
|
||||
|
||||
/* We always use dynamic sample shading in the GL driver. Indicate that. */
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT &&
|
||||
nir->info.fs.uses_sample_shading)
|
||||
@@ -4190,21 +4194,12 @@ agx_needs_passthrough_gs(struct agx_context *ctx,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Experimentally, G13 does not seem to pick the right provoking vertex for
|
||||
* triangle fans with first provoking. Inserting a GS for this case lets us
|
||||
* use our (correct) shader-based input assembly, translating to
|
||||
* appropriately oriented triangles and working around the hardware issue.
|
||||
* This warrants more investigation in case we're just misconfiguring the
|
||||
* hardware, but as tri fans are absent in Metal and GL defaults to last
|
||||
* vertex, this is a plausible part of the hardware to be broken (or absent).
|
||||
*
|
||||
* Affects piglit clipflat.
|
||||
*/
|
||||
/* TODO: Handle fans properly, we need to plumb a sysval. */
|
||||
if (info->mode == MESA_PRIM_TRIANGLE_FAN &&
|
||||
ctx->rast->base.flatshade_first &&
|
||||
ctx->stage[MESA_SHADER_FRAGMENT].shader->info.inputs_flat_shaded) {
|
||||
|
||||
perf_debug_ctx(ctx, "Using passthrough GS due to tri fan bug");
|
||||
perf_debug_ctx(ctx, "Using passthrough GS due to first tri fans");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user