diff options
Diffstat (limited to '')
3 files changed, 19 insertions, 8 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 3b969d915..02073c420 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -201,6 +201,13 @@ Id Image(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo info) { | |||
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | bool IsTextureMsaa(EmitContext& ctx, const IR::TextureInstInfo& info) { | ||
| 205 | if (info.type == TextureType::Buffer) { | ||
| 206 | return false; | ||
| 207 | } | ||
| 208 | return ctx.textures.at(info.descriptor_index).is_multisample; | ||
| 209 | } | ||
| 210 | |||
| 204 | Id Decorate(EmitContext& ctx, IR::Inst* inst, Id sample) { | 211 | Id Decorate(EmitContext& ctx, IR::Inst* inst, Id sample) { |
| 205 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 212 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 206 | if (info.relaxed_precision != 0) { | 213 | if (info.relaxed_precision != 0) { |
| @@ -452,24 +459,26 @@ Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& i | |||
| 452 | const Id zero{ctx.u32_zero_value}; | 459 | const Id zero{ctx.u32_zero_value}; |
| 453 | const bool skip_mips{skip_mips_val.U1()}; | 460 | const bool skip_mips{skip_mips_val.U1()}; |
| 454 | const auto mips{[&] { return skip_mips ? zero : ctx.OpImageQueryLevels(ctx.U32[1], image); }}; | 461 | const auto mips{[&] { return skip_mips ? zero : ctx.OpImageQueryLevels(ctx.U32[1], image); }}; |
| 462 | const bool is_msaa{IsTextureMsaa(ctx, info)}; | ||
| 463 | const bool uses_lod{!is_msaa && info.type != TextureType::Buffer}; | ||
| 464 | const auto query{[&](Id type) { | ||
| 465 | return uses_lod ? ctx.OpImageQuerySizeLod(type, image, lod) | ||
| 466 | : ctx.OpImageQuerySize(type, image); | ||
| 467 | }}; | ||
| 455 | switch (info.type) { | 468 | switch (info.type) { |
| 456 | case TextureType::Color1D: | 469 | case TextureType::Color1D: |
| 457 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod), | 470 | return ctx.OpCompositeConstruct(ctx.U32[4], query(ctx.U32[1]), zero, zero, mips()); |
| 458 | zero, zero, mips()); | ||
| 459 | case TextureType::ColorArray1D: | 471 | case TextureType::ColorArray1D: |
| 460 | case TextureType::Color2D: | 472 | case TextureType::Color2D: |
| 461 | case TextureType::ColorCube: | 473 | case TextureType::ColorCube: |
| 462 | case TextureType::Color2DRect: | 474 | case TextureType::Color2DRect: |
| 463 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[2], image, lod), | 475 | return ctx.OpCompositeConstruct(ctx.U32[4], query(ctx.U32[2]), zero, mips()); |
| 464 | zero, mips()); | ||
| 465 | case TextureType::ColorArray2D: | 476 | case TextureType::ColorArray2D: |
| 466 | case TextureType::Color3D: | 477 | case TextureType::Color3D: |
| 467 | case TextureType::ColorArrayCube: | 478 | case TextureType::ColorArrayCube: |
| 468 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[3], image, lod), | 479 | return ctx.OpCompositeConstruct(ctx.U32[4], query(ctx.U32[3]), mips()); |
| 469 | mips()); | ||
| 470 | case TextureType::Buffer: | 480 | case TextureType::Buffer: |
| 471 | return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySize(ctx.U32[1], image), zero, | 481 | return ctx.OpCompositeConstruct(ctx.U32[4], query(ctx.U32[1]), zero, zero, mips()); |
| 472 | zero, mips()); | ||
| 473 | } | 482 | } |
| 474 | throw LogicError("Unspecified image type {}", info.type.Value()); | 483 | throw LogicError("Unspecified image type {}", info.type.Value()); |
| 475 | } | 484 | } |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 3b97721e1..d48d4860e 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1288,6 +1288,7 @@ void EmitContext::DefineTextures(const Info& info, u32& binding, u32& scaling_in | |||
| 1288 | .pointer_type = pointer_type, | 1288 | .pointer_type = pointer_type, |
| 1289 | .image_type = image_type, | 1289 | .image_type = image_type, |
| 1290 | .count = desc.count, | 1290 | .count = desc.count, |
| 1291 | .is_multisample = desc.is_multisample, | ||
| 1291 | }); | 1292 | }); |
| 1292 | if (profile.supported_spirv >= 0x00010400) { | 1293 | if (profile.supported_spirv >= 0x00010400) { |
| 1293 | interfaces.push_back(id); | 1294 | interfaces.push_back(id); |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index dbc5c55b9..768a4fbb5 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h | |||
| @@ -35,6 +35,7 @@ struct TextureDefinition { | |||
| 35 | Id pointer_type; | 35 | Id pointer_type; |
| 36 | Id image_type; | 36 | Id image_type; |
| 37 | u32 count; | 37 | u32 count; |
| 38 | bool is_multisample; | ||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | struct TextureBufferDefinition { | 41 | struct TextureBufferDefinition { |