summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Rodrigo Locatti2020-02-21 15:55:05 -0300
committerGravatar GitHub2020-02-21 15:55:05 -0300
commitef27b4b7b58ccba1f4b7010aa8fddbda90f87cb3 (patch)
treeb7df5118b0b894a6fa70f37349648348e2c8193a
parentMerge pull request #3435 from namkazt/patch-3 (diff)
parentvk_device: remove left over from other branch (diff)
downloadyuzu-ef27b4b7b58ccba1f4b7010aa8fddbda90f87cb3.tar.gz
yuzu-ef27b4b7b58ccba1f4b7010aa8fddbda90f87cb3.tar.xz
yuzu-ef27b4b7b58ccba1f4b7010aa8fddbda90f87cb3.zip
Merge pull request #3434 from namkazt/patch-2
vk_shader: Implement ImageLoad
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_device.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_device.h7
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp16
3 files changed, 25 insertions, 2 deletions
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp
index 3a77aced9..d1da4f9d3 100644
--- a/src/video_core/renderer_vulkan/vk_device.cpp
+++ b/src/video_core/renderer_vulkan/vk_device.cpp
@@ -107,6 +107,8 @@ bool VKDevice::Create(const vk::DispatchLoaderDynamic& dldi, vk::Instance instan
107 features.occlusionQueryPrecise = true; 107 features.occlusionQueryPrecise = true;
108 features.fragmentStoresAndAtomics = true; 108 features.fragmentStoresAndAtomics = true;
109 features.shaderImageGatherExtended = true; 109 features.shaderImageGatherExtended = true;
110 features.shaderStorageImageReadWithoutFormat =
111 is_shader_storage_img_read_without_format_supported;
110 features.shaderStorageImageWriteWithoutFormat = true; 112 features.shaderStorageImageWriteWithoutFormat = true;
111 features.textureCompressionASTC_LDR = is_optimal_astc_supported; 113 features.textureCompressionASTC_LDR = is_optimal_astc_supported;
112 114
@@ -465,6 +467,8 @@ void VKDevice::SetupFamilies(const vk::DispatchLoaderDynamic& dldi, vk::SurfaceK
465 467
466void VKDevice::SetupFeatures(const vk::DispatchLoaderDynamic& dldi) { 468void VKDevice::SetupFeatures(const vk::DispatchLoaderDynamic& dldi) {
467 const auto supported_features{physical.getFeatures(dldi)}; 469 const auto supported_features{physical.getFeatures(dldi)};
470 is_shader_storage_img_read_without_format_supported =
471 supported_features.shaderStorageImageReadWithoutFormat;
468 is_optimal_astc_supported = IsOptimalAstcSupported(supported_features, dldi); 472 is_optimal_astc_supported = IsOptimalAstcSupported(supported_features, dldi);
469} 473}
470 474
diff --git a/src/video_core/renderer_vulkan/vk_device.h b/src/video_core/renderer_vulkan/vk_device.h
index 72603f9f6..2c27ad730 100644
--- a/src/video_core/renderer_vulkan/vk_device.h
+++ b/src/video_core/renderer_vulkan/vk_device.h
@@ -122,6 +122,11 @@ public:
122 return properties.limits.maxPushConstantsSize; 122 return properties.limits.maxPushConstantsSize;
123 } 123 }
124 124
125 /// Returns true if Shader storage Image Read Without Format supported.
126 bool IsShaderStorageImageReadWithoutFormatSupported() const {
127 return is_shader_storage_img_read_without_format_supported;
128 }
129
125 /// Returns true if ASTC is natively supported. 130 /// Returns true if ASTC is natively supported.
126 bool IsOptimalAstcSupported() const { 131 bool IsOptimalAstcSupported() const {
127 return is_optimal_astc_supported; 132 return is_optimal_astc_supported;
@@ -227,6 +232,8 @@ private:
227 bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. 232 bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted.
228 bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. 233 bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer.
229 bool nv_device_diagnostic_checkpoints{}; ///< Support for VK_NV_device_diagnostic_checkpoints. 234 bool nv_device_diagnostic_checkpoints{}; ///< Support for VK_NV_device_diagnostic_checkpoints.
235 bool is_shader_storage_img_read_without_format_supported{}; ///< Support for shader storage
236 ///< image read without format
230 237
231 // Telemetry parameters 238 // Telemetry parameters
232 std::string vendor_name; ///< Device's driver name. 239 std::string vendor_name; ///< Device's driver name.
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index f64f5da28..6d0bf6aa1 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -292,6 +292,10 @@ public:
292 } 292 }
293 } 293 }
294 294
295 if (device.IsShaderStorageImageReadWithoutFormatSupported()) {
296 AddCapability(spv::Capability::StorageImageReadWithoutFormat);
297 }
298
295 if (device.IsFloat16Supported()) { 299 if (device.IsFloat16Supported()) {
296 AddCapability(spv::Capability::Float16); 300 AddCapability(spv::Capability::Float16);
297 } 301 }
@@ -1755,8 +1759,16 @@ private:
1755 } 1759 }
1756 1760
1757 Expression ImageLoad(Operation operation) { 1761 Expression ImageLoad(Operation operation) {
1758 UNIMPLEMENTED(); 1762 if (!device.IsShaderStorageImageReadWithoutFormatSupported()) {
1759 return {}; 1763 return {v_float_zero, Type::Float};
1764 }
1765
1766 const auto& meta{std::get<MetaImage>(operation.GetMeta())};
1767
1768 const Id coords = GetCoordinates(operation, Type::Int);
1769 const Id texel = OpImageRead(t_uint4, GetImage(operation), coords);
1770
1771 return {OpCompositeExtract(t_uint, texel, meta.element), Type::Uint};
1760 } 1772 }
1761 1773
1762 Expression ImageStore(Operation operation) { 1774 Expression ImageStore(Operation operation) {