diff options
| author | 2023-12-19 10:55:56 -0500 | |
|---|---|---|
| committer | 2023-12-21 14:34:46 -0500 | |
| commit | 9e9aed41bebc1b7d29dbfcddcc203693bcdc680e (patch) | |
| tree | 5f2cae1f65daf7cdd0b1978e48764747177d949d /src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |
| parent | Merge pull request #12424 from t895/vsync-per-game-qt (diff) | |
| download | yuzu-9e9aed41bebc1b7d29dbfcddcc203693bcdc680e.tar.gz yuzu-9e9aed41bebc1b7d29dbfcddcc203693bcdc680e.tar.xz yuzu-9e9aed41bebc1b7d29dbfcddcc203693bcdc680e.zip | |
shader_recompiler: use float image operations on load/store when required
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_image.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 22ceca19c..800754554 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -214,16 +214,16 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | Id Image(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo info) { | 217 | std::pair<Id, bool> Image(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo info) { |
| 218 | if (!index.IsImmediate() || index.U32() != 0) { | 218 | if (!index.IsImmediate() || index.U32() != 0) { |
| 219 | throw NotImplementedException("Indirect image indexing"); | 219 | throw NotImplementedException("Indirect image indexing"); |
| 220 | } | 220 | } |
| 221 | if (info.type == TextureType::Buffer) { | 221 | if (info.type == TextureType::Buffer) { |
| 222 | const ImageBufferDefinition def{ctx.image_buffers.at(info.descriptor_index)}; | 222 | const ImageBufferDefinition def{ctx.image_buffers.at(info.descriptor_index)}; |
| 223 | return ctx.OpLoad(def.image_type, def.id); | 223 | return {ctx.OpLoad(def.image_type, def.id), def.is_integer}; |
| 224 | } else { | 224 | } else { |
| 225 | const ImageDefinition def{ctx.images.at(info.descriptor_index)}; | 225 | const ImageDefinition def{ctx.images.at(info.descriptor_index)}; |
| 226 | return ctx.OpLoad(def.image_type, def.id); | 226 | return {ctx.OpLoad(def.image_type, def.id), def.is_integer}; |
| 227 | } | 227 | } |
| 228 | } | 228 | } |
| 229 | 229 | ||
| @@ -566,13 +566,23 @@ Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id co | |||
| 566 | LOG_WARNING(Shader_SPIRV, "Typeless image read not supported by host"); | 566 | LOG_WARNING(Shader_SPIRV, "Typeless image read not supported by host"); |
| 567 | return ctx.ConstantNull(ctx.U32[4]); | 567 | return ctx.ConstantNull(ctx.U32[4]); |
| 568 | } | 568 | } |
| 569 | return Emit(&EmitContext::OpImageSparseRead, &EmitContext::OpImageRead, ctx, inst, ctx.U32[4], | 569 | const auto [image, is_integer] = Image(ctx, index, info); |
| 570 | Image(ctx, index, info), coords, std::nullopt, std::span<const Id>{}); | 570 | const Id result_type{is_integer ? ctx.U32[4] : ctx.F32[4]}; |
| 571 | Id color{Emit(&EmitContext::OpImageSparseRead, &EmitContext::OpImageRead, ctx, inst, | ||
| 572 | result_type, image, coords, std::nullopt, std::span<const Id>{})}; | ||
| 573 | if (!is_integer) { | ||
| 574 | color = ctx.OpBitcast(ctx.U32[4], color); | ||
| 575 | } | ||
| 576 | return color; | ||
| 571 | } | 577 | } |
| 572 | 578 | ||
| 573 | void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color) { | 579 | void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color) { |
| 574 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 580 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 575 | ctx.OpImageWrite(Image(ctx, index, info), coords, color); | 581 | const auto [image, is_integer] = Image(ctx, index, info); |
| 582 | if (!is_integer) { | ||
| 583 | color = ctx.OpBitcast(ctx.F32[4], color); | ||
| 584 | } | ||
| 585 | ctx.OpImageWrite(image, coords, color); | ||
| 576 | } | 586 | } |
| 577 | 587 | ||
| 578 | Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index) { | 588 | Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index) { |