diff options
author | Vincent Lejeune <[email protected]> | 2012-10-19 15:49:06 +0200 |
---|---|---|
committer | Vincent Lejeune <[email protected]> | 2012-10-30 00:28:42 +0100 |
commit | 5ab82e0ccf84855e9311ebfc58d1b57b437ed991 (patch) | |
tree | b173648209a43c554b6c3eff7e5435d016395049 /src | |
parent | e4e3b071814d14e56ca3feca8df4974646bc332d (diff) |
r600g: tgsi-to-llvm emits right input intrinsics
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/r600/r600_llvm.c | 62 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_shader.c | 22 |
2 files changed, 64 insertions, 20 deletions
diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c index 321966e016b..3dec8ae2537 100644 --- a/src/gallium/drivers/r600/r600_llvm.c +++ b/src/gallium/drivers/r600/r600_llvm.c @@ -90,11 +90,11 @@ llvm_face_select_helper( LLVMValueRef backcolor = llvm_load_input_helper( ctx, - "llvm.R600.load.input", + intrinsic, backcolor_regiser); LLVMValueRef front_color = llvm_load_input_helper( ctx, - "llvm.R600.load.input", + intrinsic, frontcolor_register); LLVMValueRef face = llvm_load_input_helper( ctx, @@ -120,6 +120,29 @@ static void llvm_load_input( { unsigned chan; + const char *intrinsics = "llvm.R600.load.input"; + unsigned offset = 4 * ctx->reserved_reg_count; + + if (ctx->type == TGSI_PROCESSOR_FRAGMENT && ctx->chip_class >= EVERGREEN) { + switch (decl->Interp.Interpolate) { + case TGSI_INTERPOLATE_COLOR: + case TGSI_INTERPOLATE_PERSPECTIVE: + offset = 0; + intrinsics = "llvm.R600.load.input.perspective"; + break; + case TGSI_INTERPOLATE_LINEAR: + offset = 0; + intrinsics = "llvm.R600.load.input.linear"; + break; + case TGSI_INTERPOLATE_CONSTANT: + offset = 0; + intrinsics = "llvm.R600.load.input.constant"; + break; + default: + assert(0 && "Unknow Interpolate mode"); + } + } + for (chan = 0; chan < 4; chan++) { unsigned soa_index = radeon_llvm_reg_index_soa(input_index, chan); @@ -145,24 +168,37 @@ static void llvm_load_input( break; case TGSI_SEMANTIC_COLOR: if (ctx->two_side) { + unsigned front_location, back_location; unsigned back_reg = ctx->r600_inputs[input_index] .potential_back_facing_reg; - unsigned back_soa_index = radeon_llvm_reg_index_soa( - ctx->r600_inputs[back_reg].gpr, - chan); + if (ctx->chip_class >= EVERGREEN) { + front_location = 4 * ctx->r600_inputs[input_index].lds_pos + chan; + back_location = 4 * ctx->r600_inputs[back_reg].lds_pos + chan; + } else { + front_location = soa_index + 4 * ctx->reserved_reg_count; + back_location = radeon_llvm_reg_index_soa( + ctx->r600_inputs[back_reg].gpr, + chan); + } ctx->inputs[soa_index] = llvm_face_select_helper(ctx, - "llvm.R600.load.input", - 4 * ctx->face_input, - soa_index + 4 * ctx->reserved_reg_count, - back_soa_index); + intrinsics, + 4 * ctx->face_input, front_location, back_location); break; } default: - /* The * 4 is assuming that we are in soa mode. */ - ctx->inputs[soa_index] = llvm_load_input_helper(ctx, - "llvm.R600.load.input", - soa_index + (ctx->reserved_reg_count * 4)); + { + unsigned location; + if (ctx->chip_class >= EVERGREEN) { + location = 4 * ctx->r600_inputs[input_index].lds_pos + chan; + } else { + location = soa_index + 4 * ctx->reserved_reg_count; + } + /* The * 4 is assuming that we are in soa mode. */ + ctx->inputs[soa_index] = llvm_load_input_helper(ctx, + intrinsics, location); + break; + } } } } diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 0b586f3aedb..a4d94bb4af5 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -192,6 +192,7 @@ struct r600_shader_ctx { uint32_t *literals; uint32_t nliterals; uint32_t max_driver_temp_used; + boolean use_llvm; /* needed for evergreen interpolation */ boolean input_centroid; boolean input_linear; @@ -759,10 +760,12 @@ static int evergreen_interp_input(struct r600_shader_ctx *ctx, int index) if (ctx->shader->input[index].spi_sid) { ctx->shader->input[index].lds_pos = ctx->shader->nlds++; - if (ctx->shader->input[index].interpolate > 0) { - r = evergreen_interp_alu(ctx, index); - } else { - r = evergreen_interp_flat(ctx, index); + if (!ctx->use_llvm) { + if (ctx->shader->input[index].interpolate > 0) { + r = evergreen_interp_alu(ctx, index); + } else { + r = evergreen_interp_flat(ctx, index); + } } } return r; @@ -1131,7 +1134,7 @@ static int tgsi_split_literal_constant(struct r600_shader_ctx *ctx) return 0; } -static int process_twoside_color_inputs(struct r600_shader_ctx *ctx, unsigned use_llvm) +static int process_twoside_color_inputs(struct r600_shader_ctx *ctx) { int i, r, count = ctx->shader->ninput; @@ -1143,7 +1146,7 @@ static int process_twoside_color_inputs(struct r600_shader_ctx *ctx, unsigned us return r; } - if (!use_llvm) { + if (!ctx->use_llvm) { r = select_twoside_color(ctx, i, back_facing_reg); if (r) return r; @@ -1243,6 +1246,7 @@ static int r600_shader_from_tgsi(struct r600_screen *rscreen, use_llvm = 0; } #endif + ctx.use_llvm = use_llvm; if (use_llvm) { ctx.file_offset[TGSI_FILE_OUTPUT] = @@ -1312,6 +1316,7 @@ static int r600_shader_from_tgsi(struct r600_screen *rscreen, /* Process two side if needed */ if (shader->two_side && ctx.colors_used) { int i, count = ctx.shader->ninput; + unsigned next_lds_loc = ctx.shader->nlds; /* additional inputs will be allocated right after the existing inputs, * we won't need them after the color selection, so we don't need to @@ -1335,6 +1340,9 @@ static int r600_shader_from_tgsi(struct r600_screen *rscreen, ctx.shader->input[ni].name = TGSI_SEMANTIC_BCOLOR; ctx.shader->input[ni].spi_sid = r600_spi_sid(&ctx.shader->input[ni]); ctx.shader->input[ni].gpr = gpr++; + // TGSI to LLVM needs to know the lds position of inputs. + // Non LLVM path computes it later (in process_twoside_color) + ctx.shader->input[ni].lds_pos = next_lds_loc++; ctx.shader->input[i].potential_back_facing_reg = ni; } } @@ -1409,7 +1417,7 @@ static int r600_shader_from_tgsi(struct r600_screen *rscreen, } if (shader->two_side && ctx.colors_used) { - if ((r = process_twoside_color_inputs(&ctx, use_llvm))) + if ((r = process_twoside_color_inputs(&ctx))) return r; } |