summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ameerj2021-09-29 20:53:30 -0400
committerGravatar Fernando Sahmkow2021-11-16 22:11:30 +0100
commit581ea900627b398c2fa06b70facd5dcd8bbb7d68 (patch)
tree193101d5b64fadc1f4ee54dec4f23165a2015d03
parentTexture Cache: Fix Rescaling on Multisample (diff)
downloadyuzu-581ea900627b398c2fa06b70facd5dcd8bbb7d68.tar.gz
yuzu-581ea900627b398c2fa06b70facd5dcd8bbb7d68.tar.xz
yuzu-581ea900627b398c2fa06b70facd5dcd8bbb7d68.zip
rescaling_pass: Fix IR errors when unscalable texture types are encountered
-rw-r--r--src/shader_recompiler/ir_opt/rescaling_pass.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shader_recompiler/ir_opt/rescaling_pass.cpp b/src/shader_recompiler/ir_opt/rescaling_pass.cpp
index 0d642dd0d..a5fa4ee83 100644
--- a/src/shader_recompiler/ir_opt/rescaling_pass.cpp
+++ b/src/shader_recompiler/ir_opt/rescaling_pass.cpp
@@ -14,6 +14,22 @@
14 14
15namespace Shader::Optimization { 15namespace Shader::Optimization {
16namespace { 16namespace {
17[[nodiscard]] bool IsTextureTypeRescalable(TextureType type) {
18 switch (type) {
19 case TextureType::Color2D:
20 case TextureType::ColorArray2D:
21 return true;
22 case TextureType::Color1D:
23 case TextureType::ColorArray1D:
24 case TextureType::Color3D:
25 case TextureType::ColorCube:
26 case TextureType::ColorArrayCube:
27 case TextureType::Buffer:
28 break;
29 }
30 return false;
31}
32
17void VisitMark(const IR::Inst& inst) { 33void VisitMark(const IR::Inst& inst) {
18 switch (inst.GetOpcode()) { 34 switch (inst.GetOpcode()) {
19 case IR::Opcode::ShuffleIndex: 35 case IR::Opcode::ShuffleIndex:
@@ -179,6 +195,9 @@ void SubScaleCoord(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled) {
179void SubScaleImageFetch(IR::Block& block, IR::Inst& inst) { 195void SubScaleImageFetch(IR::Block& block, IR::Inst& inst) {
180 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; 196 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
181 const auto info{inst.Flags<IR::TextureInstInfo>()}; 197 const auto info{inst.Flags<IR::TextureInstInfo>()};
198 if (!IsTextureTypeRescalable(info.type)) {
199 return;
200 }
182 const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; 201 const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))};
183 SubScaleCoord(ir, inst, is_scaled); 202 SubScaleCoord(ir, inst, is_scaled);
184 // Scale ImageFetch offset 203 // Scale ImageFetch offset
@@ -188,6 +207,9 @@ void SubScaleImageFetch(IR::Block& block, IR::Inst& inst) {
188void SubScaleImageRead(IR::Block& block, IR::Inst& inst) { 207void SubScaleImageRead(IR::Block& block, IR::Inst& inst) {
189 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; 208 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
190 const auto info{inst.Flags<IR::TextureInstInfo>()}; 209 const auto info{inst.Flags<IR::TextureInstInfo>()};
210 if (!IsTextureTypeRescalable(info.type)) {
211 return;
212 }
191 const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))}; 213 const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))};
192 SubScaleCoord(ir, inst, is_scaled); 214 SubScaleCoord(ir, inst, is_scaled);
193} 215}
@@ -195,6 +217,9 @@ void SubScaleImageRead(IR::Block& block, IR::Inst& inst) {
195void PatchImageFetch(IR::Block& block, IR::Inst& inst) { 217void PatchImageFetch(IR::Block& block, IR::Inst& inst) {
196 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; 218 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
197 const auto info{inst.Flags<IR::TextureInstInfo>()}; 219 const auto info{inst.Flags<IR::TextureInstInfo>()};
220 if (!IsTextureTypeRescalable(info.type)) {
221 return;
222 }
198 const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; 223 const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))};
199 ScaleIntegerComposite(ir, inst, is_scaled, 1); 224 ScaleIntegerComposite(ir, inst, is_scaled, 1);
200 // Scale ImageFetch offset 225 // Scale ImageFetch offset
@@ -204,6 +229,9 @@ void PatchImageFetch(IR::Block& block, IR::Inst& inst) {
204void PatchImageRead(IR::Block& block, IR::Inst& inst) { 229void PatchImageRead(IR::Block& block, IR::Inst& inst) {
205 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; 230 IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
206 const auto info{inst.Flags<IR::TextureInstInfo>()}; 231 const auto info{inst.Flags<IR::TextureInstInfo>()};
232 if (!IsTextureTypeRescalable(info.type)) {
233 return;
234 }
207 const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))}; 235 const IR::U1 is_scaled{ir.IsImageScaled(ir.Imm32(info.descriptor_index))};
208 ScaleIntegerComposite(ir, inst, is_scaled, 1); 236 ScaleIntegerComposite(ir, inst, is_scaled, 1);
209} 237}