texture.array.gather-alpha.hlsl 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Run: %dxc -T ps_6_0 -E main
  2. SamplerState gSampler : register(s5);
  3. Texture2DArray<float4> t2f4 : register(t1);
  4. Texture2DArray<uint4> t2u4 : register(t2);
  5. TextureCubeArray<uint4> tCubeArray : register(t3);
  6. // .GatherAlpha() does not support Texture1DArray.
  7. // CHECK: OpCapability SparseResidency
  8. // CHECK: [[c12:%\d+]] = OpConstantComposite %v2int %int_1 %int_2
  9. // CHECK: [[c34:%\d+]] = OpConstantComposite %v2int %int_3 %int_4
  10. // CHECK: [[c56:%\d+]] = OpConstantComposite %v2int %int_5 %int_6
  11. // CHECK: [[c78:%\d+]] = OpConstantComposite %v2int %int_7 %int_8
  12. // CHECK: [[c1to8:%\d+]] = OpConstantComposite %_arr_v2int_uint_4 [[c12]] [[c34]] [[c56]] [[c78]]
  13. // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4uint
  14. // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
  15. float4 main(float3 location: A) : SV_Target {
  16. // CHECK: [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
  17. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  18. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  19. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  20. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4float [[sampledImg]] [[loc]] %int_3 ConstOffset [[c12]]
  21. // CHECK-NEXT: OpStore %a [[res]]
  22. float4 a = t2f4.GatherAlpha(gSampler, location, int2(1, 2));
  23. // CHECK: [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
  24. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  25. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  26. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  27. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4float [[sampledImg]] [[loc]] %int_3 ConstOffsets [[c1to8]]
  28. // CHECK-NEXT: OpStore %b [[res]]
  29. float4 b = t2f4.GatherAlpha(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  30. // CHECK: [[t2u4:%\d+]] = OpLoad %type_2d_image_array_0 %t2u4
  31. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  32. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  33. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u4]] [[gSampler]]
  34. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4uint [[sampledImg]] [[loc]] %int_3 ConstOffset [[c12]]
  35. // CHECK-NEXT: OpStore %c [[res]]
  36. uint4 c = t2u4.GatherAlpha(gSampler, location, int2(1, 2));
  37. // CHECK: [[t2u4:%\d+]] = OpLoad %type_2d_image_array_0 %t2u4
  38. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  39. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  40. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u4]] [[gSampler]]
  41. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4uint [[sampledImg]] [[loc]] %int_3 ConstOffsets [[c1to8]]
  42. // CHECK-NEXT: OpStore %d [[res]]
  43. uint4 d = t2u4.GatherAlpha(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  44. uint status;
  45. // CHECK: [[t2u4:%\d+]] = OpLoad %type_2d_image_array_0 %t2u4
  46. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  47. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  48. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u4]] [[gSampler]]
  49. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[loc]] %int_3 ConstOffset [[c12]]
  50. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  51. // CHECK-NEXT: OpStore %status [[status]]
  52. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  53. // CHECK-NEXT: OpStore %e [[result]]
  54. uint4 e = t2u4.GatherAlpha(gSampler, location, int2(1, 2), status);
  55. // CHECK: [[t2u4:%\d+]] = OpLoad %type_2d_image_array_0 %t2u4
  56. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  57. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  58. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u4]] [[gSampler]]
  59. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[loc]] %int_3 ConstOffsets [[c1to8]]
  60. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  61. // CHECK-NEXT: OpStore %status [[status]]
  62. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  63. // CHECK-NEXT: OpStore %f [[result]]
  64. uint4 f = t2u4.GatherAlpha(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
  65. // CHECK: [[tCubeArray:%\d+]] = OpLoad %type_cube_image_array %tCubeArray
  66. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  67. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_1 [[tCubeArray]] [[gSampler]]
  68. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[cv4f_1_5]] %int_3 None
  69. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  70. // CHECK-NEXT: OpStore %status [[status]]
  71. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  72. // CHECK-NEXT: OpStore %g [[result]]
  73. uint4 g = tCubeArray.GatherAlpha(gSampler, /*location*/ float4(1.5, 1.5, 1.5, 1.5), status);
  74. return 1.0;
  75. }