texture.array.gather.hlsl 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Run: %dxc -T ps_6_0 -E main
  2. SamplerState gSampler : register(s1);
  3. Texture2DArray <float4> t2 : register(t2);
  4. TextureCubeArray <uint3> t4 : register(t4);
  5. Texture2DArray <int3> t6 : register(t6);
  6. TextureCubeArray <float> t8 : register(t8);
  7. // .Gather() does not support Texture1DArray.
  8. // CHECK: OpCapability ImageGatherExtended
  9. // CHECK: OpCapability SparseResidency
  10. // CHECK: [[v4fc:%\d+]] = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
  11. // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
  12. // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4float
  13. float4 main(float3 location: A, int2 offset: B) : SV_Target {
  14. // CHECK: [[t2:%\d+]] = OpLoad %type_2d_image_array %t2
  15. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  16. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  17. // CHECK-NEXT: [[offset:%\d+]] = OpLoad %v2int %offset
  18. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2]] [[gSampler]]
  19. // CHECK-NEXT: {{%\d+}} = OpImageGather %v4float [[sampledImg]] [[loc]] %int_0 Offset [[offset]]
  20. float4 val2 = t2.Gather(gSampler, location, offset);
  21. // CHECK: [[t4:%\d+]] = OpLoad %type_cube_image_array %t4
  22. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  23. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t4]] [[gSampler]]
  24. // CHECK-NEXT: {{%\d+}} = OpImageGather %v4uint [[sampledImg]] [[v4fc]] %int_0
  25. uint4 val4 = t4.Gather(gSampler, float4(1, 2, 3, 4));
  26. // CHECK: [[t6:%\d+]] = OpLoad %type_2d_image_array_0 %t6
  27. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  28. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  29. // CHECK-NEXT: [[offset:%\d+]] = OpLoad %v2int %offset
  30. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_1 [[t6]] [[gSampler]]
  31. // CHECK-NEXT: {{%\d+}} = OpImageGather %v4int [[sampledImg]] [[loc]] %int_0 Offset [[offset]]
  32. int4 val6 = t6.Gather(gSampler, location, offset);
  33. // CHECK: [[t8:%\d+]] = OpLoad %type_cube_image_array_0 %t8
  34. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  35. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_2 [[t8]] [[gSampler]]
  36. // CHECK-NEXT: {{%\d+}} = OpImageGather %v4float [[sampledImg]] [[v4fc]] %int_0
  37. float4 val8 = t8.Gather(gSampler, float4(1, 2, 3, 4));
  38. uint status;
  39. // CHECK: [[t6:%\d+]] = OpLoad %type_2d_image_array_0 %t6
  40. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  41. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  42. // CHECK-NEXT: [[offset:%\d+]] = OpLoad %v2int %offset
  43. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_1 [[t6]] [[gSampler]]
  44. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[loc]] %int_0 Offset [[offset]]
  45. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  46. // CHECK-NEXT: OpStore %status [[status]]
  47. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  48. // CHECK-NEXT: OpStore %val9 [[result]]
  49. int4 val9 = t6.Gather(gSampler, location, offset, status);
  50. // CHECK: [[t8:%\d+]] = OpLoad %type_cube_image_array_0 %t8
  51. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  52. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_2 [[t8]] [[gSampler]]
  53. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct_0 [[sampledImg]] [[v4fc]] %int_0 None
  54. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  55. // CHECK-NEXT: OpStore %status [[status]]
  56. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4float [[structResult]] 1
  57. // CHECK-NEXT: OpStore %val10 [[result]]
  58. float4 val10 = t8.Gather(gSampler, float4(1, 2, 3, 4), status);
  59. return 1.0;
  60. }