Issue 184487
Summary [Matrix] Implement matrix support for the `select` HLSL Function
Labels HLSL, bot:HLSL
Assignees
Reporter kmpeng
    > Note: This issue tracks matrix support for `select`. The original implementation issue is [here](https://github.com/llvm/llvm-project/issues/75377).  

Matrix requirements:
- [ ] https://github.com/llvm/wg-hlsl/issues/387  


## HLSL:

## Syntax


```syntax
any<> select(bool<> cond, any<> t, any<> f);
```

```syntax
any_sampler select(bool cond, any_sampler t, any_sampler f);
```


## Type Description

| Name  | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md)| [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md) | Size |
|-------|--------------------------------------------------------------------|----------------------------------------------------------------------|------|
| *ret* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool**, [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | any |
| *cond* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool** | any |
| *t* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool**, [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | any |
| *f* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool**, [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | any |
## Type Description

| Name  | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md)| [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md) | Size |
|-------|--------------------------------------------------------------------|----------------------------------------------------------------------|------|
| *ret* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**uint**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | 1 |
| *cond* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | **bool** | 1 |
| *t* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**uint**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | 1 |
| *f* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), [**int**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md), or [**uint**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | 1 |

## Minimum Shader Model

This function is supported in the following shader models.
|Shader Model |	Supported|
|-------------|----------|
|HLSL 2021 and higher shader models | yes |

## Shader Stages


## Remarks

In HLSL 2021 `int3 Z = select(X, 1, 0);` is a replacement for
```hlsl
int3 X = {1, 1, 1};
int3 Z = X ? 1 : 0;
```

## See also


- [**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
- **See [HLSL 2021 Logical operation short-circuiting for scalars](https://github.com/microsoft/DirectXShaderCompiler/wiki/HLSL-2021#logical-operation-short-circuiting-for-scalars)**
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to