Skip to content

[HLSL] Add ConstantBuffer<T> template definition to HLSLExternalSemaSource and enable direct member access #112993

@hekota

Description

@hekota

Add ConstantBuffer<T> definition to HLSLExternalSemaSource. The resource definition will contain a handle that will be lowered to a dx.CBuffer target extension type.

Note that members of a struct that is passed as a template argument to ConstantBuffer can be accessed directly as if they are members of the ConstantBuffer class.

struct MyConstants {
    int MyConstValue;
};

ConstantBuffer<MyConstants> CB : register(b0);

RWBuffer<int> Buf;

[numthreads(32, 1, 1)]
void main(uint3 dispatch_thread_id : SV_DispatchThreadID) {
    Buf[0] = CB.MyConstValue;
}

https://godbolt.org/z/6GdE383j3

Refer to Proposal for mapping resource attributes for resource attribute mapping.

Depends on llvm/wg-hlsl#178

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Support

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions