op.buffer.access.hlsl 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Run: %dxc -T ps_6_0 -E main
  2. // CHECK: OpCapability ImageBuffer
  3. Buffer<int> intbuf;
  4. Buffer<uint> uintbuf;
  5. Buffer<float> floatbuf;
  6. RWBuffer<int2> int2buf;
  7. RWBuffer<uint2> uint2buf;
  8. RWBuffer<float2> float2buf;
  9. Buffer<int3> int3buf;
  10. Buffer<uint3> uint3buf;
  11. Buffer<float3> float3buf;
  12. RWBuffer<int4> int4buf;
  13. RWBuffer<uint4> uint4buf;
  14. RWBuffer<float4> float4buf;
  15. struct S {
  16. float a;
  17. float2 b;
  18. float1 c;
  19. };
  20. Buffer<S> sBuf;
  21. void main() {
  22. int address;
  23. // CHECK: [[img1:%\d+]] = OpLoad %type_buffer_image %intbuf
  24. // CHECK: [[f1:%\d+]] = OpImageFetch %v4int [[img1]] {{%\d+}} None
  25. // CHECK-NEXT: [[r1:%\d+]] = OpCompositeExtract %int [[f1]] 0
  26. // CHECK-NEXT: OpStore %int1 [[r1]]
  27. int int1 = intbuf[address];
  28. // CHECK: [[img2:%\d+]] = OpLoad %type_buffer_image_0 %uintbuf
  29. // CHECK: [[f2:%\d+]] = OpImageFetch %v4uint [[img2]] {{%\d+}} None
  30. // CHECK-NEXT: [[r2:%\d+]] = OpCompositeExtract %uint [[f2]] 0
  31. // CHECK-NEXT: OpStore %uint1 [[r2]]
  32. uint uint1 = uintbuf[address];
  33. // CHECK: [[img3:%\d+]] = OpLoad %type_buffer_image_1 %floatbuf
  34. // CHECK: [[f3:%\d+]] = OpImageFetch %v4float [[img3]] {{%\d+}} None
  35. // CHECK-NEXT: [[r3:%\d+]] = OpCompositeExtract %float [[f3]] 0
  36. // CHECK-NEXT: OpStore %float1 [[r3]]
  37. float float1 = floatbuf[address];
  38. // CHECK: [[img4:%\d+]] = OpLoad %type_buffer_image_2 %int2buf
  39. // CHECK: [[ret4:%\d+]] = OpImageRead %v4int [[img4]] {{%\d+}} None
  40. // CHECK-NEXT: [[r4:%\d+]] = OpVectorShuffle %v2int [[ret4]] [[ret4]] 0 1
  41. // CHECK-NEXT: OpStore %int2 [[r4]]
  42. int2 int2 = int2buf[address];
  43. // CHECK: [[img5:%\d+]] = OpLoad %type_buffer_image_3 %uint2buf
  44. // CHECK: [[ret5:%\d+]] = OpImageRead %v4uint [[img5]] {{%\d+}} None
  45. // CHECK-NEXT: [[r5:%\d+]] = OpVectorShuffle %v2uint [[ret5]] [[ret5]] 0 1
  46. // CHECK-NEXT: OpStore %uint2 [[r5]]
  47. uint2 uint2 = uint2buf[address];
  48. // CHECK: [[img6:%\d+]] = OpLoad %type_buffer_image_4 %float2buf
  49. // CHECK: [[ret6:%\d+]] = OpImageRead %v4float [[img6]] {{%\d+}} None
  50. // CHECK-NEXT: [[r6:%\d+]] = OpVectorShuffle %v2float [[ret6]] [[ret6]] 0 1
  51. // CHECK-NEXT: OpStore %float2 [[r6]]
  52. float2 float2 = float2buf[address];
  53. // CHECK: [[img7:%\d+]] = OpLoad %type_buffer_image_5 %int3buf
  54. // CHECK: [[f7:%\d+]] = OpImageFetch %v4int [[img7]] {{%\d+}} None
  55. // CHECK-NEXT: [[r7:%\d+]] = OpVectorShuffle %v3int [[f7]] [[f7]] 0 1 2
  56. // CHECK-NEXT: OpStore %int3 [[r7]]
  57. int3 int3 = int3buf[address];
  58. // CHECK: [[img8:%\d+]] = OpLoad %type_buffer_image_6 %uint3buf
  59. // CHECK: [[f8:%\d+]] = OpImageFetch %v4uint [[img8]] {{%\d+}} None
  60. // CHECK-NEXT: [[r8:%\d+]] = OpVectorShuffle %v3uint [[f8]] [[f8]] 0 1 2
  61. // CHECK-NEXT: OpStore %uint3 [[r8]]
  62. uint3 uint3 = uint3buf[address];
  63. // CHECK: [[img9:%\d+]] = OpLoad %type_buffer_image_7 %float3buf
  64. // CHECK: [[f9:%\d+]] = OpImageFetch %v4float [[img9]] {{%\d+}} None
  65. // CHECK-NEXT: [[r9:%\d+]] = OpVectorShuffle %v3float [[f9]] [[f9]] 0 1 2
  66. // CHECK-NEXT: OpStore %float3 [[r9]]
  67. float3 float3 = float3buf[address];
  68. // CHECK: [[img10:%\d+]] = OpLoad %type_buffer_image_8 %int4buf
  69. // CHECK: [[r10:%\d+]] = OpImageRead %v4int [[img10]] {{%\d+}} None
  70. // CHECK-NEXT: OpStore %int4 [[r10]]
  71. int4 int4 = int4buf[address];
  72. // CHECK: [[img11:%\d+]] = OpLoad %type_buffer_image_9 %uint4buf
  73. // CHECK: [[r11:%\d+]] = OpImageRead %v4uint [[img11]] {{%\d+}} None
  74. // CHECK-NEXT: OpStore %uint4 [[r11]]
  75. uint4 uint4 = uint4buf[address];
  76. // CHECK: [[img12:%\d+]] = OpLoad %type_buffer_image_10 %float4buf
  77. // CHECK: [[r12:%\d+]] = OpImageRead %v4float [[img12]] {{%\d+}} None
  78. // CHECK-NEXT: OpStore %float4 [[r12]]
  79. float4 float4 = float4buf[address];
  80. // CHECK: [[img13:%\d+]] = OpLoad %type_buffer_image_5 %int3buf
  81. // CHECK-NEXT: [[f13:%\d+]] = OpImageFetch %v4int [[img13]] %uint_0 None
  82. // CHECK-NEXT: [[r13:%\d+]] = OpVectorShuffle %v3int [[f13]] [[f13]] 0 1 2
  83. // CHECK-NEXT: OpStore %temp_var_vector [[r13]]
  84. // CHECK-NEXT: [[ac13:%\d+]] = OpAccessChain %_ptr_Function_int %temp_var_vector %uint_1
  85. // CHECK-NEXT: [[a:%\d+]] = OpLoad %int [[ac13]]
  86. // CHECK-NEXT: OpStore %a [[a]]
  87. int a = int3buf[0][1];
  88. // CHECK: [[img14:%\d+]] = OpLoad %type_buffer_image_10 %float4buf
  89. // CHECK-NEXT: [[f14:%\d+]] = OpImageRead %v4float [[img14]] {{%\d+}} None
  90. // CHECK-NEXT: OpStore %temp_var_vector_0 [[f14]]
  91. // CHECK-NEXT: [[ac14:%\d+]] = OpAccessChain %_ptr_Function_float %temp_var_vector_0 %uint_2
  92. // CHECK-NEXT: [[b:%\d+]] = OpLoad %float [[ac14]]
  93. // CHECK-NEXT: OpStore %b [[b]]
  94. float b = float4buf[address][2];
  95. // CHECK: [[img:%\d+]] = OpLoad %type_buffer_image_7 %sBuf
  96. // CHECK-NEXT: [[fetch:%\d+]] = OpImageFetch %v4float [[img]] %uint_0 None
  97. // CHECK-NEXT: [[s_a:%\d+]] = OpCompositeExtract %float [[fetch]] 0
  98. // CHECK-NEXT: [[s_b:%\d+]] = OpVectorShuffle %v2float [[fetch]] [[fetch]] 1 2
  99. // CHECK-NEXT: [[s_c:%\d+]] = OpCompositeExtract %float [[fetch]] 3
  100. // CHECK-NEXT: [[s:%\d+]] = OpCompositeConstruct %S [[s_a]] [[s_b]] [[s_c]]
  101. // CHECK-NEXT: OpStore %temp_var_S [[s]]
  102. // CHECK-NEXT: [[ptr:%\d+]] = OpAccessChain %_ptr_Function_float %temp_var_S %int_0
  103. // CHECK-NEXT: [[c:%\d+]] = OpLoad %float [[ptr]]
  104. // CHECK-NEXT: OpStore %c [[c]]
  105. float c = sBuf[0].a;
  106. // CHECK: [[img:%\d+]] = OpLoad %type_buffer_image_7 %sBuf
  107. // CHECK-NEXT: [[fetch:%\d+]] = OpImageFetch %v4float [[img]] %uint_1 None
  108. // CHECK-NEXT: [[s_a:%\d+]] = OpCompositeExtract %float [[fetch]] 0
  109. // CHECK-NEXT: [[s_b:%\d+]] = OpVectorShuffle %v2float [[fetch]] [[fetch]] 1 2
  110. // CHECK-NEXT: [[s_c:%\d+]] = OpCompositeExtract %float [[fetch]] 3
  111. // CHECK-NEXT: [[s:%\d+]] = OpCompositeConstruct %S [[s_a]] [[s_b]] [[s_c]]
  112. // CHECK-NEXT: OpStore %temp_var_S_0 [[s]]
  113. // CHECK-NEXT: [[ptr:%\d+]] = OpAccessChain %_ptr_Function_v2float %temp_var_S_0 %int_1
  114. // CHECK-NEXT: [[val:%\d+]] = OpLoad %v2float [[ptr]]
  115. // CHECK-NEXT: [[d:%\d+]] = OpCompositeExtract %float [[val]] 1
  116. // CHECK-NEXT: OpStore %d [[d]]
  117. float d = sBuf[1].b.y;
  118. }