From 4f979d74acf2800d7bd2b38155d2bdc47b57d54b Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 24 Sep 2018 19:17:12 -0700 Subject: Fixes around atomic operations (#652) * Fixes around atomic operations Work on #651 The existing handling of atomic operations had a few issues: * The HLSL atomic functions (`Interlocked*`) didn't have mappings to GLSL * Atomic operations on images weren't supported at all because the subscript operation on `RWTexture*` types didn't provide a `ref` acessor * The HLSL atomic functions were only providing the overloads that return the previous value through an `out` parameter, and not the ones that ignore the previous value. This change fixes these issues with the following changes: * `RWTexture*` types now have a `ref` accessor on their subscript operation which maps to a new `imageSubscript` operation in the IR. By default this translates back to `tex[idx]` in output HLSL, but it makes a custom mapping possible for GLSL * The `Interlocked*` function definitions were expanded to include the overloads without the `out` parameter * GLSL translations were added for the `Interlocked*` functions. These mappings use some new customization points in the intrinsic operation emit logic to support outputting calls to either `atomic*` or `imageAtomic*` as required, and to expand an argument that is a subscript into an image as multiple arguments. This whole approach is quite hacky, and it doesn't seem like the approach we should take in the long run. * Fix: typo in InterlockedAnd lowering One of the cases of `InterlockedAnd` was lowering to `atomicAnd` with a `$0` where we wanted the `$A` substitution to handle the possibility of an image. --- source/slang/core.meta.slang | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source/slang/core.meta.slang') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 56f5d8d1f..aa93863df 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -784,11 +784,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) default: sb << "__target_intrinsic(glsl, \"imageStore($0, " << ivecN << "($1), $V2)\") set;\n"; - // Note: HLSL doesn't support component-granularity access into typed UAVs, - // and also doesn't support atomic operations on them. As such, there should - // be no reason why a `ref` accessor is required here. - // - // sb << "ref;\n"; + sb << "__intrinsic_op(" << int(kIROp_ImageSubscript) << ") ref;\n"; break; } -- cgit v1.2.3