diff --git a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c index d03462c52c8..b3ccb7a429b 100644 --- a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c +++ b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c @@ -109,6 +109,7 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c) struct radeon_program_transformation native_rewrite_r300[] = { { &radeonTransformALU, 0 }, + { &radeonStubDeriv, 0 }, { &r300_transform_trig_simple, 0 }, { 0, 0 } }; diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c index 5178da1f1c8..3a2aecf71e2 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c @@ -1185,6 +1185,25 @@ int r300_transform_trig_scale_vertex(struct radeon_compiler *c, return 1; } +/** + * Replaces DDX/DDY instructions with MOV 0 to avoid using dummy shaders on r300/r400. + * + * @warning This explicitly changes the form of DDX and DDY! + */ + +int radeonStubDeriv(struct radeon_compiler* c, + struct rc_instruction* inst, + void* unused) +{ + if (inst->U.I.Opcode != RC_OPCODE_DDX && inst->U.I.Opcode != RC_OPCODE_DDY) + return 0; + + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000; + + return 1; +} + /** * Rewrite DDX/DDY instructions to properly work with r5xx shaders. * The r5xx MDH/MDV instruction provides per-quad partial derivatives. diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.h b/src/gallium/drivers/r300/compiler/radeon_program_alu.h index d1006827616..6f347d1c9f0 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.h +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.h @@ -55,6 +55,11 @@ int r300_transform_trig_scale_vertex( struct rc_instruction *inst, void*); +int radeonStubDeriv( + struct radeon_compiler * c, + struct rc_instruction * inst, + void*); + int radeonTransformDeriv( struct radeon_compiler * c, struct rc_instruction * inst,