Add test for sk_Caps.inBlendModesFailRandomlyForAllZeroVec.
This CL also alphabetizes the various factories in ShaderCapsFactory. Change-Id: I0378ceb821678173e72690d5563d2a9a92d90201 Bug: skia:10694, skia:10819 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324257 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
658ae8fc6a
commit
8f84cee9ab
@ -303,6 +303,7 @@ sksl_settings_tests = [
|
||||
"$_tests/sksl/shared/Derivatives.sksl",
|
||||
"$_tests/sksl/shared/DerivativesFlipY.sksl",
|
||||
"$_tests/sksl/workarounds/AbsInt.sksl",
|
||||
"$_tests/sksl/workarounds/BlendModesAllZeroVec.sksl",
|
||||
"$_tests/sksl/workarounds/FractNegative.sksl",
|
||||
"$_tests/sksl/workarounds/FragCoords.sksl",
|
||||
"$_tests/sksl/workarounds/LoopCondition.sksl",
|
||||
|
@ -77,6 +77,10 @@ static void detect_shader_settings(const SkSL::String& text, SkSL::Program::Sett
|
||||
static auto s_addAndTrueCaps = Factory::AddAndTrueToLoopCondition();
|
||||
settings->fCaps = s_addAndTrueCaps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" BlendModesFailRandomlyForAllZeroVec")) {
|
||||
static auto s_blendZeroCaps = Factory::BlendModesFailRandomlyForAllZeroVec();
|
||||
settings->fCaps = s_blendZeroCaps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" CannotUseFractForNegativeValues")) {
|
||||
static auto s_negativeFractCaps = Factory::CannotUseFractForNegativeValues();
|
||||
settings->fCaps = s_negativeFractCaps.get();
|
||||
|
@ -294,30 +294,16 @@ public:
|
||||
return MakeShaderCaps();
|
||||
}
|
||||
|
||||
static ShaderCapsPointer Version450Core() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 450 core";
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer Version110() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 110";
|
||||
result->fGLSLGeneration = GrGLSLGeneration::k110_GrGLSLGeneration;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer UsesPrecisionModifiers() {
|
||||
static ShaderCapsPointer AddAndTrueToLoopCondition() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fUsesPrecisionModifiers = true;
|
||||
result->fAddAndTrueToLoopCondition = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer CannotUseMinAndAbsTogether() {
|
||||
static ShaderCapsPointer BlendModesFailRandomlyForAllZeroVec() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fCanUseMinAndAbsTogether = false;
|
||||
result->fInBlendModesFailRandomlyForAllZeroVec = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -328,27 +314,24 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer MustForceNegatedAtanParamToFloat() {
|
||||
static ShaderCapsPointer CannotUseFragCoord() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fMustForceNegatedAtanParamToFloat = true;
|
||||
result->fCanUseFragCoord = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer ShaderDerivativeExtensionString() {
|
||||
static ShaderCapsPointer CannotUseMinAndAbsTogether() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fShaderDerivativeSupport = true;
|
||||
result->fShaderDerivativeExtensionString = "GL_OES_standard_derivatives";
|
||||
result->fUsesPrecisionModifiers = true;
|
||||
result->fCanUseMinAndAbsTogether = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer FragCoordsOld() {
|
||||
static ShaderCapsPointer EmulateAbsIntFunction() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 110";
|
||||
result->fGLSLGeneration = GrGLSLGeneration::k110_GrGLSLGeneration;
|
||||
result->fFragCoordConventionsExtensionString = "GL_ARB_fragment_coord_conventions";
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fEmulateAbsIntFunction = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -358,20 +341,11 @@ public:
|
||||
result->fFragCoordConventionsExtensionString = "GL_ARB_fragment_coord_conventions";
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer GeometryShaderSupport() {
|
||||
static ShaderCapsPointer FragCoordsOld() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fGeometryShaderSupport = true;
|
||||
result->fGSInvocationsSupport = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer NoGSInvocationsSupport() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fGeometryShaderSupport = true;
|
||||
result->fGSInvocationsSupport = false;
|
||||
result->fVersionDeclString = "#version 110";
|
||||
result->fGLSLGeneration = GrGLSLGeneration::k110_GrGLSLGeneration;
|
||||
result->fFragCoordConventionsExtensionString = "GL_ARB_fragment_coord_conventions";
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -384,6 +358,14 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer GeometryShaderSupport() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fGeometryShaderSupport = true;
|
||||
result->fGSInvocationsSupport = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer GSInvocationsExtensionString() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
@ -393,22 +375,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer VariousCaps() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fExternalTextureSupport = true;
|
||||
result->fFBFetchSupport = false;
|
||||
result->fCanUseAnyFunctionInShader = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer CannotUseFragCoord() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fCanUseFragCoord = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer IncompleteShortIntPrecision() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 310es";
|
||||
@ -417,31 +383,18 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer AddAndTrueToLoopCondition() {
|
||||
static ShaderCapsPointer MustForceNegatedAtanParamToFloat() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fAddAndTrueToLoopCondition = true;
|
||||
result->fMustForceNegatedAtanParamToFloat = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer UnfoldShortCircuitAsTernary() {
|
||||
static ShaderCapsPointer NoGSInvocationsSupport() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fUnfoldShortCircuitAsTernary = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer EmulateAbsIntFunction() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fEmulateAbsIntFunction = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer RewriteDoWhileLoops() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fRewriteDoWhileLoops = true;
|
||||
result->fGeometryShaderSupport = true;
|
||||
result->fGSInvocationsSupport = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -452,12 +405,55 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer RewriteDoWhileLoops() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fRewriteDoWhileLoops = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer SampleMaskSupport() {
|
||||
ShaderCapsPointer result = Default();
|
||||
result->fSampleMaskSupport = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer ShaderDerivativeExtensionString() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fShaderDerivativeSupport = true;
|
||||
result->fShaderDerivativeExtensionString = "GL_OES_standard_derivatives";
|
||||
result->fUsesPrecisionModifiers = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer UnfoldShortCircuitAsTernary() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fUnfoldShortCircuitAsTernary = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer UsesPrecisionModifiers() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 400";
|
||||
result->fUsesPrecisionModifiers = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer Version110() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 110";
|
||||
result->fGLSLGeneration = GrGLSLGeneration::k110_GrGLSLGeneration;
|
||||
return result;
|
||||
}
|
||||
|
||||
static ShaderCapsPointer Version450Core() {
|
||||
ShaderCapsPointer result = MakeShaderCaps();
|
||||
result->fVersionDeclString = "#version 450 core";
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static ShaderCapsPointer MakeShaderCaps();
|
||||
};
|
||||
|
8
tests/sksl/workarounds/BlendModesAllZeroVec.sksl
Normal file
8
tests/sksl/workarounds/BlendModesAllZeroVec.sksl
Normal file
@ -0,0 +1,8 @@
|
||||
/*#pragma settings BlendModesFailRandomlyForAllZeroVec*/
|
||||
|
||||
in half4 src, dst;
|
||||
|
||||
void main() {
|
||||
sk_FragColor = blend_src_in(src, dst);
|
||||
sk_FragColor = blend_dst_in(src, dst);
|
||||
}
|
25
tests/sksl/workarounds/golden/BlendModesAllZeroVec.glsl
Normal file
25
tests/sksl/workarounds/golden/BlendModesAllZeroVec.glsl
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src;
|
||||
in vec4 dst;
|
||||
void main() {
|
||||
vec4 _0_blend_src_in;
|
||||
{
|
||||
_0_blend_src_in = src == vec4(0.0) ? vec4(0.0) : src * dst.w;
|
||||
}
|
||||
|
||||
sk_FragColor = _0_blend_src_in;
|
||||
|
||||
vec4 _1_blend_dst_in;
|
||||
{
|
||||
vec4 _3_blend_src_in;
|
||||
{
|
||||
_3_blend_src_in = dst == vec4(0.0) ? vec4(0.0) : dst * src.w;
|
||||
}
|
||||
_1_blend_dst_in = _3_blend_src_in;
|
||||
|
||||
}
|
||||
|
||||
sk_FragColor = _1_blend_dst_in;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src;
|
||||
in vec4 dst;
|
||||
void main() {
|
||||
vec4 _0_blend_src_in;
|
||||
{
|
||||
_0_blend_src_in = src * dst.w;
|
||||
}
|
||||
|
||||
sk_FragColor = _0_blend_src_in;
|
||||
|
||||
vec4 _1_blend_dst_in;
|
||||
{
|
||||
vec4 _3_blend_src_in;
|
||||
{
|
||||
_3_blend_src_in = dst * src.w;
|
||||
}
|
||||
_1_blend_dst_in = _3_blend_src_in;
|
||||
|
||||
}
|
||||
|
||||
sk_FragColor = _1_blend_dst_in;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user