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/spirv_emit_context.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/spirv_emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 2abc21a17..ed023fcfe 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -74,20 +74,19 @@ spv::ImageFormat GetImageFormat(ImageFormat format) { | |||
| 74 | throw InvalidArgument("Invalid image format {}", format); | 74 | throw InvalidArgument("Invalid image format {}", format); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | Id ImageType(EmitContext& ctx, const ImageDescriptor& desc) { | 77 | Id ImageType(EmitContext& ctx, const ImageDescriptor& desc, Id sampled_type) { |
| 78 | const spv::ImageFormat format{GetImageFormat(desc.format)}; | 78 | const spv::ImageFormat format{GetImageFormat(desc.format)}; |
| 79 | const Id type{ctx.U32[1]}; | ||
| 80 | switch (desc.type) { | 79 | switch (desc.type) { |
| 81 | case TextureType::Color1D: | 80 | case TextureType::Color1D: |
| 82 | return ctx.TypeImage(type, spv::Dim::Dim1D, false, false, false, 2, format); | 81 | return ctx.TypeImage(sampled_type, spv::Dim::Dim1D, false, false, false, 2, format); |
| 83 | case TextureType::ColorArray1D: | 82 | case TextureType::ColorArray1D: |
| 84 | return ctx.TypeImage(type, spv::Dim::Dim1D, false, true, false, 2, format); | 83 | return ctx.TypeImage(sampled_type, spv::Dim::Dim1D, false, true, false, 2, format); |
| 85 | case TextureType::Color2D: | 84 | case TextureType::Color2D: |
| 86 | return ctx.TypeImage(type, spv::Dim::Dim2D, false, false, false, 2, format); | 85 | return ctx.TypeImage(sampled_type, spv::Dim::Dim2D, false, false, false, 2, format); |
| 87 | case TextureType::ColorArray2D: | 86 | case TextureType::ColorArray2D: |
| 88 | return ctx.TypeImage(type, spv::Dim::Dim2D, false, true, false, 2, format); | 87 | return ctx.TypeImage(sampled_type, spv::Dim::Dim2D, false, true, false, 2, format); |
| 89 | case TextureType::Color3D: | 88 | case TextureType::Color3D: |
| 90 | return ctx.TypeImage(type, spv::Dim::Dim3D, false, false, false, 2, format); | 89 | return ctx.TypeImage(sampled_type, spv::Dim::Dim3D, false, false, false, 2, format); |
| 91 | case TextureType::Buffer: | 90 | case TextureType::Buffer: |
| 92 | throw NotImplementedException("Image buffer"); | 91 | throw NotImplementedException("Image buffer"); |
| 93 | default: | 92 | default: |
| @@ -1273,7 +1272,9 @@ void EmitContext::DefineImageBuffers(const Info& info, u32& binding) { | |||
| 1273 | throw NotImplementedException("Array of image buffers"); | 1272 | throw NotImplementedException("Array of image buffers"); |
| 1274 | } | 1273 | } |
| 1275 | const spv::ImageFormat format{GetImageFormat(desc.format)}; | 1274 | const spv::ImageFormat format{GetImageFormat(desc.format)}; |
| 1276 | const Id image_type{TypeImage(U32[1], spv::Dim::Buffer, false, false, false, 2, format)}; | 1275 | const Id sampled_type{desc.is_integer ? U32[1] : F32[1]}; |
| 1276 | const Id image_type{ | ||
| 1277 | TypeImage(sampled_type, spv::Dim::Buffer, false, false, false, 2, format)}; | ||
| 1277 | const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)}; | 1278 | const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)}; |
| 1278 | const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)}; | 1279 | const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)}; |
| 1279 | Decorate(id, spv::Decoration::Binding, binding); | 1280 | Decorate(id, spv::Decoration::Binding, binding); |
| @@ -1283,6 +1284,7 @@ void EmitContext::DefineImageBuffers(const Info& info, u32& binding) { | |||
| 1283 | .id = id, | 1284 | .id = id, |
| 1284 | .image_type = image_type, | 1285 | .image_type = image_type, |
| 1285 | .count = desc.count, | 1286 | .count = desc.count, |
| 1287 | .is_integer = desc.is_integer, | ||
| 1286 | }); | 1288 | }); |
| 1287 | if (profile.supported_spirv >= 0x00010400) { | 1289 | if (profile.supported_spirv >= 0x00010400) { |
| 1288 | interfaces.push_back(id); | 1290 | interfaces.push_back(id); |
| @@ -1327,7 +1329,8 @@ void EmitContext::DefineImages(const Info& info, u32& binding, u32& scaling_inde | |||
| 1327 | if (desc.count != 1) { | 1329 | if (desc.count != 1) { |
| 1328 | throw NotImplementedException("Array of images"); | 1330 | throw NotImplementedException("Array of images"); |
| 1329 | } | 1331 | } |
| 1330 | const Id image_type{ImageType(*this, desc)}; | 1332 | const Id sampled_type{desc.is_integer ? U32[1] : F32[1]}; |
| 1333 | const Id image_type{ImageType(*this, desc, sampled_type)}; | ||
| 1331 | const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)}; | 1334 | const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)}; |
| 1332 | const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)}; | 1335 | const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)}; |
| 1333 | Decorate(id, spv::Decoration::Binding, binding); | 1336 | Decorate(id, spv::Decoration::Binding, binding); |
| @@ -1337,6 +1340,7 @@ void EmitContext::DefineImages(const Info& info, u32& binding, u32& scaling_inde | |||
| 1337 | .id = id, | 1340 | .id = id, |
| 1338 | .image_type = image_type, | 1341 | .image_type = image_type, |
| 1339 | .count = desc.count, | 1342 | .count = desc.count, |
| 1343 | .is_integer = desc.is_integer, | ||
| 1340 | }); | 1344 | }); |
| 1341 | if (profile.supported_spirv >= 0x00010400) { | 1345 | if (profile.supported_spirv >= 0x00010400) { |
| 1342 | interfaces.push_back(id); | 1346 | interfaces.push_back(id); |