summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-02-19 22:10:18 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:22 +0200
commit6db69990da9f232e6d982cdcb69c2e27d93075cf (patch)
tree9367909cd030622ea36c4cadccd2fabc6f28d471 /src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
parentshader: Primitive Vulkan integration (diff)
downloadyuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar.gz
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar.bz2
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar.lz
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar.xz
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.tar.zst
yuzu-6db69990da9f232e6d982cdcb69c2e27d93075cf.zip
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
index 77d698ffd..808c1b401 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_memory.cpp
@@ -94,8 +94,7 @@ void EmitLoadStorageS16(EmitContext&) {
throw NotImplementedException("SPIR-V Instruction");
}
-Id EmitLoadStorage32(EmitContext& ctx, const IR::Value& binding,
- const IR::Value& offset) {
+Id EmitLoadStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) {
if (!binding.IsImmediate()) {
throw NotImplementedException("Dynamic storage buffer indexing");
}
@@ -129,8 +128,8 @@ void EmitWriteStorageS16(EmitContext&) {
throw NotImplementedException("SPIR-V Instruction");
}
-void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding,
- const IR::Value& offset, Id value) {
+void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
+ Id value) {
if (!binding.IsImmediate()) {
throw NotImplementedException("Dynamic storage buffer indexing");
}
@@ -140,8 +139,19 @@ void EmitWriteStorage32(EmitContext& ctx, const IR::Value& binding,
ctx.OpStore(pointer, value);
}
-void EmitWriteStorage64(EmitContext&) {
- throw NotImplementedException("SPIR-V Instruction");
+void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
+ Id value) {
+ if (!binding.IsImmediate()) {
+ throw NotImplementedException("Dynamic storage buffer indexing");
+ }
+ // TODO: Support reinterpreting bindings, guaranteed to be aligned
+ const Id ssbo{ctx.ssbos[binding.U32()]};
+ const Id low_index{StorageIndex(ctx, offset, sizeof(u32))};
+ const Id high_index{ctx.OpIAdd(ctx.U32[1], low_index, ctx.Constant(ctx.U32[1], 1U))};
+ const Id low_pointer{ctx.OpAccessChain(ctx.storage_u32, ssbo, ctx.u32_zero_value, low_index)};
+ const Id high_pointer{ctx.OpAccessChain(ctx.storage_u32, ssbo, ctx.u32_zero_value, high_index)};
+ ctx.OpStore(low_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 0U));
+ ctx.OpStore(high_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 1U));
}
void EmitWriteStorage128(EmitContext&) {