<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99186>99186</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `DispatchRaysDimensions` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
backend:SPIR-V,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `DispatchRaysDimensions` clang builtin,
- [ ] Link `DispatchRaysDimensions` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `DispatchRaysDimensions` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `DispatchRaysDimensions` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/DispatchRaysDimensions.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/DispatchRaysDimensions-errors.hlsl`
- [ ] Create the `int_dx_DispatchRaysDimensions` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_DispatchRaysDimensions` to `146` in `DXIL.td`
- [ ] Create the `DispatchRaysDimensions.ll` and `DispatchRaysDimensions_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Create the `int_spv_DispatchRaysDimensions` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `DispatchRaysDimensions` lowering and map it to `int_spv_DispatchRaysDimensions` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/DispatchRaysDimensions.ll`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 146 | DispatchRaysDimensions | 6.3 | ('library', 'raygeneration', 'intersection', 'anyhit', 'closesthit', 'miss', 'callable') |
## SPIR-V
<div id="header">
# [LaunchSizeKHR](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/LaunchSizeKHR.html)
## Short Description
<div class="sectionbody">
LaunchSizeKHR - Launch dimensions for ray shaders
</div>
</div>
<div id="content" class="loadable">
<div class="sect1">
## <a href="#_description" class="anchor"></a> Description
<div class="sectionbody">
<div class="dlist">
` LaunchSizeKHR `
A variable decorated with the ` LaunchSizeKHR ` decoration will contain
the ` width ` , ` height ` , and ` depth ` dimensions passed to the
[vkCmdTraceRaysKHR](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/None) command that initiated this
shader execution. The ` width ` is in the first component, the
` height ` is in the second component, and the ` depth ` is in the third
component.
</div>
<div class="sidebarblock">
<div class="content">
<div class="title">
Valid Usage
</div>
<div class="ulist">
- <a href="#VUID-LaunchSizeKHR-LaunchSizeKHR-04269"
id="VUID-LaunchSizeKHR-LaunchSizeKHR-04269"></a> <span class="vuid">
VUID-LaunchSizeKHR-LaunchSizeKHR-04269 </span>
The ` LaunchSizeKHR ` decoration **must** be used only within the
` RayGenerationKHR ` , ` IntersectionKHR ` , ` AnyHitKHR ` ,
` ClosestHitKHR ` , ` MissKHR ` , or ` CallableKHR ` ` Execution `
` Model `
- <a href="#VUID-LaunchSizeKHR-LaunchSizeKHR-04270"
id="VUID-LaunchSizeKHR-LaunchSizeKHR-04270"></a> <span class="vuid">
VUID-LaunchSizeKHR-LaunchSizeKHR-04270 </span>
The variable decorated with ` LaunchSizeKHR ` **must** be declared
using the ` Input ` ` Storage ` ` Class `
- <a href="#VUID-LaunchSizeKHR-LaunchSizeKHR-04271"
id="VUID-LaunchSizeKHR-LaunchSizeKHR-04271"></a> <span class="vuid">
VUID-LaunchSizeKHR-LaunchSizeKHR-04271 </span>
The variable decorated with ` LaunchSizeKHR ` **must** be declared as
a three-component vector of 32-bit integer values
</div>
</div>
</div>
</div>
</div>
</div>
## Test Case(s)
### Example 1
```hlsl
//dxc DispatchRaysDimensions_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint3 fn() {
return DispatchRaysDimensions();
}
```
### SPIRV Example(s):
### Example 2
```hlsl
//dxc DispatchRaysDimensions_spirv_test.hlsl -T lib_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
[shader("intersection")]
void fn() {
uint3 ret = DispatchRaysDimensions();
}
```
## HLSL:
The width, height and depth values from the **D3D12\_DISPATCH\_RAYS\_DESC** structure specified in the originating [**DispatchRays**](/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist4-dispatchrays) call.
## Syntax
```
uint3 DispatchRaysDimensions();
```
## Remarks
This function can be called from the following raytracing shader types:
* [**Any Hit Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/any-hit-shader.md)
* [**Callable Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/callable-shader.md)
* [**Closest Hit Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/closest-hit-shader.md)
* [**Intersection Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/intersection-shader.md)
* [**Miss Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/miss-shader.md)
* [**Ray Generation Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/ray-generation-shader.md)
## See also
* [Direct3D 12 Raytracing HLSL Reference](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/direct3d-12-raytracing-hlsl-reference.md)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWVtz4rjy_zTKi8qUkbmEBx4IhJnUf2ZnK5md2v9TSrYbrBNZckkyCfvpT7VkG5MQks2Z3UmlCtxu9eXXF7UEt1ZsFcCcjK_IeHXBa1doM99w85dW8iLV-X4eUTK-omS8ojdlJaEE5SiZxCth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