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 <alyssa.rosenzweig@collabora.com>
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 */
* 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;
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