texture.array.gather-blue.hlsl 5.5 KB

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