CEPL (Code Evaluate Play Loop) - [Beta]
CEPL is a lispy and REPL-friendly Common Lisp library for working with OpenGL.
Its definition of success is making the user feel that GPU programming has always been part of the languages standard.
The usual approach to using CEPL is to start it at the beginning of your Lisp session and leave it open for the duration of your work. You can then treat the window it creates as just another output for your graphics, analogous to how
*standard-output* is treated for text.
CEPL is in beta. The API is close to what it needs to be but there are still many bugs to fix, features to add, and experiences to smooth out.
See the cepl.examples repository for some examples of how CEPL can be used
(ql:quickload :cepl) at your REPL.
Whilst it is recommended to get CEPL 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 CEPL release.
Currently we have full documentation of every exported symbol in the CEPL package. You can find this here: CEPL API Docs
Guides will be provided in future, however these take much longer to write.
I can also be reached by my email (techsnuffle [at] gmail ? com) and sometimes on #lispgames IRC. Come to #lispgames anyway though, there are some lovely folks, all lispy dialects welcome!
All of the following will be downloaded automatically by quicklisp
C Library dependency
CEPL uses OpenGL ( version >= 3.1 ) so you need to make sure it is available on your machine. Installing your GPU drivers will usually handle this.
CEPL abstracts working with OpenGL but is not responsible for creating a window or GL context; this is handled by a
Host. Right now the only supported host is
SDL2; the system to load is called
cepl.sdl2, you can find it here: cepl.sdl2
slime users will need to read
docs/single-thread-swank.md to deal with a complication specific to projects interacting with the window manager. You can then follow the rest of this guide as usual.
To load CEPL and the default host (
sdl2) do the following:
You should see an empty window appear, OpenGL is now initialized, and you can use CEPL as you like.
Making a CEPL Project
The best way to get started is to make a new project that uses CEPL. Do the following in your REPL to get set up:
- First, run
- Then run
(ql:quickload :quickproject). CEPL uses this to create a lisp project using its own templates
- Then run
(cepl:make-project "my-proj"). This will use quickproject to make a new project with all the correct dependencies. Remember that cepl does not handle window managers or input so by default your new project will use the following
- cepl for the graphics
- cepl.sdl2 for the host
- skitter for handling input and events
- dirt for loading images There are many good event systems & image loaders out there so browse around. But here are two :)
You are now ready to get started. Simply run: -
(ql:quickload "my-proj") -
(in-package :my-proj) - and finally (if you havent already)
Windows C Library Hack
If you are having issues getting the C libraries to load and just need to rule out whether Lisp can find them, try putting them in the same folder as the lisp exe. For example
This mainly covers features & news rather than individual bugfixes. When we are out of beta these will be covered more often
- Return from work crunch to add anisotropy support to samplers :)
- Added support for MultiDrawIndirect using
- Added support for base-vertex in buffer-streams
wait-on-gpu-fencenow expects an
nilis used to indicate no timeout and anything else is the timeout in nanoseconds
copy-gas an more general alternative to
pull-gfor moving data.
- exported the many typed functions
pull-guse behind the scenes for transfers
- fixed serious bug in clear which, when passed no fbo, would try to clear both the read & draw fbo attachments. Now only clears draw as per the gl spec.
make-texturecan now take
gpu-arrays as the 'initial-contents' argument.
- transfers between buffer & texture backed gpu arrays now work
- c-arrays & gpu-arrays now accept a row-alignment value on creation. This defaults to 1 but can be 1, 2, 4 or 8
- texture uploads/downloads now correctly take row alignment into account.
- Fixes to ensure mutable textures are 'complete' on creation
- fix issues when creating c-arrays from lisp arrays that stemed from specification of dimensions being (x-size y-size) in CEPL/GL and (column-size row-size) in lisp.
make-gpu-arrays-from-buffer-idwhich lets you speicify a gl buffer-id and layouts of the data and get a CEPL gpu-buffer in return
make-gpu-array-from-buffer-idwhich in shorthand for the above when you only need one gpu-array.
- added option to
make-gpu-buffer-from-idso you can pass layouts instead of initial-contents. This is handy when you allocate and layout out the buffer storage without providing new data.
- add a
keep-dataargument, to a bunch of buffer related functions which take layouts. This lets you create the buffer object, specifying the content layout without replacing the data.
make-buffer-stream-from-id-and-layouts. Makes it possible to make streams out of vaos without having gpu-arrays.
- print-object for
- misc bug fixes
The most important change this release is that lambda pipelines now recompile when the functions they use as stages are recompiled. This change comes with a performance cost of course so if you wish to opt out of this (recommended for when you ship your project) then pass
:static in the context argument to
Also if you are using GL>=4.3 you can now create empty fbos, which are handy if you want to use the fragment stage without writing data to bound textures (compute-type fun to be had here)
Other important changes:
viewport-resolution-yhad been documented as returning
single-floats but were returning unsigned ints, this now fixed.
- I'm an idiot that didn't know about
~/.swank.lisp, please see the new 'single-thread-swank' advice above if running on macOS.
Due to the changes listed below you will now want to change your current asd's to require :rtg-math.vari and to change your packages to :use :rtg-math.
Some folks were asking for the ability to use their own math libraries rather than rtg-math which CEPL has depended on up until now. I have made this change but this means that this is something users will have to add themselves from now on.
For those picking a library cepl expects vectors & matrices to be sized simple-arrays of single-floats e.g.
(make-array 3 :element-type 'single-float) for 3 component vectors.
We have also removed the dependency on fn & cl-fad.
Other Changes: - added the remove-surface function - closing primary window no longer quits cepl - removed interactive from lifecycle events (will add surface lifecycle events in future release)
*I am terrible at changelogs. I am retroactively making the updates for everything between june 2017 and jan 2018
- Added support for using gpu-lambdas inline in
- Lots of work on the
cepl.testsproject resulting in fixes for:
- struct uniforms
- uniform baking
- Add render-buffer support
- Fix struct layout bugs. SSBOS work correctly now
- Add funcall-g (limited support for calling gpu-functions from cpu directly)
- Remove the deprecated
- Add compute support
- Add SSBO support (though currently hobbled by struct layout bug)
- Add single stage pipeline support
- Add transform feedback support
- Add shared context support
- Add gpu-fence support
- Add gl query support
- Complete rewrite of pipeline state cache (now faster and safer)
- Avoid recompilation of pipelines where dependencies have not changed
- Rewrite struct code to get away from some dependencies
- Multiple (non-shared) context support
- Add border-color support
- Mostly bugfixes
- Add instance array support (per instance data in pipelines)
- Add stencil support
- Add scissor support
- Add color-mask support
- Add multisample support
- renaming macros with confusing/inconsistent naming
- blending param caching on context (not optimized yet)
- Make #'free work with pipelines
You can now modify a buffer-stream's primitive type after creation
- Huge improvements to per-frame performance through:
- typing of functions & inlining where it made sense
- fixing bug where uniforms ids queried too often
- macros to reduce frequency of fetching the context object
- much better state caching in context object
- avoiding cffi enum conversion when lookup functions are faster
- precompute & cache more size info in wrapper types
- attachments have their own viewports, no more computing of viewport during draw
- dont set viewport on every map-g (this was unnecessary)
- remove some of the 'with-*' macros whos contract forced us to do more state changes/caching that we would otherwise like.
- pipelines can be declared static. This tells cepl to type the generated functions.
a huge pile of other small changes
pipelines can take
:dynamicas their draw mode. This means they will take the draw-mode from the
buffer-streamthey are mapped over. This only works for pipelines with
buffer-streams now hold the primitive type of their data. Defaults to
Fix bug that was stopping g-structs contain matrices
Cache more values in
buffer-streamto save time during rendering
adjust-gpu-array(pretty basic right now)
cepl.spaces, It is now a seperate project (and will be in quicklisp in the next cycle)
cepl.misc. If you were using the
draw-texturefunction then please consider
Nineveh(which will be in quicklisp in the next cycle)
cl-soilwhich ships with binaries for multiple paltforms so has a better 'out of the box' experience (plus also supports more formats)
I missed some logs here so this is a recap of everything since 2017-02-19
Geometry & Tessellation fully supported (including for inline glsl stages)
Draw mode can now be specified for pipelines
fixes for pull-g with gpu-functions & pipelines
with-gpu-array-range-as-c-array. These still feel experimental to me.
buffer-streams always hold on to their gpu-arrays by default
Refactoring based on changes in Varjo
Added bordeux-threads as a dependency. Will be needed for some context related things
Very basic support for multiple surfaces (windows)
New 'host' api. Is versioned so old hosts are still supported
run-session. All of these attempts at thread hackery felt bad. I'm sticking with
slime-styleuntil we have a better fix
- Removed the
continuablemacro. The macro can be found in the
- Chris Bagley (Baggers) <email@example.com>, Chris Bagley <firstname.lastname@example.org>
- BSD 2 Clause