summaryrefslogtreecommitdiff
path: root/source/slang/core.meta.slang.h
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-07-31 09:02:22 -0700
committerGitHub <noreply@github.com>2018-07-31 09:02:22 -0700
commit5ea746a571ced32a8975eb3a238c562b3d487149 (patch)
tree8f041cf1a17215ee908b2459168d637f2b93f71d /source/slang/core.meta.slang.h
parent9914ca800c92e9b3fe768dec4e913a302f3d678d (diff)
Fix imageStore output for types other than 4-vectors (#622)
Fixes issue #620 Given a `RWTexture*` store operation like: ```hlsl RWTexture3D a<float>; ... float x = 1.0f; a[crd] = x; ``` We were generating output GLSL like: ```glsl layout(rgba32f) image3D a; ... float x = 1.0f; imageStore(a, crd, x); ``` but in that case, the `imageStore` operation expected a `vec4` and not a `float` for the last argument, and we fail GLSL compilation. This change extends our handling of the `imageStore` operation in the stdlib so that we pad out the last argument if it is not a 4-vector. We also flesh out the code that was picking a `layout(...)` modifier for image formats so that it doesn't just blindly use `layout(rgba32f)` and instead takes the element type fed to `RWTexture3D<...>` into account. With these two changes, the above HLSL/Slang code now translates to: ```glsl layout(r32f) image3D a; ... float x = 1.0f; imageStore(a, crd, vec4(x, float(0), float(0), float(0))); ``` Note that we are padding out the `x` argument to a full vector, and also that we declare the image with `layout(r32f)` to reflect the fact that it has only as single channel.
Diffstat (limited to 'source/slang/core.meta.slang.h')
-rw-r--r--source/slang/core.meta.slang.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/source/slang/core.meta.slang.h b/source/slang/core.meta.slang.h
index 555353c92..0f69d0b5b 100644
--- a/source/slang/core.meta.slang.h
+++ b/source/slang/core.meta.slang.h
@@ -759,7 +759,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
break;
default:
- sb << "__target_intrinsic(glsl, \"imageStore($0, " << ivecN << "($1), $2)\") set;\n";
+ 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