<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/compute/matrix-layout-structured-buffer.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>2025-08-25T05:20:41+00:00</updated>
<entry>
<title>Fix#8084: Batch-8: Enable cuda tests (#8268)</title>
<updated>2025-08-25T05:20:41+00:00</updated>
<author>
<name>Harsh Aggarwal (NVIDIA)</name>
<email>haaggarwal@nvidia.com</email>
</author>
<published>2025-08-25T05:20:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=1562f98c07954ae17f9e7ef186f6c8eb029740ab'/>
<id>urn:sha1:1562f98c07954ae17f9e7ef186f6c8eb029740ab</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Metal: misc fixes and enable more tests. (#4374)</title>
<updated>2024-06-13T23:29:58+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2024-06-13T23:29:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cfef0c6f66c9d36ae2899c8c2790c3fe422a7700'/>
<id>urn:sha1:cfef0c6f66c9d36ae2899c8c2790c3fe422a7700</id>
<content type='text'>
* Fix and enable tests for metal.

* Fix.

* Fix.

* Fix tests.

* Fix warnings.

* Fix.

---------

Co-authored-by: Yong He &lt;yonghe@Yongs-Mac-mini.local&gt;</content>
</entry>
<entry>
<title>Metal compute tests (#4292)</title>
<updated>2024-06-07T07:28:16+00:00</updated>
<author>
<name>skallweitNV</name>
<email>64953474+skallweitNV@users.noreply.github.com</email>
</author>
<published>2024-06-07T07:28:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=004fe27a52b7952111ad7e749397aeff499de7ed'/>
<id>urn:sha1:004fe27a52b7952111ad7e749397aeff499de7ed</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Warning on lossy implicit casts. (#2367)</title>
<updated>2022-08-18T06:08:34+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2022-08-18T06:08:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=adaea0e993fd8db351b5dad92802e47ed6d0ec77'/>
<id>urn:sha1:adaea0e993fd8db351b5dad92802e47ed6d0ec77</id>
<content type='text'>
* Warning on bool to float conversion.

* Fix test cases.

* Improve.

* LanguageServer: don't show constant value for non constant variables.

* Fix tests.

* Fix warnings in tests.

Co-authored-by: Yong He &lt;yhe@nvidia.com&gt;</content>
</entry>
<entry>
<title>Convert more tests to use shader objects (#1659)</title>
<updated>2021-01-15T20:10:06+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2021-01-15T20:10:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2a5d5b32348c33aac7ca62aa9a4c2bb7cff8e08a'/>
<id>urn:sha1:2a5d5b32348c33aac7ca62aa9a4c2bb7cff8e08a</id>
<content type='text'>
This change converts a large number of our existing tests to use the `ShaderObject` support that was added to the `gfx` layer.

In many cases, tests were just updated to pass `-shaderobj` and the result Just Worked.
In other cases, a `name` attribute had to be added to one or more `TEST_INPUT` lines.

For tests that did not work with shader objects "out of the box," I spent a little bit of time trying to get them work, but fell back to letting those tests run in the older mode.
Future changes to the infrastructure will be needed to get those additional tests working in the new path.

Along with the changes to test files, the following implementation changes were made to get additional tests working:

* Because the shader object mode uses explicit register bindings (from reflection), the hacky logic that was offseting `u` registers for D3D12 based on the number of render targets gets disabled (by another hack).

* The "flat" reflection information coming from Slang was not correctly reporting "binding ranges" for things that consumed only uniform data (which would be everything on CUDA/CPU), so it was refactored to properly include binding ranges for anything where the type of the field/variable implied a binding range should be created (even if the `LayoutResourceKind` was `::Uniform`).

* A few fixes were made to the CUDA implementation of `Renderer`, in order to get additional tests up and running. Most of these changes had to do with texture bindings, which hadn't really been tested previously.

In addition, a few changes were made that were attempts at getting more tests working, but didn't actually help. These could be dropped if requested:

* As a quality-of-life feature (not being used) the `object` style of `TEST_INPUT` line is upgraded to support inferring the type to use from the type of the input being set.

* Any `object` shader input lines get ignored in non-shader-object mode.</content>
</entry>
<entry>
<title>Add shader object parameter binding to renderer_test. (#1622)</title>
<updated>2020-12-03T16:23:05+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2020-12-03T16:23:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=44c0a56974b664e50b2cb8cb6f10740b19c4e02f'/>
<id>urn:sha1:44c0a56974b664e50b2cb8cb6f10740b19c4e02f</id>
<content type='text'>
* Add shader object parameter binding to renderer_test.

* remove multiple-definitions.hlsl

* Fix cuda implementation.

Co-authored-by: Tim Foley &lt;tfoleyNV@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>Fix layout for structured buffers of matrices (#1184)</title>
<updated>2020-01-28T20:35:13+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2020-01-28T20:35:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=8b3e3beea66d9773adf11ea2e163577d649f3d7c'/>
<id>urn:sha1:8b3e3beea66d9773adf11ea2e163577d649f3d7c</id>
<content type='text'>
When using row-major layout (via command-line or API option), the following sort of declaration:

```hlsl
StructuredBuffer&lt;float4x4&gt; gBuffer;

... gBuffer[i] ...
```

Generates unexpected results when compiled to DXBC via fxc or DXIL via dxc, because the fxc/dxc compilers do not respect the matrix layout mode in this specific case (a structured buffer of matrices). Instead, they always use column-major layout, even if row-major was requested by the user.

A user can work around this behavior by wrapping the matrix in a `struct`:

```hlsl
struct Wrapper { float4x4 wrapped; }
SturcturedBuffer&lt;Wrapper&gt; gBuffer;

... gBuffer[i].wrapped ...
```

This change simply automates that workaround when compiling for an HLSL-based downstream compiler, so that we get the same behavior across all our backends.

The change adds a test case to confirm the behavior across multiple targets, but it turns out we also had a test checked in that confirmed the buggy (or at least surprising) fxc/dxc behavior, so that one had its baselines changed and can work as a regression test for this fix as well.</content>
</entry>
<entry>
<title>Remove support for explicit register/binding syntax on TEST_INPUT (#1132)</title>
<updated>2019-11-21T22:06:19+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-11-21T22:06:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2ea64ff4f2c7c43b72ff24650330fca79a87500f'/>
<id>urn:sha1:2ea64ff4f2c7c43b72ff24650330fca79a87500f</id>
<content type='text'>
The `TEST_INPUT` facility allows textual Slang test cases to provide two kinds of information to the `render-test` tool:

1. Information on what shader inputs exist
2. Information on what values/objects to bind into those shader inputs

Under the first category of information, there exists supporting for attaching a `dxbinding(...)` annotation to a `TEST_INPUT` which seemingly indicates what HLSL `register` the input uses. There is a similar `glbinding(...)` annotation, used for OpenGL and Vulkan.

It turns out that these annotations were, in practice, completely ignored and had no bearing on how `render-test` allocates or bindings graphics API objects. There was some amount of code attempting to validate that explicit registers/bindings were being set appropriately, but the actual values were being ignored.

The visible consequence of the `dxbinding` and `glbinding` annotations being ignored is issue #1036: the order of `TEST_INPUT` lines was *de facto* determining the registers/bindings that were being used by `render-test`.

This change simply removes the placebo features and strips things down to what is implemented in practice: the `TEST_INPUT` lines do not need target-API-specific binding/register numbers, because their order in the file implicitly defines them.

I added logic to the parsing of `TEST_INPUT` lines to make sure I got an error message on any leftover annotations, and went ahead and systematicaly deleted all of the placebo annotations from our test cases.

If we decide to make `TEST_INPUT` lines *not* depend on order of declaration in the future, we can build it up as a new and better considered feature.

The main alternative I considered was to keep the annotations in place, and change `render-test` and the `gfx` abstraction layer to properly respect them, but that path actually creates much more opportunity for breakage (since every single test case would suddenly be specifying its root signature / pipeline layout via a different path using data that has never been tested). The approach in this change has the benefit of giving me high confidence that all the test cases continue to work just as they had before.</content>
</entry>
<entry>
<title>WIP: CPU compute coverage (#1030)</title>
<updated>2019-08-22T19:58:28+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2019-08-22T19:58:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=06a0e3980fd04fa265bd20eb11f2abc18bd6a215'/>
<id>urn:sha1:06a0e3980fd04fa265bd20eb11f2abc18bd6a215</id>
<content type='text'>
* Add support for '=' when defining a name in test.

* Add support for  double intrinsics.

* Add support for asdouble
Add findOrAddInst - used instead of findOrEmitHoistableInst, for nominal instructions.
Support cloning of string literals.
C++ working on more compute tests.

* Constant buffer support in reflection.
Fixed debugging into source for generated C++.
buffer-layout.slang works.

* Added cpu test result.

* Remove some commented out code.
Comment on next fixes.

* Improvements to reflection CPU code.

* C++ working with ByteAddressBuffer.

* Enabled more compute tests for CPU.

* Enabled more compute tests on CPU.
Added support for [] style access to a vector.

* Enabled more CPU compute tests.

* Handling of buffer-type-splitting.slang
Named buffers can be paths to resources

* Fix some warnings, remove some dead code.

* Fix problem with verification of number of operands for asuint/asint as they can have 1 or 3 operands. asdouble takes 2.

* Fix handling in MemoryArena around aligned allocations. That _allocateAlignedFromNewBlock assumed the block allocated has the aligment that was requested and so did not correct the start address.
</content>
</entry>
<entry>
<title>Confirm layout for structured buffer of matrices, and related fixes (#889)</title>
<updated>2019-03-08T22:59:47+00:00</updated>
<author>
<name>Tim Foley</name>
<email>tfoleyNV@users.noreply.github.com</email>
</author>
<published>2019-03-08T22:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=281c67b8d92899f462695fe75a26467743a497e8'/>
<id>urn:sha1:281c67b8d92899f462695fe75a26467743a497e8</id>
<content type='text'>
* Fix up handling of NumElements for D3D buffer views

For everything but structured buffers we'd been setting this to the size in bytes, but that isn't really valid at all.
The `NumElements` member in the view descs is supposed to be the number of buffer elements, so it would be capped at the byte size divided by the element size.

This change fixes the computation of `NumElements` to take the size of the format into account for non-structured views.
For the "raw" case, we use a size of 4 bytes since that matches the `DXGI_FORMAT_R32_TYPELESS` format we use (which seems to be required for raw buffers).

I also added support for the raw case for SRVs where it didn't seem to be supported before (not that any of our tests cover it).

* Fix handling of size padding for D3D11 buffers

The existing code was enforcing a 256-byte-aligned size for all buffers, but this can cause problems for a structured buffer.
A structured buffer must have a size that is a multiple of the stride, so a structured buffer with a 48-byte stride and a 96-byte size would get rounded up to 256 bytes, which is not an integer multiple of 48.

This change makes it so that we only apply the padding to constant buffers.
According to MSDN, constant buffers only require padding to a 16-byte aligned size, and no other restrictions are listed for D3D11, but it is difficult to know whether those constrains are exhaustive.

I've left in the 256-byte padding for now (rather than switch to 16-byte), even though I suspect that was only needed as a band-aid for the `NumElements` issue fixed by another commit.

* Fix an IR generation bug when indxing into a strutured buffer element

The problem here arises when we have a structured buffer of matrices (an array type would likely trigger it too):

```hlsl
RWStructuredBuffer&lt;float3x4&gt; gMatrices;
```

and then we index into it directly, rather than copying to a temporary:

```hlsl
// CRASH:
float v = gMatrices[i][j][k];

// OKAY:
float3x4 m = gMatrices[i];
float v = m[j][k];
```

The underlying issue is that our IR lowering pass tries to defer the decision about whether to use a `get` vs. `set` vs. `ref` accessor for a subscript until as late as possible (this is to deal with the fact that sometimes D3D can provide a `ref` accessor where GLSL can only provide a `get` or `set`).

We probably need to overhaul that aspect of IR codegen sooner or later, but this change uses some of the existing machinery to try to force the `gMatrices[i]` subexpression to take the form of a pointer when doing sub-indexing like this. This fixes the present case, and hopefully shouldn't break anything else that used to work (because the subroutines I'm using to coerce the `gMatrices[i]` expression should be idempotent on the cases that were already implemented).

* Add a test case to confirm fxc/dxc layout for structured buffers of matrices

Even when row-major layout is requested globally, fxc and dxc seem to lay out a `StructuredBuffer&lt;float3x4&gt;` with column-major layout on the elements.
This commit adds a test that confirms that behavior.

This commit does not try to implement a fix for the issue (either fixing Slang's layout reflection information to be correct for what fxc/dxc do in practice, or fixing Slang's HLSL output to work around the fxc/dxc behavior), but just documents the status quo.
If/when we decide how we'd like to handle the issue long-term, this test can/should be updated to match the decision we make.

* fixup: build breakage on clang/gcc

This is one of those cases where the Microsoft compiler is letting through some stuff that isn't technically valid C++ ("delayed template parsing").
Fixed by just moving some declarations to earlier in the file.
</content>
</entry>
</feed>
