glasm: Use ARB_derivative_control conditionally
This commit is contained in:
parent
4a2361a1e2
commit
79f2fe1a39
|
@ -265,9 +265,7 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
|
||||||
// TODO: Track the shared atomic ops
|
// TODO: Track the shared atomic ops
|
||||||
header += "OPTION NV_internal;"
|
header += "OPTION NV_internal;"
|
||||||
"OPTION NV_shader_storage_buffer;"
|
"OPTION NV_shader_storage_buffer;"
|
||||||
"OPTION NV_gpu_program_fp64;"
|
"OPTION NV_gpu_program_fp64;";
|
||||||
"OPTION NV_bindless_texture;"
|
|
||||||
"OPTION ARB_derivative_control;";
|
|
||||||
if (info.uses_int64_bit_atomics) {
|
if (info.uses_int64_bit_atomics) {
|
||||||
header += "OPTION NV_shader_atomic_int64;";
|
header += "OPTION NV_shader_atomic_int64;";
|
||||||
}
|
}
|
||||||
|
@ -295,6 +293,9 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
|
||||||
if (info.uses_typeless_image_reads && profile.support_typeless_image_loads) {
|
if (info.uses_typeless_image_reads && profile.support_typeless_image_loads) {
|
||||||
header += "OPTION EXT_shader_image_load_formatted;";
|
header += "OPTION EXT_shader_image_load_formatted;";
|
||||||
}
|
}
|
||||||
|
if (profile.support_derivative_control) {
|
||||||
|
header += "OPTION ARB_derivative_control;";
|
||||||
|
}
|
||||||
if (stage == Stage::Fragment && runtime_info.force_early_z != 0) {
|
if (stage == Stage::Fragment && runtime_info.force_early_z != 0) {
|
||||||
header += "OPTION NV_early_fragment_tests;";
|
header += "OPTION NV_early_fragment_tests;";
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "shader_recompiler/backend/glasm/emit_context.h"
|
#include "shader_recompiler/backend/glasm/emit_context.h"
|
||||||
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
|
#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
|
||||||
#include "shader_recompiler/frontend/ir/value.h"
|
#include "shader_recompiler/frontend/ir/value.h"
|
||||||
|
#include "shader_recompiler/profile.h"
|
||||||
|
|
||||||
namespace Shader::Backend::GLASM {
|
namespace Shader::Backend::GLASM {
|
||||||
|
|
||||||
|
@ -111,19 +112,39 @@ void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a, ScalarF32
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
||||||
ctx.Add("DDX.FINE {}.x,{};", inst, p);
|
if (ctx.profile.support_derivative_control) {
|
||||||
|
ctx.Add("DDX.FINE {}.x,{};", inst, p);
|
||||||
|
} else {
|
||||||
|
// LOG_WARNING
|
||||||
|
ctx.Add("DDX {}.x,{};", inst, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitDPdyFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
void EmitDPdyFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
||||||
ctx.Add("DDY.FINE {}.x,{};", inst, p);
|
if (ctx.profile.support_derivative_control) {
|
||||||
|
ctx.Add("DDY.FINE {}.x,{};", inst, p);
|
||||||
|
} else {
|
||||||
|
// LOG_WARNING
|
||||||
|
ctx.Add("DDY {}.x,{};", inst, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitDPdxCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
void EmitDPdxCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
||||||
ctx.Add("DDX.COARSE {}.x,{};", inst, p);
|
if (ctx.profile.support_derivative_control) {
|
||||||
|
ctx.Add("DDX.COARSE {}.x,{};", inst, p);
|
||||||
|
} else {
|
||||||
|
// LOG_WARNING
|
||||||
|
ctx.Add("DDX {}.x,{};", inst, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitDPdyCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
void EmitDPdyCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {
|
||||||
ctx.Add("DDY.COARSE {}.x,{};", inst, p);
|
if (ctx.profile.support_derivative_control) {
|
||||||
|
ctx.Add("DDY.COARSE {}.x,{};", inst, p);
|
||||||
|
} else {
|
||||||
|
// LOG_WARNING
|
||||||
|
ctx.Add("DDY {}.x,{};", inst, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Shader::Backend::GLASM
|
} // namespace Shader::Backend::GLASM
|
||||||
|
|
|
@ -82,6 +82,7 @@ struct Profile {
|
||||||
bool support_typeless_image_loads{};
|
bool support_typeless_image_loads{};
|
||||||
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 warp_size_potentially_larger_than_guest{};
|
bool warp_size_potentially_larger_than_guest{};
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,7 @@ Device::Device() {
|
||||||
has_precise_bug = TestPreciseBug();
|
has_precise_bug = TestPreciseBug();
|
||||||
has_broken_texture_view_formats = is_amd || (!is_linux && is_intel);
|
has_broken_texture_view_formats = is_amd || (!is_linux && is_intel);
|
||||||
has_nv_viewport_array2 = GLAD_GL_NV_viewport_array2;
|
has_nv_viewport_array2 = GLAD_GL_NV_viewport_array2;
|
||||||
|
has_derivative_control = GLAD_GL_ARB_derivative_control;
|
||||||
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");
|
||||||
|
|
|
@ -96,6 +96,10 @@ public:
|
||||||
return has_nv_viewport_array2;
|
return has_nv_viewport_array2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasDerivativeControl() const {
|
||||||
|
return has_derivative_control;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasDebuggingToolAttached() const {
|
bool HasDebuggingToolAttached() const {
|
||||||
return has_debugging_tool_attached;
|
return has_debugging_tool_attached;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +145,7 @@ private:
|
||||||
bool has_broken_texture_view_formats{};
|
bool has_broken_texture_view_formats{};
|
||||||
bool has_fast_buffer_sub_data{};
|
bool has_fast_buffer_sub_data{};
|
||||||
bool has_nv_viewport_array2{};
|
bool has_nv_viewport_array2{};
|
||||||
|
bool has_derivative_control{};
|
||||||
bool has_debugging_tool_attached{};
|
bool has_debugging_tool_attached{};
|
||||||
bool use_assembly_shaders{};
|
bool use_assembly_shaders{};
|
||||||
bool use_asynchronous_shaders{};
|
bool use_asynchronous_shaders{};
|
||||||
|
|
|
@ -274,6 +274,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
|
||||||
.support_typeless_image_loads = device.HasImageLoadFormatted(),
|
.support_typeless_image_loads = device.HasImageLoadFormatted(),
|
||||||
.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(),
|
||||||
|
|
||||||
.warp_size_potentially_larger_than_guest = true,
|
.warp_size_potentially_larger_than_guest = true,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue