summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl
diff options
context:
space:
mode:
authorGravatar ameerj2021-07-04 00:34:53 -0400
committerGravatar ameerj2021-07-22 21:51:40 -0400
commit11f04f1022d0820a1fdba38221ecd38f19d86d9e (patch)
treec30e87d0a66b0100cb3f7b3ad2fb3bd769654a7a /src/shader_recompiler/backend/glsl
parentvulkan_device: Add missing include algorithm (diff)
downloadyuzu-11f04f1022d0820a1fdba38221ecd38f19d86d9e.tar.gz
yuzu-11f04f1022d0820a1fdba38221ecd38f19d86d9e.tar.xz
yuzu-11f04f1022d0820a1fdba38221ecd38f19d86d9e.zip
shader: Ignore global memory ops on devices lacking int64 support
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp6
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp34
2 files changed, 31 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp
index 0dcdff152..e08d2d2eb 100644
--- a/src/shader_recompiler/backend/glsl/emit_context.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_context.cpp
@@ -378,7 +378,7 @@ void EmitContext::SetupExtensions() {
378 if (info.uses_shadow_lod && profile.support_gl_texture_shadow_lod) { 378 if (info.uses_shadow_lod && profile.support_gl_texture_shadow_lod) {
379 header += "#extension GL_EXT_texture_shadow_lod : enable\n"; 379 header += "#extension GL_EXT_texture_shadow_lod : enable\n";
380 } 380 }
381 if (info.uses_int64) { 381 if (info.uses_int64 && profile.support_int64) {
382 header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; 382 header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
383 } 383 }
384 if (info.uses_int64_bit_atomics) { 384 if (info.uses_int64_bit_atomics) {
@@ -402,7 +402,7 @@ void EmitContext::SetupExtensions() {
402 info.uses_subgroup_shuffles || info.uses_fswzadd) { 402 info.uses_subgroup_shuffles || info.uses_fswzadd) {
403 header += "#extension GL_ARB_shader_ballot : enable\n" 403 header += "#extension GL_ARB_shader_ballot : enable\n"
404 "#extension GL_ARB_shader_group_vote : enable\n"; 404 "#extension GL_ARB_shader_group_vote : enable\n";
405 if (!info.uses_int64) { 405 if (!info.uses_int64 && profile.support_int64) {
406 header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; 406 header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
407 } 407 }
408 if (profile.support_gl_warp_intrinsics) { 408 if (profile.support_gl_warp_intrinsics) {
@@ -539,7 +539,7 @@ void EmitContext::DefineHelperFunctions() {
539 if (info.uses_atomic_s32_max) { 539 if (info.uses_atomic_s32_max) {
540 header += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}"; 540 header += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}";
541 } 541 }
542 if (info.uses_global_memory) { 542 if (info.uses_global_memory && profile.support_int64) {
543 header += DefineGlobalMemoryFunctions(); 543 header += DefineGlobalMemoryFunctions();
544 } 544 }
545 if (info.loads_indexed_attributes) { 545 if (info.loads_indexed_attributes) {
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
index daef5fb84..e3957491f 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp
@@ -7,6 +7,7 @@
7#include "shader_recompiler/backend/glsl/emit_context.h" 7#include "shader_recompiler/backend/glsl/emit_context.h"
8#include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" 8#include "shader_recompiler/backend/glsl/emit_glsl_instructions.h"
9#include "shader_recompiler/frontend/ir/value.h" 9#include "shader_recompiler/frontend/ir/value.h"
10#include "shader_recompiler/profile.h"
10 11
11namespace Shader::Backend::GLSL { 12namespace Shader::Backend::GLSL {
12namespace { 13namespace {
@@ -38,15 +39,27 @@ void EmitLoadGlobalS16(EmitContext&) {
38} 39}
39 40
40void EmitLoadGlobal32(EmitContext& ctx, IR::Inst& inst, std::string_view address) { 41void EmitLoadGlobal32(EmitContext& ctx, IR::Inst& inst, std::string_view address) {
41 ctx.AddU32("{}=LoadGlobal32({});", inst, address); 42 if (ctx.profile.support_int64) {
43 return ctx.AddU32("{}=LoadGlobal32({});", inst, address);
44 }
45 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
46 ctx.AddU32("{}=0u;", inst);
42} 47}
43 48
44void EmitLoadGlobal64(EmitContext& ctx, IR::Inst& inst, std::string_view address) { 49void EmitLoadGlobal64(EmitContext& ctx, IR::Inst& inst, std::string_view address) {
45 ctx.AddU32x2("{}=LoadGlobal64({});", inst, address); 50 if (ctx.profile.support_int64) {
51 return ctx.AddU32x2("{}=LoadGlobal64({});", inst, address);
52 }
53 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
54 ctx.AddU32x2("{}=uvec2(0);", inst);
46} 55}
47 56
48void EmitLoadGlobal128(EmitContext& ctx, IR::Inst& inst, std::string_view address) { 57void EmitLoadGlobal128(EmitContext& ctx, IR::Inst& inst, std::string_view address) {
49 ctx.AddU32x4("{}=LoadGlobal128({});", inst, address); 58 if (ctx.profile.support_int64) {
59 return ctx.AddU32x4("{}=LoadGlobal128({});", inst, address);
60 }
61 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
62 ctx.AddU32x4("{}=uvec4(0);", inst);
50} 63}
51 64
52void EmitWriteGlobalU8(EmitContext&) { 65void EmitWriteGlobalU8(EmitContext&) {
@@ -66,15 +79,24 @@ void EmitWriteGlobalS16(EmitContext&) {
66} 79}
67 80
68void EmitWriteGlobal32(EmitContext& ctx, std::string_view address, std::string_view value) { 81void EmitWriteGlobal32(EmitContext& ctx, std::string_view address, std::string_view value) {
69 ctx.Add("WriteGlobal32({},{});", address, value); 82 if (ctx.profile.support_int64) {
83 return ctx.Add("WriteGlobal32({},{});", address, value);
84 }
85 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
70} 86}
71 87
72void EmitWriteGlobal64(EmitContext& ctx, std::string_view address, std::string_view value) { 88void EmitWriteGlobal64(EmitContext& ctx, std::string_view address, std::string_view value) {
73 ctx.Add("WriteGlobal64({},{});", address, value); 89 if (ctx.profile.support_int64) {
90 return ctx.Add("WriteGlobal64({},{});", address, value);
91 }
92 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
74} 93}
75 94
76void EmitWriteGlobal128(EmitContext& ctx, std::string_view address, std::string_view value) { 95void EmitWriteGlobal128(EmitContext& ctx, std::string_view address, std::string_view value) {
77 ctx.Add("WriteGlobal128({},{});", address, value); 96 if (ctx.profile.support_int64) {
97 return ctx.Add("WriteGlobal128({},{});", address, value);
98 }
99 LOG_WARNING(Shader_GLSL, "Int64 not supported, ignoring memory operation");
78} 100}
79 101
80void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 102void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,