Add support for #pragma settings comments in SkSL.
This will allow us to write skslc-based golden tests that deviate from the standalone skslc settings. This CL provides six options; more will be added as necessary. - Default (caps) - UsesPrecisionModifiers (caps) - Version110 (caps) - Version450Core (caps) - ForceHighPrecision (settings flag bit) - Sharpen (settings flag bit) Change-Id: I9b779e039b2f0c0ccf43dca226fb4844aff3526b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317237 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
3ee25e942e
commit
72664bede4
@ -31,6 +31,7 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/DependentInitializers.sksl",
|
||||
"$_tests/sksl/glsl/Discard.sksl",
|
||||
"$_tests/sksl/glsl/FloatFolding.sksl",
|
||||
"$_tests/sksl/glsl/ForceHighPrecision.sksl",
|
||||
"$_tests/sksl/glsl/FrExp.sksl",
|
||||
"$_tests/sksl/glsl/Functions.sksl",
|
||||
"$_tests/sksl/glsl/Height.sksl",
|
||||
@ -72,9 +73,18 @@ sksl_glsl_tests_sources = [
|
||||
"$_tests/sksl/glsl/TernaryAsLValueEntirelyFoldable.sksl",
|
||||
"$_tests/sksl/glsl/TernaryAsLValueFoldableTest.sksl",
|
||||
"$_tests/sksl/glsl/TernaryAsLValueUnfoldable.sksl",
|
||||
"$_tests/sksl/glsl/Texture.sksl",
|
||||
"$_tests/sksl/glsl/TextureSharpen.sksl",
|
||||
"$_tests/sksl/glsl/TextureSharpenVersion110.sksl",
|
||||
"$_tests/sksl/glsl/TextureVersion110.sksl",
|
||||
"$_tests/sksl/glsl/TypePrecisionDisabled.sksl",
|
||||
"$_tests/sksl/glsl/TypePrecisionEnabled.sksl",
|
||||
"$_tests/sksl/glsl/UnusedVariables.sksl",
|
||||
"$_tests/sksl/glsl/UsesPrecisionModifiers.sksl",
|
||||
"$_tests/sksl/glsl/VectorConstructors.sksl",
|
||||
"$_tests/sksl/glsl/VectorFolding.sksl",
|
||||
"$_tests/sksl/glsl/Version110.sksl",
|
||||
"$_tests/sksl/glsl/Version450Core.sksl",
|
||||
"$_tests/sksl/glsl/VertexID.vert",
|
||||
"$_tests/sksl/glsl/Width.sksl",
|
||||
"$_tests/sksl/inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl",
|
||||
|
@ -263,7 +263,7 @@ void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
|
||||
|
||||
// If the primary output is declared, we must declare also the secondary output
|
||||
// and vice versa, since it is not allowed to use a built-in gl_FragColor and a custom
|
||||
// output. The condition also co-incides with the condition in whici GLES SL 2.0
|
||||
// output. The condition also co-incides with the condition in which GLES SL 2.0
|
||||
// requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
|
||||
if (caps.mustDeclareFragmentShaderOutput()) {
|
||||
fOutputs.emplace_back(DeclaredSecondaryColorOutputName(), kHalf4_GrSLType,
|
||||
|
@ -33,6 +33,62 @@ static SkSL::String base_name(const char* fpPath, const char* prefix, const char
|
||||
return result;
|
||||
}
|
||||
|
||||
// Given a string containing an SkSL program, searches for a #pragma settings comment, like so:
|
||||
// /*#pragma settings Default Sharpen*/
|
||||
// The passed-in Settings object will be updated accordingly. Any number of options can be provided.
|
||||
static void detect_shader_settings(const SkSL::String& text, SkSL::Program::Settings* settings) {
|
||||
// Find a matching comment and isolate the name portion.
|
||||
static constexpr char kPragmaSettings[] = "/*#pragma settings ";
|
||||
const char* settingsPtr = strstr(text.c_str(), kPragmaSettings);
|
||||
if (settingsPtr != nullptr) {
|
||||
// Subtract one here in order to preserve the leading space, which is necessary to allow
|
||||
// consumeSuffix to find the first item.
|
||||
settingsPtr += strlen(kPragmaSettings) - 1;
|
||||
|
||||
const char* settingsEnd = strstr(settingsPtr, "*/");
|
||||
if (settingsEnd != nullptr) {
|
||||
SkSL::String settingsText{settingsPtr, size_t(settingsEnd - settingsPtr)};
|
||||
|
||||
// Apply settings as requested. Since they can come in any order, repeat until we've
|
||||
// consumed them all.
|
||||
for (;;) {
|
||||
const size_t startingLength = settingsText.length();
|
||||
|
||||
if (settingsText.consumeSuffix(" Default")) {
|
||||
static auto s_defaultCaps = SkSL::ShaderCapsFactory::Default();
|
||||
settings->fCaps = s_defaultCaps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" UsesPrecisionModifiers")) {
|
||||
static auto s_precisionCaps = SkSL::ShaderCapsFactory::UsesPrecisionModifiers();
|
||||
settings->fCaps = s_precisionCaps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" Version110")) {
|
||||
static auto s_version110Caps = SkSL::ShaderCapsFactory::Version110();
|
||||
settings->fCaps = s_version110Caps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" Version450Core")) {
|
||||
static auto s_version450CoreCaps = SkSL::ShaderCapsFactory::Version450Core();
|
||||
settings->fCaps = s_version450CoreCaps.get();
|
||||
}
|
||||
if (settingsText.consumeSuffix(" ForceHighPrecision")) {
|
||||
settings->fForceHighPrecision = true;
|
||||
}
|
||||
if (settingsText.consumeSuffix(" Sharpen")) {
|
||||
settings->fSharpenTextures = true;
|
||||
}
|
||||
|
||||
if (settingsText.empty()) {
|
||||
break;
|
||||
}
|
||||
if (settingsText.length() == startingLength) {
|
||||
printf("Unrecognized #pragma settings: %s\n", settingsText.c_str());
|
||||
exit(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Very simple standalone executable to facilitate testing.
|
||||
*/
|
||||
@ -60,17 +116,15 @@ int main(int argc, const char** argv) {
|
||||
}
|
||||
|
||||
std::ifstream in(argv[1]);
|
||||
std::string stdText((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
SkSL::String text(stdText.c_str());
|
||||
SkSL::String text((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
if (in.rdstate()) {
|
||||
printf("error reading '%s'\n", argv[1]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
SkSL::ShaderCapsPointer caps = SkSL::ShaderCapsFactory::Standalone();
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fCaps = caps.get();
|
||||
detect_shader_settings(text, &settings);
|
||||
SkSL::String name(argv[2]);
|
||||
if (name.endsWith(".spirv")) {
|
||||
SkSL::FileOutputStream out(argv[2]);
|
||||
|
@ -61,6 +61,18 @@ bool String::endsWith(const char suffix[]) const {
|
||||
return !strncmp(this->data() + this->size() - suffixLength, suffix, suffixLength);
|
||||
}
|
||||
|
||||
bool String::consumeSuffix(const char suffix[]) {
|
||||
size_t suffixLength = strlen(suffix);
|
||||
if (this->length() < suffixLength) {
|
||||
return false;
|
||||
}
|
||||
if (0 != strncmp(this->data() + this->size() - suffixLength, suffix, suffixLength)) {
|
||||
return false;
|
||||
}
|
||||
this->resize(this->length() - suffixLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
String String::operator+(const char* s) const {
|
||||
String result(*this);
|
||||
result.append(s);
|
||||
|
@ -65,8 +65,9 @@ public:
|
||||
void appendf(const char* fmt, ...);
|
||||
void vappendf(const char* fmt, va_list va);
|
||||
|
||||
bool startsWith(const char* prefix) const;
|
||||
bool endsWith(const char* suffix) const;
|
||||
bool startsWith(const char prefix[]) const;
|
||||
bool endsWith(const char suffix[]) const;
|
||||
bool consumeSuffix(const char suffix[]);
|
||||
|
||||
String operator+(const char* s) const;
|
||||
String operator+(const String& s) const;
|
||||
|
@ -85,9 +85,8 @@ public:
|
||||
return fUsesPrecisionModifiers;
|
||||
}
|
||||
|
||||
bool fMustDeclareFragmentShaderOutput = true;
|
||||
bool mustDeclareFragmentShaderOutput() const {
|
||||
return fMustDeclareFragmentShaderOutput;
|
||||
return fGLSLGeneration > k110_GrGLSLGeneration;
|
||||
}
|
||||
|
||||
bool fFBFetchSupport = true;
|
||||
|
@ -49,57 +49,6 @@ static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& cap
|
||||
test(r, src, settings, expected, &inputs, kind);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLVersion, r) {
|
||||
test(r,
|
||||
"in float test; void main() { sk_FragColor.r = half(test); }",
|
||||
*SkSL::ShaderCapsFactory::Version450Core(),
|
||||
"#version 450 core\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"in float test;\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = test;\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"in float test; void main() { sk_FragColor.r = half(test); }",
|
||||
*SkSL::ShaderCapsFactory::Version110(),
|
||||
"#version 110\n"
|
||||
"varying float test;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor.x = test;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLUsesPrecisionModifiers, r) {
|
||||
test(r,
|
||||
"void main() { half x = 0.75; float y = 1; x++; y++;"
|
||||
"sk_FragColor.rg = half2(x, half(y)); }",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" float x = 0.75;\n"
|
||||
" float y = 1.0;\n"
|
||||
" x++;\n"
|
||||
" y++;\n"
|
||||
" sk_FragColor.xy = vec2(x, y);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"void main() { half x = 0.75; float y = 1; x++; y++;"
|
||||
"sk_FragColor.rg = half2(x, half(y)); }",
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" mediump float x = 0.75;\n"
|
||||
" highp float y = 1.0;\n"
|
||||
" x++;\n"
|
||||
" y++;\n"
|
||||
" sk_FragColor.xy = vec2(x, y);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLMinAbs, r) {
|
||||
test(r,
|
||||
"void main() {"
|
||||
@ -230,108 +179,6 @@ DEF_TEST(SkSLDerivatives, r) {
|
||||
&inputs);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLTexture, r) {
|
||||
test(r,
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"float4 a = sample(one, 0);"
|
||||
"float4 b = sample(two, float2(0));"
|
||||
"float4 c = sample(one, float2(0));"
|
||||
"float4 d = sample(two, float3(0));"
|
||||
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"uniform sampler1D one;\n"
|
||||
"uniform sampler2D two;\n"
|
||||
"void main() {\n"
|
||||
" vec4 a = texture(one, 0.0);\n"
|
||||
" vec4 b = texture(two, vec2(0.0));\n"
|
||||
" vec4 c = textureProj(one, vec2(0.0));\n"
|
||||
" vec4 d = textureProj(two, vec3(0.0));\n"
|
||||
" sk_FragColor = vec4(a.x, b.x, c.x, d.x);\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"float4 a = sample(one, 0);"
|
||||
"float4 b = sample(two, float2(0));"
|
||||
"float4 c = sample(one, float2(0));"
|
||||
"float4 d = sample(two, float3(0));"
|
||||
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Version110(),
|
||||
"#version 110\n"
|
||||
"uniform sampler1D one;\n"
|
||||
"uniform sampler2D two;\n"
|
||||
"void main() {\n"
|
||||
" vec4 a = texture1D(one, 0.0);\n"
|
||||
" vec4 b = texture2D(two, vec2(0.0));\n"
|
||||
" vec4 c = texture1DProj(one, vec2(0.0));\n"
|
||||
" vec4 d = texture2DProj(two, vec3(0.0));\n"
|
||||
" gl_FragColor = vec4(a.x, b.x, c.x, d.x);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLSharpen, r) {
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fSharpenTextures = true;
|
||||
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
|
||||
settings.fCaps = caps.get();
|
||||
SkSL::Program::Inputs inputs;
|
||||
test(r,
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"float4 a = sample(one, 0);"
|
||||
"float4 b = sample(two, float2(0));"
|
||||
"float4 c = sample(one, float2(0));"
|
||||
"float4 d = sample(two, float3(0));"
|
||||
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
|
||||
"}",
|
||||
settings,
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"uniform sampler1D one;\n"
|
||||
"uniform sampler2D two;\n"
|
||||
"void main() {\n"
|
||||
" vec4 a = texture(one, 0.0, -0.5);\n"
|
||||
" vec4 b = texture(two, vec2(0.0), -0.5);\n"
|
||||
" vec4 c = textureProj(one, vec2(0.0), -0.5);\n"
|
||||
" vec4 d = textureProj(two, vec3(0.0), -0.5);\n"
|
||||
" sk_FragColor = vec4(a.x, b.x, c.x, d.x);\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
|
||||
caps = SkSL::ShaderCapsFactory::Version110();
|
||||
settings.fCaps = caps.get();
|
||||
test(r,
|
||||
"uniform sampler1D one;"
|
||||
"uniform sampler2D two;"
|
||||
"void main() {"
|
||||
"float4 a = sample(one, 0);"
|
||||
"float4 b = sample(two, float2(0));"
|
||||
"float4 c = sample(one, float2(0));"
|
||||
"float4 d = sample(two, float3(0));"
|
||||
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
|
||||
"}",
|
||||
settings,
|
||||
"#version 110\n"
|
||||
"uniform sampler1D one;\n"
|
||||
"uniform sampler2D two;\n"
|
||||
"void main() {\n"
|
||||
" vec4 a = texture1D(one, 0.0, -0.5);\n"
|
||||
" vec4 b = texture2D(two, vec2(0.0), -0.5);\n"
|
||||
" vec4 c = texture1DProj(one, vec2(0.0), -0.5);\n"
|
||||
" vec4 d = texture2DProj(two, vec3(0.0), -0.5);\n"
|
||||
" gl_FragColor = vec4(a.x, b.x, c.x, d.x);\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLFragCoord, r) {
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fFlipY = true;
|
||||
@ -540,96 +387,6 @@ void main() {
|
||||
SkSL::Program::kGeometry_Kind);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLTypePrecision, r) {
|
||||
test(r,
|
||||
"float f = 1;"
|
||||
"half h = 2;"
|
||||
"float d = 3;"
|
||||
"float2 f2 = float2(1, 2);"
|
||||
"half3 h3 = half3(1, 2, 3);"
|
||||
"float4 d4 = float4(1, 2, 3, 4);"
|
||||
"float2x2 f22 = float2x2(1, 2, 3, 4);"
|
||||
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);"
|
||||
"float4x2 d42 = float4x2(1, 2, 3, 4, 5, 6, 7, 8);"
|
||||
"void main() {"
|
||||
"sk_FragColor.r = half(f + h + d + f2.x + h3.x + d4.x + f22[0][0] + h24[0][0] + "
|
||||
"d42[0][0]);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
"#version 400\n"
|
||||
"out vec4 sk_FragColor;\n"
|
||||
"float f = 1.0;\n"
|
||||
"float h = 2.0;\n"
|
||||
"float d = 3.0;\n"
|
||||
"vec2 f2 = vec2(1.0, 2.0);\n"
|
||||
"vec3 h3 = vec3(1.0, 2.0, 3.0);\n"
|
||||
"vec4 d4 = vec4(1.0, 2.0, 3.0, 4.0);\n"
|
||||
"mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);\n"
|
||||
"mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n"
|
||||
"mat4x2 d42 = mat4x2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = (((((((f + h) + d) + f2.x) + h3.x) + d4.x) + "
|
||||
"f22[0][0]) + h24[0][0]) + d42[0][0];\n"
|
||||
"}\n");
|
||||
test(r,
|
||||
"float f = 1;"
|
||||
"half h = 2;"
|
||||
"float2 f2 = float2(1, 2);"
|
||||
"half3 h3 = half3(1, 2, 3);"
|
||||
"float2x2 f22 = float2x2(1, 2, 3, 4);"
|
||||
"half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);"
|
||||
"void main() {"
|
||||
"sk_FragColor.r = half(f + h + f2.x + h3.x + f22[0][0] + h24[0][0]);"
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"highp float f = 1.0;\n"
|
||||
"mediump float h = 2.0;\n"
|
||||
"highp vec2 f2 = vec2(1.0, 2.0);\n"
|
||||
"mediump vec3 h3 = vec3(1.0, 2.0, 3.0);\n"
|
||||
"highp mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);\n"
|
||||
"mediump mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);\n"
|
||||
"void main() {\n"
|
||||
" sk_FragColor.x = ((((f + h) + f2.x) + h3.x) + f22[0][0]) + h24[0][0];\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLForceHighPrecision, r) {
|
||||
test(r,
|
||||
"void main() {\n half x = half(sqrt(1));\n half4 y = half4(x);\n sk_FragColor = y;\n }",
|
||||
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" mediump float x = sqrt(1.0);\n"
|
||||
" mediump vec4 y = vec4(x);\n"
|
||||
" sk_FragColor = y;\n"
|
||||
"}\n");
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fForceHighPrecision = true;
|
||||
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::UsesPrecisionModifiers();
|
||||
settings.fCaps = caps.get();
|
||||
SkSL::Program::Inputs inputs;
|
||||
test(r,
|
||||
"void main() { half x = half(sqrt(1)); half4 y = half4(x); sk_FragColor = y; }",
|
||||
settings,
|
||||
"#version 400\n"
|
||||
"precision mediump float;\n"
|
||||
"precision mediump sampler2D;\n"
|
||||
"out mediump vec4 sk_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" highp float x = sqrt(1.0);\n"
|
||||
" highp vec4 y = vec4(x);\n"
|
||||
" sk_FragColor = y;\n"
|
||||
"}\n",
|
||||
&inputs);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLNormalization, r) {
|
||||
test(r,
|
||||
"uniform float4 sk_RTAdjust; void main() { sk_Position = half4(1); }",
|
||||
|
6
tests/sksl/glsl/ForceHighPrecision.sksl
Normal file
6
tests/sksl/glsl/ForceHighPrecision.sksl
Normal file
@ -0,0 +1,6 @@
|
||||
/*#pragma settings UsesPrecisionModifiers ForceHighPrecision*/
|
||||
|
||||
void main() { half x = half(sqrt(1));
|
||||
half4 y = half4(x);
|
||||
sk_FragColor = y;
|
||||
}
|
10
tests/sksl/glsl/Texture.sksl
Normal file
10
tests/sksl/glsl/Texture.sksl
Normal file
@ -0,0 +1,10 @@
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
|
||||
void main() {
|
||||
float4 a = sample(one, 0);
|
||||
float4 b = sample(two, float2(0));
|
||||
float4 c = sample(one, float2(0));
|
||||
float4 d = sample(two, float3(0));
|
||||
sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));
|
||||
}
|
12
tests/sksl/glsl/TextureSharpen.sksl
Normal file
12
tests/sksl/glsl/TextureSharpen.sksl
Normal file
@ -0,0 +1,12 @@
|
||||
/*#pragma settings Sharpen*/
|
||||
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
|
||||
void main() {
|
||||
float4 a = sample(one, 0);
|
||||
float4 b = sample(two, float2(0));
|
||||
float4 c = sample(one, float2(0));
|
||||
float4 d = sample(two, float3(0));
|
||||
sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));
|
||||
}
|
12
tests/sksl/glsl/TextureSharpenVersion110.sksl
Normal file
12
tests/sksl/glsl/TextureSharpenVersion110.sksl
Normal file
@ -0,0 +1,12 @@
|
||||
/*#pragma settings Version110 Sharpen*/
|
||||
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
|
||||
void main() {
|
||||
float4 a = sample(one, 0);
|
||||
float4 b = sample(two, float2(0));
|
||||
float4 c = sample(one, float2(0));
|
||||
float4 d = sample(two, float3(0));
|
||||
sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));
|
||||
}
|
12
tests/sksl/glsl/TextureVersion110.sksl
Normal file
12
tests/sksl/glsl/TextureVersion110.sksl
Normal file
@ -0,0 +1,12 @@
|
||||
/*#pragma settings Version110*/
|
||||
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
|
||||
void main() {
|
||||
float4 a = sample(one, 0);
|
||||
float4 b = sample(two, float2(0));
|
||||
float4 c = sample(one, float2(0));
|
||||
float4 d = sample(two, float3(0));
|
||||
sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));
|
||||
}
|
10
tests/sksl/glsl/TypePrecisionDisabled.sksl
Normal file
10
tests/sksl/glsl/TypePrecisionDisabled.sksl
Normal file
@ -0,0 +1,10 @@
|
||||
float f = 1;
|
||||
half h = 2;
|
||||
float2 f2 = float2(1, 2);
|
||||
half3 h3 = half3(1, 2, 3);
|
||||
float2x2 f22 = float2x2(1, 2, 3, 4);
|
||||
half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
void main() {
|
||||
sk_FragColor.r = half(f + h + f2.x + h3.x + f22[0][0] + h24[0][0]);
|
||||
}
|
12
tests/sksl/glsl/TypePrecisionEnabled.sksl
Normal file
12
tests/sksl/glsl/TypePrecisionEnabled.sksl
Normal file
@ -0,0 +1,12 @@
|
||||
/*#pragma settings UsesPrecisionModifiers*/
|
||||
|
||||
float f = 1;
|
||||
half h = 2;
|
||||
float2 f2 = float2(1, 2);
|
||||
half3 h3 = half3(1, 2, 3);
|
||||
float2x2 f22 = float2x2(1, 2, 3, 4);
|
||||
half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
void main() {
|
||||
sk_FragColor.r = half(f + h + f2.x + h3.x + f22[0][0] + h24[0][0]);
|
||||
}
|
9
tests/sksl/glsl/UsesPrecisionModifiers.sksl
Normal file
9
tests/sksl/glsl/UsesPrecisionModifiers.sksl
Normal file
@ -0,0 +1,9 @@
|
||||
/*#pragma settings UsesPrecisionModifiers*/
|
||||
|
||||
void main() {
|
||||
half x = 0.75;
|
||||
float y = 1;
|
||||
x++;
|
||||
y++;
|
||||
sk_FragColor.rg = half2(x, half(y));
|
||||
}
|
5
tests/sksl/glsl/Version110.sksl
Normal file
5
tests/sksl/glsl/Version110.sksl
Normal file
@ -0,0 +1,5 @@
|
||||
/*#pragma settings Version110*/
|
||||
|
||||
in float test;
|
||||
|
||||
void main() { sk_FragColor.r = half(test); }
|
5
tests/sksl/glsl/Version450Core.sksl
Normal file
5
tests/sksl/glsl/Version450Core.sksl
Normal file
@ -0,0 +1,5 @@
|
||||
/*#pragma settings Version450Core*/
|
||||
|
||||
in float test;
|
||||
|
||||
void main() { sk_FragColor.r = half(test); }
|
9
tests/sksl/glsl/golden/ForceHighPrecision.glsl
Normal file
9
tests/sksl/glsl/golden/ForceHighPrecision.glsl
Normal file
@ -0,0 +1,9 @@
|
||||
#version 400
|
||||
precision mediump float;
|
||||
precision mediump sampler2D;
|
||||
out mediump vec4 sk_FragColor;
|
||||
void main() {
|
||||
highp float x = sqrt(1.0);
|
||||
highp vec4 y = vec4(x);
|
||||
sk_FragColor = y;
|
||||
}
|
11
tests/sksl/glsl/golden/Texture.glsl
Normal file
11
tests/sksl/glsl/golden/Texture.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
void main() {
|
||||
vec4 a = texture(one, 0.0);
|
||||
vec4 b = texture(two, vec2(0.0));
|
||||
vec4 c = textureProj(one, vec2(0.0));
|
||||
vec4 d = textureProj(two, vec3(0.0));
|
||||
sk_FragColor = vec4(a.x, b.x, c.x, d.x);
|
||||
}
|
11
tests/sksl/glsl/golden/TextureSharpen.glsl
Normal file
11
tests/sksl/glsl/golden/TextureSharpen.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
void main() {
|
||||
vec4 a = texture(one, 0.0, -0.5);
|
||||
vec4 b = texture(two, vec2(0.0), -0.5);
|
||||
vec4 c = textureProj(one, vec2(0.0), -0.5);
|
||||
vec4 d = textureProj(two, vec3(0.0), -0.5);
|
||||
sk_FragColor = vec4(a.x, b.x, c.x, d.x);
|
||||
}
|
10
tests/sksl/glsl/golden/TextureSharpenVersion110.glsl
Normal file
10
tests/sksl/glsl/golden/TextureSharpenVersion110.glsl
Normal file
@ -0,0 +1,10 @@
|
||||
#version 110
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
void main() {
|
||||
vec4 a = texture1D(one, 0.0, -0.5);
|
||||
vec4 b = texture2D(two, vec2(0.0), -0.5);
|
||||
vec4 c = texture1DProj(one, vec2(0.0), -0.5);
|
||||
vec4 d = texture2DProj(two, vec3(0.0), -0.5);
|
||||
gl_FragColor = vec4(a.x, b.x, c.x, d.x);
|
||||
}
|
10
tests/sksl/glsl/golden/TextureVersion110.glsl
Normal file
10
tests/sksl/glsl/golden/TextureVersion110.glsl
Normal file
@ -0,0 +1,10 @@
|
||||
#version 110
|
||||
uniform sampler1D one;
|
||||
uniform sampler2D two;
|
||||
void main() {
|
||||
vec4 a = texture1D(one, 0.0);
|
||||
vec4 b = texture2D(two, vec2(0.0));
|
||||
vec4 c = texture1DProj(one, vec2(0.0));
|
||||
vec4 d = texture2DProj(two, vec3(0.0));
|
||||
gl_FragColor = vec4(a.x, b.x, c.x, d.x);
|
||||
}
|
11
tests/sksl/glsl/golden/TypePrecisionDisabled.glsl
Normal file
11
tests/sksl/glsl/golden/TypePrecisionDisabled.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
out vec4 sk_FragColor;
|
||||
float f = 1.0;
|
||||
float h = 2.0;
|
||||
vec2 f2 = vec2(1.0, 2.0);
|
||||
vec3 h3 = vec3(1.0, 2.0, 3.0);
|
||||
mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);
|
||||
mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
|
||||
void main() {
|
||||
sk_FragColor.x = ((((f + h) + f2.x) + h3.x) + f22[0][0]) + h24[0][0];
|
||||
}
|
13
tests/sksl/glsl/golden/TypePrecisionEnabled.glsl
Normal file
13
tests/sksl/glsl/golden/TypePrecisionEnabled.glsl
Normal file
@ -0,0 +1,13 @@
|
||||
#version 400
|
||||
precision mediump float;
|
||||
precision mediump sampler2D;
|
||||
out mediump vec4 sk_FragColor;
|
||||
highp float f = 1.0;
|
||||
mediump float h = 2.0;
|
||||
highp vec2 f2 = vec2(1.0, 2.0);
|
||||
mediump vec3 h3 = vec3(1.0, 2.0, 3.0);
|
||||
highp mat2 f22 = mat2(1.0, 2.0, 3.0, 4.0);
|
||||
mediump mat2x4 h24 = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
|
||||
void main() {
|
||||
sk_FragColor.x = ((((f + h) + f2.x) + h3.x) + f22[0][0]) + h24[0][0];
|
||||
}
|
11
tests/sksl/glsl/golden/UsesPrecisionModifiers.glsl
Normal file
11
tests/sksl/glsl/golden/UsesPrecisionModifiers.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
#version 400
|
||||
precision mediump float;
|
||||
precision mediump sampler2D;
|
||||
out mediump vec4 sk_FragColor;
|
||||
void main() {
|
||||
mediump float x = 0.75;
|
||||
highp float y = 1.0;
|
||||
x++;
|
||||
y++;
|
||||
sk_FragColor.xy = vec2(x, y);
|
||||
}
|
5
tests/sksl/glsl/golden/Version110.glsl
Normal file
5
tests/sksl/glsl/golden/Version110.glsl
Normal file
@ -0,0 +1,5 @@
|
||||
#version 110
|
||||
varying float test;
|
||||
void main() {
|
||||
gl_FragColor.x = test;
|
||||
}
|
6
tests/sksl/glsl/golden/Version450Core.glsl
Normal file
6
tests/sksl/glsl/golden/Version450Core.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
#version 450 core
|
||||
out vec4 sk_FragColor;
|
||||
in float test;
|
||||
void main() {
|
||||
sk_FragColor.x = test;
|
||||
}
|
Loading…
Reference in New Issue
Block a user