<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99102>99102</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `GetRenderTargetSampleCount` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `GetRenderTargetSampleCount` clang builtin,
- [ ] Link `GetRenderTargetSampleCount` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `GetRenderTargetSampleCount` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `GetRenderTargetSampleCount` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/GetRenderTargetSampleCount.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/GetRenderTargetSampleCount-errors.hlsl`
- [ ] Create the `int_dx_GetRenderTargetSampleCount` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_GetRenderTargetSampleCount` to `77` in `DXIL.td`
- [ ] Create the `GetRenderTargetSampleCount.ll` and `GetRenderTargetSampleCount_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 77 | RenderTargetGetSampleCount | 6.0 | ('pixel',) |
## SPIR-V
There is no support for `GetRenderTargetSampleCount` when targeting SPIR-V.
## Test Case(s)
### Example 1
```hlsl
//dxc GetRenderTargetSampleCount_test.hlsl -T lib_6_8 -enable-16bit-types -O0
[numthreads(1, 1, 1)]
[shader("pixel")]
uint fn( ) : SV_Target {
return GetRenderTargetSampleCount();
}
```
## HLSL:
Gets the number of samples for a render target.
| *UINT* GetRenderTargetSampleCount() |
|-------------------------------------|
## Parameters
| Item | Description |
|--------------------------------------------------------------------------------------|-------------|
| <span id="None"></span><span id="none"></span><span id="NONE"></span>None<br/> | |
## Return Value
The number of samples.
## Remarks
Use this function and [**GetRenderTargetSamplePosition**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-getrendertargetsampleposition.md) to find out the number and position of the sampling locations for a render target.
## Minimum Shader Model
This function is supported in the following shader models.
| Shader Model | Supported |
|---------------------------------------------------------------------|-----------|
| [Shader Model 4](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm4.md) and higher shader models | yes |
| [Shader Model 3 (DirectX HLSL)](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm3.md) | no |
| [Shader Model 2 (DirectX HLSL)](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm2.md) | no |
| [Shader Model 1 (DirectX HLSL)](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm1.md) | no |
## See also
<dl> <dt>
[**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
</dt> </dl>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWMtu27wSfhp6Q8iwKcuyFl44cpwTIJeizl90F1DSWOKJRAok1aTn6Q-GlG-NayfAD7SCcxE5nG_mmwtJc2NEKQHmJLoi0XLAO1spPd9w_T8l60Gmip_zgJLoipJoSW-btoYGpKVkOroB-xVkAfqJ6xLsmuNkqjppyXRE85rLkmadqK2QhKVktNjruRPy5ZMq6KuwFa6palM_C2m1kEbkZliR6ehI-aIoqIGG07yC_MXQjdKXsaxCmRRX_OdufXflQVedzK1QMuV1jVJCotQaGu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