diff options
| author | 2023-01-28 16:09:58 -0500 | |
|---|---|---|
| committer | 2023-01-28 16:25:18 -0500 | |
| commit | 2c2e019a44e353921d5fdf3cc6ab4304502eb2bd (patch) | |
| tree | 37c9582394bca3fe15fe2827d82f4b0da4e450a8 /src/shader_recompiler/backend/glsl | |
| parent | Merge pull request #9685 from liamwhite/minmax (diff) | |
| download | yuzu-2c2e019a44e353921d5fdf3cc6ab4304502eb2bd.tar.gz yuzu-2c2e019a44e353921d5fdf3cc6ab4304502eb2bd.tar.xz yuzu-2c2e019a44e353921d5fdf3cc6ab4304502eb2bd.zip | |
shader_recompiler: TXQ: Skip QueryLevels when possible
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | 20 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index cecdbb9d6..a7e433f7d 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -455,27 +455,27 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 457 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 458 | std::string_view lod) { | 458 | std::string_view lod, const IR::Value& skip_mips_val) { |
| 459 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 459 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 460 | const auto texture{Texture(ctx, info, index)}; | 460 | const auto texture{Texture(ctx, info, index)}; |
| 461 | const bool skip_mips{skip_mips_val.U1()}; | ||
| 462 | const auto mips{ | ||
| 463 | [&] { return skip_mips ? "0u" : fmt::format("uint(textureQueryLevels({}))", texture); }}; | ||
| 461 | switch (info.type) { | 464 | switch (info.type) { |
| 462 | case TextureType::Color1D: | 465 | case TextureType::Color1D: |
| 463 | return ctx.AddU32x4( | 466 | return ctx.AddU32x4("{}=uvec4(uint(textureSize({},int({}))),0u,0u,{});", inst, texture, lod, |
| 464 | "{}=uvec4(uint(textureSize({},int({}))),0u,0u,uint(textureQueryLevels({})));", inst, | 467 | mips()); |
| 465 | texture, lod, texture); | ||
| 466 | case TextureType::ColorArray1D: | 468 | case TextureType::ColorArray1D: |
| 467 | case TextureType::Color2D: | 469 | case TextureType::Color2D: |
| 468 | case TextureType::ColorCube: | 470 | case TextureType::ColorCube: |
| 469 | case TextureType::Color2DRect: | 471 | case TextureType::Color2DRect: |
| 470 | return ctx.AddU32x4( | 472 | return ctx.AddU32x4("{}=uvec4(uvec2(textureSize({},int({}))),0u,{});", inst, texture, lod, |
| 471 | "{}=uvec4(uvec2(textureSize({},int({}))),0u,uint(textureQueryLevels({})));", inst, | 473 | mips()); |
| 472 | texture, lod, texture); | ||
| 473 | case TextureType::ColorArray2D: | 474 | case TextureType::ColorArray2D: |
| 474 | case TextureType::Color3D: | 475 | case TextureType::Color3D: |
| 475 | case TextureType::ColorArrayCube: | 476 | case TextureType::ColorArrayCube: |
| 476 | return ctx.AddU32x4( | 477 | return ctx.AddU32x4("{}=uvec4(uvec3(textureSize({},int({}))),{});", inst, texture, lod, |
| 477 | "{}=uvec4(uvec3(textureSize({},int({}))),uint(textureQueryLevels({})));", inst, texture, | 478 | mips()); |
| 478 | lod, texture); | ||
| 479 | case TextureType::Buffer: | 479 | case TextureType::Buffer: |
| 480 | throw NotImplementedException("EmitImageQueryDimensions Texture buffers"); | 480 | throw NotImplementedException("EmitImageQueryDimensions Texture buffers"); |
| 481 | } | 481 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 4151c89de..02f91f2f4 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -655,7 +655,7 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 655 | std::string_view coords, std::string_view offset, std::string_view lod, | 655 | std::string_view coords, std::string_view offset, std::string_view lod, |
| 656 | std::string_view ms); | 656 | std::string_view ms); |
| 657 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 657 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 658 | std::string_view lod); | 658 | std::string_view lod, const IR::Value& skip_mips); |
| 659 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 659 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 660 | std::string_view coords); | 660 | std::string_view coords); |
| 661 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 661 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |