texture.array.gather-cmp-red.hlsl 6.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Run: %dxc -T ps_6_0 -E main
  2. SamplerComparisonState gSampler : register(s5);
  3. Texture2DArray<float4> t2f4 : register(t1);
  4. Texture2DArray<uint> t2u1 : register(t2);
  5. TextureCubeArray<int4> tCubeArray : register(t3);
  6. // .GatherCmpRed() 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. // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4int
  16. float4 main(float3 location: A, float comparator: B) : 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: [[comparator:%\d+]] = OpLoad %float %comparator
  21. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  22. // CHECK-NEXT: [[res:%\d+]] = OpImageDrefGather %v4float [[sampledImg]] [[loc]] [[comparator]] ConstOffset [[c12]]
  23. // CHECK-NEXT: OpStore %a [[res]]
  24. float4 a = t2f4.GatherCmpRed(gSampler, location, comparator, 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: [[comparator:%\d+]] = OpLoad %float %comparator
  29. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image [[t2f4]] [[gSampler]]
  30. // CHECK-NEXT: [[res:%\d+]] = OpImageDrefGather %v4float [[sampledImg]] [[loc]] [[comparator]] ConstOffsets [[c1to8]]
  31. // CHECK-NEXT: OpStore %b [[res]]
  32. float4 b = t2f4.GatherCmpRed(gSampler, location, comparator, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  33. // CHECK: [[t2u1:%\d+]] = OpLoad %type_2d_image_array_0 %t2u1
  34. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  35. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  36. // CHECK-NEXT: [[comparator:%\d+]] = OpLoad %float %comparator
  37. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u1]] [[gSampler]]
  38. // CHECK-NEXT: [[res:%\d+]] = OpImageDrefGather %v4uint [[sampledImg]] [[loc]] [[comparator]] ConstOffset [[c12]]
  39. // CHECK-NEXT: OpStore %c [[res]]
  40. uint4 c = t2u1.GatherCmpRed(gSampler, location, comparator, int2(1, 2));
  41. // CHECK: [[t2u1:%\d+]] = OpLoad %type_2d_image_array_0 %t2u1
  42. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  43. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  44. // CHECK-NEXT: [[comparator:%\d+]] = OpLoad %float %comparator
  45. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u1]] [[gSampler]]
  46. // CHECK-NEXT: [[res:%\d+]] = OpImageDrefGather %v4uint [[sampledImg]] [[loc]] [[comparator]] ConstOffsets [[c1to8]]
  47. // CHECK-NEXT: OpStore %d [[res]]
  48. uint4 d = t2u1.GatherCmpRed(gSampler, location, comparator, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8));
  49. uint status;
  50. // CHECK: [[t2u1:%\d+]] = OpLoad %type_2d_image_array_0 %t2u1
  51. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  52. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  53. // CHECK-NEXT: [[comparator:%\d+]] = OpLoad %float %comparator
  54. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u1]] [[gSampler]]
  55. // CHECK-NEXT:[[structResult:%\d+]] = OpImageSparseDrefGather %SparseResidencyStruct [[sampledImg]] [[loc]] [[comparator]] ConstOffset [[c12]]
  56. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  57. // CHECK-NEXT: OpStore %status [[status]]
  58. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  59. // CHECK-NEXT: OpStore %e [[result]]
  60. uint4 e = t2u1.GatherCmpRed(gSampler, location, comparator, int2(1, 2), status);
  61. // CHECK: [[t2u1:%\d+]] = OpLoad %type_2d_image_array_0 %t2u1
  62. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  63. // CHECK-NEXT: [[loc:%\d+]] = OpLoad %v3float %location
  64. // CHECK-NEXT: [[comparator:%\d+]] = OpLoad %float %comparator
  65. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_0 [[t2u1]] [[gSampler]]
  66. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseDrefGather %SparseResidencyStruct [[sampledImg]] [[loc]] [[comparator]] ConstOffsets [[c1to8]]
  67. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  68. // CHECK-NEXT: OpStore %status [[status]]
  69. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  70. // CHECK-NEXT: OpStore %f [[result]]
  71. uint4 f = t2u1.GatherCmpRed(gSampler, location, comparator, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
  72. // CHECK: [[tCubeArray:%\d+]] = OpLoad %type_cube_image_array %tCubeArray
  73. // CHECK-NEXT: [[gSampler:%\d+]] = OpLoad %type_sampler %gSampler
  74. // CHECK-NEXT: [[sampledImg:%\d+]] = OpSampledImage %type_sampled_image_1 [[tCubeArray]] [[gSampler]]
  75. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseDrefGather %SparseResidencyStruct_0 [[sampledImg]] [[cv4f_1_5]] %float_2_5 None
  76. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  77. // CHECK-NEXT: OpStore %status [[status]]
  78. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  79. // CHECK-NEXT: OpStore %g [[result]]
  80. int4 g = tCubeArray.GatherCmpRed(gSampler, /*location*/ float4(1.5, 1.5, 1.5, 1.5), /*compare_value*/ 2.5, status);
  81. return 1.0;
  82. }