|
| 1 | +// TODO: There are issues running tests combined texture samplers in DX12. |
| 2 | +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -shaderobj -output-using-type -use-dxil -profile cs_6_7 -dx12 |
| 3 | + |
| 4 | +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type -emit-spirv-directly -render-feature hardware-device -xslang -DVK |
| 5 | + |
| 6 | +//TEST_INPUT: ubuffer(data=[2], stride=4):out,name outputBuffer |
| 7 | +RWStructuredBuffer<int> outputBuffer; |
| 8 | + |
| 9 | +//TEST_INPUT:ubuffer(data=[1 1 1 1]):name=iBuf |
| 10 | +RWByteAddressBuffer iBuf; |
| 11 | + |
| 12 | +// |
| 13 | +// Combined texture samplers. |
| 14 | +// |
| 15 | + |
| 16 | +//TEST_INPUT: TextureSampler1D(size=4, content = one):name st1D_f32v3 |
| 17 | +Sampler1D<float3> st1D_f32v3; |
| 18 | +//TEST_INPUT: TextureSampler2D(size=4, content = one):name st2D_f32v3 |
| 19 | +Sampler2D<float3> st2D_f32v3; |
| 20 | +//TEST_INPUT: TextureSampler3D(size=4, content = one):name st3D_f32v3 |
| 21 | +Sampler3D<float3> st3D_f32v3; |
| 22 | + |
| 23 | +//TEST_INPUT: TextureSampler1D(size=4, content = one, arrayLength=2):name st1DArray_f32v3 |
| 24 | +Sampler1DArray<float3> st1DArray_f32v3; |
| 25 | +//TEST_INPUT: TextureSampler2D(size=4, content = one, arrayLength=2):name st2DArray_f32v3 |
| 26 | +Sampler2DArray<float3> st2DArray_f32v3; |
| 27 | + |
| 28 | +//TEST_INPUT: TextureSampler1D(size=4, content = one):name st1D_f32v4 |
| 29 | +Sampler1D<float4> st1D_f32v4; |
| 30 | +//TEST_INPUT: TextureSampler2D(size=4, content = one):name st2D_f32v4 |
| 31 | +Sampler2D<float4> st2D_f32v4; |
| 32 | +//TEST_INPUT: TextureSampler3D(size=4, content = one):name st3D_f32v4 |
| 33 | +Sampler3D<float4> st3D_f32v4; |
| 34 | + |
| 35 | +//TEST_INPUT: TextureSampler1D(size=4, content = one, arrayLength=2):name st1DArray_f32v4 |
| 36 | +Sampler1DArray<float4> st1DArray_f32v4; |
| 37 | +//TEST_INPUT: TextureSampler2D(size=4, content = one, arrayLength=2):name st2DArray_f32v4 |
| 38 | +Sampler2DArray<float4> st2DArray_f32v4; |
| 39 | + |
| 40 | +// |
| 41 | +// Combined depth texture samplers. |
| 42 | +// |
| 43 | + |
| 44 | +__generic<T : ITexelElement, let sampleCount:int=0, let format:int=0> |
| 45 | +typealias CombinedDepth2d = _Texture< |
| 46 | + T, |
| 47 | + __Shape2D, |
| 48 | + 0, // isArray |
| 49 | + 0, // isMS |
| 50 | + sampleCount, |
| 51 | + 0, // access |
| 52 | + 1, // isShadow |
| 53 | + 1, // isCombined |
| 54 | + format |
| 55 | +>; |
| 56 | + |
| 57 | +__generic<T : ITexelElement, let sampleCount:int=0, let format:int=0> |
| 58 | +typealias CombinedDepth2d_array = _Texture< |
| 59 | + T, |
| 60 | + __Shape2D, |
| 61 | + 1, // isArray |
| 62 | + 0, // isMS |
| 63 | + sampleCount, |
| 64 | + 0, // access |
| 65 | + 1, // isShadow |
| 66 | + 1, // isCombined |
| 67 | + format |
| 68 | +>; |
| 69 | + |
| 70 | + |
| 71 | +//TEST_INPUT: TextureSampler2D(size=4, content = zero):name cd2D |
| 72 | +CombinedDepth2d<float> cd2D; |
| 73 | +//TEST_INPUT: TextureSampler2D(size=4, content = zero, arrayLength=2):name cd2DArray |
| 74 | +CombinedDepth2d_array<float> cd2DArray; |
| 75 | + |
| 76 | +uint getNotMapped() |
| 77 | +{ |
| 78 | + // We want to return a status uint that causes `CheckAccessFullyMapped` to return false. |
| 79 | + // These are just educated guesses - actual implementation differ between platforms and drivers. |
| 80 | +#if defined(VK) |
| 81 | + return 0xFFFFFFFFU; |
| 82 | +#else |
| 83 | + return 0; |
| 84 | +#endif |
| 85 | +} |
| 86 | + |
| 87 | +bool TEST_combinedDepth() |
| 88 | +{ |
| 89 | + float u = 0.0; |
| 90 | + int offset = 0; |
| 91 | + float clamp = 0.0; |
| 92 | + float slice = 0.0; |
| 93 | + float level = 0.0; |
| 94 | + float compareValue = 0.0; |
| 95 | + |
| 96 | + uint status; |
| 97 | + |
| 98 | + return true |
| 99 | + // ================= |
| 100 | + // float SampleCmp() |
| 101 | + // ================= |
| 102 | + && (status = getNotMapped(), all(0.0 == cd2D.SampleCmp(float2(u), compareValue, int2(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 103 | + && (status = getNotMapped(), all(0.0 == cd2DArray.SampleCmp(float3(u, u, slice), compareValue, int2(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 104 | + |
| 105 | + // ========================== |
| 106 | + // float SampleCmpLevelZero() |
| 107 | + // ========================== |
| 108 | + && (status = getNotMapped(), all(0.0 == cd2D.SampleCmpLevelZero(float2(u), compareValue, int2(offset), status))) && CheckAccessFullyMapped(status) |
| 109 | + && (status = getNotMapped(), all(0.0 == cd2DArray.SampleCmpLevelZero(float3(u, u, slice), compareValue, int2(offset), status))) && CheckAccessFullyMapped(status) |
| 110 | + |
| 111 | + // ====================== |
| 112 | + // float SampleCmpLevel() |
| 113 | + // ====================== |
| 114 | + && (status = getNotMapped(), all(0.0 == cd2D.SampleCmpLevel(float2(u), compareValue, level, int2(offset), status))) && CheckAccessFullyMapped(status) |
| 115 | + && (status = getNotMapped(), all(0.0 == cd2DArray.SampleCmpLevel(float3(u, u, slice), compareValue, level, int2(offset), status))) && CheckAccessFullyMapped(status) |
| 116 | + ; |
| 117 | +} |
| 118 | + |
| 119 | +bool TEST_sampler<T>( |
| 120 | + Sampler1D<T> t1D, |
| 121 | + Sampler2D<T> t2D, |
| 122 | + Sampler3D<T> t3D, |
| 123 | + Sampler1DArray<T> t1DArray, |
| 124 | + Sampler2DArray<T> t2DArray, |
| 125 | +) where T : ITexelElement, IArithmetic |
| 126 | +{ |
| 127 | + typealias TN = T; |
| 128 | + |
| 129 | + float u = 0.0; |
| 130 | + int offset = 0; |
| 131 | + float clamp = 0.0; |
| 132 | + float slice = 0.0; |
| 133 | + float bias = 0.0; |
| 134 | + float grad = 0.0; |
| 135 | + float level = 0.0; |
| 136 | + constexpr const float ddx = 0.0f; |
| 137 | + constexpr const float ddy = 0.0f; |
| 138 | + |
| 139 | + uint status; |
| 140 | + |
| 141 | + return true |
| 142 | + // ========== |
| 143 | + // T Sample() |
| 144 | + // ========== |
| 145 | + && (status = getNotMapped(), all(TN(T(1)) == t1D.Sample(u, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 146 | + && (status = getNotMapped(), all(TN(T(1)) == t2D.Sample(float2(u), int2(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 147 | + && (status = getNotMapped(), all(TN(T(1)) == t3D.Sample(float3(u), int3(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 148 | + && (status = getNotMapped(), all(TN(T(1)) == t1DArray.Sample(float2(u, slice), offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 149 | + && (status = getNotMapped(), all(TN(T(1)) == t2DArray.Sample(float3(u, u, slice), offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 150 | + |
| 151 | + // ============== |
| 152 | + // T SampleBias() |
| 153 | + // ============== |
| 154 | + && (status = getNotMapped(), all(TN(T(1)) == t1D.SampleBias(u, bias, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 155 | + && (status = getNotMapped(), all(TN(T(1)) == t2D.SampleBias(float2(u), bias, int2(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 156 | + && (status = getNotMapped(), all(TN(T(1)) == t3D.SampleBias(float3(u), bias, int3(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 157 | + && (status = getNotMapped(), all(TN(T(1)) == t1DArray.SampleBias(float2(u, slice), bias, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 158 | + && (status = getNotMapped(), all(TN(T(1)) == t2DArray.SampleBias(float3(u, u, slice), bias, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 159 | + |
| 160 | + // ============== |
| 161 | + // T SampleGrad() |
| 162 | + // ============== |
| 163 | + && (status = getNotMapped(), all(TN(T(1)) == t1D.SampleGrad(u, ddx, ddy, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 164 | + && (status = getNotMapped(), all(TN(T(1)) == t2D.SampleGrad(float2(u), ddx, ddy, int2(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 165 | + && (status = getNotMapped(), all(TN(T(1)) == t3D.SampleGrad(float3(u), ddx, ddy, int3(offset), clamp, status))) && CheckAccessFullyMapped(status) |
| 166 | + && (status = getNotMapped(), all(TN(T(1)) == t1DArray.SampleGrad(float2(u, slice), ddx, ddy, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 167 | + && (status = getNotMapped(), all(TN(T(1)) == t2DArray.SampleGrad(float3(u, u, slice), ddx, ddy, offset, clamp, status))) && CheckAccessFullyMapped(status) |
| 168 | + |
| 169 | + // ============== |
| 170 | + // T SampleLevel() |
| 171 | + // ============== |
| 172 | + && (status = getNotMapped(), all(TN(T(1)) == t1D.SampleLevel(u, level, offset, status))) && CheckAccessFullyMapped(status) |
| 173 | + && (status = getNotMapped(), all(TN(T(1)) == t2D.SampleLevel(float2(u), level, int2(offset), status))) && CheckAccessFullyMapped(status) |
| 174 | + && (status = getNotMapped(), all(TN(T(1)) == t3D.SampleLevel(float3(u), level, int3(offset), status))) && CheckAccessFullyMapped(status) |
| 175 | + && (status = getNotMapped(), all(TN(T(1)) == t1DArray.SampleLevel(float2(u, slice), level, offset, status))) && CheckAccessFullyMapped(status) |
| 176 | + && (status = getNotMapped(), all(TN(T(1)) == t2DArray.SampleLevel(float3(u, u, slice), level, offset, status))) && CheckAccessFullyMapped(status) |
| 177 | + ; |
| 178 | +} |
| 179 | + |
| 180 | +[numthreads(4, 1, 1)] |
| 181 | +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) |
| 182 | +{ |
| 183 | + bool result = true |
| 184 | + // Make sure CheckAccessFullyMapped can return false |
| 185 | + && (!CheckAccessFullyMapped(getNotMapped())) |
| 186 | + && TEST_sampler( |
| 187 | + st1D_f32v3, |
| 188 | + st2D_f32v3, |
| 189 | + st3D_f32v3, |
| 190 | + st1DArray_f32v3, |
| 191 | + st2DArray_f32v3, |
| 192 | + ) |
| 193 | + && TEST_sampler( |
| 194 | + st1D_f32v4, |
| 195 | + st2D_f32v4, |
| 196 | + st3D_f32v4, |
| 197 | + st1DArray_f32v4, |
| 198 | + st2DArray_f32v4, |
| 199 | + ) |
| 200 | + && TEST_combinedDepth() |
| 201 | + ; |
| 202 | + |
| 203 | + //CHK:1 |
| 204 | + outputBuffer[0] = int(result); |
| 205 | +} |
0 commit comments