Now that the declaration function is out of the way, the tracing pass,
which is very long and 100% the same can be shared between pixel and
vertex shaders.
The new function is called shader_trace_init(), and is responsible for:
- tracing the shader
- initializing the function length
- setting the shader version [needed very early]
The new function is called in pass 2 (getister counting/maps), and
it's now in baseshader. It operates on all INPUT and OUTPUT registers,
which, in addition to the old vertex shader input declarations covers
Shader Model 3.0 vshader output and pshader input declarations. The
result is stored into the reg_map structure.
Delete the entire namedArrays code path and all its dependencies (one
of which is quite long - storeOrder in drawprim is always FALSE, for
example). Delete declaredArrays, and make its code path the default.
I missed a register mask in the move to share the shader_hw_def()
function between pixel and vertex shaders for ARB shaders. Fixed
that, and made the GLSL version use the same mask for consistency.
- Based on comments from H. Verbeet
- Changed the distinction from .rgba & .xyzw masks to only use .xyzw
in GLSL shaders. They are interchangeable, and only served to make
the trace look more intuitive, but they don't always apply as-is, so
we'll just leave everything to .xyzw.
- Got rid of the "UseProgramObjectARB(0)" call in drawprim. If there
is no shader set on the next primitive, then that primitive will
call UseProgramObjectARB(0) when it begins to draw.
- Add functions to attach & detach shader objects, create and delete programs, and maintain the list of programs.
- Add a list of GLSL shader programs to the device which is initialized on Init3D(), and deleted on Release().
- Declare more variable names for GLSL programs.
- Some of these won't need to be declared eventually, but it doesn't hurt to do it for now.
- Correct output name for pixel shaders (gl_FragColor instead of glFragColor).
- Add a new file glsl_shader.c which contains almost every GLSL specific function we'll need
- Move print_glsl_info() into glsl_shader.c
- Move the shader_reg_maps struct info into the private header, and make it part of SHADER_OPCODE_ARG.
- Create a new shared ps/vs register map for float constants (future patch will make ARB programs use this, too)
loading float constants for GLSL.
- DrawPrim is just too big of a function. This separates the passing
of constants to the shader into new functions.
- Fixes an off-by-one error when loading vertex declaration constants
(should be <, not <=)
- Adds a function for GLSL loading of constants (aka Uniforms)
- Adds a GLSL program variable to the stateblock and sets it to 0 (a
future patch will actually create this program)
It is wrong to maintain a mapping from a constant index to a type
field, because different constant types do not share an index -
boolean constant 0 is supposed to co-exist with floating point
constant 0, not replace it. Drawprim and other code using the type
array to decide whether to look up a constant in bools, floats, or
ints is wrong - you can't make that decision based on the index.