skia2/src/sksl
Ethan Nicholas 8feeff929e fixed skslc SPIR-V memory error
BUG=skia:6446

Change-Id: Ibc55124db60d6a05964ddcd02d285e313379f93e
Reviewed-on: https://skia-review.googlesource.com/10756
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-03-30 19:39:20 +00:00
..
ast Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
ir fixed skslc SPIR-V memory error 2017-03-30 19:39:20 +00:00
disable_flex_warnings.h Ignore Clang's -Wdeprecated-register for flex-generated code 2017-03-20 18:44:56 +00:00
GLSL.std.450.h initial checkin of SkSL compiler 2016-07-01 08:22:01 -07:00
layout.flex changed skslc layout parsing strategy 2017-03-01 17:23:58 +00:00
lex.layout.c changed skslc layout parsing strategy 2017-03-01 17:23:58 +00:00
lex.layout.cpp changed skslc layout parsing strategy 2017-03-01 17:23:58 +00:00
lex.layout.h changed skslc layout parsing strategy 2017-03-01 17:23:58 +00:00
lex.sksl.c Re-land of skslc switch support 2017-02-27 19:01:55 +00:00
README Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
sksl_frag.include added support for sk_ClipDistance 2017-02-09 19:29:33 +00:00
sksl_geom.include sksl support for geometry shaders 2017-02-17 22:00:23 +00:00
sksl_vert.include sksl support for geometry shaders 2017-02-17 22:00:23 +00:00
sksl.flex changed skslc layout parsing strategy 2017-03-01 17:23:58 +00:00
sksl.include sksl support for geometry shaders 2017-02-17 22:00:23 +00:00
SkSLCFGGenerator.cpp Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLCFGGenerator.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLCodeGenerator.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLCompiler.cpp fixed skslc SPIR-V memory error 2017-03-30 19:39:20 +00:00
SkSLCompiler.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLContext.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLErrorReporter.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLGLSLCodeGenerator.cpp Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLGLSLCodeGenerator.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLIRGenerator.cpp fixed skslc SPIR-V memory error 2017-03-30 19:39:20 +00:00
SkSLIRGenerator.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLMain.cpp Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLMemoryLayout.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLParser.cpp Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLParser.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLPosition.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLSPIRVCodeGenerator.cpp fixed skslc SPIR-V memory error 2017-03-30 19:39:20 +00:00
SkSLSPIRVCodeGenerator.h fixed skslc SPIR-V memory error 2017-03-30 19:39:20 +00:00
SkSLToken.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLUtil.cpp Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
SkSLUtil.h Revert "skslc can now be compiled with no Skia dependencies, in preparation for" 2017-03-30 18:42:59 +00:00
spirv.h initial checkin of SkSL compiler 2016-07-01 08:22:01 -07:00

Overview
========

SkSL ("Skia Shading Language") is a variant of GLSL which is used as Skia's 
internal shading language. SkSL is, at its heart, a single standardized version
of GLSL which avoids all of the various version and dialect differences found
in GLSL "in the wild", but it does bring a few of its own changes to the table.

Skia uses the SkSL compiler to convert SkSL code to GLSL, GLSL ES, or SPIR-V
before handing it over to the graphics driver.

Differences from GLSL
=====================

SkSL is based on GLSL 4.5. For the most part, write SkSL exactly as you would
desktop GLSL, and the SkSL compiler will take care of version and dialect
differences (for instance, you always use "in" and "out", and skslc will handle
translating them to "varying" and "attribute" as appropriate). Be aware of the 
following differences between SkSL and GLSL:

* GLSL caps can be referenced via the syntax 'sk_Caps.<name>', e.g.
  sk_Caps.sampleVariablesSupport. The value will be a constant boolean or int,
  as appropriate. As SkSL supports constant folding and branch elimination, this
  means that an 'if' statement which statically queries a cap will collapse down
  to the chosen branch, meaning that:

    if (sk_Caps.externalTextureSupport)
        do_something();
    else
        do_something_else();

  will compile as if you had written either 'do_something();' or
  'do_something_else();', depending on whether that cap is enabled or not.
* no #version statement is required, and will be ignored if present
* the output color is sk_FragColor (do not declare it)
* use sk_VertexID instead of gl_VertexID
* the fragment coordinate is sk_FragCoord, and is always relative to the upper
  left.
* lowp, mediump, and highp are always permitted (but will only be respected if 
  you run on a device which supports them)
* you do not need to include ".0" to make a number a float (meaning that
  "vec2(x, y) * 4" is perfectly legal in SkSL, unlike GLSL where it would often
  have to be expressed "vec2(x, y) * 4.0". There is no performance penalty for 
  this, as the number is converted to a float at compile time)
* type suffixes on numbers (1.0f, 0xFFu) are both unnecessary and unsupported
* creating a smaller vector from a larger vector (e.g. vec2(vec3(1))) is
  intentionally disallowed, as it is just a wordier way of performing a swizzle.
  Use swizzles instead.
* Use texture() instead of textureProj(), e.g. texture(sampler2D, vec3) is
  equivalent to GLSL's textureProj(sampler2D, vec3)
* some built-in functions and one or two rarely-used language features are not
  yet supported (sorry!)

SkSL is still under development, and is expected to diverge further from GLSL
over time.