[Mesa-dev] [PATCH 12/24] i965: Initialize registers' file to BAD_FILE.

Matt Turner mattst88 at gmail.com
Wed Nov 11 13:07:24 PST 2015


On Wed, Nov 11, 2015 at 12:46 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On Monday, November 02, 2015 04:29:22 PM Matt Turner wrote:
>> The test (file == BAD_FILE) works on registers for which the constructor
>> has not run because BAD_FILE is zero.  The next commit will move
>> BAD_FILE in the enum so that it's no longer zero.
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp     | 10 +++++++++-
>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  3 +++
>>  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp   |  9 +++++++++
>>  3 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> index 7eeff93..611347c 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> @@ -260,6 +260,10 @@ void
>>  fs_visitor::nir_emit_system_values()
>>  {
>>     nir_system_values = ralloc_array(mem_ctx, fs_reg, SYSTEM_VALUE_MAX);
>> +   for (unsigned i = 0; i < SYSTEM_VALUE_MAX; i++) {
>> +      nir_system_values[i].file = BAD_FILE;
>
> How about we do this instead:
>
>    nir_system_values[i] = fs_reg();
>
> That way, they're properly constructed using the default constructor,
> which would not only set BAD_FILE, but properly initialize everything,
> so we don't have to revisit this if we make other changes in fs_reg().

Is it worth is? The function this code exists in is the thing that
initializes the system values. And, of course if file == BAD_FILE, no
other fields mean anything. Neither of those are likely to change.

> Similarly below.
>
> That patch would get a:
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list