[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 4da15566a6dbe3f7fec1e09ec1bd5ea681a7bab5 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/5] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 0..259e93463f59b
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/5] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 0..259e93463f59b
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Xiang Li via cfe-commits


@@ -0,0 +1,292 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]

python3kgae wrote:

Good catch.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Xiang Li via cfe-commits


@@ -0,0 +1,292 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:

python3kgae wrote:

-rootsig-define is for profiles other than rootsig_1_0 and rootsig_1_1.
I'll add something for -rootsig-define.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Cooper Partin via cfe-commits


@@ -0,0 +1,292 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:

coopp wrote:

I am confused.  I thought the rootsignature define was specified on the 
commandline as -rootsig-define ?  And -E was to specify the shader entry point.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-07-17 Thread Cooper Partin via cfe-commits


@@ -0,0 +1,292 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]

coopp wrote:

In this sample the Root signature is #define RS, but the [RootSignature( ) ] 
statement is referring to 'MyRS'.. Should this be 'RS' instead?

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/4] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

python3kgae wrote:

Register ranges do not overlap.
Used resource in the shader has bindings in root signature.
No mix of sampler and other resources (CBV,SRV,UAV) in one descriptor table
...

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/3] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae edited 
https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

python3kgae wrote:

Could we link the D3D runtime doc 
[https://learn.microsoft.com/en-us/windows/win32/direct3d12/root-signatures](url)
 ?
That should have all the things about root signature.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits

https://github.com/damyanp requested changes to this pull request.

See other comments.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

damyanp wrote:

> ... and verify ...

What sort of verifications does it do?

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

damyanp wrote:

I wonder if it'd be helpful to show the runtime side of this?  Just by reading 
this, I think it's hard to understand what a root signature is, why I'd need to 
specify one, and what I'd do with one once I'd specified it.

https://github.com/llvm/llvm-project/pull/88781
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/2] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Xiang Li (python3kgae)


Changes

This patch adds documentation for the root signature in HLSL.

For issue #55116

---
Full diff: https://github.com/llvm/llvm-project/pull/88781.diff


1 Files Affected:

- (added) clang/docs/HLSL/RootSignature.rst (+291) 


``diff
diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Xiang Li (python3kgae)


Changes

This patch adds documentation for the root signature in HLSL.

For issue #55116

---
Full diff: https://github.com/llvm/llvm-project/pull/88781.diff


1 Files Affected:

- (added) clang/docs/HLSL/RootSignature.rst (+291) 


``diff
diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae created 
https://github.com/llvm/llvm-project/pull/88781

This patch adds documentation for the root signature in HLSL.

For issue #55116

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+