[Mesa-dev] [PATCH 4/6] glsl: When we've emitted a semantic error for ==, return a bool constant.

Ian Romanick idr at freedesktop.org
Tue Apr 12 10:57:12 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/12/2011 09:40 AM, Eric Anholt wrote:
> On Mon, 11 Apr 2011 15:51:55 -0700, Ian Romanick <idr at freedesktop.org> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 04/09/2011 10:17 PM, Eric Anholt wrote:
>>> This prevents later errors (including an assertion failure) from
>>> cascading the failure.
>>>
>>> Fixes invalid-equality-04.vert.
>>> ---
>>>  src/glsl/ast_to_hir.cpp |   10 +++++++---
>>>  1 files changed, 7 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>>> index 108c7c3..ea20eba 100644
>>> --- a/src/glsl/ast_to_hir.cpp
>>> +++ b/src/glsl/ast_to_hir.cpp
>>> @@ -1073,10 +1073,14 @@ ast_expression::hir(exec_list *instructions,
>>>  	 error_emitted = true;
>>>        }
>>>  
>>> -      result = do_comparison(ctx, operations[this->oper], op[0], op[1]);
>>> -      type = glsl_type::bool_type;
>>> +      if (error_emitted) {
>>> +	 result = new(ctx) ir_constant(false);
>>> +      } else {
>>> +	 result = do_comparison(ctx, operations[this->oper], op[0], op[1]);
>>> +	 assert(result->type == glsl_type::bool_type);
>>> +	 type = glsl_type::bool_type;
>>> +      }
>>
>> Doesn't this leave type unset in the 'if (error_emitted)' case?
> 
> Hmm, so we get the 'type mismatch' in addition to the error message.  In
> every case it looks to me like type should be set to result->type after
> the giant switch().  Can we just kill it?

I think so.  I think we can also get rid of error_emitted and just use
state->error.  It's probably worth slitting that into two patches to be
safe.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2kkngACgkQX1gOwKyEAw+BRgCfWIIOpfWWv+uzQHtx7n0upDEh
ka0AoJG0cgL1ldEbu0UXI66vgx9/MBAX
=qxGC
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list