summaryrefslogtreecommitdiff
path: root/src
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
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 '')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_context.cpp6
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp34
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp2
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp36
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc28
-rw-r--r--src/shader_recompiler/profile.h1
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp1
8 files changed, 79 insertions, 30 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,
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index 865f34291..2d29d8c14 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -830,7 +830,7 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) {
830} 830}
831 831
832void EmitContext::DefineGlobalMemoryFunctions(const Info& info) { 832void EmitContext::DefineGlobalMemoryFunctions(const Info& info) {
833 if (!info.uses_global_memory) { 833 if (!info.uses_global_memory || !profile.support_int64) {
834 return; 834 return;
835 } 835 }
836 using DefPtr = Id StorageDefinitions::*; 836 using DefPtr = Id StorageDefinitions::*;
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
index ccebf170d..679ee2684 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
@@ -84,15 +84,27 @@ void EmitLoadGlobalS16(EmitContext&) {
84} 84}
85 85
86Id EmitLoadGlobal32(EmitContext& ctx, Id address) { 86Id EmitLoadGlobal32(EmitContext& ctx, Id address) {
87 return ctx.OpFunctionCall(ctx.U32[1], ctx.load_global_func_u32, address); 87 if (ctx.profile.support_int64) {
88 return ctx.OpFunctionCall(ctx.U32[1], ctx.load_global_func_u32, address);
89 }
90 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
91 return ctx.Const(0u);
88} 92}
89 93
90Id EmitLoadGlobal64(EmitContext& ctx, Id address) { 94Id EmitLoadGlobal64(EmitContext& ctx, Id address) {
91 return ctx.OpFunctionCall(ctx.U32[2], ctx.load_global_func_u32x2, address); 95 if (ctx.profile.support_int64) {
96 return ctx.OpFunctionCall(ctx.U32[2], ctx.load_global_func_u32x2, address);
97 }
98 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
99 return ctx.Const(0u, 0u);
92} 100}
93 101
94Id EmitLoadGlobal128(EmitContext& ctx, Id address) { 102Id EmitLoadGlobal128(EmitContext& ctx, Id address) {
95 return ctx.OpFunctionCall(ctx.U32[4], ctx.load_global_func_u32x4, address); 103 if (ctx.profile.support_int64) {
104 return ctx.OpFunctionCall(ctx.U32[4], ctx.load_global_func_u32x4, address);
105 }
106 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
107 return ctx.Const(0u, 0u, 0u, 0u);
96} 108}
97 109
98void EmitWriteGlobalU8(EmitContext&) { 110void EmitWriteGlobalU8(EmitContext&) {
@@ -112,15 +124,27 @@ void EmitWriteGlobalS16(EmitContext&) {
112} 124}
113 125
114void EmitWriteGlobal32(EmitContext& ctx, Id address, Id value) { 126void EmitWriteGlobal32(EmitContext& ctx, Id address, Id value) {
115 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32, address, value); 127 if (ctx.profile.support_int64) {
128 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32, address, value);
129 return;
130 }
131 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
116} 132}
117 133
118void EmitWriteGlobal64(EmitContext& ctx, Id address, Id value) { 134void EmitWriteGlobal64(EmitContext& ctx, Id address, Id value) {
119 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32x2, address, value); 135 if (ctx.profile.support_int64) {
136 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32x2, address, value);
137 return;
138 }
139 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
120} 140}
121 141
122void EmitWriteGlobal128(EmitContext& ctx, Id address, Id value) { 142void EmitWriteGlobal128(EmitContext& ctx, Id address, Id value) {
123 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32x4, address, value); 143 if (ctx.profile.support_int64) {
144 ctx.OpFunctionCall(ctx.void_id, ctx.write_global_func_u32x4, address, value);
145 return;
146 }
147 LOG_WARNING(Shader_SPIRV, "Int64 not supported, ignoring memory operation");
124} 148}
125 149
126Id EmitLoadStorageU8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) { 150Id EmitLoadStorageU8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) {
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index 9af750283..d91098c80 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -71,20 +71,20 @@ OPCODE(UndefU32, U32,
71OPCODE(UndefU64, U64, ) 71OPCODE(UndefU64, U64, )
72 72
73// Memory operations 73// Memory operations
74OPCODE(LoadGlobalU8, U32, U64, ) 74OPCODE(LoadGlobalU8, U32, Opaque, )
75OPCODE(LoadGlobalS8, U32, U64, ) 75OPCODE(LoadGlobalS8, U32, Opaque, )
76OPCODE(LoadGlobalU16, U32, U64, ) 76OPCODE(LoadGlobalU16, U32, Opaque, )
77OPCODE(LoadGlobalS16, U32, U64, ) 77OPCODE(LoadGlobalS16, U32, Opaque, )
78OPCODE(LoadGlobal32, U32, U64, ) 78OPCODE(LoadGlobal32, U32, Opaque, )
79OPCODE(LoadGlobal64, U32x2, U64, ) 79OPCODE(LoadGlobal64, U32x2, Opaque, )
80OPCODE(LoadGlobal128, U32x4, U64, ) 80OPCODE(LoadGlobal128, U32x4, Opaque, )
81OPCODE(WriteGlobalU8, Void, U64, U32, ) 81OPCODE(WriteGlobalU8, Void, Opaque, U32, )
82OPCODE(WriteGlobalS8, Void, U64, U32, ) 82OPCODE(WriteGlobalS8, Void, Opaque, U32, )
83OPCODE(WriteGlobalU16, Void, U64, U32, ) 83OPCODE(WriteGlobalU16, Void, Opaque, U32, )
84OPCODE(WriteGlobalS16, Void, U64, U32, ) 84OPCODE(WriteGlobalS16, Void, Opaque, U32, )
85OPCODE(WriteGlobal32, Void, U64, U32, ) 85OPCODE(WriteGlobal32, Void, Opaque, U32, )
86OPCODE(WriteGlobal64, Void, U64, U32x2, ) 86OPCODE(WriteGlobal64, Void, Opaque, U32x2, )
87OPCODE(WriteGlobal128, Void, U64, U32x4, ) 87OPCODE(WriteGlobal128, Void, Opaque, U32x4, )
88 88
89// Storage buffer operations 89// Storage buffer operations
90OPCODE(LoadStorageU8, U32, U32, U32, ) 90OPCODE(LoadStorageU8, U32, U32, U32, )
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h
index 6ff12387b..501dcaf71 100644
--- a/src/shader_recompiler/profile.h
+++ b/src/shader_recompiler/profile.h
@@ -15,6 +15,7 @@ struct Profile {
15 bool support_descriptor_aliasing{}; 15 bool support_descriptor_aliasing{};
16 bool support_int8{}; 16 bool support_int8{};
17 bool support_int16{}; 17 bool support_int16{};
18 bool support_int64{};
18 bool support_vertex_instance_id{}; 19 bool support_vertex_instance_id{};
19 bool support_float_controls{}; 20 bool support_float_controls{};
20 bool support_separate_denorm_behavior{}; 21 bool support_separate_denorm_behavior{};
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 2d7eb3e33..58a4f0fb4 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -168,6 +168,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
168 .support_descriptor_aliasing = false, 168 .support_descriptor_aliasing = false,
169 .support_int8 = false, 169 .support_int8 = false,
170 .support_int16 = false, 170 .support_int16 = false,
171 .support_int64 = device.HasShaderInt64(),
171 .support_vertex_instance_id = true, 172 .support_vertex_instance_id = true,
172 .support_float_controls = false, 173 .support_float_controls = false,
173 .support_separate_denorm_behavior = false, 174 .support_separate_denorm_behavior = false,
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 87b843e3d..a2646fc6d 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -280,6 +280,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw
280 .support_descriptor_aliasing = true, 280 .support_descriptor_aliasing = true,
281 .support_int8 = true, 281 .support_int8 = true,
282 .support_int16 = device.IsShaderInt16Supported(), 282 .support_int16 = device.IsShaderInt16Supported(),
283 .support_int64 = device.IsShaderInt64Supported(),
283 .support_vertex_instance_id = false, 284 .support_vertex_instance_id = false,
284 .support_float_controls = true, 285 .support_float_controls = true,
285 .support_separate_denorm_behavior = float_control.denormBehaviorIndependence == 286 .support_separate_denorm_behavior = float_control.denormBehaviorIndependence ==