[Mesa-dev] [PATCH 3/8] mesa: Pass number of samples as a program state variable
Ian Romanick
idr at freedesktop.org
Tue Oct 15 22:54:56 CEST 2013
On 10/15/2013 09:53 AM, Ian Romanick wrote:
> On 10/14/2013 10:12 AM, Anuj Phogat wrote:
>> @@ -852,6 +858,9 @@ append_token(char *dst, gl_state_index k)
>> case STATE_TEXENV_COLOR:
>> append(dst, "texenv");
>> break;
>> + case STATE_NUM_SAMPLES:
>> + append(dst, "num.samples");
>> + break;
>
> There is some really broken code in append_token and
> _mesa_program_state_string... and, of course, none of it is ever
> exercised. :(
>
> Here's how this works... In ARB_vertex_program and ARB_fragment_program
> (the ARB assembly shader extensions), there was a big structure-like
> thing called "state". This is where all of the built-in variables that
> represented things like gl_DepthRange.near or
> gl_ModelViewProjectionMatrix lived. They were accessed as
> state.depth.range (and the x, y, z, and w fields had the data) or
> state.matrix.modelview.
>
> The state[] tokens passed to _mesa_program_state_string represents a
> dereference of the assembly program state structure. Each element
> (usually) represents one level of the dereference. So, gl_DepthRange is
> state.depth.range is { STATE_DEPTH_RANGE, 0, 0 } and
> gl_ModelViewProjectionMatrix[1] is state.matrix.modelview[1] is {
> STATE_MVP_MATRIX, 1, 0 }.
>
> _mesa_program_state_string converts the list of tokens back into an
> assembly-style string. When it gets { STATE_DEPTH_RANGE, 0, 0 }, it
> should return "state.depth.range". When it gets { STATE_NUM_SAMPLES, 0,
> 0 }, it should return "state.numsamples" (or similar). Right now each
> of these queries returns... nothing.
>
> The "append(dst, ...)" should go in _mesa_program_state_string.
Ignore this. I missed the calls at the very top of
_mesa_program_state_string:
append(str, "state.");
append_token(str, state[0]);
Your code (other than maybe the name "num.samples") and the existing
depth.range code is correct as-is.
More information about the mesa-dev
mailing list