3
0
Fork 0
forked from suyu/suyu

glsl: Query GL Device for FP16 extension support

This commit is contained in:
ameerj 2021-05-25 19:55:40 -04:00
parent 3482df1176
commit bd24fa9713
5 changed files with 23 additions and 2 deletions

View file

@ -5,6 +5,7 @@
#include "shader_recompiler/backend/bindings.h" #include "shader_recompiler/backend/bindings.h"
#include "shader_recompiler/backend/glsl/emit_context.h" #include "shader_recompiler/backend/glsl/emit_context.h"
#include "shader_recompiler/frontend/ir/program.h" #include "shader_recompiler/frontend/ir/program.h"
#include "shader_recompiler/profile.h"
namespace Shader::Backend::GLSL { namespace Shader::Backend::GLSL {
@ -40,9 +41,13 @@ void EmitContext::SetupExtensions(std::string& header) {
header += "#extension NV_shader_atomic_fp16_vector : enable\n"; header += "#extension NV_shader_atomic_fp16_vector : enable\n";
} }
if (info.uses_fp16) { if (info.uses_fp16) {
// TODO: AMD if (profile.support_gl_nv_gpu_shader_5) {
header += "#extension GL_NV_gpu_shader5 : enable\n"; header += "#extension GL_NV_gpu_shader5 : enable\n";
} }
if (profile.support_gl_amd_gpu_shader_half_float) {
header += "#extension GL_AMD_gpu_shader_half_float : enable\n";
}
}
} }
void EmitContext::DefineConstantBuffers() { void EmitContext::DefineConstantBuffers() {

View file

@ -83,6 +83,8 @@ struct Profile {
bool support_demote_to_helper_invocation{}; bool support_demote_to_helper_invocation{};
bool support_int64_atomics{}; bool support_int64_atomics{};
bool support_derivative_control{}; bool support_derivative_control{};
bool support_gl_nv_gpu_shader_5{};
bool support_gl_amd_gpu_shader_half_float{};
bool warp_size_potentially_larger_than_guest{}; bool warp_size_potentially_larger_than_guest{};

View file

@ -158,6 +158,8 @@ Device::Device() {
has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory; has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory;
has_debugging_tool_attached = IsDebugToolAttached(extensions); has_debugging_tool_attached = IsDebugToolAttached(extensions);
has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float"); has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float");
has_nv_gpu_shader_5 = GLAD_GL_NV_gpu_shader5;
has_amd_shader_half_float = GLAD_GL_AMD_gpu_shader_half_float;
// At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive // At the moment of writing this, only Nvidia's driver optimizes BufferSubData on exclusive
// uniform buffers as "push constants" // uniform buffers as "push constants"

View file

@ -120,6 +120,14 @@ public:
return has_depth_buffer_float; return has_depth_buffer_float;
} }
bool HasNvGpuShader5() const {
return has_nv_gpu_shader_5;
}
bool HasAmdShaderHalfFloat() const {
return has_amd_shader_half_float;
}
private: private:
static bool TestVariableAoffi(); static bool TestVariableAoffi();
static bool TestPreciseBug(); static bool TestPreciseBug();
@ -151,6 +159,8 @@ private:
bool use_asynchronous_shaders{}; bool use_asynchronous_shaders{};
bool use_driver_cache{}; bool use_driver_cache{};
bool has_depth_buffer_float{}; bool has_depth_buffer_float{};
bool has_nv_gpu_shader_5{};
bool has_amd_shader_half_float{};
}; };
} // namespace OpenGL } // namespace OpenGL

View file

@ -217,6 +217,8 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
.support_demote_to_helper_invocation = false, .support_demote_to_helper_invocation = false,
.support_int64_atomics = false, .support_int64_atomics = false,
.support_derivative_control = device.HasDerivativeControl(), .support_derivative_control = device.HasDerivativeControl(),
.support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(),
.support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(),
.warp_size_potentially_larger_than_guest = true, .warp_size_potentially_larger_than_guest = true,