Implement the msad4
HLSL Function
#99137
Labels
backend:DirectX
backend:SPIR-V
bot:HLSL
HLSL
HLSL Language Support
metabug
Issue to collect references to a group of similar or related issues.
msad4
clang builtin,msad4
clang builtin withhlsl_intrinsics.h
msad4
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
msad4
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/msad4.hlsl
clang/test/SemaHLSL/BuiltIns/msad4-errors.hlsl
int_dx_msad4
intrinsic inIntrinsicsDirectX.td
DXILOpMapping
ofint_dx_msad4
to53
inDXIL.td
msad4.ll
andmsad4_errors.ll
tests inllvm/test/CodeGen/DirectX/
int_spv_msad4
intrinsic inIntrinsicsSPIRV.td
msad4
lowering and map it toint_spv_msad4
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/msad4.ll
DirectX
SPIR-V
SAbs:
Description:
SAbs
Result is x if x ≥ 0; otherwise result is -x, where x is
interpreted as a signed integer.
Result Type and the type of x must both be integer scalar or integer
vector types. Result Type and operand types must have the same number
of components with the same component width. Results are computed per
component.
5
<id>
x
Test Case(s)
Example 1
HLSL:
Compares a 4-byte reference value and an 8-byte source value and accumulates a vector of 4 sums. Each sum corresponds to the masked sum of absolute differences of a different byte alignment between the reference value and the source value.
Parameters
reference
[in] The reference array of 4 bytes in one uint value.
source
[in] The source array of 8 bytes in two uint2 values.
accum
[in] A vector of 4 values. msad4 adds this vector to the masked sum of absolute differences of the different byte alignments between the reference value and the source value.
Return Value
A vector of 4 sums. Each sum corresponds to the masked sum of absolute differences of different byte alignments between the reference value and the source value. msad4 doesn't include a difference in the sum if that difference is masked (that is, the reference byte is 0).
Remarks
To use the msad4 intrinsic in your shader code, call the ID3D11Device::CheckFeatureSupport method with D3D11_FEATURE_D3D11_OPTIONS to verify that the Direct3D device supports the SAD4ShaderInstructions feature option. The msad4 intrinsic requires a WDDM 1.2 display driver, and all WDDM 1.2 display drivers must support msad4. If your app creates a rendering device with feature level 11.0 or 11.1 and the compilation target is shader model 5 or later, the HLSL source code can use the msad4 intrinsic.
Return values are only accurate up to 65535. If you call the msad4 intrinsic with inputs that might result in return values greater than 65535, msad4 produces undefined results.
Minimum Shader Model
This function is supported in the following shader models.
Examples
Here is an example result calculation for msad4:
Here is an example of how you can use msad4 to search for a reference pattern within a buffer:
Requirements
See also
Intrinsic Functions
The text was updated successfully, but these errors were encountered: