• Stars
    star
    209
  • Rank 188,325 (Top 4 %)
  • Language
    Common Lisp
  • License
    BSD 2-Clause "Sim...
  • Created almost 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lisp to GLSL Language Translator

Varjo [BETA]

Varjo is a Lisp to GLSL compiler.

Varjo has no OpenGL dependency as is designed to be integrated into other projects, see CEPL for an example.

Vari is the dialect of lisp Varjo compiles. It aims to be as close to Common Lisp as possible, but naturally it is statically typed so there are differences.

Features

Subset of common lisp. Including:

  • Macros
    • defmacro, define-compiler-macro, macrolet, symbol-macrolet all supported
    • &environment supported (currently custom API for introspection but cltl2 API planned)
  • Multiple-value return via values & multiple-value-bind
  • local functions via labels
  • defstruct which can be used across multiple shaders (Less repeated code)
  • limited first-class function support (Functions have to be statically resolved to avoid runtime conditionals)
  • inline GLSL expressions
  • WIP for declare and extensible declaration identifiers
  • Type checking in and across shader stages
  • Rolling translate, where out vars from one stage can be automatically fed into the next
  • Easy to extend (API still in progress)

Documentation

The user guide can be found in docs/user-guide.md

The reference documentation for the compiler can be found here

The reference documentation for the Vari language can be found here

Installing

Run (ql:quickload :varjo) at your REPL.

Cloning

Whist it is recommended to get Varjo from quicklisp, if you clone please note that master is not the stable branch. Please use release-quicklisp for the stable code that will be in the next Varjo release.

Name Origins

  • Varjo is 'shadow' in Finnish
  • Vari is 'shadow' in Estonian

Updates

2018-04-05

  • Tonnes of improvements to docs (see the links in the 'Documentation' section above)
  • vari-describe, which is function that given a symbol that names a gpu func/var gives you documentation (check out vari-describe.el for emacs integration)
  • Lots more glsl operators are supported. WARNING we now have pre & post vector/matrix multiplication, please remember that the order matters (just like in regular glsl). To use the glsl specific operators (e.g. ~ ! & etc) please :use the :glsl-symbols.operators package in your project.

2018-03-14

Lots landing this month, whilst my current test suite passes I'm still expecting some issues or regressions, if these hit you PLEASE let me know so I can avoid merging this to quicklisp before the regressions have been handled. Quick summary of changes are:

  • Documentation! (see the Documentation section above for the links)
  • GLSL 460 fixes
  • compute bug fixes
  • tonnes of functions from the CL spec added (see below)
  • swizzle of rgba & stpq
  • more closely mimick the CL type tree (Still lots to be done here)
  • fix long standing bug which stopped you passing ubo/ssbo structs to functions (due to them being represented by interface blocks)
  • fix max array length bug
  • dont emit spurious function & struct glsl in various cases. Wasnt hurting anything except glsl compile time, but was still ugly.
  • internal environment object now uses the uniform-variable objects rather than lists
  • qualifier refactor to reduce duplication of information
  • some more validation checks around ubos & ssbos (though the validation code is scattered and needs a cleanup)
  • internal macro renaming
  • def-metadata-infer deprecated, use define-metadata-infer instead
  • def-metadata-kind deprecated, use define-metadata-kind instead
  • def-shadow-type-constructor deprecated, use define-shadow-type-constructor instead
  • :int32 & :uint32 type names now work as expected
  • improvements to slot-value
  • fix bug letting you assign to a read-only place
  • perf improvements
  • [BREAKING CHANGE] Removed ast (non trivial ammount of cons and not used for compile)
  • [BREAKING CHANGE] Removed the unused draw-modes variable

CL functions added listed below. Some of the predicates are basically pointless, but for completeness it's nice to have them

  • symbolp
  • keywordp
  • row-major-aref
  • svref
  • array-rank
  • array-row-major-index
  • array-total-size
  • adjustable-array-p
  • array-has-fill-pointer-p
  • arrayp
  • bit-vector-p
  • simple-bit-vector-p
  • simple-vector-p
  • vectorp
  • compiled-function-p
  • functionp
  • 1+
  • 1-
  • cis
  • float (add optional args)
  • integer-length
  • signum
  • conjugate
  • random-state-p (though just false for now)
  • complexp
  • evenp
  • floatp
  • integerp
  • minusp
  • numberp
  • oddp
  • plusp
  • rationalp
  • realp
  • zerop
  • copy-structure
  • prog2
  • dotimes
  • typecase
  • phase
  • isqrt
  • logand
  • logandc1
  • logandc2
  • logcount
  • logeqv
  • logior
  • lognand
  • lognor
  • lognot
  • logorc1
  • logorc2
  • logtest
  • logxor
  • with-accessors
  • multiple-value-setq
  • nth-value

Also added the complex & ratio types. Complex support is limited right now and ratio basically useless. But we have a place to work from. Complex numbers are always single-float in vari.

2017-06-04

PACKAGES

There has been a huge refactoring of packages.

