[Mesa-dev] [RFC PATCH 23/40] i965/fs: Associate the uniform location for the fragment shader
Kenneth Graunke
kenneth at whitecape.org
Sun Jan 4 22:39:10 PST 2015
On Sunday, January 04, 2015 04:04:37 PM Abdiel Janulgue wrote:
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_fs.cpp | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 3639ed2..0f2c2c4 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1144,6 +1144,7 @@ fs_visitor::setup_uniform_values(ir_variable *ir)
> continue;
> }
>
> + brw->uniformstagemap[u] |= _NEW_FRAGMENT_CONSTANTS;
> unsigned slots = storage->type->component_slots();
> if (storage->array_elements)
> slots *= storage->array_elements;
>
You can't just put a giant array in brw_context and index it by uniform
numbers like this. Every shader program has its own set of uniforms.
Let's say I use two shader programs:
Program A is:
[vertex shader]
uniform mat4 mvp;
void main() { gl_Position = mvp * gl_Vertex; }
[fragment shader]
void main() { gl_FragColor = vec4(1.0); }
Program B is:
[vertex shader]
void main() { gl_Position = gl_Vertex; }
[fragment shader]
uniform vec4 color;
void main() { gl_FragColor = color; }
In program A, "mvp" will be uniform 0. In program B, "color" will be
uniform 0. Your single global map will contain:
brw->uniformstagemap[0] == _NEW_VERTEX_CONSTANTS | _NEW_FRAGMENT_CONSTANTS
which is wrong - each program has distinct uniforms that are each only used
in a single stage.
I think the approach I recommended in my reply to patch 19 should solve this
without the need for the global table.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150104/f8af8a38/attachment.sig>
More information about the mesa-dev
mailing list