[clang] fc47001 - [Docs] Add HLSL ResourceType documentation

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 07:06:47 PDT 2022


Author: Chris Bieneman
Date: 2022-08-08T09:06:38-05:00
New Revision: fc470013d13f2b996731c865b921df5a87a40e3f

URL: https://github.com/llvm/llvm-project/commit/fc470013d13f2b996731c865b921df5a87a40e3f
DIFF: https://github.com/llvm/llvm-project/commit/fc470013d13f2b996731c865b921df5a87a40e3f.diff

LOG: [Docs] Add HLSL ResourceType documentation

Along with the new documentation this also re-organizes the HLSL docs
to a subdirectory. The hope is to continue to expand this documentation
as the HLSL implementation advances.

Differential Revision: https://reviews.llvm.org/D130794

Added: 
    clang/docs/HLSL/HLSLDocs.rst
    clang/docs/HLSL/HLSLSupport.rst
    clang/docs/HLSL/ResourceTypes.rst

Modified: 
    clang/docs/index.rst

Removed: 
    clang/docs/HLSLSupport.rst


################################################################################
diff  --git a/clang/docs/HLSL/HLSLDocs.rst b/clang/docs/HLSL/HLSLDocs.rst
new file mode 100644
index 0000000000000..0b66e517a73a0
--- /dev/null
+++ b/clang/docs/HLSL/HLSLDocs.rst
@@ -0,0 +1,14 @@
+.. title:: Clang HLSL Documentation
+
+.. toctree::
+   :maxdepth: 1
+
+   HLSLSupport
+
+HLSL Design and Implementation
+==============================
+
+.. toctree::
+   :maxdepth: 1
+
+   ResourceTypes

diff  --git a/clang/docs/HLSLSupport.rst b/clang/docs/HLSL/HLSLSupport.rst
similarity index 100%
rename from clang/docs/HLSLSupport.rst
rename to clang/docs/HLSL/HLSLSupport.rst

diff  --git a/clang/docs/HLSL/ResourceTypes.rst b/clang/docs/HLSL/ResourceTypes.rst
new file mode 100644
index 0000000000000..c537e824758b3
--- /dev/null
+++ b/clang/docs/HLSL/ResourceTypes.rst
@@ -0,0 +1,34 @@
+============
+HLSL Support
+============
+
+.. contents::
+   :local:
+
+Introduction
+============
+
+HLSL Resources are runtime-bound data that is provided as input, output or both
+to shader programs written in HLSL. Resource Types in HLSL provide key user
+abstractions for reading and writing resource data.
+
+Implementation Details
+======================
+
+In Clang resource types are forward declared by the ``HLSLExternalSemaSource``
+on initialization. They are then lazily completed when ``requiresCompleteType``
+is called later in Sema.
+
+Resource types are templated class declarations. The template parameter
+specifies the expected return type of resource loads, and the expected parameter
+type for stores.
+
+In Clang's AST and code generation, resource types are classes that store a
+pointer of the template parameter type. The pointer is populated from a call to
+``__builtin_hlsl_create_handle``, and treated as a pointer to an array of typed
+data through until lowering in the backend.
+
+Resource types are annotated with the ``HLSLResource`` attribute, which drives
+code generation for resource binding metadata. The ``hlsl`` metadata nodes are
+transformed in the backend to the binding information expected by the target
+runtime.

diff  --git a/clang/docs/index.rst b/clang/docs/index.rst
index 78a1ed12bcf3c..81ffc9d7e5f00 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -46,7 +46,7 @@ Using Clang as a Compiler
    OpenCLSupport
    OpenMPSupport
    SYCLSupport
-   HLSLSupport
+   HLSL/HLSLDocs
    ThinLTO
    APINotes
    DebuggingCoroutines


        


More information about the cfe-commits mailing list