diff options
| author | 2022-08-10 10:10:32 +0800 | |
|---|---|---|
| committer | 2022-08-25 12:45:58 +0800 | |
| commit | b2a6dde4380a5526e9d936f92a9e3d6ad9393bfa (patch) | |
| tree | 0606caece955ac68899b71325b769a174af2f9f4 /src/shader_recompiler/ir_opt/texture_pass.cpp | |
| parent | Merge pull request #8734 from liamwhite/bors-is-my-best-friend (diff) | |
| download | yuzu-b2a6dde4380a5526e9d936f92a9e3d6ad9393bfa.tar.gz yuzu-b2a6dde4380a5526e9d936f92a9e3d6ad9393bfa.tar.xz yuzu-b2a6dde4380a5526e9d936f92a9e3d6ad9393bfa.zip | |
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.cpp | 23 |
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 | |||
| 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; |