Skip to content

Commit 7e406ce

Browse files
bogneryuxuanchen1997
authored andcommitted
[DirectX] Start documenting DXIL Resource handling (#90553)
Summary: This adds a new document about DXIL Resource Handling. I've attempted to describe here how we intend to use TargetExtTypes to represent resources in LLVM IR and the various intrinsics we'll need to lower these through LLVM to DXIL. For now this document is limited to the high level concepts and a few details on buffer types, and there are a number of TODOs in the document that we'll iterate on as we progress in the implementation. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251613
1 parent d889a57 commit 7e406ce

File tree

4 files changed

+439
-23
lines changed

4 files changed

+439
-23
lines changed

clang/docs/HLSL/HLSLIRReference.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ Introduction
1111
The goal of this document is to provide a reference for all the special purpose
1212
IR metadata and attributes used by the HLSL code generation path.
1313

14-
IR Metadata
15-
===========
16-
17-
``hlsl.uavs``
18-
-------------
19-
20-
The ``hlsl.uavs`` metadata is a list of all the external global variables that
21-
represent UAV resources.
22-
2314
Function Attributes
2415
===================
2516

clang/docs/HLSL/ResourceTypes.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ In Clang resource types are forward declared by the ``HLSLExternalSemaSource``
1919
on initialization. They are then lazily completed when ``requiresCompleteType``
2020
is called later in Sema.
2121

22-
Resource types are templated class declarations. The template parameter
23-
specifies the expected return type of resource loads, and the expected parameter
24-
type for stores.
25-
26-
In Clang's AST and code generation, resource types are classes that store a
27-
pointer of the template parameter type. The pointer is populated from a call to
28-
``__builtin_hlsl_create_handle``, and treated as a pointer to an array of typed
29-
data through until lowering in the backend.
30-
31-
Resource types are annotated with the ``HLSLResource`` attribute, which drives
32-
code generation for resource binding metadata. The ``hlsl`` metadata nodes are
33-
transformed in the backend to the binding information expected by the target
34-
runtime.
22+
Resource types are classes that have the "intangible" resource handle type,
23+
`__hlsl_resource_t`, as a member. These are generally templated class
24+
declarations that specify the type of data that can be loaded from or stored
25+
into the resource. The handle is annotated with hlsl-specific attributes
26+
describing properties of the resource. Member functions of a resource type are
27+
generally fairly simple wrappers around builtins that operate on the handle
28+
member.
29+
30+
During code generation resource types are lowered to target extension types in
31+
IR. These types are target specific and differ between DXIL and SPIR-V
32+
generation, providing the necessary information for the targets to generate
33+
binding metadata for their respective target runtimes.

0 commit comments

Comments
 (0)