From 1f32d5d59fff7a4ef42cd2811ef4116c5827b9a0 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Tue, 19 Apr 2016 14:08:13 +0200 Subject: [PATCH] radeonsi: Consider input SGPR count for compute shader SGPR count. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit si_shader_create corrects the SGPR count with si_fix_num_sgprs. We then recompute the rsrc1 register to use the new SGPR count. Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_compute.c | 16 +++++++++++----- src/gallium/drivers/radeonsi/si_shader.c | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 557e89236fa..905c169dd14 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -81,14 +81,20 @@ static void *si_create_compute_state( program->shader.selector = &sel; - if (si_compile_tgsi_shader(sscreen, sctx->tm, &program->shader, - true, &sctx->b.debug)) { + if (si_shader_create(sscreen, sctx->tm, &program->shader, + &sctx->b.debug)) { FREE(sel.tokens); return NULL; } scratch_enabled = shader->config.scratch_bytes_per_wave > 0; + shader->config.rsrc1 = + S_00B848_VGPRS((shader->config.num_vgprs - 1) / 4) | + S_00B848_SGPRS((shader->config.num_sgprs - 1) / 8) | + S_00B848_DX10_CLAMP(1) | + S_00B848_FLOAT_MODE(shader->config.float_mode); + shader->config.rsrc2 = S_00B84C_USER_SGPR(SI_CS_NUM_USER_SGPR) | S_00B84C_SCRATCH_EN(scratch_enabled) | S_00B84C_TGID_X_EN(1) | S_00B84C_TGID_Y_EN(1) | @@ -105,10 +111,10 @@ static void *si_create_compute_state( radeon_elf_read(code, header->num_bytes, &program->shader.binary); si_shader_binary_read_config(&program->shader.binary, &program->shader.config, 0); + si_shader_dump(sctx->screen, &program->shader, &sctx->b.debug, + PIPE_SHADER_COMPUTE, stderr); + si_shader_binary_upload(sctx->screen, &program->shader); } - si_shader_dump(sctx->screen, &program->shader, &sctx->b.debug, - TGSI_PROCESSOR_COMPUTE, stderr); - si_shader_binary_upload(sctx->screen, &program->shader); return program; } diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 605b964d379..3bf68eb025d 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -7022,7 +7022,8 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm, (shader->key.vs.as_es != mainp->key.vs.as_es || shader->key.vs.as_ls != mainp->key.vs.as_ls)) || (shader->selector->type == PIPE_SHADER_TESS_EVAL && - shader->key.tes.as_es != mainp->key.tes.as_es)) { + shader->key.tes.as_es != mainp->key.tes.as_es) || + shader->selector->type == PIPE_SHADER_COMPUTE) { /* Monolithic shader (compiled as a whole, has many variants, * may take a long time to compile). */ -- 2.30.2