<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/cross-compile/image-load.slang.glsl, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2019-05-22T16:58:19+00:00</updated>
<entry>
<title>Translate .Load() to imageLoad() for Vulkan (#967)</title>
<updated>2019-05-22T16:58:19+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-05-22T16:58:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=06e1ab6982df097727b74174d5b39a7f27c2dae3'/>
<id>urn:sha1:06e1ab6982df097727b74174d5b39a7f27c2dae3</id>
<content type='text'>
* Translate .Load() to imageLoad() for Vulkan

We were already emitting calls to `imageLoad()` and `imageStore` when a `RWTexture*` was used with `operator[]`:

```hlsl
RWTexture2D&lt;float&gt; myTex;
...
float value = myTex[xy]; // becomes an imageLoad
myTex[xy] = value;       // becomes an imageStore
```

However, we were *not* correctly handling the translation of an explicit `.Load()` operation:

```hlsl
float value = myTex.Load(xy);
```

The `.Load()` operation was being translated to a GLSL `texelFetch` as it would be a for a `Texture2D`, and not to an `imageLoad()` as would make sense for a `RWTexture2D` (which becomes a GLSL `image2D`).

This fix is confined to the stdlib, and is mostly a matter of emitting either `texelFetch` or `imageLoad` as the GLSL function name depending on the "access" of the resource type. It is messy code, but straightforward.

One extra detail was that there had been logic to emit a `, 0` argument in the `texelFetch` calls in the non-read-only case, because `texelFetch` usualy requires an explicit mip-level argument and `.Load()` on a `RWTexture*` doesn't recieve an LOD parameter. This is a non-issue now that we are calling `imageLoad()` instead, because `imageLoad` doesn't need/want the extra argument.

* fixup: change test baseline based on recent GLSL output changes

* fixup: review feedback
</content>
</entry>
</feed>
