svga: check that we don't exceed input/ouput register limits

This commit is contained in:
Brian Paul 2011-07-19 14:52:54 -06:00
parent 2f40e4aac7
commit 49a6f5e68e
3 changed files with 13 additions and 2 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}