diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c index 3b25f2633bd..3de652f949e 100644 --- a/src/compiler/nir/nir_lower_wpos_ytransform.c +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c @@ -24,11 +24,11 @@ #include "nir.h" #include "nir_builder.h" -/* Lower gl_FragCoord (and fddy) to account for driver's requested coordinate- +/* Lower gl_FragCoord (and ddy) to account for driver's requested coordinate- * origin and pixel-center vs. shader. If transformation is required, a * gl_FbWposYTransform uniform is inserted (with the specified state-slots) * and additional instructions are inserted to transform gl_FragCoord (and - * fddy src arg). + * ddy src arg). * * This is based on the logic in emit_wpos()/emit_wpos_adjustment() in TGSI * compiler. @@ -232,29 +232,7 @@ lower_fragcoord(lower_wpos_ytransform_state *state, nir_intrinsic_instr *intr) emit_wpos_adjustment(state, intr, invert, adjX, adjY); } -/* turns 'fddy(p)' into 'fddy(fmul(p, transform.x))' */ -static void -lower_fddy(lower_wpos_ytransform_state *state, nir_alu_instr *fddy) -{ - nir_builder *b = &state->b; - nir_def *p, *pt, *trans; - nir_def *wpostrans = get_transform(state); - - b->cursor = nir_before_instr(&fddy->instr); - - p = nir_ssa_for_alu_src(b, fddy, 0); - trans = nir_channel(b, wpostrans, 0); - if (p->bit_size == 16) - trans = nir_f2f16(b, trans); - - pt = nir_fmul(b, p, trans); - - nir_src_rewrite(&fddy->src[0].src, pt); - - for (unsigned i = 0; i < 4; i++) - fddy->src[0].swizzle[i] = MIN2(i, pt->num_components - 1); -} - +/* turns 'ddy(p)' into 'ddy(fmul(p, transform.x))' */ static void lower_ddy(lower_wpos_ytransform_state *state, nir_intrinsic_instr *ddy) { @@ -352,12 +330,6 @@ lower_wpos_ytransform_instr(nir_builder *b, nir_instr *instr, intr->intrinsic == nir_intrinsic_ddy_coarse) { lower_ddy(state, intr); } - } else if (instr->type == nir_instr_type_alu) { - nir_alu_instr *alu = nir_instr_as_alu(instr); - if (alu->op == nir_op_fddy || - alu->op == nir_op_fddy_fine || - alu->op == nir_op_fddy_coarse) - lower_fddy(state, alu); } return state->transform != NULL; diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index dd1d3165f9e..e0a9f76e1f5 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -348,19 +348,6 @@ unop("fcos", tfloat, "bit_size == 64 ? cos(src0) : cosf(src0)") unop_convert("frexp_exp", tint32, tfloat, "frexp(src0, &dst);") unop_convert("frexp_sig", tfloat, tfloat, "int n; dst = frexp(src0, &n);") -# Partial derivatives. -deriv_template = """ -Calculate the screen-space partial derivative using {} derivatives of the input -with respect to the {}-axis. The constant folding is trivial as the derivative -of a constant is 0 if the constant is not Inf or NaN. -""" - -for mode, suffix in [("either fine or coarse", ""), ("fine", "_fine"), ("coarse", "_coarse")]: - for axis in ["x", "y"]: - unop(f"fdd{axis}{suffix}", tfloat, "isfinite(src0) ? 0.0 : NAN", - algebraic_properties = derivative, - description = deriv_template.format(mode, axis.upper())) - # Floating point pack and unpack operations. def pack_2x16(fmt, in_type): diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index fceb1948f81..e014b2a5d0b 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2892,18 +2892,6 @@ for op in ['fadd', 'fmul', 'fmulz', 'iadd', 'imul']: ((op, ('bcsel(is_used_once)', a, '#b', c), '#d'), ('bcsel', a, (op, b, d), (op, c, d))) ] -# For derivatives in compute shaders, GLSL_NV_compute_shader_derivatives -# states: -# -# If neither layout qualifier is specified, derivatives in compute shaders -# return zero, which is consistent with the handling of built-in texture -# functions like texture() in GLSL 4.50 compute shaders. -for op in ['fddx', 'fddx_fine', 'fddx_coarse', - 'fddy', 'fddy_fine', 'fddy_coarse']: - optimizations += [ - ((op, 'a'), 0.0, 'info->stage == MESA_SHADER_COMPUTE && info->derivative_group == DERIVATIVE_GROUP_NONE') -] - # Some optimizations for ir3-specific instructions. optimizations += [ # 'al * bl': If either 'al' or 'bl' is zero, return zero.