Skip to content

ShaderState

Steven Johnson edited this page Mar 2, 2022 · 3 revisions

(This is not exactly an ideal name for this object, but I don't know what might be better.)

Certain choices suggested in the kernel extensions imply a need to interact with the resulting shader(s). These suggest a master object that could be retrieved like so:

local state = graphics.getShaderState("filter.custom.my_shader")

and return nil or simply be useless if the shader in question specified no relevant settings. (Then again, there are operations like getting the full or kernel sources that would still be useful.)

For uniform arrays, some options might be:

state:SetUniform(index, { --[[ blah, blah ]] }) -- perhaps vector and matrix variants

and maybe some range- and byte-based variants.

Something like local n = state:GetUniformsCount() makes sense too.

The isReleasable flag naturally suggests a state:Release(). This would only prevent new accesses to the shader and state, leaving in place any current uses.

A way to change the uniforms within the hierarchy might be useful, with one possibility being to add little command objects where appropriate, say ones made by local setter = state:newUniformsSetter(). This idea might need some iteration, yet.

UPDATE: This has all been implemented, albeit in different ways.