From: Brian Paul Date: Tue, 19 Jul 2011 20:52:54 +0000 (-0600) Subject: svga: check that we don't exceed input/ouput register limits X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=49a6f5e68eeb6b23bb040cfc1f93befc2f1eb35a;p=mesa.git svga: check that we don't exceed input/ouput register limits --- diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 8a50bfd344a..5b96750bbf1 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -76,7 +76,7 @@ static enum pipe_error compile_fs( struct svga_context *svga, result = svga_translate_fragment_program( fs, key ); if (result == NULL) { - ret = PIPE_ERROR_OUT_OF_MEMORY; + ret = PIPE_ERROR; /* some problem during translation */ goto fail; } diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c index 6f162ea7e33..6f408704863 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c @@ -124,6 +124,9 @@ ps30_input_emit_depth_fog( struct svga_shader_emitter *emit, return TRUE; } + if (emit->ps30_input_count >= SVGA3D_INPUTREG_MAX) + return FALSE; + reg = src_register( SVGA3DREG_INPUT, emit->ps30_input_count++ ); @@ -195,6 +198,9 @@ static boolean ps30_input( struct svga_shader_emitter *emit, if (!translate_vs_ps_semantic( semantic, &usage, &index )) return FALSE; + if (emit->ps30_input_count >= SVGA3D_INPUTREG_MAX) + return FALSE; + reg = dst_register( SVGA3DREG_INPUT, emit->ps30_input_count++ ); if (!emit_decl( emit, reg, usage, index )) @@ -231,6 +237,9 @@ static boolean ps30_input( struct svga_shader_emitter *emit, if (!translate_vs_ps_semantic( semantic, &usage, &index )) return FALSE; + if (emit->ps30_input_count >= SVGA3D_INPUTREG_MAX) + return FALSE; + emit->input_map[idx] = src_register( SVGA3DREG_INPUT, emit->ps30_input_count++ ); reg = dst( emit->input_map[idx] ); @@ -392,6 +401,9 @@ static boolean vs30_output( struct svga_shader_emitter *emit, if (!translate_vs_ps_semantic( semantic, &usage, &index )) return FALSE; + if (emit->vs30_output_count >= SVGA3D_OUTPUTREG_MAX) + return FALSE; + dcl.dst = dst_register( SVGA3DREG_OUTPUT, emit->vs30_output_count++ ); dcl.usage = usage; dcl.index = index; diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c index 6f03e61db55..05531a15eb5 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -3184,7 +3184,6 @@ boolean svga_shader_emit_instructions( struct svga_shader_emitter *emit, goto done; done: - assert(ret); tgsi_parse_free( &parse ); return ret; }