r600g: check gpr count limit
authorVadim Girlin <vadimgirlin@gmail.com>
Mon, 9 Apr 2012 20:44:52 +0000 (00:44 +0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Apr 2012 22:05:57 +0000 (18:05 -0400)
This should help to prevent gpu lockups.
See https://bugs.freedesktop.org/show_bug.cgi?id=48472

NOTE: This is a candidate for the stable branches.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/r600/r600_shader.c

index 1adf34420c1fa829d5d6656d994fb2e9c19d6c2f..4932dcc6e5b0f9dc4ebe4810c7d69b310eb95270 100644 (file)
@@ -1266,6 +1266,14 @@ static int r600_shader_from_tgsi(struct r600_context * rctx, struct r600_pipe_sh
        if (ctx.bc->chip_class == CAYMAN)
                cm_bytecode_add_cf_end(ctx.bc);
 
+       /* check GPR limit - we have 124 = 128 - 4
+        * (4 are reserved as alu clause temporary registers) */
+       if (ctx.bc->ngpr > 124) {
+               R600_ERR("GPR limit exceeded - shader requires %d registers\n", ctx.bc->ngpr);
+               r = -ENOMEM;
+               goto out_err;
+       }
+
        free(ctx.literals);
        tgsi_parse_free(&ctx.parse);
        return 0;