diff options
| author | Yong He <yonghe@outlook.com> | 2021-09-09 11:39:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-09 11:39:04 -0700 |
| commit | 28adf8917e53953dbfebd746410a427a55eed814 (patch) | |
| tree | b575bcdcc7860d64065e538d3fbf1d0466803aa3 /tests | |
| parent | cc075b76ee25876135584d31ec650776fcb69166 (diff) | |
`reinterpret` and 16-bit value packing. (#1933)
* `reinterpret` and 16-bit value packing.
* Update `half-texture` cross-compile test reference result.
* Revert inadvertent reformatting of slang-ir-inst-defs.h
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/half-texture.slang.1.expected | 14 | ||||
| -rw-r--r-- | tests/compute/pack-any-value-16bit.slang | 65 | ||||
| -rw-r--r-- | tests/compute/pack-any-value-16bit.slang.expected.txt | 4 |
3 files changed, 76 insertions, 7 deletions
diff --git a/tests/compute/half-texture.slang.1.expected b/tests/compute/half-texture.slang.1.expected index 7dd96403f..cd1f1e4f7 100644 --- a/tests/compute/half-texture.slang.1.expected +++ b/tests/compute/half-texture.slang.1.expected @@ -5,11 +5,11 @@ standard output = { #pragma pack_matrix(column_major) #line 8 "tests/compute/half-texture.slang" -RWTexture2D<half > halfTexture_0 : register(u1); +RWTexture2D<min16float > halfTexture_0 : register(u1); -RWTexture2D<vector<half,2> > halfTexture2_0 : register(u2); +RWTexture2D<vector<min16float,2> > halfTexture2_0 : register(u2); -RWTexture2D<vector<half,4> > halfTexture4_0 : register(u3); +RWTexture2D<vector<min16float,4> > halfTexture4_0 : register(u3); #line 5 @@ -27,15 +27,15 @@ void computeMain(vector<uint,3> dispatchThreadID_0 : SV_DISPATCHTHREADID) vector<int,2> pos2_0 = vector<int,2>(int(3) - pos_0.y, int(3) - pos_0.x); #line 29 - half h_0 = halfTexture_0[(vector<uint,2>) pos2_0]; - vector<half,2> h2_0 = halfTexture2_0[(vector<uint,2>) pos2_0]; - vector<half,4> h4_0 = halfTexture4_0[(vector<uint,2>) pos2_0]; + min16float h_0 = halfTexture_0[(vector<uint,2>) pos2_0]; + vector<min16float,2> h2_0 = halfTexture2_0[(vector<uint,2>) pos2_0]; + vector<min16float,4> h4_0 = halfTexture4_0[(vector<uint,2>) pos2_0]; halfTexture_0[(vector<uint,2>) pos_0] = h2_0.x + h2_0.y; halfTexture2_0[(vector<uint,2>) pos_0] = h4_0.xy; - halfTexture4_0[(vector<uint,2>) pos_0] = vector<half,4>(h2_0, h_0, h_0); + halfTexture4_0[(vector<uint,2>) pos_0] = vector<min16float,4>(h2_0, h_0, h_0); int index_0 = pos_0.x + pos_0.y * int(4); outputBuffer_0[(uint) index_0] = index_0; diff --git a/tests/compute/pack-any-value-16bit.slang b/tests/compute/pack-any-value-16bit.slang new file mode 100644 index 000000000..b4f41bb94 --- /dev/null +++ b/tests/compute/pack-any-value-16bit.slang @@ -0,0 +1,65 @@ +// Test anyvalue packing of 16bit types. + +//TEST_DISABLED(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -output-using-type +//TEST_DISABLED(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -output-using-type +//TEST(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(32)] +interface IInterface +{ + float run(); +} + +struct Val : IInterface +{ + int16_t v0; + float f0; + uint16_t v1; + float16_t v2; + half v3; + uint16_t v4; + float run() + { + return v0 + f0 + v1 + v2 + v3 + v4; + } +}; + +struct UserDefinedPackedType +{ + uint4 values[2]; +}; + +//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer<float> gOutputBuffer; + +//TEST_INPUT: type_conformance Val:IInterface = 11 + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint half_4_0 = 0x4400; // 4.0f + uint half_5_0 = 0x4500; // 5.0f + + UserDefinedPackedType objStorage; + objStorage.values[0] = uint4(1, asuint(2.0), (3U | (half_4_0<<16)), (half_5_0 | (6<<16))); + objStorage.values[1] = 0; + + IInterface dynamicObj = createDynamicObject<IInterface, UserDefinedPackedType>(11, objStorage); + float result = dynamicObj.run(); + gOutputBuffer[0] = result; + + Val v; + v.v0 = 1; + v.f0 = 2; + v.v1 = 3; + v.v2 = 4; + v.v3 = 5; + v.v4 = 6; + IInterface dynamicObj1 = createDynamicObject<IInterface, Val>(11, v);; + gOutputBuffer[1] = dynamicObj1.run(); + + var packed = reinterpret<UserDefinedPackedType, Val>(v); + var unpacked = reinterpret<Val, UserDefinedPackedType>(packed); + gOutputBuffer[2] = unpacked.run(); +} diff --git a/tests/compute/pack-any-value-16bit.slang.expected.txt b/tests/compute/pack-any-value-16bit.slang.expected.txt new file mode 100644 index 000000000..a285fe901 --- /dev/null +++ b/tests/compute/pack-any-value-16bit.slang.expected.txt @@ -0,0 +1,4 @@ +type: float +21.0 +21.0 +21.0
\ No newline at end of file |
