diff options
Diffstat (limited to 'src/shader_recompiler/backend')
6 files changed, 19 insertions, 16 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index cf6065208..b7bc11416 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -532,7 +532,7 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 534 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 535 | ScalarS32 lod) { | 535 | ScalarS32 lod, [[maybe_unused]] const IR::Value& skip_mips) { |
| 536 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 536 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 537 | const std::string texture{Texture(ctx, info, index)}; | 537 | const std::string texture{Texture(ctx, info, index)}; |
| 538 | const std::string_view type{TextureType(info)}; | 538 | const std::string_view type{TextureType(info)}; |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h index 415a249e4..1a1ea61d5 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h +++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h | |||
| @@ -581,7 +581,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde | |||
| 581 | void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 581 | void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 582 | const IR::Value& coord, const IR::Value& offset, ScalarS32 lod, ScalarS32 ms); | 582 | const IR::Value& coord, const IR::Value& offset, ScalarS32 lod, ScalarS32 ms); |
| 583 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 583 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 584 | ScalarS32 lod); | 584 | ScalarS32 lod, const IR::Value& skip_mips); |
| 585 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord); | 585 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord); |
| 586 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 586 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 587 | const IR::Value& coord, const IR::Value& derivatives, | 587 | const IR::Value& coord, const IR::Value& derivatives, |
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 | ||
| 462 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 462 | void 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); |
| 656 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 656 | void 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); |
| 658 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 658 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 659 | std::string_view coords); | 659 | std::string_view coords); |
| 660 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 660 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index c898ce12f..3b969d915 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -445,11 +445,13 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c | |||
| 445 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); | 445 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod) { | 448 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, |
| 449 | const IR::Value& skip_mips_val) { | ||
| 449 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 450 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 450 | const Id image{TextureImage(ctx, info, index)}; | 451 | const Id image{TextureImage(ctx, info, index)}; |
| 451 | const Id zero{ctx.u32_zero_value}; | 452 | const Id zero{ctx.u32_zero_value}; |
| 452 | const auto mips{[&] { return ctx.OpImageQueryLevels(ctx.U32[1], image); }}; | 453 | const bool skip_mips{skip_mips_val.U1()}; |
| 454 | const auto mips{[&] { return skip_mips ? zero : ctx.OpImageQueryLevels(ctx.U32[1], image); }}; | ||
| 453 | switch (info.type) { | 455 | switch (info.type) { |
| 454 | case TextureType::Color1D: | 456 | case TextureType::Color1D: |
| 455 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod), | 457 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod), |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index db12e8176..a440b557d 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -539,7 +539,8 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, | |||
| 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); | 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); |
| 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, |
| 541 | Id lod, Id ms); | 541 | Id lod, Id ms); |
| 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod); | 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, |
| 543 | const IR::Value& skip_mips); | ||
| 543 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |
| 544 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 545 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 545 | Id derivates, Id offset, Id lod_clamp); | 546 | Id derivates, Id offset, Id lod_clamp); |