<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112968>112968</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Implement `Append` and `Consume` on `Append`/`ConsumeStructuredBuffer`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hekota
</td>
</tr>
</table>
<pre>
Introduce a clang builtins that wil be used to implement the implement the `Append` method on `AppendStructuredBuffer` and `Consume` method on `ConsumeStructuredBuffer`.
The builtins could be something like this:
`void __builtin_hlsl_resource_append(resource_t x, T val)`;
`T __builtin_hlsl_resource_consume(resource_t x)`;
These builtins would be lowered to appropriate LLVM DirectX intrinsics during clang codegen.
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:
- These builtins are available and lower to appropriate LLVM DirectX intrinsics during clang codegen
- `Append` / `Consume` methods can be implemented using these builtins
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VUuz4jYT_TVi0wVltw2YhRc8Pn-Zyp3V3EolK0q2Gqw7skT0gMz8-pQfmMe9N5tUqsBgWX1ap_v0MXdOHjVRzuYbNt9NePC1sXlN343nk9KIH_kX7a0RoSLgUCmuj1AGqbzUDnzNPVykgpIgOBLgDcjmpKgh7cHX9HTHFtH6dCIt2CKChnxtBBh9W_7mbah8sCQ24XAg227jWrQbtka70NC7wGH9g8gZsGjHonV_fa3pdu7KBCXaQzvTgkl9BCW_E_haOpas7-PYIjobKWC_H6L3tXJqb8mZYCva854PZuOKh78YbuEVzlwxXLFFxJLNCPb6KVI1MHyGekS4knF3dC5XOspcyPZt4KeTNScruSd4efntK-ykpcr_DlJ7K7WTlQMRbEu9b2plBB1Jz-7z1N6fuoJgwbA4GlEa5WfGHhkWPxkWf_76f_HH2_zn20hv-HS3rusJfP3RNwfYciABAHBQhvsU-I3ZcvfE8hNNJNsrIkv-B-vNGPWZFB4DtpunNGy-0aHxtSUuHMMsZbiN---KzXf9pk4DDZeaYcZwdc9l5HfmCliyg-1mth172YJc88F6M1tf9TKo457-R0XsrztT3YT52BVF3OpZIytrnDn4WWUahgXpaXAMi4vUwlyGfwkyLESng0S04mNYuGY-NeUbVX7aS9mN5Su78g3L_23qQfvvcl9n4l4V27EQU3gaBG4J-JlLxUtFnXN0E_Fv5uGa6cG6GBYfepKDiut2EEfbIwHBtaD-4aQ96kTkiVglKz6hPF7iCjPEJU7qvFphgjyhOBLLQ5Rk6YJ4ki7FkqpkjhlNZI4RpnEUZxjFcYyzOC0zXPJFmpZJQoQsjajhUs2UOjftxE6kc4HyOMbVIpsoXpJynekjarpA95Qhtu8Am7dB0zIcHUsjJZ13NxgvvereFr-8fHth8x18GR3-oUTvbfve6Ft5Y_GP9j0JVuVPBiR9HcpBZu2Jhp_pyZpWRgyLjkeruYHoOce_AwAA__84IDOh">