method.rw-structured-buffer.counter.hlsl 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. // Run: %dxc -T ps_6_0 -E main
  2. struct S {
  3. float4 f;
  4. };
  5. // CHECK: OpMemberDecorate %type_ACSBuffer_counter 0 Offset 0
  6. // CHECK: OpDecorate %type_ACSBuffer_counter BufferBlock
  7. // CHECK: %type_ACSBuffer_counter = OpTypeStruct %int
  8. // CHECK: %counter_var_wCounter1 = OpVariable %_ptr_Uniform_type_ACSBuffer_counter Uniform
  9. // CHECK: %counter_var_wCounter2 = OpVariable %_ptr_Uniform_type_ACSBuffer_counter Uniform
  10. RWStructuredBuffer<S> wCounter1;
  11. RWStructuredBuffer<S> wCounter2;
  12. // CHECK: %counter_var_woCounter = OpVariable %_ptr_Uniform_type_ACSBuffer_counter Uniform
  13. RWStructuredBuffer<S> woCounter;
  14. float4 main() : SV_Target {
  15. // CHECK: [[ptr1:%\d+]] = OpAccessChain %_ptr_Uniform_int %counter_var_wCounter1 %uint_0
  16. // CHECK-NEXT: [[pre1:%\d+]] = OpAtomicIAdd %int [[ptr1]] %uint_1 %uint_0 %int_1
  17. // CHECK-NEXT: [[val1:%\d+]] = OpBitcast %uint [[pre1]]
  18. // CHECK-NEXT: OpStore %a [[val1]]
  19. uint a = wCounter1.IncrementCounter();
  20. // CHECK: [[ptr2:%\d+]] = OpAccessChain %_ptr_Uniform_int %counter_var_wCounter2 %uint_0
  21. // CHECK-NEXT: [[pre2:%\d+]] = OpAtomicISub %int [[ptr2]] %uint_1 %uint_0 %int_1
  22. // CHECK-NEXT: [[cnt2:%\d+]] = OpISub %int [[pre2]] %int_1
  23. // CHECK-NEXT: [[val2:%\d+]] = OpBitcast %uint [[cnt2]]
  24. // CHECK-NEXT: OpStore %b [[val2]]
  25. uint b = wCounter2.DecrementCounter();
  26. return woCounter[0].f + float4(a, b, 0, 0);
  27. }