summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-11-26 16:49:20 -0300
committerGravatar ReinUsesLisp2020-11-26 17:52:26 -0300
commit2ccf85a9103afbb4dc227e481bb0e3a7360e833b (patch)
treec5f6f65bdf56a35560a105fbe18a7ea673ae450d /src/video_core/renderer_vulkan
parentMerge pull request #4975 from comex/invalid-syncpoint-id (diff)
downloadyuzu-2ccf85a9103afbb4dc227e481bb0e3a7360e833b.tar.gz
yuzu-2ccf85a9103afbb4dc227e481bb0e3a7360e833b.tar.xz
yuzu-2ccf85a9103afbb4dc227e481bb0e3a7360e833b.zip
vk_shader_decompiler: Implement force early fragment tests
Force early fragment tests when the 3D method is enabled. The established pipeline cache takes care of recompiling if needed. This is implemented only on Vulkan to avoid invalidating the shader cache on OpenGL.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.cpp7
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.h8
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp6
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.h1
5 files changed, 13 insertions, 10 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
index fffae528e..5ec43db11 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
@@ -46,7 +46,7 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta
46 regs.polygon_offset_fill_enable}; 46 regs.polygon_offset_fill_enable};
47 const u32 topology_index = static_cast<u32>(regs.draw.topology.Value()); 47 const u32 topology_index = static_cast<u32>(regs.draw.topology.Value());
48 48
49 raw = 0; 49 raw1 = 0;
50 primitive_restart_enable.Assign(regs.primitive_restart.enabled != 0 ? 1 : 0); 50 primitive_restart_enable.Assign(regs.primitive_restart.enabled != 0 ? 1 : 0);
51 depth_bias_enable.Assign(enabled_lut[POLYGON_OFFSET_ENABLE_LUT[topology_index]] != 0 ? 1 : 0); 51 depth_bias_enable.Assign(enabled_lut[POLYGON_OFFSET_ENABLE_LUT[topology_index]] != 0 ? 1 : 0);
52 depth_clamp_disabled.Assign(regs.view_volume_clip_control.depth_clamp_disabled.Value()); 52 depth_clamp_disabled.Assign(regs.view_volume_clip_control.depth_clamp_disabled.Value());
@@ -61,12 +61,13 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta
61 rasterize_enable.Assign(regs.rasterize_enable != 0 ? 1 : 0); 61 rasterize_enable.Assign(regs.rasterize_enable != 0 ? 1 : 0);
62 topology.Assign(regs.draw.topology); 62 topology.Assign(regs.draw.topology);
63 63
64 alpha_raw = 0; 64 raw2 = 0;
65 const auto test_func = 65 const auto test_func =
66 regs.alpha_test_enabled == 1 ? regs.alpha_test_func : Maxwell::ComparisonOp::Always; 66 regs.alpha_test_enabled == 1 ? regs.alpha_test_func : Maxwell::ComparisonOp::Always;
67 alpha_test_func.Assign(PackComparisonOp(test_func)); 67 alpha_test_func.Assign(PackComparisonOp(test_func));
68 alpha_test_ref = Common::BitCast<u32>(regs.alpha_test_ref); 68 early_z.Assign(regs.force_early_fragment_tests != 0 ? 1 : 0);
69 69
70 alpha_test_ref = Common::BitCast<u32>(regs.alpha_test_ref);
70 point_size = Common::BitCast<u32>(regs.point_size); 71 point_size = Common::BitCast<u32>(regs.point_size);
71 72
72 for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { 73 for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
index 42480e8d0..c26b77790 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
@@ -171,7 +171,7 @@ struct FixedPipelineState {
171 }; 171 };
172 172
173 union { 173 union {
174 u32 raw; 174 u32 raw1;
175 BitField<0, 1, u32> no_extended_dynamic_state; 175 BitField<0, 1, u32> no_extended_dynamic_state;
176 BitField<2, 1, u32> primitive_restart_enable; 176 BitField<2, 1, u32> primitive_restart_enable;
177 BitField<3, 1, u32> depth_bias_enable; 177 BitField<3, 1, u32> depth_bias_enable;
@@ -187,13 +187,13 @@ struct FixedPipelineState {
187 BitField<23, 1, u32> rasterize_enable; 187 BitField<23, 1, u32> rasterize_enable;
188 BitField<24, 4, Maxwell::PrimitiveTopology> topology; 188 BitField<24, 4, Maxwell::PrimitiveTopology> topology;
189 }; 189 };
190
191 u32 alpha_test_ref; ///< Alpha test reference value
192 union { 190 union {
193 u32 alpha_raw; 191 u32 raw2;
194 BitField<0, 3, u32> alpha_test_func; 192 BitField<0, 3, u32> alpha_test_func;
193 BitField<3, 1, u32> early_z;
195 }; 194 };
196 195
196 u32 alpha_test_ref;
197 u32 point_size; 197 u32 point_size;
198 std::array<u32, Maxwell::NumVertexArrays> binding_divisors; 198 std::array<u32, Maxwell::NumVertexArrays> binding_divisors;
199 std::array<VertexAttribute, Maxwell::NumVertexAttributes> attributes; 199 std::array<VertexAttribute, Maxwell::NumVertexAttributes> attributes;
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index f9efe526d..df7e8c864 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -344,6 +344,7 @@ VKPipelineCache::DecompileShaders(const FixedPipelineState& fixed_state) {
344 specialization.attribute_types[i] = attribute.Type(); 344 specialization.attribute_types[i] = attribute.Type();
345 } 345 }
346 specialization.ndc_minus_one_to_one = fixed_state.ndc_minus_one_to_one; 346 specialization.ndc_minus_one_to_one = fixed_state.ndc_minus_one_to_one;
347 specialization.early_fragment_tests = fixed_state.early_z;
347 348
348 // Alpha test 349 // Alpha test
349 specialization.alpha_test_func = 350 specialization.alpha_test_func =
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 1c52f40bb..fed9ebecd 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -315,7 +315,6 @@ public:
315 "supported on this device"); 315 "supported on this device");
316 } 316 }
317 } 317 }
318
319 if (ir.UsesLayer() || ir.UsesViewportIndex()) { 318 if (ir.UsesLayer() || ir.UsesViewportIndex()) {
320 if (ir.UsesViewportIndex()) { 319 if (ir.UsesViewportIndex()) {
321 AddCapability(spv::Capability::MultiViewport); 320 AddCapability(spv::Capability::MultiViewport);
@@ -325,11 +324,9 @@ public:
325 AddCapability(spv::Capability::ShaderViewportIndexLayerEXT); 324 AddCapability(spv::Capability::ShaderViewportIndexLayerEXT);
326 } 325 }
327 } 326 }
328
329 if (device.IsFormatlessImageLoadSupported()) { 327 if (device.IsFormatlessImageLoadSupported()) {
330 AddCapability(spv::Capability::StorageImageReadWithoutFormat); 328 AddCapability(spv::Capability::StorageImageReadWithoutFormat);
331 } 329 }
332
333 if (device.IsFloat16Supported()) { 330 if (device.IsFloat16Supported()) {
334 AddCapability(spv::Capability::Float16); 331 AddCapability(spv::Capability::Float16);
335 } 332 }
@@ -377,6 +374,9 @@ public:
377 if (header.ps.omap.depth) { 374 if (header.ps.omap.depth) {
378 AddExecutionMode(main, spv::ExecutionMode::DepthReplacing); 375 AddExecutionMode(main, spv::ExecutionMode::DepthReplacing);
379 } 376 }
377 if (specialization.early_fragment_tests) {
378 AddExecutionMode(main, spv::ExecutionMode::EarlyFragmentTests);
379 }
380 break; 380 break;
381 case ShaderType::Compute: 381 case ShaderType::Compute:
382 const auto workgroup_size = specialization.workgroup_size; 382 const auto workgroup_size = specialization.workgroup_size;
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.h b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
index cd3d0a415..110848922 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.h
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
@@ -95,6 +95,7 @@ struct Specialization final {
95 std::bitset<Maxwell::NumVertexAttributes> enabled_attributes; 95 std::bitset<Maxwell::NumVertexAttributes> enabled_attributes;
96 std::array<Maxwell::VertexAttribute::Type, Maxwell::NumVertexAttributes> attribute_types{}; 96 std::array<Maxwell::VertexAttribute::Type, Maxwell::NumVertexAttributes> attribute_types{};
97 bool ndc_minus_one_to_one{}; 97 bool ndc_minus_one_to_one{};
98 bool early_fragment_tests{};
98 float alpha_test_ref{}; 99 float alpha_test_ref{};
99 Maxwell::ComparisonOp alpha_test_func{}; 100 Maxwell::ComparisonOp alpha_test_func{};
100}; 101};