summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-05-09 04:55:15 -0300
committerGravatar ReinUsesLisp2020-05-09 04:55:15 -0300
commit4e57f9d5cfc32b37fe7b6a1563ca2101ec59887c (patch)
tree057619ab05268d2c757dda7f5cec30c319a56bcb /src/video_core/renderer_vulkan
parentMerge pull request #3879 from lioncash/global2 (diff)
downloadyuzu-4e57f9d5cfc32b37fe7b6a1563ca2101ec59887c.tar.gz
yuzu-4e57f9d5cfc32b37fe7b6a1563ca2101ec59887c.tar.xz
yuzu-4e57f9d5cfc32b37fe7b6a1563ca2101ec59887c.zip
shader_ir: Separate float-point comparisons in ordered and unordered
This allows us to use native SPIR-V instructions without having to manually check for NAN.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 18678968c..167e20e91 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1618,6 +1618,24 @@ private:
1618 return {}; 1618 return {};
1619 } 1619 }
1620 1620
1621 Expression LogicalFOrdered(Operation operation) {
1622 // Emulate SPIR-V's OpOrdered
1623 const Id op_a = AsFloat(Visit(operation[0]));
1624 const Id op_b = AsFloat(Visit(operation[1]));
1625 const Id is_num_a = OpFOrdEqual(t_bool, op_a, op_a);
1626 const Id is_num_b = OpFOrdEqual(t_bool, op_b, op_b);
1627 return {OpLogicalAnd(t_bool, is_num_a, is_num_b), Type::Bool};
1628 }
1629
1630 Expression LogicalFUnordered(Operation operation) {
1631 // Emulate SPIR-V's OpUnordered
1632 const Id op_a = AsFloat(Visit(operation[0]));
1633 const Id op_b = AsFloat(Visit(operation[1]));
1634 const Id is_nan_a = OpIsNan(t_bool, op_a);
1635 const Id is_nan_b = OpIsNan(t_bool, op_b);
1636 return {OpLogicalOr(t_bool, is_nan_a, is_nan_b), Type::Bool};
1637 }
1638
1621 Id GetTextureSampler(Operation operation) { 1639 Id GetTextureSampler(Operation operation) {
1622 const auto& meta = std::get<MetaTexture>(operation.GetMeta()); 1640 const auto& meta = std::get<MetaTexture>(operation.GetMeta());
1623 ASSERT(!meta.sampler.is_buffer); 1641 ASSERT(!meta.sampler.is_buffer);
@@ -2511,7 +2529,14 @@ private:
2511 &SPIRVDecompiler::Binary<&Module::OpFOrdGreaterThan, Type::Bool, Type::Float>, 2529 &SPIRVDecompiler::Binary<&Module::OpFOrdGreaterThan, Type::Bool, Type::Float>,
2512 &SPIRVDecompiler::Binary<&Module::OpFOrdNotEqual, Type::Bool, Type::Float>, 2530 &SPIRVDecompiler::Binary<&Module::OpFOrdNotEqual, Type::Bool, Type::Float>,
2513 &SPIRVDecompiler::Binary<&Module::OpFOrdGreaterThanEqual, Type::Bool, Type::Float>, 2531 &SPIRVDecompiler::Binary<&Module::OpFOrdGreaterThanEqual, Type::Bool, Type::Float>,
2514 &SPIRVDecompiler::Unary<&Module::OpIsNan, Type::Bool, Type::Float>, 2532 &SPIRVDecompiler::LogicalFOrdered,
2533 &SPIRVDecompiler::LogicalFUnordered,
2534 &SPIRVDecompiler::Binary<&Module::OpFUnordLessThan, Type::Bool, Type::Float>,
2535 &SPIRVDecompiler::Binary<&Module::OpFUnordEqual, Type::Bool, Type::Float>,
2536 &SPIRVDecompiler::Binary<&Module::OpFUnordLessThanEqual, Type::Bool, Type::Float>,
2537 &SPIRVDecompiler::Binary<&Module::OpFUnordGreaterThan, Type::Bool, Type::Float>,
2538 &SPIRVDecompiler::Binary<&Module::OpFUnordNotEqual, Type::Bool, Type::Float>,
2539 &SPIRVDecompiler::Binary<&Module::OpFUnordGreaterThanEqual, Type::Bool, Type::Float>,
2515 2540
2516 &SPIRVDecompiler::Binary<&Module::OpSLessThan, Type::Bool, Type::Int>, 2541 &SPIRVDecompiler::Binary<&Module::OpSLessThan, Type::Bool, Type::Int>,
2517 &SPIRVDecompiler::Binary<&Module::OpIEqual, Type::Bool, Type::Int>, 2542 &SPIRVDecompiler::Binary<&Module::OpIEqual, Type::Bool, Type::Int>,