summaryrefslogtreecommitdiffstats
path: root/docs/user-guide
diff options
context:
space:
mode:
Diffstat (limited to 'docs/user-guide')
-rw-r--r--docs/user-guide/a2-01-spirv-target-specific.md19
-rw-r--r--docs/user-guide/a2-02-metal-target-specific.md2
-rw-r--r--docs/user-guide/a2-03-wgsl-target-specific.md4
-rw-r--r--docs/user-guide/toc.html2
4 files changed, 18 insertions, 9 deletions
diff --git a/docs/user-guide/a2-01-spirv-target-specific.md b/docs/user-guide/a2-01-spirv-target-specific.md
index 1ab143cb0..dee19cd28 100644
--- a/docs/user-guide/a2-01-spirv-target-specific.md
+++ b/docs/user-guide/a2-01-spirv-target-specific.md
@@ -72,7 +72,7 @@ The system-value semantics are translated to the following SPIR-V code.
| `SV_GroupThreadID` | `BuiltIn LocalInvocationId` |
| `SV_InnerCoverage` | `BuiltIn FullyCoveredEXT` |
| `SV_InsideTessFactor` | `BuiltIn TessLevelInner` |
-| `SV_InstanceID`<sup>**</sup> | `BuiltIn InstanceIndex` |
+| `SV_InstanceID`<sup>**</sup> | `BuiltIn InstanceIndex` - `Builtin BaseInstance` |
| `SV_IntersectionAttributes` | *Not supported* |
| `SV_IsFrontFace` | `BuiltIn FrontFacing` |
| `SV_OutputControlPointID` | `BuiltIn InvocationId` |
@@ -88,20 +88,25 @@ The system-value semantics are translated to the following SPIR-V code.
| `SV_StencilRef` | `BuiltIn FragStencilRefEXT` |
| `SV_Target<N>` | `Location` |
| `SV_TessFactor` | `BuiltIn TessLevelOuter` |
-| `SV_VertexID` | `BuiltIn VertexIndex` |
+| `SV_VertexID`<sup>**</sup> | `BuiltIn VertexIndex` - `Builtin BaseVertex` |
| `SV_ViewID` | `BuiltIn ViewIndex` |
| `SV_ViewportArrayIndex` | `BuiltIn ViewportIndex` |
+| `SV_VulkanInstanceID` | `BuiltIn InstanceIndex` |
+| `SV_VulkanVertexID` | `BuiltIn VertexIndex` |
*Note* that `SV_DrawIndex`, `SV_PointSize` and `SV_PointCoord` are Slang-specific semantics that are not defined in HLSL.
-Also *Note* that `SV_InstanceID` counts all instances in a draw call, unlike how `InstanceIndex` is relative to `BaseInstance`. See [Using SV_InstanceID with SPIR-V target](#using-sv_instanceid-with-spir-v-target)
+Also *Note* that `SV_InstanceID`/`SV_VertexID` counts all instances/vertices in a draw call, unlike how `InstanceIndex`/`VertexIndex` is relative to `BaseInstance`/`BaseVertex`.
+See [Using SV_InstanceID/SV_VertexID with SPIR-V target](#using-sv_instanceid-and-sv_vertexid-with-spir-v-target)
-Using SV_InstanceID with SPIR-V target
+Using SV_InstanceID and SV_VertexID with SPIR-V target
--------------------------------------
-When using `SV_InstanceID` with SPIR-V target, it is equivalent to the difference between the `InstanceIndex` and `BaseInstance` builtins.
-This matches the behavior of D3D where `SV_InstanceID` starts from zero for each draw call, while in SPIR-V, `InstanceIndex` includes the base instance.
+When using `SV_InstanceID` and `SV_VertexID` with SPIR-V target, it is equivalent to the difference between the index and base builtins.
+This matches the behavior of D3D where `SV_InstanceID` and `SV_VertexID` starts from zero for each draw call, while in SPIR-V,
+`InstanceIndex` and `VertexIndex` includes the base instance.
-If you need direct access to the `InstanceIndex` value, you can use parameters with `SV_InstanceID` and `SV_StartInstanceLocation` semantics:
+If you need direct access to `InstanceIndex` and `VertexIndex` values, use `SV_VulkanInstanceID` and `SV_VulkanVertexID` semantic names. These are supported for all targets except HLSL.
+Alternatively you can use parameters with `SV_InstanceID`(or `SV_VertexID`) and `SV_StartInstanceLocation`(or `SV_StartVertexLocation`) semantics:
```slang
void myVertexShader(
diff --git a/docs/user-guide/a2-02-metal-target-specific.md b/docs/user-guide/a2-02-metal-target-specific.md
index 8d69a5975..c0360efda 100644
--- a/docs/user-guide/a2-02-metal-target-specific.md
+++ b/docs/user-guide/a2-02-metal-target-specific.md
@@ -44,6 +44,8 @@ The system-value semantics are translated to the following Metal attributes:
| `SV_ViewportArrayIndex` | `[[viewport_array_index]]` |
| `SV_StartVertexLocation` | `[[base_vertex]]` |
| `SV_StartInstanceLocation` | `[[base_instance]]` |
+| `SV_VulkanInstanceID` | `[[instance_id]]` |
+| `SV_VulkanVertexID` | `[[vertex_id]]` |
Custom semantics are mapped to user attributes:
diff --git a/docs/user-guide/a2-03-wgsl-target-specific.md b/docs/user-guide/a2-03-wgsl-target-specific.md
index cf28d4b49..e8a918dc8 100644
--- a/docs/user-guide/a2-03-wgsl-target-specific.md
+++ b/docs/user-guide/a2-03-wgsl-target-specific.md
@@ -50,6 +50,8 @@ The system-value semantics are translated to the following WGSL code.
| SV_VertexID | `@builtin(vertex_index)` |
| SV_ViewID | *Not supported* |
| SV_ViewportArrayIndex | *Not supported* |
+| SV_VulkanInstanceID | `@builtin(instance_index)` |
+| SV_VulkanVertexID | `@builtin(vertex_index)` |
Supported HLSL features when targeting WGSL
@@ -179,4 +181,4 @@ Translates to:
```wgsl
@id(7) override a : i32 = 2;
-``` \ No newline at end of file
+```
diff --git a/docs/user-guide/toc.html b/docs/user-guide/toc.html
index ace7da1d0..47e0c05ad 100644
--- a/docs/user-guide/toc.html
+++ b/docs/user-guide/toc.html
@@ -195,7 +195,7 @@
<li data-link="spirv-target-specific#memory-model"><span>Memory model</span></li>
<li data-link="spirv-target-specific#combined-texture-sampler"><span>Combined texture sampler</span></li>
<li data-link="spirv-target-specific#system-value-semantics"><span>System-Value semantics</span></li>
-<li data-link="spirv-target-specific#using-sv_instanceid-with-spir-v-target"><span>Using SV_InstanceID with SPIR-V target</span></li>
+<li data-link="spirv-target-specific#using-sv_instanceid-and-sv_vertexid-with-spir-v-target"><span>Using SV_InstanceID and SV_VertexID with SPIR-V target</span></li>
<li data-link="spirv-target-specific#behavior-of-discard-after-spir-v-16"><span>Behavior of `discard` after SPIR-V 1.6</span></li>
<li data-link="spirv-target-specific#supported-hlsl-features-when-targeting-spir-v"><span>Supported HLSL features when targeting SPIR-V</span></li>
<li data-link="spirv-target-specific#unsupported-glsl-keywords-when-targeting-spir-v"><span>Unsupported GLSL keywords when targeting SPIR-V</span></li>