Skip to content

Commit 4a6e8a2

Browse files
committed
Fixed Grass and fur regression
1 parent a8f5424 commit 4a6e8a2

File tree

2 files changed

+68
-8
lines changed

2 files changed

+68
-8
lines changed

src/shader_recompiler/frontend/translate/translate.cpp

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,74 @@ void Translator::EmitPrologue() {
7777
ir.SetVectorReg(IR::VectorReg::V3, ir.GetAttributeU32(IR::Attribute::PrimitiveId));
7878
break;
7979
case LogicalStage::Fragment:
80-
// https://github.com/chaotic-cx/mesa-mirror/blob/72326e15/src/amd/vulkan/radv_shader_args.c#L258
81-
// The first two VGPRs are used for i/j barycentric coordinates. In the vast majority of
82-
// cases it will be only those two, but if shader is using both e.g linear and perspective
83-
// inputs it can be more For now assume that this isn't the case.
84-
dst_vreg = IR::VectorReg::V2;
85-
for (u32 i = 0; i < 4; i++) {
86-
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, i));
80+
dst_vreg = IR::VectorReg::V0;
81+
if (runtime_info.fs_info.addr_flags.persp_sample_ena) {
82+
++dst_vreg; // I
83+
++dst_vreg; // J
84+
}
85+
if (runtime_info.fs_info.addr_flags.persp_center_ena) {
86+
++dst_vreg; // I
87+
++dst_vreg; // J
88+
}
89+
if (runtime_info.fs_info.addr_flags.persp_centroid_ena) {
90+
++dst_vreg; // I
91+
++dst_vreg; // J
92+
}
93+
if (runtime_info.fs_info.addr_flags.persp_pull_model_ena) {
94+
++dst_vreg; // I/W
95+
++dst_vreg; // J/W
96+
++dst_vreg; // 1/W
97+
}
98+
if (runtime_info.fs_info.addr_flags.linear_sample_ena) {
99+
++dst_vreg; // I
100+
++dst_vreg; // J
101+
}
102+
if (runtime_info.fs_info.addr_flags.linear_center_ena) {
103+
++dst_vreg; // I
104+
++dst_vreg; // J
105+
}
106+
if (runtime_info.fs_info.addr_flags.linear_centroid_ena) {
107+
++dst_vreg; // I
108+
++dst_vreg; // J
109+
}
110+
if (runtime_info.fs_info.addr_flags.line_stipple_tex_ena) {
111+
++dst_vreg;
112+
}
113+
if (runtime_info.fs_info.addr_flags.pos_x_float_ena) {
114+
if (runtime_info.fs_info.en_flags.pos_x_float_ena) {
115+
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 0));
116+
} else {
117+
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
118+
}
119+
}
120+
if (runtime_info.fs_info.addr_flags.pos_y_float_ena) {
121+
if (runtime_info.fs_info.en_flags.pos_y_float_ena) {
122+
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 1));
123+
} else {
124+
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
125+
}
126+
}
127+
if (runtime_info.fs_info.addr_flags.pos_z_float_ena) {
128+
if (runtime_info.fs_info.en_flags.pos_z_float_ena) {
129+
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 2));
130+
} else {
131+
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
132+
}
133+
}
134+
if (runtime_info.fs_info.addr_flags.pos_w_float_ena) {
135+
if (runtime_info.fs_info.en_flags.pos_w_float_ena) {
136+
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 3));
137+
} else {
138+
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
139+
}
140+
}
141+
if (runtime_info.fs_info.addr_flags.front_face_ena) {
142+
if (runtime_info.fs_info.en_flags.front_face_ena) {
143+
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::IsFrontFace));
144+
} else {
145+
ir.SetVectorReg(dst_vreg++, ir.Imm32(0));
146+
}
87147
}
88-
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::IsFrontFace));
89148
break;
90149
case LogicalStage::Compute:
91150
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::LocalInvocationId, 0));

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,7 @@ static_assert(GFX6_3D_REG_INDEX(viewports) == 0xA10F);
14751475
static_assert(GFX6_3D_REG_INDEX(clip_user_data) == 0xA16F);
14761476
static_assert(GFX6_3D_REG_INDEX(ps_inputs) == 0xA191);
14771477
static_assert(GFX6_3D_REG_INDEX(vs_output_config) == 0xA1B1);
1478+
static_assert(GFX6_3D_REG_INDEX(num_interp) == 0xA1B6);
14781479
static_assert(GFX6_3D_REG_INDEX(ps_input_ena) == 0xA1B3);
14791480
static_assert(GFX6_3D_REG_INDEX(ps_input_addr) == 0xA1B4);
14801481
static_assert(GFX6_3D_REG_INDEX(num_interp) == 0xA1B6);

0 commit comments

Comments
 (0)