1=================== 2HLSL Resource Types 3=================== 4 5.. contents:: 6 :local: 7 8Introduction 9============ 10 11HLSL Resources are runtime-bound data that is provided as input, output or both 12to shader programs written in HLSL. Resource Types in HLSL provide key user 13abstractions for reading and writing resource data. 14 15Implementation Details 16====================== 17 18In Clang resource types are forward declared by the ``HLSLExternalSemaSource`` 19on initialization. They are then lazily completed when ``requiresCompleteType`` 20is called later in Sema. 21 22Resource types are templated class declarations. The template parameter 23specifies the expected return type of resource loads, and the expected parameter 24type for stores. 25 26In Clang's AST and code generation, resource types are classes that store a 27pointer 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 29data through until lowering in the backend. 30 31Resource types are annotated with the ``HLSLResource`` attribute, which drives 32code generation for resource binding metadata. The ``hlsl`` metadata nodes are 33transformed in the backend to the binding information expected by the target 34runtime. 35