summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl
diff options
context:
space:
mode:
authorGravatar liamwhite2023-01-29 12:27:26 -0500
committerGravatar GitHub2023-01-29 12:27:26 -0500
commit208e635f370d7cf90b80e9a5301f161283eefd8b (patch)
tree830bb769857629e25b0e43fefd79d8bfe0b231e9 /src/shader_recompiler/backend/glsl
parentMerge pull request #9684 from liamwhite/read-the-spec (diff)
parentshader_recompiler: TXQ: Skip QueryLevels when possible (diff)
downloadyuzu-208e635f370d7cf90b80e9a5301f161283eefd8b.tar.gz
yuzu-208e635f370d7cf90b80e9a5301f161283eefd8b.tar.xz
yuzu-208e635f370d7cf90b80e9a5301f161283eefd8b.zip
Merge pull request #9694 from ameerj/txq-mips
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.cpp20
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_instructions.h2
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 d8874b0cc..4be2c25ec 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp
@@ -460,27 +460,27 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
460} 460}
461 461
462void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 462void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
463 std::string_view lod) { 463 std::string_view lod, const IR::Value& skip_mips_val) {
464 const auto info{inst.Flags<IR::TextureInstInfo>()}; 464 const auto info{inst.Flags<IR::TextureInstInfo>()};
465 const auto texture{Texture(ctx, info, index)}; 465 const auto texture{Texture(ctx, info, index)};
466 const bool skip_mips{skip_mips_val.U1()};
467 const auto mips{
468 [&] { return skip_mips ? "0u" : fmt::format("uint(textureQueryLevels({}))", texture); }};
466 switch (info.type) { 469 switch (info.type) {
467 case TextureType::Color1D: 470 case TextureType::Color1D:
468 return ctx.AddU32x4( 471 return ctx.AddU32x4("{}=uvec4(uint(textureSize({},int({}))),0u,0u,{});", inst, texture, lod,
469 "{}=uvec4(uint(textureSize({},int({}))),0u,0u,uint(textureQueryLevels({})));", inst, 472 mips());
470 texture, lod, texture);
471 case TextureType::ColorArray1D: 473 case TextureType::ColorArray1D:
472 case TextureType::Color2D: 474 case TextureType::Color2D:
473 case TextureType::ColorCube: 475 case TextureType::ColorCube:
474 case TextureType::Color2DRect: 476 case TextureType::Color2DRect:
475 return ctx.AddU32x4( 477 return ctx.AddU32x4("{}=uvec4(uvec2(textureSize({},int({}))),0u,{});", inst, texture, lod,
476 "{}=uvec4(uvec2(textureSize({},int({}))),0u,uint(textureQueryLevels({})));", inst, 478 mips());
477 texture, lod, texture);
478 case TextureType::ColorArray2D: 479 case TextureType::ColorArray2D:
479 case TextureType::Color3D: 480 case TextureType::Color3D:
480 case TextureType::ColorArrayCube: 481 case TextureType::ColorArrayCube:
481 return ctx.AddU32x4( 482 return ctx.AddU32x4("{}=uvec4(uvec3(textureSize({},int({}))),{});", inst, texture, lod,
482 "{}=uvec4(uvec3(textureSize({},int({}))),uint(textureQueryLevels({})));", inst, texture, 483 mips());
483 lod, texture);
484 case TextureType::Buffer: 484 case TextureType::Buffer:
485 throw NotImplementedException("EmitImageQueryDimensions Texture buffers"); 485 throw NotImplementedException("EmitImageQueryDimensions Texture buffers");
486 } 486 }
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
index c6df1dba7..8d0a65047 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
@@ -654,7 +654,7 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
654 std::string_view coords, std::string_view offset, std::string_view lod, 654 std::string_view coords, std::string_view offset, std::string_view lod,
655 std::string_view ms); 655 std::string_view ms);
656void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 656void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
657 std::string_view lod); 657 std::string_view lod, const IR::Value& skip_mips);
658void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 658void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
659 std::string_view coords); 659 std::string_view coords);
660void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, 660void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,