diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-11-18 08:02:58 -0500 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-11-18 08:48:54 -0500 |
commit | 36633400499d109865eefd0e226fcd78cf33e02f (patch) | |
tree | 10cce0b2ed9451d5805c7760a4e389b201ea110d /src/panfrost | |
parent | 6f17fe0606a144f977d8b70a7ee9f8371abc144b (diff) |
pan/midgard: Use shader stage in mir_op_computes_derivative
A 'normal' texture op may be emitted in a vertex shader on T720 but it
still doesn't take any derivatives.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/midgard/compiler.h | 2 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_derivatives.c | 9 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_emit.c | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index 7e3f998ab4f..b308552e7c9 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -621,7 +621,7 @@ midgard_emit_derivatives(compiler_context *ctx, nir_alu_instr *instr); void midgard_lower_derivatives(compiler_context *ctx, midgard_block *block); -bool mir_op_computes_derivatives(unsigned op); +bool mir_op_computes_derivatives(gl_shader_stage stage, unsigned op); /* Final emission */ diff --git a/src/panfrost/midgard/midgard_derivatives.c b/src/panfrost/midgard/midgard_derivatives.c index ad12293dd33..ceb3bb96166 100644 --- a/src/panfrost/midgard/midgard_derivatives.c +++ b/src/panfrost/midgard/midgard_derivatives.c @@ -72,12 +72,19 @@ mir_derivative_op(nir_op op) * implicitly */ bool -mir_op_computes_derivatives(unsigned op) +mir_op_computes_derivatives(gl_shader_stage stage, unsigned op) { + /* Only fragment shaders may compute derivatives, but the sense of + * "normal" changes in vertex shaders on certain GPUs */ + + if (op == TEXTURE_OP_NORMAL && stage != MESA_SHADER_FRAGMENT) + return false; + switch (op) { case TEXTURE_OP_NORMAL: case TEXTURE_OP_DFDX: case TEXTURE_OP_DFDY: + assert(stage == MESA_SHADER_FRAGMENT); return true; default: return false; diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index 7559a34dcfb..63dcb41ad41 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -430,7 +430,7 @@ emit_binary_bundle(compiler_context *ctx, ctx->texture_op_count--; - if (mir_op_computes_derivatives(ins->texture.op)) { + if (mir_op_computes_derivatives(ctx->stage, ins->texture.op)) { bool continues = ctx->texture_op_count > 0; /* Control flow complicates helper invocation |