diff options
Diffstat (limited to 'src/shader_recompiler/ir_opt')
| -rw-r--r-- | src/shader_recompiler/ir_opt/rescaling_pass.cpp | 7 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/texture_pass.cpp | 23 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/shader_recompiler/ir_opt/rescaling_pass.cpp b/src/shader_recompiler/ir_opt/rescaling_pass.cpp index 0d5f2e4d8..9198fa5f2 100644 --- a/src/shader_recompiler/ir_opt/rescaling_pass.cpp +++ b/src/shader_recompiler/ir_opt/rescaling_pass.cpp | |||
| @@ -16,6 +16,7 @@ namespace { | |||
| 16 | switch (type) { | 16 | switch (type) { |
| 17 | case TextureType::Color2D: | 17 | case TextureType::Color2D: |
| 18 | case TextureType::ColorArray2D: | 18 | case TextureType::ColorArray2D: |
| 19 | case TextureType::Color2DRect: | ||
| 19 | return true; | 20 | return true; |
| 20 | case TextureType::Color1D: | 21 | case TextureType::Color1D: |
| 21 | case TextureType::ColorArray1D: | 22 | case TextureType::ColorArray1D: |
| @@ -132,7 +133,8 @@ void PatchImageQueryDimensions(IR::Block& block, IR::Inst& inst) { | |||
| 132 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; | 133 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; |
| 133 | switch (info.type) { | 134 | switch (info.type) { |
| 134 | case TextureType::Color2D: | 135 | case TextureType::Color2D: |
| 135 | case TextureType::ColorArray2D: { | 136 | case TextureType::ColorArray2D: |
| 137 | case TextureType::Color2DRect: { | ||
| 136 | const IR::Value new_inst{&*block.PrependNewInst(it, inst)}; | 138 | const IR::Value new_inst{&*block.PrependNewInst(it, inst)}; |
| 137 | const IR::U32 width{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 0)})}; | 139 | const IR::U32 width{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 0)})}; |
| 138 | const IR::U32 height{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 1)})}; | 140 | const IR::U32 height{DownScale(ir, is_scaled, IR::U32{ir.CompositeExtract(new_inst, 1)})}; |
| @@ -163,6 +165,7 @@ void ScaleIntegerComposite(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_s | |||
| 163 | const IR::U32 y{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 1)})}; | 165 | const IR::U32 y{Scale(ir, is_scaled, IR::U32{ir.CompositeExtract(composite, 1)})}; |
| 164 | switch (info.type) { | 166 | switch (info.type) { |
| 165 | case TextureType::Color2D: | 167 | case TextureType::Color2D: |
| 168 | case TextureType::Color2DRect: | ||
| 166 | inst.SetArg(index, ir.CompositeConstruct(x, y)); | 169 | inst.SetArg(index, ir.CompositeConstruct(x, y)); |
| 167 | break; | 170 | break; |
| 168 | case TextureType::ColorArray2D: { | 171 | case TextureType::ColorArray2D: { |
| @@ -193,6 +196,7 @@ void ScaleIntegerOffsetComposite(IR::IREmitter& ir, IR::Inst& inst, const IR::U1 | |||
| 193 | switch (info.type) { | 196 | switch (info.type) { |
| 194 | case TextureType::ColorArray2D: | 197 | case TextureType::ColorArray2D: |
| 195 | case TextureType::Color2D: | 198 | case TextureType::Color2D: |
| 199 | case TextureType::Color2DRect: | ||
| 196 | inst.SetArg(index, ir.CompositeConstruct(x, y)); | 200 | inst.SetArg(index, ir.CompositeConstruct(x, y)); |
| 197 | break; | 201 | break; |
| 198 | case TextureType::Color1D: | 202 | case TextureType::Color1D: |
| @@ -216,6 +220,7 @@ void SubScaleCoord(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled) { | |||
| 216 | const IR::U32 scaled_y{SubScale(ir, is_scaled, coord_y, IR::Attribute::PositionY)}; | 220 | const IR::U32 scaled_y{SubScale(ir, is_scaled, coord_y, IR::Attribute::PositionY)}; |
| 217 | switch (info.type) { | 221 | switch (info.type) { |
| 218 | case TextureType::Color2D: | 222 | case TextureType::Color2D: |
| 223 | case TextureType::Color2DRect: | ||
| 219 | inst.SetArg(1, ir.CompositeConstruct(scaled_x, scaled_y)); | 224 | inst.SetArg(1, ir.CompositeConstruct(scaled_x, scaled_y)); |
| 220 | break; | 225 | break; |
| 221 | case TextureType::ColorArray2D: { | 226 | case TextureType::ColorArray2D: { |
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index ca3e306e8..5cead5135 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp | |||
| @@ -362,6 +362,21 @@ private: | |||
| 362 | TextureDescriptors& texture_descriptors; | 362 | TextureDescriptors& texture_descriptors; |
| 363 | ImageDescriptors& image_descriptors; | 363 | ImageDescriptors& image_descriptors; |
| 364 | }; | 364 | }; |
| 365 | |||
| 366 | void PatchImageSampleImplicitLod(IR::Block& block, IR::Inst& inst) { | ||
| 367 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 368 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 369 | const IR::Value coord(inst.Arg(1)); | ||
| 370 | const IR::Value handle(ir.Imm32(0)); | ||
| 371 | const IR::U32 lod{ir.Imm32(0)}; | ||
| 372 | const IR::Value texture_size = ir.ImageQueryDimension(handle, lod, info); | ||
| 373 | inst.SetArg( | ||
| 374 | 1, ir.CompositeConstruct( | ||
| 375 | ir.FPMul(IR::F32(ir.CompositeExtract(coord, 0)), | ||
| 376 | ir.FPRecip(ir.ConvertUToF(32, 32, ir.CompositeExtract(texture_size, 0)))), | ||
| 377 | ir.FPMul(IR::F32(ir.CompositeExtract(coord, 1)), | ||
| 378 | ir.FPRecip(ir.ConvertUToF(32, 32, ir.CompositeExtract(texture_size, 1)))))); | ||
| 379 | } | ||
| 365 | } // Anonymous namespace | 380 | } // Anonymous namespace |
| 366 | 381 | ||
| 367 | void TexturePass(Environment& env, IR::Program& program) { | 382 | void TexturePass(Environment& env, IR::Program& program) { |
| @@ -399,6 +414,14 @@ void TexturePass(Environment& env, IR::Program& program) { | |||
| 399 | flags.type.Assign(ReadTextureType(env, cbuf)); | 414 | flags.type.Assign(ReadTextureType(env, cbuf)); |
| 400 | inst->SetFlags(flags); | 415 | inst->SetFlags(flags); |
| 401 | break; | 416 | break; |
| 417 | case IR::Opcode::ImageSampleImplicitLod: | ||
| 418 | if (flags.type == TextureType::Color2D) { | ||
| 419 | auto texture_type = ReadTextureType(env, cbuf); | ||
| 420 | if (texture_type == TextureType::Color2DRect) { | ||
| 421 | PatchImageSampleImplicitLod(*texture_inst.block, *texture_inst.inst); | ||
| 422 | } | ||
| 423 | } | ||
| 424 | break; | ||
| 402 | case IR::Opcode::ImageFetch: | 425 | case IR::Opcode::ImageFetch: |
| 403 | if (flags.type != TextureType::Color1D) { | 426 | if (flags.type != TextureType::Color1D) { |
| 404 | break; | 427 | break; |