Skip to content

[HLSL] Implement Append and Consume on Append/ConsumeStructuredBuffer #112968

@hekota

Description

@hekota

Use existing clang builtins __builtin_hlsl_buffer_update_counter and __builtin_hlsl_resource_getpointer to implement the Append method on AppendStructuredBuffer and Consume method on ConsumeStructuredBuffer.

These builtins would be lowered to appropriate LLVM DirectX intrinsics during clang codegen.
Depends on #92147 and #106188.

https://godbolt.org/z/qKGdYj5zj

struct MyStruct {
    float4 a;
};

AppendStructuredBuffer<MyStruct> AB;
ConsumeStructuredBuffer<MyStruct> CB;

[numthreads(4,1,1)]
void main() {
  MyStruct val = CB.Consume();
  AB.Append(val);
}

Docs:
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-appendstructuredbuffer-append
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-consumestructuredbuffer-consume

AC:

  • Append/Consume methods are added to the AppendStructuredBuffer/ConsumeStructuredBuffer using the builtins
  • Tests added

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions