[Mesa-dev] [PATCH 4/6] glsl: Avoid GLboolean vs bool arithmetic MSVC warnings.

Ian Romanick idr at freedesktop.org
Wed Mar 18 11:58:14 PDT 2015


On 03/18/2015 09:34 AM, Jose Fonseca wrote:
> Note that GLboolean is an alias for unsigned char, which lacks the
> implicit true/false semantics that C++/C99 bool have.
> ---
>  src/glsl/linker.cpp | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 0c44677..1abcb32 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -2536,14 +2536,15 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
>        min_version = MIN2(min_version, prog->Shaders[i]->Version);
>        max_version = MAX2(max_version, prog->Shaders[i]->Version);
>  
> -      if (prog->Shaders[i]->IsES != is_es_prog) {
> +      if (bool(prog->Shaders[i]->IsES) != is_es_prog) {

I think it would be better to change gl_shader::IsES and
gl_shader_program::IsES to be bool.  A quick 'git grep IsES' leads me to
believe that is safe.

>  	 linker_error(prog, "all shaders must use same shading "
>  		      "language version\n");
>  	 goto done;
>        }
>  
> -      prog->ARB_fragment_coord_conventions_enable |=
> -         prog->Shaders[i]->ARB_fragment_coord_conventions_enable;
> +      if (prog->Shaders[i]->ARB_fragment_coord_conventions_enable) {
> +         prog->ARB_fragment_coord_conventions_enable = true;
> +      }
>  
>        gl_shader_stage shader_type = prog->Shaders[i]->Stage;
>        shader_list[shader_type][num_shaders[shader_type]] = prog->Shaders[i];
> 



More information about the mesa-dev mailing list