v0.11.3
Uniform arrays, pixel-upload textures, and render targets that work in the browser
Shaders can now declare uniform arrays and be handed a whole palette at once, CPU-side pixels can become a texture and be refilled every frame, and offscreen render targets draw on the web build for the first time. Together these are what a GPU cellular automaton needs: test/test-shader-limits runs a Game of Life entirely on the GPU by ping-pong between two render targets, natively and in the browser, and its verifier compares every cell of the presented frame against a CPU model on both.
Changes
- Fragment shaders may declare
uniform vec4 name[N];(float, vec2, vec3, vec4 and mat4, a literal N, whitespace anywhere, an optional precision qualifier). The uniform block grew from 256 bytes to 512; the 16-declaration cap is sokol's and stays. set-shader-uniformaccepts a list or a vector, flat or nested per element, for any uniform; the float count must match the declaration exactly and a mismatch names both counts.make-texture-from-pixels width height bytes [filter]andupdate-texture tex bytes: RGBA8 bytevectors, top row first, size-checked. One upload per texture per frame, refused with an error on every build rather than left to sokol's debug-only validation; creating the texture is that frame's upload.make-render-targetandmake-texture-from-pixelstake an optional'nearestor'linearsampler filter (linear, the previous behaviour, is the default).load-shader vert frag [blend]bakes'normal(default),'additiveor'noneblending into the shader's pipeline. A simulation step that stores data in the alpha channel needs'none.- Inside
with-render-target, the auto-uniformu_resolutionis the target's size rather than the window's. Consumers whose targets are the virtual viewport size (cinder-cadence's bloom) see the same numbers as before. - Render targets work on the
webconfig. Before this release every offscreen pass there was refused: the depth attachment was created in the environment's default depth format, which the web environment declares as none, so the image failed and sokol dropped the pass, logging at a level the console does not flag. The attachment now exists only when the environment has a depth format. - A texture, render target or shader collected by the GC after
gfx-shutdownno longer trips sokol's_sg.validassert. - A GLSL compile or link error, a failed view or pipeline, and a uniform block past 16 declarations or 512 bytes are
load-shadererrors naming the cause. Before, a compile error aborted a dev build inside sokol's validation and a 17th declaration was dropped without a word. - A uniform array sized by a macro (
uniform vec4 x[N]) is no longer registered as a single element; declare the count as a literal. - A sokol image whose creation failed (a valid-looking id in FAILED state) is now an error at creation, not a texture that silently draws nothing.
Upgrade notes
Nothing is required of you: every v0.11.2 call keeps its signature. If a shader bound inside with-render-target used u_resolution as the window size on a target of a different size, it now receives the target's size.
The commit this tag names.