From fb54c38631439575a327c13531e9d84e4b4af18c Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Sun, 14 Feb 2021 23:21:42 +0000 Subject: Implement texture offset support for TexelFetch and TextureGather and add offsets for Tlds Formatting --- .../renderer_vulkan/vk_shader_decompiler.cpp | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/video_core/renderer_vulkan') diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 40e2e0d38..dd6996735 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -1845,13 +1845,21 @@ private: Expression TextureGather(Operation operation) { const auto& meta = std::get(operation.GetMeta()); - UNIMPLEMENTED_IF(!meta.aoffi.empty()); const Id coords = GetCoordinates(operation, Type::Float); + + spv::ImageOperandsMask mask = spv::ImageOperandsMask::MaskNone; + std::vector operands{}; Id texture{}; + + if (!meta.aoffi.empty()) { + mask = mask | spv::ImageOperandsMask::Offset; + operands.push_back(GetOffsetCoordinates(operation)); + } + if (meta.sampler.is_shadow) { texture = OpImageDrefGather(t_float4, GetTextureSampler(operation), coords, - AsFloat(Visit(meta.depth_compare))); + AsFloat(Visit(meta.depth_compare)), mask, operands); } else { u32 component_value = 0; if (meta.component) { @@ -1860,7 +1868,7 @@ private: component_value = component->GetValue(); } texture = OpImageGather(t_float4, GetTextureSampler(operation), coords, - Constant(t_uint, component_value)); + Constant(t_uint, component_value), mask, operands); } return GetTextureElement(operation, texture, Type::Float); } @@ -1928,13 +1936,22 @@ private: const Id image = GetTextureImage(operation); const Id coords = GetCoordinates(operation, Type::Int); + + spv::ImageOperandsMask mask = spv::ImageOperandsMask::MaskNone; + std::vector operands{}; Id fetch; + if (meta.lod && !meta.sampler.is_buffer) { - fetch = OpImageFetch(t_float4, image, coords, spv::ImageOperandsMask::Lod, - AsInt(Visit(meta.lod))); - } else { - fetch = OpImageFetch(t_float4, image, coords); + mask = mask | spv::ImageOperandsMask::Lod; + operands.push_back(AsInt(Visit(meta.lod))); } + + if (!meta.aoffi.empty()) { + mask = mask | spv::ImageOperandsMask::Offset; + operands.push_back(GetOffsetCoordinates(operation)); + } + + fetch = OpImageFetch(t_float4, image, coords, mask, operands); return GetTextureElement(operation, fetch, Type::Float); } -- cgit v1.2.3 From 9d8f793969b8d13e5312f92ff96fd80f142688a3 Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Mon, 15 Feb 2021 05:26:28 +0000 Subject: Review 1 --- src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/renderer_vulkan') diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index dd6996735..c6846d886 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -1849,7 +1849,7 @@ private: const Id coords = GetCoordinates(operation, Type::Float); spv::ImageOperandsMask mask = spv::ImageOperandsMask::MaskNone; - std::vector operands{}; + std::vector operands; Id texture{}; if (!meta.aoffi.empty()) { @@ -1938,7 +1938,7 @@ private: const Id coords = GetCoordinates(operation, Type::Int); spv::ImageOperandsMask mask = spv::ImageOperandsMask::MaskNone; - std::vector operands{}; + std::vector operands; Id fetch; if (meta.lod && !meta.sampler.is_buffer) { -- cgit v1.2.3