diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index b9128bd38..97429cc59 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -971,7 +971,7 @@ private: | |||
| 971 | constexpr int depth = 0; | 971 | constexpr int depth = 0; |
| 972 | constexpr bool ms = false; | 972 | constexpr bool ms = false; |
| 973 | constexpr int sampled = 2; // This won't be accessed with a sampler | 973 | constexpr int sampled = 2; // This won't be accessed with a sampler |
| 974 | constexpr auto format = spv::ImageFormat::Unknown; | 974 | const auto format = image.is_atomic ? spv::ImageFormat::R32ui : spv::ImageFormat::Unknown; |
| 975 | const Id image_type = TypeImage(t_uint, dim, depth, arrayed, ms, sampled, format, {}); | 975 | const Id image_type = TypeImage(t_uint, dim, depth, arrayed, ms, sampled, format, {}); |
| 976 | const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type); | 976 | const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type); |
| 977 | const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant); | 977 | const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant); |
| @@ -1274,7 +1274,7 @@ private: | |||
| 1274 | } else { | 1274 | } else { |
| 1275 | UNREACHABLE_MSG("Unmanaged offset node type"); | 1275 | UNREACHABLE_MSG("Unmanaged offset node type"); |
| 1276 | } | 1276 | } |
| 1277 | pointer = OpAccessChain(t_cbuf_float, buffer_id, Constant(t_uint, 0), buffer_index, | 1277 | pointer = OpAccessChain(t_cbuf_float, buffer_id, v_uint_zero, buffer_index, |
| 1278 | buffer_element); | 1278 | buffer_element); |
| 1279 | } | 1279 | } |
| 1280 | return {OpLoad(t_float, pointer), Type::Float}; | 1280 | return {OpLoad(t_float, pointer), Type::Float}; |
| @@ -1629,7 +1629,7 @@ private: | |||
| 1629 | 1629 | ||
| 1630 | const Id result = OpIAddCarry(TypeStruct({t_uint, t_uint}), op_a, op_b); | 1630 | const Id result = OpIAddCarry(TypeStruct({t_uint, t_uint}), op_a, op_b); |
| 1631 | const Id carry = OpCompositeExtract(t_uint, result, 1); | 1631 | const Id carry = OpCompositeExtract(t_uint, result, 1); |
| 1632 | return {OpINotEqual(t_bool, carry, Constant(t_uint, 0)), Type::Bool}; | 1632 | return {OpINotEqual(t_bool, carry, v_uint_zero), Type::Bool}; |
| 1633 | } | 1633 | } |
| 1634 | 1634 | ||
| 1635 | Expression LogicalAssign(Operation operation) { | 1635 | Expression LogicalAssign(Operation operation) { |
| @@ -1969,39 +1969,20 @@ private: | |||
| 1969 | return {}; | 1969 | return {}; |
| 1970 | } | 1970 | } |
| 1971 | 1971 | ||
| 1972 | Expression AtomicImageAdd(Operation operation) { | 1972 | template <Id (Module::*func)(Id, Id, Id, Id, Id)> |
| 1973 | UNIMPLEMENTED(); | 1973 | Expression AtomicImage(Operation operation) { |
| 1974 | return {}; | 1974 | const auto& meta{std::get<MetaImage>(operation.GetMeta())}; |
| 1975 | } | 1975 | ASSERT(meta.values.size() == 1); |
| 1976 | |||
| 1977 | Expression AtomicImageMin(Operation operation) { | ||
| 1978 | UNIMPLEMENTED(); | ||
| 1979 | return {}; | ||
| 1980 | } | ||
| 1981 | |||
| 1982 | Expression AtomicImageMax(Operation operation) { | ||
| 1983 | UNIMPLEMENTED(); | ||
| 1984 | return {}; | ||
| 1985 | } | ||
| 1986 | |||
| 1987 | Expression AtomicImageAnd(Operation operation) { | ||
| 1988 | UNIMPLEMENTED(); | ||
| 1989 | return {}; | ||
| 1990 | } | ||
| 1991 | 1976 | ||
| 1992 | Expression AtomicImageOr(Operation operation) { | 1977 | const Id coordinate = GetCoordinates(operation, Type::Int); |
| 1993 | UNIMPLEMENTED(); | 1978 | const Id image = images.at(meta.image.index).image; |
| 1994 | return {}; | 1979 | const Id sample = v_uint_zero; |
| 1995 | } | 1980 | const Id pointer = OpImageTexelPointer(t_image_uint, image, coordinate, sample); |
| 1996 | 1981 | ||
| 1997 | Expression AtomicImageXor(Operation operation) { | 1982 | const Id scope = Constant(t_uint, static_cast<u32>(spv::Scope::Device)); |
| 1998 | UNIMPLEMENTED(); | 1983 | const Id semantics = v_uint_zero; |
| 1999 | return {}; | 1984 | const Id value = AsUint(Visit(meta.values[0])); |
| 2000 | } | 1985 | return {(this->*func)(t_uint, pointer, scope, semantics, value), Type::Uint}; |
| 2001 | |||
| 2002 | Expression AtomicImageExchange(Operation operation) { | ||
| 2003 | UNIMPLEMENTED(); | ||
| 2004 | return {}; | ||
| 2005 | } | 1986 | } |
| 2006 | 1987 | ||
| 2007 | template <Id (Module::*func)(Id, Id, Id, Id, Id)> | 1988 | template <Id (Module::*func)(Id, Id, Id, Id, Id)> |
| @@ -2016,7 +1997,7 @@ private: | |||
| 2016 | return {v_float_zero, Type::Float}; | 1997 | return {v_float_zero, Type::Float}; |
| 2017 | } | 1998 | } |
| 2018 | const Id scope = Constant(t_uint, static_cast<u32>(spv::Scope::Device)); | 1999 | const Id scope = Constant(t_uint, static_cast<u32>(spv::Scope::Device)); |
| 2019 | const Id semantics = Constant(t_uint, 0); | 2000 | const Id semantics = v_uint_zero; |
| 2020 | const Id value = AsUint(Visit(operation[1])); | 2001 | const Id value = AsUint(Visit(operation[1])); |
| 2021 | 2002 | ||
| 2022 | return {(this->*func)(t_uint, pointer, scope, semantics, value), Type::Uint}; | 2003 | return {(this->*func)(t_uint, pointer, scope, semantics, value), Type::Uint}; |
| @@ -2640,11 +2621,11 @@ private: | |||
| 2640 | 2621 | ||
| 2641 | &SPIRVDecompiler::ImageLoad, | 2622 | &SPIRVDecompiler::ImageLoad, |
| 2642 | &SPIRVDecompiler::ImageStore, | 2623 | &SPIRVDecompiler::ImageStore, |
| 2643 | &SPIRVDecompiler::AtomicImageAdd, | 2624 | &SPIRVDecompiler::AtomicImage<&Module::OpAtomicIAdd>, |
| 2644 | &SPIRVDecompiler::AtomicImageAnd, | 2625 | &SPIRVDecompiler::AtomicImage<&Module::OpAtomicAnd>, |
| 2645 | &SPIRVDecompiler::AtomicImageOr, | 2626 | &SPIRVDecompiler::AtomicImage<&Module::OpAtomicOr>, |
| 2646 | &SPIRVDecompiler::AtomicImageXor, | 2627 | &SPIRVDecompiler::AtomicImage<&Module::OpAtomicXor>, |
| 2647 | &SPIRVDecompiler::AtomicImageExchange, | 2628 | &SPIRVDecompiler::AtomicImage<&Module::OpAtomicExchange>, |
| 2648 | 2629 | ||
| 2649 | &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange>, | 2630 | &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange>, |
| 2650 | &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd>, | 2631 | &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd>, |
| @@ -2786,8 +2767,11 @@ private: | |||
| 2786 | Decorate(TypeStruct(t_gmem_array), spv::Decoration::Block), 0, spv::Decoration::Offset, 0); | 2767 | Decorate(TypeStruct(t_gmem_array), spv::Decoration::Block), 0, spv::Decoration::Offset, 0); |
| 2787 | const Id t_gmem_ssbo = TypePointer(spv::StorageClass::StorageBuffer, t_gmem_struct); | 2768 | const Id t_gmem_ssbo = TypePointer(spv::StorageClass::StorageBuffer, t_gmem_struct); |
| 2788 | 2769 | ||
| 2770 | const Id t_image_uint = TypePointer(spv::StorageClass::Image, t_uint); | ||
| 2771 | |||
| 2789 | const Id v_float_zero = Constant(t_float, 0.0f); | 2772 | const Id v_float_zero = Constant(t_float, 0.0f); |
| 2790 | const Id v_float_one = Constant(t_float, 1.0f); | 2773 | const Id v_float_one = Constant(t_float, 1.0f); |
| 2774 | const Id v_uint_zero = Constant(t_uint, 0); | ||
| 2791 | 2775 | ||
| 2792 | // Nvidia uses these defaults for varyings (e.g. position and generic attributes) | 2776 | // Nvidia uses these defaults for varyings (e.g. position and generic attributes) |
| 2793 | const Id v_varying_default = | 2777 | const Id v_varying_default = |