summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/ir_opt/texture_pass.cpp
diff options
context:
space:
mode:
authorGravatar Fernando S2022-08-31 10:40:45 +0200
committerGravatar GitHub2022-08-31 10:40:45 +0200
commita83a5d2e4c8932df864dd4cea2b04d87a12c8760 (patch)
tree53bd0ce10e965110c7811bd227443fd51e054eff /src/shader_recompiler/ir_opt/texture_pass.cpp
parentMerge pull request #8809 from german77/finally_is_fixed (diff)
parentvideo_code: support rectangle texture (diff)
downloadyuzu-a83a5d2e4c8932df864dd4cea2b04d87a12c8760.tar.gz
yuzu-a83a5d2e4c8932df864dd4cea2b04d87a12c8760.tar.xz
yuzu-a83a5d2e4c8932df864dd4cea2b04d87a12c8760.zip
Merge pull request #8752 from vonchenplus/rectangle_texture
video_code: support rectangle texture
Diffstat (limited to 'src/shader_recompiler/ir_opt/texture_pass.cpp')
-rw-r--r--src/shader_recompiler/ir_opt/texture_pass.cpp23
1 files changed, 23 insertions, 0 deletions
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
366void 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
367void TexturePass(Environment& env, IR::Program& program) { 382void 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;