summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-04-06 02:24:47 -0300
committerGravatar ReinUsesLisp2020-04-06 02:24:47 -0300
commit3185245845f7487c3b832035b0c19fdc4f1a8262 (patch)
treec002fb721c5db8fc5f035bbf218e423b8d982f85 /src/video_core/renderer_vulkan
parentshader/memory: Add "using std::move" (diff)
downloadyuzu-3185245845f7487c3b832035b0c19fdc4f1a8262.tar.gz
yuzu-3185245845f7487c3b832035b0c19fdc4f1a8262.tar.xz
yuzu-3185245845f7487c3b832035b0c19fdc4f1a8262.zip
shader/memory: Implement RED.E.ADD
Implements a reduction operation. It's an atomic operation that doesn't return a value. This commit introduces another primitive because some shading languages might have a primitive for reduction operations.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp65
1 files changed, 40 insertions, 25 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index d67f08cf9..24d3ca08f 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1941,11 +1941,8 @@ private:
1941 return {}; 1941 return {};
1942 } 1942 }
1943 1943
1944 template <Id (Module::*func)(Id, Id, Id, Id, Id), Type result_type, 1944 template <Id (Module::*func)(Id, Id, Id, Id, Id)>
1945 Type value_type = result_type>
1946 Expression Atomic(Operation operation) { 1945 Expression Atomic(Operation operation) {
1947 const Id type_def = GetTypeDefinition(result_type);
1948
1949 Id pointer; 1946 Id pointer;
1950 if (const auto smem = std::get_if<SmemNode>(&*operation[0])) { 1947 if (const auto smem = std::get_if<SmemNode>(&*operation[0])) {
1951 pointer = GetSharedMemoryPointer(*smem); 1948 pointer = GetSharedMemoryPointer(*smem);
@@ -1953,15 +1950,19 @@ private:
1953 pointer = GetGlobalMemoryPointer(*gmem); 1950 pointer = GetGlobalMemoryPointer(*gmem);
1954 } else { 1951 } else {
1955 UNREACHABLE(); 1952 UNREACHABLE();
1956 return {Constant(type_def, 0), result_type}; 1953 return {v_float_zero, Type::Float};
1957 } 1954 }
1958
1959 const Id value = As(Visit(operation[1]), value_type);
1960
1961 const Id scope = Constant(t_uint, static_cast<u32>(spv::Scope::Device)); 1955 const Id scope = Constant(t_uint, static_cast<u32>(spv::Scope::Device));
1962 const Id semantics = Constant(type_def, 0); 1956 const Id semantics = Constant(t_uint, 0);
1957 const Id value = AsUint(Visit(operation[1]));
1958
1959 return {(this->*func)(t_uint, pointer, scope, semantics, value), Type::Uint};
1960 }
1963 1961
1964 return {(this->*func)(type_def, pointer, scope, semantics, value), result_type}; 1962 template <Id (Module::*func)(Id, Id, Id, Id, Id)>
1963 Expression Reduce(Operation operation) {
1964 Atomic<func>(operation);
1965 return {};
1965 } 1966 }
1966 1967
1967 Expression Branch(Operation operation) { 1968 Expression Branch(Operation operation) {
@@ -2550,21 +2551,35 @@ private:
2550 &SPIRVDecompiler::AtomicImageXor, 2551 &SPIRVDecompiler::AtomicImageXor,
2551 &SPIRVDecompiler::AtomicImageExchange, 2552 &SPIRVDecompiler::AtomicImageExchange,
2552 2553
2553 &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange, Type::Uint>, 2554 &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange>,
2554 &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd, Type::Uint>, 2555 &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd>,
2555 &SPIRVDecompiler::Atomic<&Module::OpAtomicUMin, Type::Uint>, 2556 &SPIRVDecompiler::Atomic<&Module::OpAtomicUMin>,
2556 &SPIRVDecompiler::Atomic<&Module::OpAtomicUMax, Type::Uint>, 2557 &SPIRVDecompiler::Atomic<&Module::OpAtomicUMax>,
2557 &SPIRVDecompiler::Atomic<&Module::OpAtomicAnd, Type::Uint>, 2558 &SPIRVDecompiler::Atomic<&Module::OpAtomicAnd>,
2558 &SPIRVDecompiler::Atomic<&Module::OpAtomicOr, Type::Uint>, 2559 &SPIRVDecompiler::Atomic<&Module::OpAtomicOr>,
2559 &SPIRVDecompiler::Atomic<&Module::OpAtomicXor, Type::Uint>, 2560 &SPIRVDecompiler::Atomic<&Module::OpAtomicXor>,
2560 2561
2561 &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange, Type::Int>, 2562 &SPIRVDecompiler::Atomic<&Module::OpAtomicExchange>,
2562 &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd, Type::Int>, 2563 &SPIRVDecompiler::Atomic<&Module::OpAtomicIAdd>,
2563 &SPIRVDecompiler::Atomic<&Module::OpAtomicSMin, Type::Int>, 2564 &SPIRVDecompiler::Atomic<&Module::OpAtomicSMin>,
2564 &SPIRVDecompiler::Atomic<&Module::OpAtomicSMax, Type::Int>, 2565 &SPIRVDecompiler::Atomic<&Module::OpAtomicSMax>,
2565 &SPIRVDecompiler::Atomic<&Module::OpAtomicAnd, Type::Int>, 2566 &SPIRVDecompiler::Atomic<&Module::OpAtomicAnd>,
2566 &SPIRVDecompiler::Atomic<&Module::OpAtomicOr, Type::Int>, 2567 &SPIRVDecompiler::Atomic<&Module::OpAtomicOr>,
2567 &SPIRVDecompiler::Atomic<&Module::OpAtomicXor, Type::Int>, 2568 &SPIRVDecompiler::Atomic<&Module::OpAtomicXor>,
2569
2570 &SPIRVDecompiler::Reduce<&Module::OpAtomicIAdd>,
2571 &SPIRVDecompiler::Reduce<&Module::OpAtomicUMin>,
2572 &SPIRVDecompiler::Reduce<&Module::OpAtomicUMax>,
2573 &SPIRVDecompiler::Reduce<&Module::OpAtomicAnd>,
2574 &SPIRVDecompiler::Reduce<&Module::OpAtomicOr>,
2575 &SPIRVDecompiler::Reduce<&Module::OpAtomicXor>,
2576
2577 &SPIRVDecompiler::Reduce<&Module::OpAtomicIAdd>,
2578 &SPIRVDecompiler::Reduce<&Module::OpAtomicSMin>,
2579 &SPIRVDecompiler::Reduce<&Module::OpAtomicSMax>,
2580 &SPIRVDecompiler::Reduce<&Module::OpAtomicAnd>,
2581 &SPIRVDecompiler::Reduce<&Module::OpAtomicOr>,
2582 &SPIRVDecompiler::Reduce<&Module::OpAtomicXor>,
2568 2583
2569 &SPIRVDecompiler::Branch, 2584 &SPIRVDecompiler::Branch,
2570 &SPIRVDecompiler::BranchIndirect, 2585 &SPIRVDecompiler::BranchIndirect,