From 122126c006e53bd48064f220104d425b8bf91ddf Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 5 Feb 2020 10:16:14 -0800 Subject: Add support for RWBuffer writes on GLSL/SPIR-V target (#1199) This appears to have been an oversight in the work that added support for `imageStore` as well as atomics when writing to `RWTexture*` and friends. The HLSL/Slang `RWBuffer` type maps to GLSL as an `imageBuffer`, which is effectively just another case of writable texture image (bonus points to anybody who can explain to me the meaningful distinction between an `imageBuffer` and an `image1D`). This change copies the handling of subscript access (`operator[]`) from textures over to buffers, and adds a test case to confirm that the new handling works for the simple case of setting a buffer element. --- source/slang/hlsl.meta.slang | 4 +++- source/slang/hlsl.meta.slang.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 2930494c0..a646c1b77 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -1504,7 +1504,9 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) if (access != SLANG_RESOURCE_ACCESS_READ) { - sb << "ref;\n"; + sb << "__target_intrinsic(glsl, \"imageStore($0, int($1), $V2)\") set;\n"; + + sb << "__intrinsic_op(" << int(kIROp_ImageSubscript) << ") ref;\n"; } sb << "}\n"; diff --git a/source/slang/hlsl.meta.slang.h b/source/slang/hlsl.meta.slang.h index a58709087..b66f43103 100644 --- a/source/slang/hlsl.meta.slang.h +++ b/source/slang/hlsl.meta.slang.h @@ -1580,14 +1580,16 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) if (access != SLANG_RESOURCE_ACCESS_READ) { - sb << "ref;\n"; + sb << "__target_intrinsic(glsl, \"imageStore($0, int($1), $V2)\") set;\n"; + + sb << "__intrinsic_op(" << int(kIROp_ImageSubscript) << ") ref;\n"; } sb << "}\n"; sb << "};\n"; } -SLANG_RAW("#line 1514 \"hlsl.meta.slang\"") +SLANG_RAW("#line 1516 \"hlsl.meta.slang\"") SLANG_RAW("\n") SLANG_RAW("\n") SLANG_RAW("\n") -- cgit v1.2.3