llvm / llvm/llvm-project

[Matrix] Implement matrix support for the `step` HLSL Function

Open
#184,490 4 comments 0 reactions 1 assignee Claimed by @kmpeng View on GitHub
backend:DirectX backend:SPIR-V bot:HLSL clang:codegen clang:frontend HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

> Note: This issue tracks matrix support for `step`. The original implementation issue is [here](https://github.com/llvm/llvm-project/issues/99157).

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

## HLSL:

Compares two values, returning 0 or 1 based on which value is greater.

| *ret* step(*y*, *x*) |
|----------------------|

## Parameters

| Item | Description |
|--------------------------------------------------------|---------------------------------------------------------------|
| *y*
| \[in\] The first floating-point value to compare.
|
| *x*
| \[in\] The second floating-point value to compare.
|

## Return Value

1 if the *x* parameter is greater than or equal to the *y* parameter; otherwise, 0.

## Remarks

This function uses the following formula: (*x* >= *y*) ? 1 : 0. The function returns either 0 or 1 depending on whether the *x* parameter is greater than the *y* parameter. To compute a smooth interpolation between 0 and 1, use the [**smoothstep**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-smoothstep.md) HLSL intrinsic function.

## Type Description

| Name | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md) | [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md) | Size |
|-------|----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|--------------------------------|
| *y* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md), **vector**, or **matrix** | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | any |
| *x* | same as input *y* | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | same dimension(s) as input *y* |
| *ret* | same as input *y* | [**float**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/WinProg/windows-data-types.md) | same dimension(s) as input *y* |

## Minimum Shader Model

This function is supported in the following shader models.

| Shader Model | Supported |
|------------------------------------------------------------------------------------|-----------------------------|
| [Shader Model 2 (DirectX HLSL)](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm2.md) and higher shader models | yes |
| [Shader Model 1 (DirectX HLSL)](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-sm1.md) | yes (vs\_1\_1 and ps\_1\_4) |

## See also

[**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.