Heavy use of dump_ctx hurts code clarity surrounding shader conversion
On the larger theme of simplifying the shader tgsi to glsl conversion process, I'm finding that heavy use of struct dump_ctx
as the only argument in many of the vrend_shader.c functions leads to uncertainty about when struct dump_ctx
is used for read, write, or read/write.
This ambiguity makes it difficult to inspect the vrend_convert_shader()
process and subsequent caching for the purposes of performance optimization and resolution of shader stage inter-dependencies.
The first pass towards improving clarity and conveying intent is to make struct dump_ctx
function args as const
when it's members are strictly accessed (read), and replacing struct dump_ctx
with only the members that are used within each function (such as ctx->glsl_main
in various emit_*()
calls. Propagating the intent from low-level functions upward, it will become easier to see where dump_ctx
state is modified, where changes to vrend_context
state affect shader conversion (and prompt new variant creation), and ultimately identify areas where the conversion process can be enhanced for performance and simplified.
I'll follow up shortly with this first patch, which will be a strict refactoring of vrend_shader{.c,.h}