texture.array.gather-blue.hlsl 5.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 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 %v4int
  14. // CHECK: [[cv4f_1_5:%\d+]] = OpConstantComposite %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
  15. // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
  16. float4 main(float3 location: A) : SV_Target {
  17. // CHECK: [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
  18. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  19. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  20. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  21. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4float [[sampledImg]] [[loc]] %int_2 ConstOffset [[c12]]
  22. // CHECK-NEXT: OpStore %a [[res]]
  23. float4 a = t2f4.GatherBlue(gSampler, location, int2(1, 2));
  24. // CHECK: [[t2f4:%\d+]] = OpLoad %type_2d_image_array %t2f4
  25. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  26. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  27. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  28. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4float [[sampledImg]] [[loc]] %int_2 ConstOffsets [[c1to8]]
  29. // CHECK-NEXT: OpStore %b [[res]]
  30. float4 b = t2f4.GatherBlue(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  31. // CHECK: [[t2i3:%\d+]] = OpLoad %type_2d_image_array_0 %t2i3
  32. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  33. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  34. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2i3]] [[gSampler]]
  35. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4int [[sampledImg]] [[loc]] %int_2 ConstOffset [[c12]]
  36. // CHECK-NEXT: OpStore %c [[res]]
  37. int4 c = t2i3.GatherBlue(gSampler, location, int2(1, 2));
  38. // CHECK: [[t2i3:%\d+]] = OpLoad %type_2d_image_array_0 %t2i3
  39. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  40. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  41. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2i3]] [[gSampler]]
  42. // CHECK-NEXT: [[res:%\d+]] = OpImageGather %v4int [[sampledImg]] [[loc]] %int_2 ConstOffsets [[c1to8]]
  43. // CHECK-NEXT: OpStore %d [[res]]
  44. int4 d = t2i3.GatherBlue(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  45. uint status;
  46. // CHECK: [[t2i3:%\d+]] = OpLoad %type_2d_image_array_0 %t2i3
  47. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  48. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  49. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2i3]] [[gSampler]]
  50. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[loc]] %int_2 ConstOffset [[c12]]
  51. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  52. // CHECK-NEXT: OpStore %status [[status]]
  53. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  54. // CHECK-NEXT: OpStore %e [[result]]
  55. int4 e = t2i3.GatherBlue(gSampler, location, int2(1, 2), status);
  56. // CHECK: [[t2i3:%\d+]] = OpLoad %type_2d_image_array_0 %t2i3
  57. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  58. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  59. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2i3]] [[gSampler]]
  60. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct [[sampledImg]] [[loc]] %int_2 ConstOffsets [[c1to8]]
  61. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  62. // CHECK-NEXT: OpStore %status [[status]]
  63. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  64. // CHECK-NEXT: OpStore %f [[result]]
  65. int4 f = t2i3.GatherBlue(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
  66. // CHECK: [[tCubeArray:%\d+]] = OpLoad %type_cube_image_array %tCubeArray
  67. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  68. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_1 [[tCubeArray]] [[gSampler]]
  69. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseGather %SparseResidencyStruct_0 [[sampledImg]] [[cv4f_1_5]] %int_2 None
  70. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  71. // CHECK-NEXT: OpStore %status [[status]]
  72. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  73. // CHECK-NEXT: OpStore %g [[result]]
  74. uint4 g = tCubeArray.GatherBlue(gSampler, /*location*/ float4(1.5, 1.5, 1.5, 1.5), status);
  75. return 1.0;
  76. }