diff options
| author | Yong He <yonghe@outlook.com> | 2021-06-02 16:58:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-02 16:58:25 -0700 |
| commit | e67af5b1a3993529c702ff2924dea11fd1017d2e (patch) | |
| tree | c4359fb6df6110d81a658278aef9ab7244af5496 /tests | |
| parent | 8e571669b3c8d4ac8236d0aed7a960bf88ad2bd1 (diff) | |
Various Fixes to gfx, reflection and emit. (#1867)
* Various Fixes to gfx, reflection and emit.
- Fix GLSL emit to properly output `*bitsTo*` functions for `IRBitCast` insts.
- Add line directive mode setting for `ISession`.
- Extend `TypeLayout::getElementStride` to handle `VectorType` case.
- Fix `IDevice::readBufferResource` 's D3D12 implementation to copy only the requested bytes out.
- Fix `render-test` to use the `ISession` from `gfx` instead of creating its own `ISession` to make sure `gfx` and `render-test` agree on WitnessTable and RTTI IDs.
- Extend `render-test` to support filling vector and matrix values in the new `set x = ...` TEST_INPUT syntax.
- Add a `dynamic-dispatch-15` test case to make sure packing / unpacking works correctly across all targets, and to make sure render-test's RTTI/WitnessTable ID filling logic is correct for non-trivial cases.
* Remove default-major test
* Fix cyclic reference in `ExtendedTypeLayout`.
* Move `lineDirectiveMode` setting to `TargetDesc`.
Add `structureSize` to `TargetDesc` and `SessionDesc` for future binary compatibility.
* Cleanup.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/default-major.slang | 11 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-15.slang | 82 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-15.slang.expected.txt | 2 |
3 files changed, 91 insertions, 4 deletions
diff --git a/tests/compute/default-major.slang b/tests/compute/default-major.slang index 743dbe656..858ca5632 100644 --- a/tests/compute/default-major.slang +++ b/tests/compute/default-major.slang @@ -1,11 +1,14 @@ // default-major.slang -// The default layout should be column. Unfortunately CPU and CUDA only work with row layout, so they have to be disabled here. +// The default layout should be column. +// This test is disabled because `gfx` layer always initializes Slang to use row-major layout. +// To test this behavior we need to find a way to make `gfx` use Slang default instead. +// Unfortunately CPU and CUDA only work with row layout, so they have to be disabled here. //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -compile-arg -O3 -shaderobj -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -dx12 -shaderobj -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -dx12 -shaderobj +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj // This data is in column major layout order.... diff --git a/tests/compute/dynamic-dispatch-15.slang b/tests/compute/dynamic-dispatch-15.slang new file mode 100644 index 000000000..5e2be1a4c --- /dev/null +++ b/tests/compute/dynamic-dispatch-15.slang @@ -0,0 +1,82 @@ +// Test packing/unpacking different types of fields into `AnyValue`s. + +//dTEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -output-using-type +//dTEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -output-using-type +//dTEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -output-using-type + +[anyValueSize(16)] +interface IInterface +{ + float run(); +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer<float> gOutputBuffer; + +//TEST_INPUT: set gObj = dynamic new StructuredBuffer<IInterface>[new FloatVal{1.0}, new Float4Val{{[2.0, 3.0, 4.0, 5.0]}}, new IntVal{6}, new Int4Val{[7,8,9,10]}]; +RWStructuredBuffer<IInterface> gObj; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // Test unpacking. + float result = 0.0; + for (int i = 0; i < 4; i++) + { + IInterface v0 = gObj.Load(i); + result += v0.run(); + } + + // Test packing. + IInterface v[2]; + Float4Val cval; + cval.val.val = float4(1,2,3,4); + v[0] = cval; + + Int4Val ival; + ival.val = int4(2,3,4,5); + v[1] = ival; + + for (int i = 0; i < 2; i++) + { + result += v[i].run(); + } + gOutputBuffer[0] = result; +} + +// Type must be marked `public` to ensure it is visible in the generated DLL. +public struct FloatVal : IInterface +{ + float val; + float run() + { + return val; + } +}; +interface ISomething{void g();} +struct Float4Struct : ISomething { float4 val; void g() {} } +public struct Float4Val : IInterface +{ + Float4Struct val; + float run() + { + return val.val.x; + } +}; +public struct IntVal : IInterface +{ + int val; + float run() + { + return val; + } +}; +public struct Int4Val : IInterface +{ + int4 val; + float run() + { + return val.x; + } +};
\ No newline at end of file diff --git a/tests/compute/dynamic-dispatch-15.slang.expected.txt b/tests/compute/dynamic-dispatch-15.slang.expected.txt new file mode 100644 index 000000000..efbae0290 --- /dev/null +++ b/tests/compute/dynamic-dispatch-15.slang.expected.txt @@ -0,0 +1,2 @@ +type: float +19.0 |
