method.rwtexture.load.hlsl 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Run: %dxc -T ps_6_0 -E main
  2. RWTexture1D<int> intbuf;
  3. RWTexture2D<uint2> uint2buf;
  4. RWTexture3D<float3> float3buf;
  5. RWTexture1DArray<float4> float4buf;
  6. RWTexture2DArray<int3> int3buf;
  7. // CHECK: OpCapability SparseResidency
  8. // CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4int
  9. // CHECK: %SparseResidencyStruct_0 = OpTypeStruct %uint %v4uint
  10. // CHECK: %SparseResidencyStruct_1 = OpTypeStruct %uint %v4float
  11. void main() {
  12. // CHECK: [[img1:%\d+]] = OpLoad %type_1d_image %intbuf
  13. // CHECK-NEXT: [[ret1:%\d+]] = OpImageRead %v4int [[img1]] %int_0 None
  14. // CHECK-NEXT: [[r1:%\d+]] = OpCompositeExtract %int [[ret1]] 0
  15. // CHECK-NEXT: OpStore %a [[r1]]
  16. int a = intbuf.Load(0);
  17. // CHECK-NEXT: [[img2:%\d+]] = OpLoad %type_2d_image %uint2buf
  18. // CHECK-NEXT: [[ret2:%\d+]] = OpImageRead %v4uint [[img2]] {{%\d+}} None
  19. // CHECK-NEXT: [[r2:%\d+]] = OpVectorShuffle %v2uint [[ret2]] [[ret2]] 0 1
  20. // CHECK-NEXT: OpStore %b [[r2]]
  21. uint2 b = uint2buf.Load(0);
  22. // CHECK-NEXT: [[img3:%\d+]] = OpLoad %type_3d_image %float3buf
  23. // CHECK-NEXT: [[ret3:%\d+]] = OpImageRead %v4float [[img3]] {{%\d+}} None
  24. // CHECK-NEXT: [[r3:%\d+]] = OpVectorShuffle %v3float [[ret3]] [[ret3]] 0 1 2
  25. // CHECK-NEXT: OpStore %c [[r3]]
  26. float3 c = float3buf.Load(0);
  27. // CHECK-NEXT: [[img4:%\d+]] = OpLoad %type_1d_image_array %float4buf
  28. // CHECK-NEXT: [[r4:%\d+]] = OpImageRead %v4float [[img4]] {{%\d+}} None
  29. // CHECK-NEXT: OpStore %d [[r4]]
  30. float4 d = float4buf.Load(0);
  31. // CHECK-NEXT: [[img5:%\d+]] = OpLoad %type_2d_image_array %int3buf
  32. // CHECK-NEXT: [[ret5:%\d+]] = OpImageRead %v4int [[img5]] {{%\d+}} None
  33. // CHECK-NEXT: [[r5:%\d+]] = OpVectorShuffle %v3int [[ret5]] [[ret5]] 0 1 2
  34. // CHECK-NEXT: OpStore %e [[r5]]
  35. int3 e = int3buf.Load(0);
  36. uint status;
  37. // CHECK: [[img1:%\d+]] = OpLoad %type_1d_image %intbuf
  38. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseRead %SparseResidencyStruct [[img1]] %int_0 None
  39. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  40. // CHECK-NEXT: OpStore %status [[status]]
  41. // CHECK-NEXT: [[v4result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  42. // CHECK-NEXT: [[result:%\d+]] = OpCompositeExtract %int [[v4result]] 0
  43. // CHECK-NEXT: OpStore %a2 [[result]]
  44. int a2 = intbuf.Load(0, status);
  45. // CHECK: [[img2:%\d+]] = OpLoad %type_2d_image %uint2buf
  46. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseRead %SparseResidencyStruct_0 [[img2]] {{%\d+}} None
  47. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  48. // CHECK-NEXT: OpStore %status [[status]]
  49. // CHECK-NEXT: [[v4result:%\d+]] = OpCompositeExtract %v4uint [[structResult]] 1
  50. // CHECK-NEXT: [[result:%\d+]] = OpVectorShuffle %v2uint [[v4result]] [[v4result]] 0 1
  51. // CHECK-NEXT: OpStore %b2 [[result]]
  52. uint2 b2 = uint2buf.Load(0, status);
  53. // CHECK: [[img3:%\d+]] = OpLoad %type_3d_image %float3buf
  54. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseRead %SparseResidencyStruct_1 [[img3]] {{%\d+}} None
  55. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  56. // CHECK-NEXT: OpStore %status [[status]]
  57. // CHECK-NEXT: [[v4result:%\d+]] = OpCompositeExtract %v4float [[structResult]] 1
  58. // CHECK-NEXT: [[result:%\d+]] = OpVectorShuffle %v3float [[v4result]] [[v4result]] 0 1 2
  59. // CHECK-NEXT: OpStore %c2 [[result]]
  60. float3 c2 = float3buf.Load(0, status);
  61. // CHECK: [[img4:%\d+]] = OpLoad %type_1d_image_array %float4buf
  62. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseRead %SparseResidencyStruct_1 [[img4]] {{%\d+}} None
  63. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  64. // CHECK-NEXT: OpStore %status [[status]]
  65. // CHECK-NEXT: [[v4result:%\d+]] = OpCompositeExtract %v4float [[structResult]] 1
  66. // CHECK-NEXT: OpStore %d2 [[v4result]]
  67. float4 d2 = float4buf.Load(0, status);
  68. // CHECK: [[img5:%\d+]] = OpLoad %type_2d_image_array %int3buf
  69. // CHECK-NEXT: [[structResult:%\d+]] = OpImageSparseRead %SparseResidencyStruct [[img5]] {{%\d+}} None
  70. // CHECK-NEXT: [[status:%\d+]] = OpCompositeExtract %uint [[structResult]] 0
  71. // CHECK-NEXT: OpStore %status [[status]]
  72. // CHECK-NEXT: [[v4result:%\d+]] = OpCompositeExtract %v4int [[structResult]] 1
  73. // CHECK-NEXT: [[result:%\d+]] = OpVectorShuffle %v3int [[v4result]] [[v4result]] 0 1 2
  74. // CHECK-NEXT: OpStore %e2 [[result]]
  75. int3 e2 = int3buf.Load(0, status);
  76. }