Skip to content

[DirectX] When lowering resources for library shaders, generate globals that are compatible with DXIL #75981

@bogner

Description

@bogner

In DXIL, the resource metadata includes a ["Pointer to a global constant symbol with the original shape of resource and element type."(https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#metadata-resource-records). In a library shader, this is a global of %dx.types.Handle type that is bitcast in the metadata to a type based on the resource's template parameter:

%dx.types.Handle = type { i8* }
%"class.RWBuffer<float4>" = type { <4 x float> }
@"\01?In@@3V?$RWBuffer@V?$vector@M$03@@@@A" = external constant %dx.types.Handle, align 4

!... = !{i32 0, %"class.RWBuffer<vector<float, 4> >"* bitcast (%dx.types.Handle* @"\01?In@@3V?$RWBuffer@V?$vector@M$03@@@@A" to %"class.RWBuffer<vector<float, 4> >"*), !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, !...}

We should be able to recover the appropriate type from the [element type of our target extension type (https://llvm.org/docs/DirectX/DXILResources.html#buffers) during DXILResourceAnalysis. However, because of opaque pointers, the bitcast isn't really representable in modern LLVM. We'll need to find a way to pass the necessary information along until the DXIL bitcode writer can apply types to the pointers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions