<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/bugs/gh-941.slang, 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>2024-06-08T12:12:49+00:00</updated>
<entry>
<title>SPIRV `Block` decoration fixes. (#4303)</title>
<updated>2024-06-08T12:12:49+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-06-08T12:12:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9a23a9aab3721828526c921db1e779008e133e8f'/>
<id>urn:sha1:9a23a9aab3721828526c921db1e779008e133e8f</id>
<content type='text'>
* SPIRV `Block` decoration fixes.

- SPIRV does not allow duplicate `Block` decorations. So we shouldn't be generating them.

- Also fixes duplication of OpName.

- SPIRV and HLSL do not allow ConstantBuffer with trailing unsized arrays. Added a check in the front-end against such code.

* Convert failing cross-compile tests to filecheck.

---------

Co-authored-by: Jay Kwak &lt;82421531+jkwak-work@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Enable appropriate GLSL extension for unbounded-size resource arrays (#957)</title>
<updated>2019-04-29T15:32:24+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-04-29T15:32:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b7c60910367f2af2c359d76783975de0a4659c68'/>
<id>urn:sha1:b7c60910367f2af2c359d76783975de0a4659c68</id>
<content type='text'>
Fixes #941

The GLSL we were emitting for unbounded-size arrays was the obvious:

```hlsl
// This HLSL:
Texture2D t[];
```

```glsl
// ... becomes this GLSL:
texture2D t[];
```

Unfortunately, the legacy GLSL behavior for an array without a declared size is what is called an "implicitly-sized" array, which means that it is assumed to actually have a fixed size, which is determined by the maximum integer constant value used to index into it (and only integer constants are allowed to be used when indexing into it).

Users hadn't noticed the issue for a while, because most of our users who rely on unbounded-size arrays were also using the HLSL `NonUniformResourceIndex` function:

```hlsl
float4 v = t[NonUniformResourceIndex(idx)].Sample(...);
```

When mapping such code to GLSL we use the `nonuniformEXT` qualifier added by the `GL_EXT_nonuniform_qualifier` extension, and it turns out that a secondary feature of that extension is that it changes the GLSL language semantics for arrays (of resources) with an unspecified size, so that they instead behave like we want. So users were happy and we were blissfully ignorant of the lurking issue.

The problem is that as soon as a user neglects to use `NonUniformResourceIndex` (perhaps because an index really is uniform):

```hlsl
cbuffer C { uint definitelyUniform; }
...
float4 v = t[definitelyUniform].Sample(...);
```

Now the code we emit doesn't need `nonuniformEXT` so it doesn't enable `GL_EXT_nonuniform_qualifier` and the declaration of `t` now falls under the "implicitly-sized" array rules, and thus the code fails because `definitelyUniform` is being used as an index but is *not* an integer constant.

The fix is pretty simple: when emitting a declaration of a global shader parameter to GLSL, we check if it is an unbounded-size array of resources and, if so, enable the `GL_EXT_nonuniform_qualifier` extension.

We don't need any clever handling to deal with resource parameters nested in `struct` types or in entry-point parameter lists, etc., because previous IR passes will have split up complex types and moved everything to the global scope already.</content>
</entry>
</feed>
