[Mesa-dev] [PATCH] i965: Fix INTEL_DEBUG=vs for fixed-function/ARB programs.

Ian Romanick idr at freedesktop.org
Fri Feb 7 01:07:16 CET 2014


On 02/03/2014 11:15 AM, Kenneth Graunke wrote:
> Since commit 9cee3ff562f3e4b51bfd30338fd1ba7716ac5737, INTEL_DEBUG=vs
> has caused a NULL pointer dereference for fixed-function/ARB programs.
> 
> In the vec4 generators, "prog" is a gl_program, and "shader_prog" is the
> gl_shader_program.  This is different than the FS visitor.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

I love the chech a pointer for non-NULL, then dereference a different
pointer antipattern.  Lol.

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

> ---
>  src/mesa/drivers/dri/i965/brw_vec4_generator.cpp  | 4 ++--
>  src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
> index 94d1e79..e5ed2c2 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
> @@ -1255,7 +1255,7 @@ vec4_generator::generate_code(exec_list *instructions)
>     const void *last_annotation_ir = NULL;
>  
>     if (unlikely(debug_flag)) {
> -      if (prog) {
> +      if (shader_prog) {
>           printf("Native code for vertex shader %d:\n", shader_prog->Name);
>        } else {
>           printf("Native code for vertex program %d:\n", prog->Id);
> @@ -1271,7 +1271,7 @@ vec4_generator::generate_code(exec_list *instructions)
>  	    last_annotation_ir = inst->ir;
>  	    if (last_annotation_ir) {
>  	       printf("   ");
> -               if (prog) {
> +               if (shader_prog) {
>                    ((ir_instruction *) last_annotation_ir)->print();
>                 } else {
>                    const prog_instruction *vpi;
> diff --git a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
> index 5a34858..03ed05a 100644
> --- a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp
> @@ -782,7 +782,7 @@ gen8_vec4_generator::generate_code(exec_list *instructions)
>     const void *last_annotation_ir = NULL;
>  
>     if (unlikely(debug_flag)) {
> -      if (prog) {
> +      if (shader_prog) {
>           printf("Native code for vertex shader %d:\n", shader_prog->Name);
>        } else {
>           printf("Native code for vertex program %d:\n", prog->Id);
> @@ -798,7 +798,7 @@ gen8_vec4_generator::generate_code(exec_list *instructions)
>              last_annotation_ir = ir->ir;
>              if (last_annotation_ir) {
>                 printf("   ");
> -               if (prog) {
> +               if (shader_prog) {
>                    ((ir_instruction *) last_annotation_ir)->print();
>                 } else {
>                    const prog_instruction *vpi;
> 



More information about the mesa-dev mailing list