|
| 1 | +#--- source.hlsl |
| 2 | + |
| 3 | +// This test tests three different refraction scenarios |
| 4 | +// One in 2D, 3D, and 4D |
| 5 | + |
| 6 | +StructuredBuffer<half2> IncidentRay2D : register(t0); |
| 7 | +StructuredBuffer<half4> IncidentRay3D : register(t1); |
| 8 | +StructuredBuffer<half4> IncidentRay4D : register(t2); |
| 9 | +StructuredBuffer<half2> Wall2D : register(t3); |
| 10 | +StructuredBuffer<half4> Wall3D : register(t4); |
| 11 | +StructuredBuffer<half4> Wall4D : register(t5); |
| 12 | +RWStructuredBuffer<half2> Result2D : register(u6); |
| 13 | +RWStructuredBuffer<half4> Result3D : register(u7); |
| 14 | +RWStructuredBuffer<half4> Result4D : register(u8); |
| 15 | + |
| 16 | +[numthreads(1,1,1)] |
| 17 | +void main() { |
| 18 | + // 2D case |
| 19 | + half2 result2D = refract(IncidentRay2D[0], normalize(Wall2D[0]), 0.5); |
| 20 | + Result2D[0] = result2D; |
| 21 | + half2 result2D_constant = refract(half2(0.75, -0.5), half2(0.70710677, 0.70710677), half(0.5)); |
| 22 | + Result2D[1] = result2D_constant; |
| 23 | + // the below case is a case of total internal reflection, the 0 vector is expected |
| 24 | + Result2D[2] = refract(half2(0.75, -0.5), half2(0.70710677, 0.70710677), 1.3); |
| 25 | + |
| 26 | + // 3D case, using half4 for alignment |
| 27 | + half4 result3D = half4(refract(IncidentRay3D[0].xyz, normalize(Wall3D[0].xyz), 0.5), half(0.0)); |
| 28 | + Result3D[0] = result3D; |
| 29 | + half4 result3D_constant = half4(refract(half3(0.5, -0.25, 0.75), half3(0.5, 0.5, 0.70710677), 0.5), half(0.0)); |
| 30 | + Result3D[1] = result3D_constant; |
| 31 | + |
| 32 | + // 4D case |
| 33 | + half4 result4D = refract(IncidentRay4D[0].xyzw, normalize(Wall4D[0].xyzw), 0.5); |
| 34 | + Result4D[0] = result4D; |
| 35 | + half4 result4D_constant = refract(half4(0.5, -0.25, 0.75, -0.5), half4(0.5, 0.5, 0.5, 0.5), half(0.5)); |
| 36 | + Result4D[1] = result4D_constant; |
| 37 | +} |
| 38 | + |
| 39 | +//--- pipeline.yaml |
| 40 | + |
| 41 | +--- |
| 42 | +Shaders: |
| 43 | + - Stage: Compute |
| 44 | + Entry: main |
| 45 | + DispatchSize: [1, 1, 1] |
| 46 | +Buffers: |
| 47 | + |
| 48 | + - Name: IncidentRay2D |
| 49 | + Format: Float16 |
| 50 | + Stride: 4 |
| 51 | + Data: [ 0x3a00, 0xb800 ] |
| 52 | + - Name: IncidentRay3D |
| 53 | + Format: Float16 |
| 54 | + Stride: 8 |
| 55 | + Data: [ 0x3800, 0xb400, 0x3a00, 0x0 ] |
| 56 | + # 0.5, -0.25, 0.75, 0.0 |
| 57 | + - Name: IncidentRay4D |
| 58 | + Format: Float16 |
| 59 | + Stride: 8 |
| 60 | + Data: [ 0x3800, 0xb400, 0x3a00, 0xb800] |
| 61 | + # 0.5, -0.25, 0.75, -0.5 |
| 62 | + - Name: Wall2D |
| 63 | + Format: Float16 |
| 64 | + Stride: 4 |
| 65 | + Data: [ 0x39a8, 0x39a8 ] |
| 66 | + # 0.70703125, 0.70703125 |
| 67 | + - Name: Wall3D |
| 68 | + Format: Float16 |
| 69 | + Stride: 8 |
| 70 | + Data: [ 0x3800, 0x3800, 0x39a8, 0x0 ] |
| 71 | + # 0.5, 0.5, 0.70703125, 0.0 |
| 72 | + - Name: Wall4D |
| 73 | + Format: Float16 |
| 74 | + Stride: 8 |
| 75 | + Data: [ 0x3800, 0x3800, 0x3800, 0x3800 ] |
| 76 | + # 0.5, 0.5, 0.5, 0.5 |
| 77 | + - Name: Result2D |
| 78 | + Format: Float16 |
| 79 | + Stride: 4 |
| 80 | + ZeroInitSize: 16 |
| 81 | + - Name: ExpectedResult2D |
| 82 | + Format: Float16 |
| 83 | + Stride: 4 |
| 84 | + Data: [ 0xb4d9, 0xbb6d, 0xb4d9, 0xbb6d, 0x0, 0x0, 0x0, 0x0 ] |
| 85 | + # -0.30297852, -0.92822266, -0.30297852, -0.92822266, 0.0, 0.0, 0.0, 0.0, |
| 86 | + - Name: Result3D |
| 87 | + Format: Float16 |
| 88 | + Stride: 8 |
| 89 | + ZeroInitSize: 16 |
| 90 | + - Name: ExpectedResult3D |
| 91 | + Format: Float16 |
| 92 | + Stride: 8 |
| 93 | + Data: [ 0xb607, 0xba04, 0xb817, 0x0, 0xb607, 0xba04, 0xb817, 0x0 ] |
| 94 | + # -0.37670898, -0.7519531, 0.51123047, 0.0, -0.37670898, -0.7519531, 0.51123047, 0.0 |
| 95 | + - Name: Result4D |
| 96 | + Format: Float16 |
| 97 | + Stride: 8 |
| 98 | + ZeroInitSize: 16 |
| 99 | + - Name: ExpectedResult4D |
| 100 | + Format: Float16 |
| 101 | + Stride: 8 |
| 102 | + Data: [ 0xb400, 0xb900, 0xb000, 0xba00, 0xb400, 0xb900, 0xb000, 0xba00 ] |
| 103 | + # -0.25, -0.625, -0.125, -0.75, -0.25, -0.625, -0.125, -0.75 |
| 104 | +Results: |
| 105 | + - Result: CheckResult2D |
| 106 | + Rule: BufferFloatULP |
| 107 | + ULPT: 2 |
| 108 | + Actual: Result2D |
| 109 | + Expected: ExpectedResult2D |
| 110 | + - Result: CheckResult3D |
| 111 | + Rule: BufferFloatULP |
| 112 | + ULPT: 2 |
| 113 | + Actual: Result3D |
| 114 | + Expected: ExpectedResult3D |
| 115 | + - Result: CheckResult4D |
| 116 | + Rule: BufferFloatULP |
| 117 | + ULPT: 2 |
| 118 | + Actual: Result4D |
| 119 | + Expected: ExpectedResult4D |
| 120 | + |
| 121 | +DescriptorSets: |
| 122 | + - Resources: |
| 123 | + - Name: IncidentRay2D |
| 124 | + Kind: StructuredBuffer |
| 125 | + DirectXBinding: |
| 126 | + Register: 0 |
| 127 | + Space: 0 |
| 128 | + VulkanBinding: |
| 129 | + Binding: 0 |
| 130 | + - Name: IncidentRay3D |
| 131 | + Kind: StructuredBuffer |
| 132 | + DirectXBinding: |
| 133 | + Register: 1 |
| 134 | + Space: 0 |
| 135 | + VulkanBinding: |
| 136 | + Binding: 1 |
| 137 | + - Name: IncidentRay4D |
| 138 | + Kind: StructuredBuffer |
| 139 | + DirectXBinding: |
| 140 | + Register: 2 |
| 141 | + Space: 0 |
| 142 | + VulkanBinding: |
| 143 | + Binding: 2 |
| 144 | + - Name: Wall2D |
| 145 | + Kind: StructuredBuffer |
| 146 | + DirectXBinding: |
| 147 | + Register: 3 |
| 148 | + Space: 0 |
| 149 | + VulkanBinding: |
| 150 | + Binding: 3 |
| 151 | + - Name: Wall3D |
| 152 | + Kind: StructuredBuffer |
| 153 | + DirectXBinding: |
| 154 | + Register: 4 |
| 155 | + Space: 0 |
| 156 | + VulkanBinding: |
| 157 | + Binding: 4 |
| 158 | + - Name: Wall4D |
| 159 | + Kind: StructuredBuffer |
| 160 | + DirectXBinding: |
| 161 | + Register: 5 |
| 162 | + Space: 0 |
| 163 | + VulkanBinding: |
| 164 | + Binding: 5 |
| 165 | + - Name: Result2D |
| 166 | + Kind: RWStructuredBuffer |
| 167 | + DirectXBinding: |
| 168 | + Register: 6 |
| 169 | + Space: 0 |
| 170 | + VulkanBinding: |
| 171 | + Binding: 6 |
| 172 | + - Name: Result3D |
| 173 | + Kind: RWStructuredBuffer |
| 174 | + DirectXBinding: |
| 175 | + Register: 7 |
| 176 | + Space: 0 |
| 177 | + VulkanBinding: |
| 178 | + Binding: 7 |
| 179 | + - Name: Result4D |
| 180 | + Kind: RWStructuredBuffer |
| 181 | + DirectXBinding: |
| 182 | + Register: 8 |
| 183 | + Space: 0 |
| 184 | + VulkanBinding: |
| 185 | + Binding: 8 |
| 186 | +... |
| 187 | +#--- end |
| 188 | +# REQUIRES: Half |
| 189 | + |
| 190 | +# RUN: split-file %s %t |
| 191 | +# RUN: %dxc_target -T cs_6_5 -enable-16bit-types -Fo %t.o %t/source.hlsl |
| 192 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments