updateCounter.hlsl 492 B

1234567891011121314151617181920212223242526
  1. // RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
  2. // CHECK: RWStructuredBuffers may increment or decrement their counters, but not both.
  3. struct Foo
  4. {
  5. float2 a;
  6. float3 b;
  7. int2 c[4];
  8. };
  9. StructuredBuffer<Foo> buf1;
  10. RWStructuredBuffer<Foo> buf2;
  11. float4 main(float idx1 : Idx1, float idx2 : Idx2) : SV_Target
  12. {
  13. uint status;
  14. float4 r = 0;
  15. int id = buf2.IncrementCounter();
  16. buf2[id].a = float2(idx1, idx2);
  17. id = buf2.DecrementCounter();
  18. r.xy += buf2[id].a;
  19. return r;
  20. }