- 
                Notifications
    
You must be signed in to change notification settings  - Fork 365
 
Document slang-test options and categories #8809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Document slang-test options and categories #8809
Conversation
Fixes shader-slang#7380 Add test input specification, which lists test types and their inputs, as well as options for each test type.
| 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 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: slangi --> slang
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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 { | 
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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
 
| 
           Does this also address #7651?  | 
    
There was a problem hiding this 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 | 
There was a problem hiding this comment.
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?
| Examples: | ||
| ```slang | ||
| //TEST_INPUT: type_conformance Foo:IFoo=1 | ||
| //TEST_INPUT: type_conformance Bar:IFoo=2 | ||
| //TEST_INPUT: type_conformance FloatVal:IInterface=3 | ||
| ``` | 
There was a problem hiding this comment.
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.
| **`globalSpecializationArg`** - Global specialization argument (type or value) | ||
| ```slang | ||
| //TEST_INPUT: globalSpecializationArg MyType | ||
| //TEST_INPUT: globalSpecializationArg 7 | ||
| ``` | 
There was a problem hiding this comment.
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: | 
There was a problem hiding this comment.
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 | 
There was a problem hiding this comment.
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?
| **`counter=N`** - Counter value for append/consume buffers | ||
| 
               | 
          ||
| Example: `counter=0` | 
There was a problem hiding this comment.
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?
| //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)} | ||
| } | 
There was a problem hiding this comment.
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.
Fixes #7380
Add test input specification, which lists test types and their inputs, as well as options for each test type.