On Fri, Apr 3, 2015 at 10:04 AM, Jason Ekstrand <ja...@jlekstrand.net> wrote:
> On Fri, Apr 3, 2015 at 9:46 AM, Matt Turner <matts...@gmail.com> wrote:
>> On Fri, Apr 3, 2015 at 1:07 AM, Jordan Justen <jordan.l.jus...@intel.com> 
>> wrote:
>>> On 2015-04-02 20:56:15, Jason Ekstrand wrote:
>>>> ---
>>>>  src/mesa/drivers/dri/i965/brw_context.c | 10 +++++++++-
>>>>  src/mesa/drivers/dri/i965/brw_fs.cpp    |  4 ++--
>>>>  src/mesa/drivers/dri/i965/brw_vec4.cpp  |  4 +++-
>>>>  3 files changed, 14 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
>>>> b/src/mesa/drivers/dri/i965/brw_context.c
>>>> index 84818f0..f0de711 100644
>>>> --- a/src/mesa/drivers/dri/i965/brw_context.c
>>>> +++ b/src/mesa/drivers/dri/i965/brw_context.c
>>>> @@ -560,6 +560,12 @@ brw_initialize_context_constants(struct brw_context 
>>>> *brw)
>>>>        .lower_ffma = true,
>>>>     };
>>>>
>>>> +   bool use_nir_default[MESA_SHADER_STAGES];
>>>> +   use_nir_default[MESA_SHADER_VERTEX] = false;
>>>> +   use_nir_default[MESA_SHADER_GEOMETRY] = false;
>>>> +   use_nir_default[MESA_SHADER_FRAGMENT] = false;
>>>> +   use_nir_default[MESA_SHADER_COMPUTE] = false;
>>>
>>> How about memset to 0 for now to make sure all stages are set? We can
>>> add use_nir_default[MESA_SHADER_FOO] = true; after the memset to
>>> update the default for the shader stage.
>
> Sure, we could do that.  I'm not sure if it really saves us anything.
> I guess it would make sure that we initialize everything.
>
>> Isn't this sufficient?
>>
>> bool use_nir_default[MESA_SHADER_STAGES] = {false};
>
> Yes, that would accomplish the memset in less code.
>
>> and use C99 designated initializers when we want to change the default
>> per-stage.
>
> No, we can't do this.  When we flip the switch, we're going to have
>
>> use_nir_default[MESA_SHADER_VERTEX] = brw->gen >= 8;
>
> and you can only use compile-time constants in initializers.

I was cleaning out old mail and came across this. It's irrelevant now,
especially since this patch landed long ago and has since been
deleted, but it's totally okay to have non-constant initializers in
initializer lists -- you can even initialize with function calls:

struct brw_context {
        int gen;
};

struct s {
        int bool;
};

int gencheck(struct brw_context *brw) {
        return brw->gen >= 8;
}

struct s foo(struct brw_context *brw)
{
        struct s s = { .bool = gencheck(brw) };
        return s;
}

I suspect what you were thinking about was initializer lists for
things that are themselves compile-time constants. Of course you can't
initialize them with non-constants, but that has nothing to do with
initializer lists.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to