summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-25 19:55:40 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commitbd24fa97138ff1e33a7f8d3c30a4f4482a6482a8 (patch)
tree5ae0c1d535a258dbe45d7aecccf925f6d1ab62f5
parentglsl: Simply FP storage atomics (diff)
downloadyuzu-bd24fa97138ff1e33a7f8d3c30a4f4482a6482a8.tar.gz
yuzu-bd24fa97138ff1e33a7f8d3c30a4f4482a6482a8.tar.xz
yuzu-bd24fa97138ff1e33a7f8d3c30a4f4482a6482a8.zip
glsl: Query GL Device for FP16 extension support
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp9
-rw-r--r--src/shader_recompiler/profile.h2
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_device.h10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp2
5 files changed, 23 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index 9c3fd44ba..6f769fa10 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -5,6 +5,7 @@
5#include "shader_recompiler/backend/bindings.h" 5#include "shader_recompiler/backend/bindings.h"
6#include "shader_recompiler/backend/glsl/emit_context.h" 6#include "shader_recompiler/backend/glsl/emit_context.h"
7#include "shader_recompiler/frontend/ir/program.h" 7#include "shader_recompiler/frontend/ir/program.h"
8#include "shader_recompiler/profile.h"
8 9
9namespace Shader::Backend::GLSL { 10namespace Shader::Backend::GLSL {
10 11
@@ -40,8 +41,12 @@ void EmitContext::SetupExtensions(std::string& header) {
40 header += "#extension NV_shader_atomic_fp16_vector : enable\n"; 41 header += "#extension NV_shader_atomic_fp16_vector : enable\n";
41 } 42 }
42 if (info.uses_fp16) { 43 if (info.uses_fp16) {
43 // TODO: AMD 44 if (profile.support_gl_nv_gpu_shader_5) {
44 header += "#extension GL_NV_gpu_shader5 : enable\n"; 45 header += "#extension GL_NV_gpu_shader5 : enable\n";
46 }
47 if (profile.support_gl_amd_gpu_shader_half_float) {
48 header += "#extension GL_AMD_gpu_shader_half_float : enable\n";
49 }
45 } 50 }
46} 51}
47 52
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h
index 3109fb69c..5d269368a 100644
--- a/src/shader_recompiler/profile.h
+++ b/src/shader_recompiler/profile.h
@@ -83,6 +83,8 @@ struct Profile {
83 bool support_demote_to_helper_invocation{}; 83 bool support_demote_to_helper_invocation{};
84 bool support_int64_atomics{}; 84 bool support_int64_atomics{};
85 bool support_derivative_control{}; 85 bool support_derivative_control{};
86 bool support_gl_nv_gpu_shader_5{};
87 bool support_gl_amd_gpu_shader_half_float{};
86 88
87 bool warp_size_potentially_larger_than_guest{}; 89 bool warp_size_potentially_larger_than_guest{};
88 90
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 3f7929f9e..071133781 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -158,6 +158,8 @@ Device::Device() {
158 has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory; 158 has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory;
159 has_debugging_tool_attached = IsDebugToolAttached(extensions); 159 has_debugging_tool_attached = IsDebugToolAttached(extensions);
160 has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float"); 160 has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float");
161 has_nv_gpu_shader_5 = GLAD_GL_NV_gpu_shader5;
162 has_amd_shader_half_float = GLAD_GL_AMD_gpu_shader_half_float;
161 163
162 // At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive 164 // At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive
163 // uniform buffers as "push constants" 165 // uniform buffers as "push constants"
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h
index 1ffd24883..9b9402c29 100644
--- a/src/video_core/renderer_opengl/gl_device.h
+++ b/src/video_core/renderer_opengl/gl_device.h
@@ -120,6 +120,14 @@ public:
120 return has_depth_buffer_float; 120 return has_depth_buffer_float;
121 } 121 }
122 122
123 bool HasNvGpuShader5() const {
124 return has_nv_gpu_shader_5;
125 }
126
127 bool HasAmdShaderHalfFloat() const {
128 return has_amd_shader_half_float;
129 }
130
123private: 131private:
124 static bool TestVariableAoffi(); 132 static bool TestVariableAoffi();
125 static bool TestPreciseBug(); 133 static bool TestPreciseBug();
@@ -151,6 +159,8 @@ private:
151 bool use_asynchronous_shaders{}; 159 bool use_asynchronous_shaders{};
152 bool use_driver_cache{}; 160 bool use_driver_cache{};
153 bool has_depth_buffer_float{}; 161 bool has_depth_buffer_float{};
162 bool has_nv_gpu_shader_5{};
163 bool has_amd_shader_half_float{};
154}; 164};
155 165
156} // namespace OpenGL 166} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 602cf025b..e00d01e34 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -217,6 +217,8 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
217 .support_demote_to_helper_invocation = false, 217 .support_demote_to_helper_invocation = false,
218 .support_int64_atomics = false, 218 .support_int64_atomics = false,
219 .support_derivative_control = device.HasDerivativeControl(), 219 .support_derivative_control = device.HasDerivativeControl(),
220 .support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(),
221 .support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(),
220 222
221 .warp_size_potentially_larger_than_guest = true, 223 .warp_size_potentially_larger_than_guest = true,
222 224