summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/CMakeLists.txt1
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate_program.cpp3
-rw-r--r--src/shader_recompiler/host_translate_info.h2
-rw-r--r--src/shader_recompiler/ir_opt/conditional_barrier_pass.cpp44
-rw-r--r--src/shader_recompiler/ir_opt/passes.h1
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp1
-rw-r--r--src/video_core/renderer_opengl/gl_device.h5
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp1
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp2
-rw-r--r--src/video_core/vulkan_common/vulkan_device.h5
10 files changed, 65 insertions, 0 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt
index 525b2363c..2baa64322 100644
--- a/src/shader_recompiler/CMakeLists.txt
+++ b/src/shader_recompiler/CMakeLists.txt
@@ -216,6 +216,7 @@ add_library(shader_recompiler STATIC
216 frontend/maxwell/translate_program.h 216 frontend/maxwell/translate_program.h
217 host_translate_info.h 217 host_translate_info.h
218 ir_opt/collect_shader_info_pass.cpp 218 ir_opt/collect_shader_info_pass.cpp
219 ir_opt/conditional_barrier_pass.cpp
219 ir_opt/constant_propagation_pass.cpp 220 ir_opt/constant_propagation_pass.cpp
220 ir_opt/dead_code_elimination_pass.cpp 221 ir_opt/dead_code_elimination_pass.cpp
221 ir_opt/dual_vertex_pass.cpp 222 ir_opt/dual_vertex_pass.cpp
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
index 17a6d4888..529382355 100644
--- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
@@ -286,6 +286,9 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
286 if (!host_info.support_int64) { 286 if (!host_info.support_int64) {
287 Optimization::LowerInt64ToInt32(program); 287 Optimization::LowerInt64ToInt32(program);
288 } 288 }
289 if (!host_info.support_conditional_barrier) {
290 Optimization::ConditionalBarrierPass(program);
291 }
289 Optimization::SsaRewritePass(program); 292 Optimization::SsaRewritePass(program);
290 293
291 Optimization::ConstantPropagationPass(env, program); 294 Optimization::ConstantPropagationPass(env, program);
diff --git a/src/shader_recompiler/host_translate_info.h b/src/shader_recompiler/host_translate_info.h
index 2aaa6c5ea..d4e4f4d28 100644
--- a/src/shader_recompiler/host_translate_info.h
+++ b/src/shader_recompiler/host_translate_info.h
@@ -17,6 +17,8 @@ struct HostTranslateInfo {
17 bool support_viewport_index_layer{}; ///< True when the device supports gl_Layer in VS 17 bool support_viewport_index_layer{}; ///< True when the device supports gl_Layer in VS
18 bool support_geometry_shader_passthrough{}; ///< True when the device supports geometry 18 bool support_geometry_shader_passthrough{}; ///< True when the device supports geometry
19 ///< passthrough shaders 19 ///< passthrough shaders
20 bool support_conditional_barrier{}; ///< True when the device supports barriers in conditional
21 ///< control flow
20}; 22};
21 23
22} // namespace Shader 24} // namespace Shader
diff --git a/src/shader_recompiler/ir_opt/conditional_barrier_pass.cpp b/src/shader_recompiler/ir_opt/conditional_barrier_pass.cpp
new file mode 100644
index 000000000..c3ed27f4f
--- /dev/null
+++ b/src/shader_recompiler/ir_opt/conditional_barrier_pass.cpp
@@ -0,0 +1,44 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "shader_recompiler/frontend/ir/program.h"
5#include "shader_recompiler/ir_opt/passes.h"
6
7namespace Shader::Optimization {
8
9void ConditionalBarrierPass(IR::Program& program) {
10 s32 conditional_control_flow_count{0};
11 s32 conditional_return_count{0};
12 for (IR::AbstractSyntaxNode& node : program.syntax_list) {
13 switch (node.type) {
14 case IR::AbstractSyntaxNode::Type::If:
15 case IR::AbstractSyntaxNode::Type::Loop:
16 conditional_control_flow_count++;
17 break;
18 case IR::AbstractSyntaxNode::Type::EndIf:
19 case IR::AbstractSyntaxNode::Type::Repeat:
20 conditional_control_flow_count--;
21 break;
22 case IR::AbstractSyntaxNode::Type::Unreachable:
23 case IR::AbstractSyntaxNode::Type::Return:
24 if (conditional_control_flow_count > 0) {
25 conditional_return_count++;
26 }
27 break;
28 case IR::AbstractSyntaxNode::Type::Block:
29 for (IR::Inst& inst : node.data.block->Instructions()) {
30 if ((conditional_control_flow_count > 0 || conditional_return_count > 0) &&
31 inst.GetOpcode() == IR::Opcode::Barrier) {
32 LOG_WARNING(Shader, "Barrier within conditional control flow");
33 inst.ReplaceOpcode(IR::Opcode::Identity);
34 }
35 }
36 break;
37 default:
38 break;
39 }
40 }
41 ASSERT(conditional_control_flow_count == 0);
42}
43
44} // namespace Shader::Optimization
diff --git a/src/shader_recompiler/ir_opt/passes.h b/src/shader_recompiler/ir_opt/passes.h
index 1f8f2ba95..a677bfc65 100644
--- a/src/shader_recompiler/ir_opt/passes.h
+++ b/src/shader_recompiler/ir_opt/passes.h
@@ -13,6 +13,7 @@ struct HostTranslateInfo;
13namespace Shader::Optimization { 13namespace Shader::Optimization {
14 14
15void CollectShaderInfoPass(Environment& env, IR::Program& program); 15void CollectShaderInfoPass(Environment& env, IR::Program& program);
16void ConditionalBarrierPass(IR::Program& program);
16void ConstantPropagationPass(Environment& env, IR::Program& program); 17void ConstantPropagationPass(Environment& env, IR::Program& program);
17void DeadCodeEliminationPass(IR::Program& program); 18void DeadCodeEliminationPass(IR::Program& program);
18void GlobalMemoryToStorageBufferPass(IR::Program& program); 19void GlobalMemoryToStorageBufferPass(IR::Program& program);
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 400c21981..03d234f2f 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -201,6 +201,7 @@ Device::Device(Core::Frontend::EmuWindow& emu_window) {
201 use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue() && 201 use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue() &&
202 !(is_amd || (is_intel && !is_linux)) && !strict_context_required; 202 !(is_amd || (is_intel && !is_linux)) && !strict_context_required;
203 use_driver_cache = is_nvidia; 203 use_driver_cache = is_nvidia;
204 supports_conditional_barriers = !is_intel;
204 205
205 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi); 206 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi);
206 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug); 207 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug);
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h
index cc0b95f1a..ad27264e5 100644
--- a/src/video_core/renderer_opengl/gl_device.h
+++ b/src/video_core/renderer_opengl/gl_device.h
@@ -188,6 +188,10 @@ public:
188 return strict_context_required; 188 return strict_context_required;
189 } 189 }
190 190
191 bool SupportsConditionalBarriers() const {
192 return supports_conditional_barriers;
193 }
194
191private: 195private:
192 static bool TestVariableAoffi(); 196 static bool TestVariableAoffi();
193 static bool TestPreciseBug(); 197 static bool TestPreciseBug();
@@ -233,6 +237,7 @@ private:
233 bool has_bool_ref_bug{}; 237 bool has_bool_ref_bug{};
234 bool can_report_memory{}; 238 bool can_report_memory{};
235 bool strict_context_required{}; 239 bool strict_context_required{};
240 bool supports_conditional_barriers{};
236 241
237 std::string vendor_name; 242 std::string vendor_name;
238}; 243};
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 6ecda2984..183c1a7ea 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -238,6 +238,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
238 .support_snorm_render_buffer = false, 238 .support_snorm_render_buffer = false,
239 .support_viewport_index_layer = device.HasVertexViewportLayer(), 239 .support_viewport_index_layer = device.HasVertexViewportLayer(),
240 .support_geometry_shader_passthrough = device.HasGeometryShaderPassthrough(), 240 .support_geometry_shader_passthrough = device.HasGeometryShaderPassthrough(),
241 .support_conditional_barrier = device.SupportsConditionalBarriers(),
241 } { 242 } {
242 if (use_asynchronous_shaders) { 243 if (use_asynchronous_shaders) {
243 workers = CreateWorkers(); 244 workers = CreateWorkers();
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 0158b6b0d..a46f9beed 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -386,6 +386,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
386 IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, 386 IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,
387 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal); 387 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal);
388 388
389 supports_conditional_barriers = !(is_intel_anv || is_intel_windows);
390
389 CollectPhysicalMemoryInfo(); 391 CollectPhysicalMemoryInfo();
390 CollectToolingInfo(); 392 CollectToolingInfo();
391 393
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h
index d62a103a1..ccce9429a 100644
--- a/src/video_core/vulkan_common/vulkan_device.h
+++ b/src/video_core/vulkan_common/vulkan_device.h
@@ -580,6 +580,10 @@ public:
580 return properties.properties.limits.maxVertexInputBindings; 580 return properties.properties.limits.maxVertexInputBindings;
581 } 581 }
582 582
583 bool SupportsConditionalBarriers() const {
584 return supports_conditional_barriers;
585 }
586
583private: 587private:
584 /// Checks if the physical device is suitable and configures the object state 588 /// Checks if the physical device is suitable and configures the object state
585 /// with all necessary info about its properties. 589 /// with all necessary info about its properties.
@@ -683,6 +687,7 @@ private:
683 bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. 687 bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format.
684 bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. 688 bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3.
685 bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. 689 bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3.
690 bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow.
686 u64 device_access_memory{}; ///< Total size of device local memory in bytes. 691 u64 device_access_memory{}; ///< Total size of device local memory in bytes.
687 u32 sets_per_pool{}; ///< Sets per Description Pool 692 u32 sets_per_pool{}; ///< Sets per Description Pool
688 693