[Mesa-dev] [PATCH 10/12] nir: Store num_direct_uniforms in the nir_shader.
Jason Ekstrand
jason at jlekstrand.net
Thu Apr 9 11:56:09 PDT 2015
On Wed, Apr 8, 2015 at 12:48 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 04/08/2015 12:06 AM, Kenneth Graunke wrote:
>> Storing this here is pretty sketchy - I don't know if any driver other
>> than i965 will want to use it. But this will make it a lot easier to
>> generate NIR code at link time. We'll probably rework it anyway.
>>
>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>> ---
>> src/glsl/nir/nir.h | 3 +++
>> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 5 +++--
>> 2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> index e844e4d..7d11996 100644
>> --- a/src/glsl/nir/nir.h
>> +++ b/src/glsl/nir/nir.h
>> @@ -1429,6 +1429,9 @@ typedef struct nir_shader {
>> * access plus one
>> */
>> unsigned num_inputs, num_uniforms, num_outputs;
>> +
>> + /** the number of uniforms that are only accessed directly */
>> + unsigned num_direct_uniforms;
>> } nir_shader;
>>
>> #define nir_foreach_overload(shader, overload) \
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> index 145a447..034b79a 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> @@ -120,7 +120,7 @@ fs_visitor::emit_nir_code()
>>
>> if (shader_prog) {
>> nir_assign_var_locations_scalar_direct_first(nir, &nir->uniforms,
>> - &num_direct_uniforms,
>> + &nir->num_direct_uniforms,
>> &nir->num_uniforms);
>
> Why not just have nir_assign_var_locations_scalar_direct_first modify
> the nir_shader passed in? That seems more concise.
We could, but I'm not a huge fan of storing it in the nir_shader to
begin with. As I said in my review, it's a hack I'm willing to go
with for now. However, since we made variable location assignment
separate from lowering, they are no longer a universal thing. We
could also potentially have backend-specific assignment passes and I
really don't want to set a precedent of storing this data in
nir_shader. I'm hoping (maybe foolishly) that we'll come up with a
better place to store them soon.
--Jason
>> } else {
>> /* ARB programs generally create a giant array of "uniform" data, and allow
>> @@ -128,7 +128,7 @@ fs_visitor::emit_nir_code()
>> * analysis, it's all or nothing. num_direct_uniforms is only useful when
>> * we have some direct and some indirect access; it doesn't matter here.
>> */
>> - num_direct_uniforms = 0;
>> + nir->num_direct_uniforms = 0;
>> }
>> nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs);
>> nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs);
>> @@ -343,6 +343,7 @@ void
>> fs_visitor::nir_setup_uniforms(nir_shader *shader)
>> {
>> uniforms = shader->num_uniforms;
>> + num_direct_uniforms = shader->num_direct_uniforms;
>>
>> /* We split the uniform register file in half. The first half is
>> * entirely direct uniforms. The second half is indirect.
>>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list