return inst;
}
+
+/**
+ * Create an instance of a SVGA3dShaderDestToken.
+ * Note that this function is used to create tokens for output registers,
+ * temp registers AND constants (see emit_def_const()).
+ */
static INLINE SVGA3dShaderDestToken
dst_register( unsigned file,
int number )
assert(number < (1 << 11));
assert(file <= SVGA3DREG_PREDICATE);
- assert(number < SVGA3D_TEMPREG_MAX);
-
dest.value = 0;
dest.num = number;
dest.type_upper = file >> 3;
break;
default:
- dest = dst_register( translate_file( reg->Register.File ),
- reg->Register.Index );
+ {
+ unsigned index = reg->Register.Index;
+ assert(index < SVGA3D_TEMPREG_MAX);
+ index = MIN2(index, SVGA3D_TEMPREG_MAX - 1);
+ dest = dst_register(translate_file(reg->Register.File), index);
+ }
break;
}
/*
- * Get a temporary register, return -1 if none available
+ * Get a temporary register.
+ * Note: if we exceed the temporary register limit we just use
+ * register SVGA3D_TEMPREG_MAX - 1.
*/
static INLINE SVGA3dShaderDestToken
get_temp( struct svga_shader_emitter *emit )
{
int i = emit->nr_hw_temp + emit->internal_temp_count++;
-
+ assert(i < SVGA3D_TEMPREG_MAX);
+ i = MIN2(i, SVGA3D_TEMPREG_MAX - 1);
return dst_register( SVGA3DREG_TEMP, i );
}