Add SPIR-V support for modf intrinsic.
Change-Id: I887e700a7bf11bf2d5359c9721798f72f00e53f3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342756 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
a3b8ac76e5
commit
01957273e7
@ -245,6 +245,7 @@ sksl_shared_tests = [
|
||||
"$_tests/sksl/intrinsics/Min.sksl",
|
||||
"$_tests/sksl/intrinsics/Mix.sksl",
|
||||
"$_tests/sksl/intrinsics/Mod.sksl",
|
||||
"$_tests/sksl/intrinsics/Modf.sksl",
|
||||
"$_tests/sksl/intrinsics/Normalize.sksl",
|
||||
"$_tests/sksl/intrinsics/Not.sksl",
|
||||
"$_tests/sksl/intrinsics/NotEqual.sksl",
|
||||
|
@ -72,6 +72,7 @@ void SPIRVCodeGenerator::setupIntrinsics() {
|
||||
fIntrinsicMap[String("determinant")] = ALL_GLSL(Determinant);
|
||||
fIntrinsicMap[String("matrixInverse")] = ALL_GLSL(MatrixInverse);
|
||||
fIntrinsicMap[String("mod")] = SPECIAL(Mod);
|
||||
fIntrinsicMap[String("modf")] = ALL_GLSL(Modf);
|
||||
fIntrinsicMap[String("min")] = SPECIAL(Min);
|
||||
fIntrinsicMap[String("max")] = SPECIAL(Max);
|
||||
fIntrinsicMap[String("clamp")] = SPECIAL(Clamp);
|
||||
|
1
tests/sksl/intrinsics/Modf.sksl
Normal file
1
tests/sksl/intrinsics/Modf.sksl
Normal file
@ -0,0 +1 @@
|
||||
in half a, b; void main() { sk_FragColor.x = modf(a, b); }
|
41
tests/sksl/intrinsics/golden/Modf.asm.frag
Normal file
41
tests/sksl/intrinsics/golden/Modf.asm.frag
Normal file
@ -0,0 +1,41 @@
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise %a %b
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpName %sk_FragColor "sk_FragColor"
|
||||
OpName %sk_Clockwise "sk_Clockwise"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
OpName %main "main"
|
||||
OpDecorate %sk_FragColor RelaxedPrecision
|
||||
OpDecorate %sk_FragColor Location 0
|
||||
OpDecorate %sk_FragColor Index 0
|
||||
OpDecorate %sk_Clockwise RelaxedPrecision
|
||||
OpDecorate %sk_Clockwise BuiltIn FrontFacing
|
||||
OpDecorate %a RelaxedPrecision
|
||||
OpDecorate %b RelaxedPrecision
|
||||
OpDecorate %17 RelaxedPrecision
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%sk_FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Input_bool = OpTypePointer Input %bool
|
||||
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
|
||||
%_ptr_Input_float = OpTypePointer Input %float
|
||||
%a = OpVariable %_ptr_Input_float Input
|
||||
%b = OpVariable %_ptr_Input_float Input
|
||||
%void = OpTypeVoid
|
||||
%14 = OpTypeFunction %void
|
||||
%_ptr_Output_float = OpTypePointer Output %float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%main = OpFunction %void None %14
|
||||
%15 = OpLabel
|
||||
%17 = OpLoad %float %a
|
||||
%16 = OpExtInst %float %1 Modf %17 %b
|
||||
%18 = OpAccessChain %_ptr_Output_float %sk_FragColor %int_0
|
||||
OpStore %18 %16
|
||||
OpReturn
|
||||
OpFunctionEnd
|
7
tests/sksl/intrinsics/golden/Modf.glsl
Normal file
7
tests/sksl/intrinsics/golden/Modf.glsl
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
in float a;
|
||||
in float b;
|
||||
void main() {
|
||||
sk_FragColor.x = modf(a, b);
|
||||
}
|
24
tests/sksl/intrinsics/golden/Modf.metal
Normal file
24
tests/sksl/intrinsics/golden/Modf.metal
Normal file
@ -0,0 +1,24 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float a;
|
||||
float b;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
float _skOutParamHelper0_modf(float _var0, thread float& b) {
|
||||
float _var1;
|
||||
float _skResult = modf(_var0, _var1);
|
||||
b = _var1;
|
||||
return _skResult;
|
||||
}
|
||||
|
||||
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor.x = _skOutParamHelper0_modf(_in.a, _in.b);
|
||||
return *_out;
|
||||
}
|
Loading…
Reference in New Issue
Block a user