Changeset 31205 in project


Ignore:
Timestamp:
08/11/14 16:19:25 (6 years ago)
Author:
acharlton
Message:

glls wiki: Update to 0.4.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/glls

    r30962 r31205  
    8888The shaders of glls – the forms that {{define-shader}}, {{define-pipeline}}, etc. expect – have the following syntax:
    8989
    90     (<type> [version: <version>] [extensions: <extension>] [pragmas: <pragma>])
     90    (<type> [version: <version>] [extensions: <extensions>] [pragmas: <pragmas>]
     91            [use: <imports>] [export: <exports])
    9192      <inputs> <body> -> <outputs>
    9293
     
    9596{{version}} is the integer version number of the shader, i.e. the number you would write at the top of the shader source (e.g. {{#version 410}}). Defaults to the {{glsl-version}} parameter.
    9697
    97 {{extensions}} is the list of GLSL extensions desired (in string form). E.g. {{'("GL_EXT_gpu_shader4 : enable")}}. Defaults to {{'()}}
    98 
    99 {{pragmas}} is the list of GLSL pragmas desired (in string form). E.g. {{'("optimize(on)")}}. Defaults to {{'()}}
     98{{extensions}} is the list of GLSL extensions desired (in string form). E.g. {{("GL_EXT_gpu_shader4 : enable")}}. Defaults to {{()}}
     99
     100{{pragmas}} is the list of GLSL pragmas desired (in string form). E.g. {{("optimize(on)")}}. Defaults to {{()}}
     101
     102{{imports}} is the list of shaders that the current shader depends on. See the section [[#shaders-that-export|Shaders that export]] for more details. Defaults to {{()}}
     103
     104{{exports}} is the list of symbols that the current shader exports. See the section [[#shaders-that-export|Shaders that export]] for more details. Defaults to {{()}}
    100105
    101106{{inputs}} is a list of the input variables to the shader. These are given in {{(name type)}} lists. The keyword {{uniform:}} may be used, and all following inputs will be uniforms. E.g.: {{((vertex #:vec2) (color #:vec3) uniform: (view-matrix #:mat4))}}
     
    143148* {{bitwise-not}}, {{bit-not}}: {{~}}
    144149* {{arithmetic-shift}}: {{<<}}
    145 * {{field}}: {{.}} (struct field reference, e.g. {{(field point x)}} → {{point.x}})
    146 * {{swizzle}}: {{.}} (vector swizzling, e.g. {{(swizzle color r g)}} → {{color.rg}})
     150* {{field}}, {{..}}: {{.}} (struct field reference, e.g. {{(field point x)}} → {{point.x}})
     151* {{swizzle}}, {{~~}}: {{.}} (vector swizzling, e.g. {{(swizzle color r g)}} → {{color.rg}})
    147152* {{array-ref}}, {{vector-ref}}: {{[]}} (array reference, e.g. {{(array-ref a 4)}} → {{a[4]}})
    148153* {{length}}: {{.length()}} (vector length, e.g. {{(length vec)}} → {{vec.length()}})
     
    158163    (define (<name> [(<parameter> <type>) ...]) <return-type> <body> ...)
    159164
    160 Defines the function {{name}}. The last expression in the body of a non-void function is automatically returned.
     165Defines the function {{name}}. The last expression in the body of a non-void function is automatically returned. If {{body}} is omitted, a function prototype is created.
    161166
    162167    (let ((<name> <type> [<value>]) ...) <body> ...)
     
    211216   
    212217    (%ifndef <value> <true> [<false>])
     218
     219
     220==== Shaders that export
     221It is often desirable to have shaders that contain generic, reusable functions. These shaders are linked into the pipeline (or program, in GLSL parlance) so that they can be accessed by other shaders. In order for another shader to reuse a function, it first has to (as in C) include a function prototype. glsl automates this process.
     222
     223glls lets you define shaders that export symbols through the use of the [[#shader-syntax|{{export}} keyword]]. These shaders can then be imported by others (through the [[#shader-syntax|{{use}} keyword]]). Prototypes are automatically generated for top-level functions or variables whose names match the symbols in the {{export}} keyword list. These prototypes are then inserted into shaders that {{use}} the exporting shader. Shaders that are {{use}}d by another are automatically linked into the resulting pipeline.
     224
     225Shaders that export should not have any inputs or outputs.
     226
     227See the example [[https://github.com/AlexCharlton/glls/blob/master/examples/exports.scm|exports.scm]] to see this in action.
    213228
    214229
     
    257272And for each uniform in the pipeline, {{set-SHADER-NAME-renderable-UNIFORM-NAME!}} is created.
    258273
     274<procedure> (renderable-size PIPELINE)</procedure>
     275
     276Returns the size, in bytes, of the memory needed for a renderable belonging to {{PIPELINE}}.
     277
    259278
    260279===== Fast render functions
     
    267286
    268287===== Utilities
     288<macro> (export-pipeline PIPELINE)</macro>
     289
     290Since glls-render causes {{define-pipeline}} to define multiple functions, this macro exports everything related to {{PIPELINE}}.
     291
    269292<procedure> (load-ply-renderable PLY RENDERABLE-MAKER . ARGS)</procedure>
    270293
     
    338361
    339362=== Version history
     363
     364==== Version 0.4.0
     36511 August 2014
     366
     367* Add shader exports
     368* Add function prototyping
     369* Add {{export-pipeline}}
     370* Add aliases to {{field}}, {{swizzle}} ({{..}}, {{~~}})
     371* Export {{renderable-size}} rather than {{allocate-renderable}}
     372* Improve error messages
     373* Bug fixes
     374
     375
    340376==== Version 0.3.3
    3413774 June 2014
Note: See TracChangeset for help on using the changeset viewer.