From: Neha Bhende Date: Wed, 27 May 2020 15:15:29 +0000 (+0530) Subject: util: Initialize pipe_shader_state for passthrough and transform shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=838666a41dcbbf566bff57e7a7b841e50bf2bdce;p=mesa.git util: Initialize pipe_shader_state for passthrough and transform shaders mesa/st is initializing pipe_shader_state for user define shaders. This patch intialized pipe_shader_state for all passthough and transform shaders. This fixes crashes for several opengl apps. Issue is found in vmware internal testing Fixes: f01c0565bb9 ("draw: free the NIR IR.") Reviewed-by: Charmaine Lee Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 0cd3307a1a5..a57ac48cd7a 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1688,7 +1688,7 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso) }; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; if (!tgsi_text_translate(fragment_shader_text, tokens, ARRAY_SIZE(tokens))) { assert(0); @@ -1725,7 +1725,7 @@ hud_set_draw_context(struct hud_context *hud, struct cso_context *cso) }; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; if (!tgsi_text_translate(vertex_shader_text, tokens, ARRAY_SIZE(tokens))) { assert(0); goto fail; diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 55ed7fc62b4..f3c58761e18 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -2133,7 +2133,7 @@ void *ureg_create_shader( struct ureg_program *ureg, struct pipe_context *pipe, const struct pipe_stream_output_info *so ) { - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; pipe_shader_state_from_tgsi(&state, ureg_finalize(ureg)); if(!state.tokens) diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 5faa8942be3..ceb59507901 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -145,7 +145,7 @@ void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe) "MOV OUT[2].x, SV[0].xxxx\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); @@ -189,7 +189,7 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe) "EMIT IMM[0].xxxx\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); @@ -458,7 +458,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; sprintf(text, shader_templ, write_all_cbufs ? "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" : "", @@ -551,7 +551,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe, const char *type = tgsi_texture_names[tgsi_tex]; char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA || tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA); @@ -669,7 +669,7 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe, const char *type = tgsi_texture_names[tgsi_tex]; char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state; + struct pipe_shader_state state = {0}; assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA || tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA); diff --git a/src/gallium/drivers/svga/svga_state_tgsi_transform.c b/src/gallium/drivers/svga/svga_state_tgsi_transform.c index 9d701b73772..1dcc05cfaf0 100644 --- a/src/gallium/drivers/svga/svga_state_tgsi_transform.c +++ b/src/gallium/drivers/svga/svga_state_tgsi_transform.c @@ -69,7 +69,7 @@ emulate_point_sprite(struct svga_context *svga, const struct tgsi_token *orig_tokens; struct svga_geometry_shader *orig_gs = (struct svga_geometry_shader *)shader; struct svga_geometry_shader *gs = NULL; - struct pipe_shader_state templ; + struct pipe_shader_state templ = {0}; struct svga_stream_output *streamout = NULL; int pos_out_index = -1; int aa_point_coord_index = -1;