|
| 1 | +struct VsOutput { |
| 2 | + float4 pos : SV_POSITION; |
| 3 | + float2 uv : TEXCOORD; |
| 4 | +}; |
| 5 | + |
| 6 | +static const uint kIndexCount = 64; |
| 7 | +static const uint kRows = 4; |
| 8 | +static const uint kColumns = 4; |
| 9 | +static const float4 kPass = float4(0.0, 1.0, 0.0, 1.0); |
| 10 | +static const float4 kFail = float4(1.0, 0.0, 0.0, 1.0); |
| 11 | +static const float4 kIgnore = float4(1.0, 0.0, 1.0, 1.0); |
| 12 | + |
| 13 | +uint MakeU32(uint index) { |
| 14 | + uint b0 = index * 4 + 0; |
| 15 | + uint b1 = index * 4 + 1; |
| 16 | + uint b2 = index * 4 + 2; |
| 17 | + uint b3 = index * 4 + 3; |
| 18 | + return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); |
| 19 | +} |
| 20 | + |
| 21 | +Buffer<uint> buffer_uint1; |
| 22 | + |
| 23 | +float4 RunBufferTest1() { |
| 24 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 25 | + if (buffer_uint1[u] != MakeU32(u)) { |
| 26 | + return kFail; |
| 27 | + } |
| 28 | + } |
| 29 | + return kPass; |
| 30 | +} |
| 31 | + |
| 32 | +Buffer<uint2> buffer_uint2; |
| 33 | + |
| 34 | +float4 RunBufferTest2() { |
| 35 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 36 | + if (buffer_uint2[u / 2][u % 2] != MakeU32(u)) { |
| 37 | + return kFail; |
| 38 | + } |
| 39 | + } |
| 40 | + return kPass; |
| 41 | +} |
| 42 | + |
| 43 | +float4 RunBufferTest3() { |
| 44 | + return kIgnore; |
| 45 | +} |
| 46 | + |
| 47 | +Buffer<uint4> buffer_uint4; |
| 48 | + |
| 49 | +float4 RunBufferTest4() { |
| 50 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 51 | + if (buffer_uint4[u / 4][u % 4] != MakeU32(u)) { |
| 52 | + return kFail; |
| 53 | + } |
| 54 | + } |
| 55 | + return kPass; |
| 56 | +} |
| 57 | + |
| 58 | +RWBuffer<uint> rwbuffer_uint1; |
| 59 | + |
| 60 | +float4 RunRWBufferTest1() { |
| 61 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 62 | + if (rwbuffer_uint1[u] != MakeU32(u)) { |
| 63 | + return kFail; |
| 64 | + } |
| 65 | + } |
| 66 | + return kPass; |
| 67 | +} |
| 68 | + |
| 69 | +RWBuffer<uint2> rwbuffer_uint2; |
| 70 | + |
| 71 | +float4 RunRWBufferTest2() { |
| 72 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 73 | + if (rwbuffer_uint2[u / 2][u % 2] != MakeU32(u)) { |
| 74 | + return kFail; |
| 75 | + } |
| 76 | + } |
| 77 | + return kPass; |
| 78 | +} |
| 79 | + |
| 80 | +float4 RunRWBufferTest3() { |
| 81 | + return kIgnore; |
| 82 | +} |
| 83 | + |
| 84 | +RWBuffer<uint4> rwbuffer_uint4; |
| 85 | + |
| 86 | +float4 RunRWBufferTest4() { |
| 87 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 88 | + if (rwbuffer_uint4[u / 4][u % 4] != MakeU32(u)) { |
| 89 | + return kFail; |
| 90 | + } |
| 91 | + } |
| 92 | + return kPass; |
| 93 | +} |
| 94 | + |
| 95 | +StructuredBuffer<uint> structured_buffer_uint1; |
| 96 | + |
| 97 | +float4 RunStructuredBufferTest1() { |
| 98 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 99 | + if (structured_buffer_uint1[u] != MakeU32(u)) { |
| 100 | + return kFail; |
| 101 | + } |
| 102 | + } |
| 103 | + return kPass; |
| 104 | +} |
| 105 | + |
| 106 | +StructuredBuffer<uint2> structured_buffer_uint2; |
| 107 | + |
| 108 | +float4 RunStructuredBufferTest2() { |
| 109 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 110 | + if (structured_buffer_uint2[u / 2][u % 2] != MakeU32(u)) { |
| 111 | + return kFail; |
| 112 | + } |
| 113 | + } |
| 114 | + return kPass; |
| 115 | +} |
| 116 | + |
| 117 | +StructuredBuffer<uint3> structured_buffer_uint3; |
| 118 | + |
| 119 | +float4 RunStructuredBufferTest3() { |
| 120 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 121 | + if (structured_buffer_uint3[u / 3][u % 3] != MakeU32(u)) { |
| 122 | + return kFail; |
| 123 | + } |
| 124 | + } |
| 125 | + return kPass; |
| 126 | +} |
| 127 | + |
| 128 | +StructuredBuffer<uint4> structured_buffer_uint4; |
| 129 | + |
| 130 | +float4 RunStructuredBufferTest4() { |
| 131 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 132 | + if (structured_buffer_uint4[u / 4][u % 4] != MakeU32(u)) { |
| 133 | + return kFail; |
| 134 | + } |
| 135 | + } |
| 136 | + return kPass; |
| 137 | +} |
| 138 | + |
| 139 | +RWStructuredBuffer<uint> rwstructured_buffer_uint1; |
| 140 | + |
| 141 | +float4 RunRWStructuredBufferTest1() { |
| 142 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 143 | + if (rwstructured_buffer_uint1[u] != MakeU32(u)) { |
| 144 | + return kFail; |
| 145 | + } |
| 146 | + } |
| 147 | + return kPass; |
| 148 | +} |
| 149 | + |
| 150 | +RWStructuredBuffer<uint2> rwstructured_buffer_uint2; |
| 151 | + |
| 152 | +float4 RunRWStructuredBufferTest2() { |
| 153 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 154 | + if (rwstructured_buffer_uint2[u / 2][u % 2] != MakeU32(u)) { |
| 155 | + return kFail; |
| 156 | + } |
| 157 | + } |
| 158 | + return kPass; |
| 159 | +} |
| 160 | + |
| 161 | +RWStructuredBuffer<uint3> rwstructured_buffer_uint3; |
| 162 | + |
| 163 | +float4 RunRWStructuredBufferTest3() { |
| 164 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 165 | + if (rwstructured_buffer_uint3[u / 3][u % 3] != MakeU32(u)) { |
| 166 | + return kFail; |
| 167 | + } |
| 168 | + } |
| 169 | + return kPass; |
| 170 | +} |
| 171 | + |
| 172 | +RWStructuredBuffer<uint4> rwstructured_buffer_uint4; |
| 173 | + |
| 174 | +float4 RunRWStructuredBufferTest4() { |
| 175 | + for (uint u = 0; u < kIndexCount; ++u) { |
| 176 | + if (rwstructured_buffer_uint4[u / 4][u % 4] != MakeU32(u)) { |
| 177 | + return kFail; |
| 178 | + } |
| 179 | + } |
| 180 | + return kPass; |
| 181 | +} |
| 182 | + |
| 183 | +float4 RunTest(uint index) { |
| 184 | + switch (index) { |
| 185 | + case 0: |
| 186 | + return RunBufferTest1(); |
| 187 | + case 1: |
| 188 | + return RunBufferTest2(); |
| 189 | + case 2: |
| 190 | + return RunBufferTest3(); |
| 191 | + case 3: |
| 192 | + return RunBufferTest4(); |
| 193 | + case 4: |
| 194 | + return RunRWBufferTest1(); |
| 195 | + case 5: |
| 196 | + return RunRWBufferTest2(); |
| 197 | + case 6: |
| 198 | + return RunRWBufferTest3(); |
| 199 | + case 7: |
| 200 | + return RunRWBufferTest4(); |
| 201 | + case 8: |
| 202 | + return RunStructuredBufferTest1(); |
| 203 | + case 9: |
| 204 | + return RunStructuredBufferTest2(); |
| 205 | + case 10: |
| 206 | + return RunStructuredBufferTest3(); |
| 207 | + case 11: |
| 208 | + return RunStructuredBufferTest4(); |
| 209 | + case 12: |
| 210 | + return RunRWStructuredBufferTest1(); |
| 211 | + case 13: |
| 212 | + return RunRWStructuredBufferTest2(); |
| 213 | + case 14: |
| 214 | + return RunRWStructuredBufferTest3(); |
| 215 | + case 15: |
| 216 | + return RunRWStructuredBufferTest4(); |
| 217 | + default: |
| 218 | + return kIgnore; |
| 219 | + } |
| 220 | +} |
| 221 | + |
| 222 | +float4 main(VsOutput input) : SV_TARGET |
| 223 | +{ |
| 224 | + uint i = min(uint(input.uv.y * kRows), kRows - 1); |
| 225 | + uint j = min(uint(input.uv.x * kColumns), kColumns - 1); |
| 226 | + return RunTest(i * kColumns + j); |
| 227 | +} |
0 commit comments