Skip to content

Conversation

@jkiviluoto-nv
Copy link
Contributor

Fixes #7380

Add test input specification, which lists test types and their inputs, as well as options for each test type.

Fixes shader-slang#7380

Add test input specification, which lists test types and their inputs,
as well as options for each test type.
@jkiviluoto-nv jkiviluoto-nv requested a review from a team as a code owner October 24, 2025 06:06
Available test types:
- `SIMPLE`: Runs the slangc compiler with specified options after the command
- `REFLECTION`: Runs slang-reflection-test with the options specified after the command
- `INTERPRET`: Runs slangi interpreter to execute shader code and compare output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: slangi --> slang

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually slangi with "i".


Example: `size=4` creates a 4×4 2D texture or 4×4×4 3D texture

**`arrayLength=N`** - Number of array elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could maybe be reworded a bit. While array elements is technically correct, the element itself is a texture. Perhaps better wording would be: Number of textures in the array

For terminology etc, see:


**`arrayLength=N`** - Number of array elements

Example: `arrayLength=2` on Texture2D creates Texture2DArray with 2 elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, perhaps: a Texture2DArray with two 2D textures

(Also, I'd maybe use another arrayLength to avoid repeating the number 2.)

#### Complex Parameter Block
```slang
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
//TEST_INPUT: set scene = new Scene {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can break the line in TEST_INPUT.

I tested locally by modifying bindings/nested-parameter-block-2.slang, but couldn't make the line breaks work. I'd presume this test is the source for this example.

RWStructuredBuffer<float> output;
```

#### Array of Textures
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Care must be taken so that this doesn't get confused with Texture2DArray.

Here, I think this is an array of two independent texture handles.

For reference, Texture2DArray is a single handle to an array of homogeneous 2D textures. The textures inside a 2D array must have matching sizes.

There's two things I'd consider:

  • Use two differently sized Texture2D elements to make the point that these are independent handles.
  • Add a similar example for Texture2DArray to make it clear that these are two different things

@samestep
Copy link
Contributor

Does this also address #7651?

Copy link
Collaborator

@jkwak-work jkwak-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me so far and I left some comments.

I didn't realize how many features slang-test supports until I read this doc.

Specify type conformances for interface/dynamic dispatch testing:

```slang
//TEST_INPUT: type_conformance DerivedType:BaseInterface=id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does id mean and do?

Comment on lines +391 to +396
Examples:
```slang
//TEST_INPUT: type_conformance Foo:IFoo=1
//TEST_INPUT: type_conformance Bar:IFoo=2
//TEST_INPUT: type_conformance FloatVal:IInterface=3
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need more complete example for this.
We need the actual shader that has Foo, Bar, IFoo, FloatVal and IInterface.

Comment on lines +402 to +406
**`globalSpecializationArg`** - Global specialization argument (type or value)
```slang
//TEST_INPUT: globalSpecializationArg MyType
//TEST_INPUT: globalSpecializationArg 7
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is globalSpecializationArg a keyword? or can I use any variable name there?
I have never seen this one.

I think we need a more complete shader as an example for this too.


### Modifiers

Resource declarations can include modifiers after a colon (`:`), separated by commas:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen inconsistent expression where name is followed by = but not always.
I am not sure if we want to document that = is optional or change the code to strictly either require =; or not require.

Options: `data`, `stride`, `count`, `counter`, `random`, `format`

Examples:
```slang
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually help for syntax highlight?
Maybe it should be c# or anything actually working?

Comment on lines +257 to +259
**`counter=N`** - Counter value for append/consume buffers

Example: `counter=0`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how this works...
I mean what does 0 means and what happens if I use 1?

Comment on lines +358 to +362
//TEST_INPUT: set scene = new Scene {
{ {1,2,3,4} },
ubuffer(data=[1 2 3 4], stride=4),
new MaterialSystem {{ {1,2,3,4} }, ubuffer(data=[1 2 3 4], stride=4)}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the slang shader that goes with this setting.

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Oct 29, 2025
@jkwak-work jkwak-work self-assigned this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to write slang-test test cases

4 participants