[Mesa-dev] [PATCH] i965: Add var->location != -1 assertions.

Ian Romanick idr at freedesktop.org
Wed Dec 3 15:05:48 PST 2014


Now that my patches that fix the problem have landed,

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 12/01/2014 01:44 PM, Kenneth Graunke wrote:
> We shouldn't receive variables with invalid locations set - adding these
> assertions should help catch problems before they cause crashes later.
> 
> Inspired by similar code in st_glsl_to_tgsi.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 1 +
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index 0b62496..34907e3 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -57,6 +57,7 @@ fs_visitor::visit(ir_variable *ir)
>        return;
>  
>     if (ir->data.mode == ir_var_shader_in) {
> +      assert(ir->data.location != -1);
>        if (!strcmp(ir->name, "gl_FragCoord")) {
>  	 reg = emit_fragcoord_interpolation(ir);
>        } else if (!strcmp(ir->name, "gl_FrontFacing")) {
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index c1c24ac..ffd97f1 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -1020,10 +1020,12 @@ vec4_visitor::visit(ir_variable *ir)
>  
>     switch (ir->data.mode) {
>     case ir_var_shader_in:
> +      assert(ir->data.location != -1);
>        reg = new(mem_ctx) dst_reg(ATTR, ir->data.location);
>        break;
>  
>     case ir_var_shader_out:
> +      assert(ir->data.location != -1);
>        reg = new(mem_ctx) dst_reg(this, ir->type);
>  
>        for (int i = 0; i < type_size(ir->type); i++) {
> 



More information about the mesa-dev mailing list