svga: check that we don't exceed input/ouput register limits
[mesa.git] / src / gallium / drivers / svga / svga_tgsi_decl_sm30.c
index 6f162ea7e33d60e321cd3dbd3181c3848e78079b..6f4087048636b25cde8a2c0a19d3787521ead46c 100644 (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;