This is annoying but a neccessary step before I could start documenting the project. The original structure just appeared out of neccessity so I'm hoping this will last a little longer. The most important changes are:

  • Our lisp dialect has a name. The naming around Varjo and it's lisp dialect were confusing people so I have named the dialect Vari, Varjo remains as the name of the compiler.

  • varjo-lang renamed to vari. You will need to update your package :useings to pull in vari and not varjo-lang.

  • No more dependency on rtg-math! If you want to use rtg-math's functions in your shaders please quickload rtg-math.vari

  • The varjo package now only exports symbols for interacting with the compiler.

  • There are places where GLSL & Common Lisp's function names overlap. This is fine when the behaviour is also the same but this is not always the case. For this reason we have a vari.cl package and a vari.glsl package. When there are conflicts (that people care about) we will put the different versions in the respective packages and vari will use the most common case.

Bugfixes & Enhancements

  • if will now generate a ternary expression (e.g. x<0 ? -1 : 1) if the followiung is true

    • there is an 'else' form
    • both the 'then' & 'else' forms return a value of the same type
    • both the 'then' & 'else' forms are pure
    • neither the 'then' & 'else' forms return multiple values
    • there is also a 'style' restriction that means if the glsl code for the expression goes over 100 characters then it will emit a regular if block. This is just to keep code readable.
  • If you use -> in a symbol it will become _to_ in glsl. So int->float becomes int_to_float

  • Fix bug where, if the 'then' clause of an if contained a progn, that code would be missing from the glsl.

  • Redamentary checks for purity of an expression (whether it has side effects). This feature is currently young and over conservative

  • Better error messages when assigning the wrong type to a place

  • Better error message for invalid argument format in function definition

  • Add the dynamic draw mode. Used when you dont know (or don't want to specify) the primitive for the compile. This will only work for vertex & fragment stages but will throw a sensible error if passed to anything else.

  • vec2, vec3, vec4, mat3 & mat4 constructors

  • Fix bug where #' would get confused in the presence of local & external functions

2017-05-16

  • Tesselation & Geometry stages are now fully supported (for real this time :D)

  • Very basic mutual recursion checks.

  • Fix bug where inlining and indirect recursion could cause compiler to infinite loop

  • Make use of {} braces consistent in emitted glsl

  • Add continue

  • Add /=

  • Add with-slots & with-accessors

  • Add multiple-value-call

  • strings containing floats will be spliced into the emitted glsl unchanged (very useful when float used for bits & you dont want the risk of lisp rounding something)

  • strings containing integers will be turned integer literals (only here for completeness with above code) doesnt not yet detect signed'ness of int.

  • make the value argument to incf, decf etc optional (defaulting to 1)

  • Better errors when can't find function match

  • Don't allow funcall on special operators. Give better error message

  • Fix bad glsl emitted for tail-calls to functions returning multiple values

  • Fix funcall so it handles multiple values correctly (dumb mistake :p)

  • Add the stage name (as a comment) to the generated glsl.

  • Large amount of refactoring how types are stored/propegated

  • v-defun renamed to v-def-glsl-template-fun, v-defun will be used for functions with lisp code.

More Repositories

1

cepl

Code Evaluate Play Loop
Common Lisp
842
star
2

rtg-math

common lisp library providing common math functions used in games
Common Lisp
49
star
3

cepl.examples

Some examples for the CEPL library
Common Lisp
44
star
4

draw-cons-tree

Draws and ascii picture of a cons tree
Common Lisp
42
star
5

glsl-spec

The GLSL spec as a datastructure
Common Lisp
38
star
6

tamei

Common Lisp symbols separated into packages according to their purity
Common Lisp
32
star
7

livesupport

Some helpers that may make livecoding with slime/sly a little easier
Common Lisp
28
star
8

fn

A couple of lambda shorthand macros
Common Lisp
23
star
9

mk-string-metrics

Calculate various string metrics efficiently in Common Lisp (Damerau-Levenshtein, Hamming, Jaro, Jaro-Winkler, Levenshtein, etc.)
Common Lisp
20
star
10

nineveh

Library of common helpful gpu functions
Common Lisp
17
star
11

backup-uk-keyboard-layouts-for-macos

WORKS FOR SIERRA TOO. Fuck you apple
16
star
12

fraggle

A place to play with shaders in CEPL
Common Lisp
15
star
13

skitter

A small event system for games
Common Lisp
15
star
14

daft

A little 2d engine
Common Lisp
14
star
15

trivial-macroexpand-all

macroexpand-all function that calls each implementation's equivalent
Common Lisp
13
star
16

l-lisp

L-Lisp is a framework for generating and simulating plants and fractals in Common Lisp - One day I will port this to cl-opengl or CEPL
Common Lisp
11
star
17

shipshape

A system to help ship lisp code with C dependencies
Common Lisp
10
star
18

cl-soil

Common lisp wrapper around the SOIL library (http://www.lonesock.net/soil.html)
Common Lisp
10
star
19

cepl.sdl2

Package that let's sdl2 host cepl
Common Lisp
9
star
20

dotemacs

just my wip emacs setup, havent tried on my windows or mac so may have some linux specific sillyness
Emacs Lisp
9
star
21

deadstuff

Lisp readable spec and stuff
HTML
8
star
22

pile

Common Lisp
8
star
23

hasty

A simple and hopefully performant Entity Component System for Common Lisp
Common Lisp
6
star
24

talk-20170313-khronos-cepl

The slides & code I used for this talk: https://www.youtube.com/watch?v=XEtlxJsPR40
Common Lisp
6
star
25

play-with-verts

From the stream
Common Lisp
6
star
26

trivial-update

Easy modification of places with any given function
Common Lisp
5
star
27

tiling-viewport-manager

Split a gl windows into 'frames' which can be rendered into, inspired by emacs & tiling window managers
Common Lisp
5
star
28

cepl.sdl2-ttf

A library that adds a couple of helper functions to make working with the excellent sdl2-ttf library even easier from CEPL
Common Lisp
5
star
29

.files

Common Lisp
5
star
30

topology-notes

study
NewLisp
4
star
31

cepl.fond

A helper library for using cl-fond with CEPL
Common Lisp
4
star
32

with-setf

Macros for setting a place for the duration of a scope
Common Lisp
4
star
33

dirt

A front-end for cl-soil which loads images straight to cepl:c-arrays and cepl:textures
Common Lisp
4
star
34

temporal-functions

Rewrite of the temporal function code from cepl.
Common Lisp
4
star
35

gl-to-sexp

GLSL Spec as a machine readable s-expression (and json)
Common Lisp
3
star
36

bomber-chap

entry 0 for lisp game jam 2018
Common Lisp
3
star
37

cepl.tests

Tests for CEPL
Common Lisp
3
star
38

cepl.sdl2-image

Two helper methods for using sdl2-image to load image data into CEPL types
Common Lisp
3
star
39

Indy

Thread safe compare and swap
Common Lisp
3
star
40

cbaggers.github.com

HTML
3
star
41

completable-types

Just some messing around with a convenience macro for classes
Common Lisp
2
star
42

grovel-locally

Grovel using cffi and cache the result locally to the system
Common Lisp
2
star
43

structy-defclass

Make classes like structs
Common Lisp
2
star
44

lbol-macros

macro code from little bits of lisp episode
Common Lisp
2
star
45

play-with-fond

Messing around with cl-fond and CEPL
Common Lisp
2
star
46

raw-bindings-nuklear

Moot - Please use bodge-nuklear instead
Python
2
star
47

cepl.spaces

Provides a vector-space type for both CPU & GPU coding
Common Lisp
2
star
48

checkmate

nothing yet
Common Lisp
2
star
49

lark

Test for some cepl stuff
Common Lisp
2
star
50

cl-fuse

Work hackathon project
Common Lisp
2
star
51

cepl.glop

glop host for cepl
Common Lisp
2
star
52

injectables

Like global variables...only worse
Common Lisp
2
star
53

FuseAndroidNFCExample

Example showing how to hook up NFC in android with Fuse
Uno
1
star
54

walg

Learning about the W-Algorithm from a fantastic python example
Common Lisp
1
star
55

LocalNotify

Uno
1
star
56

orb

gamejam entry 1
Common Lisp
1
star
57

talks

Common Lisp
1
star
58

spring-lisp-gamejam

this will be an entry eventually
Common Lisp
1
star
59

tutnotes

miscs notes that may end up in things
1
star
60

cepl.camera

A camera implementation that plays well with cepl
Common Lisp
1
star
61

cepl.skitter

Plumbing to use skitter.sdl2 with cepl
Common Lisp
1
star
62

multi-stopwatch

simplifying the stopwatch example and supporting multiple stopwatches
JavaScript
1
star
63

cl-ode-lower-levels

Low level bindings for cl-ode - Based on the excellent cl-ode package by Brad Beer
Common Lisp
1
star
64

eccles

CLOS game objects for CEPL
Common Lisp
1
star
65

TeachChrisFuseStream

The code from the stream
JavaScript
1
star
66

hi-charts

hello-charts fuse hackathon entry
Uno
1
star
67

classimp-fallback-libs

Fallback libraries for classimp
Common Lisp
1
star
68

issac

Lispy bindings over the Newton Dynamics physics library
Common Lisp
1
star
69

swank.live

Some helpers for swank in the area of live coding
Common Lisp
1
star
70

dendrite

Master package to load all dendrite packages
Common Lisp
1
star
71

cepl.diatom

Uses the cells library to propogate cepl events
1
star
72

box2c

Automatically exported from code.google.com/p/box2c
C#
1
star
73

cl-nuklear

CL api for the nuklear ui library
1
star
74

pathology

Another dive into the madness that is filepaths
Common Lisp
1
star
75

with-cached-reader-conditionals

Call a function can return the result and also any features expressions that were read inside the funcall
Common Lisp
1
star
76

defstruct-plus-methods

So for some reason you want to define a struct which also has method accessor for some slots. We have a macro for that
Common Lisp
1
star
77

tiny-path

farting around with paths again, not for human consumption
Common Lisp
1
star
78

cparse

Tim Moores old cparse library
Common Lisp
1
star