radeonsi: implement fragment color clamping
using the shader key for now. Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
parent
acc6a07874
commit
208d1ed38d
|
@ -271,6 +271,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
|
||||||
case PIPE_CAP_START_INSTANCE:
|
case PIPE_CAP_START_INSTANCE:
|
||||||
case PIPE_CAP_NPOT_TEXTURES:
|
case PIPE_CAP_NPOT_TEXTURES:
|
||||||
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
|
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
|
||||||
|
case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
|
||||||
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
|
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
|
||||||
case PIPE_CAP_TGSI_INSTANCEID:
|
case PIPE_CAP_TGSI_INSTANCEID:
|
||||||
case PIPE_CAP_COMPUTE:
|
case PIPE_CAP_COMPUTE:
|
||||||
|
@ -330,7 +331,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
|
||||||
/* Unsupported features. */
|
/* Unsupported features. */
|
||||||
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
|
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
|
||||||
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
|
case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
|
||||||
case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
|
|
||||||
case PIPE_CAP_VERTEX_COLOR_CLAMPED:
|
case PIPE_CAP_VERTEX_COLOR_CLAMPED:
|
||||||
case PIPE_CAP_USER_VERTEX_BUFFERS:
|
case PIPE_CAP_USER_VERTEX_BUFFERS:
|
||||||
case PIPE_CAP_FAKE_SW_MSAA:
|
case PIPE_CAP_FAKE_SW_MSAA:
|
||||||
|
|
|
@ -2110,6 +2110,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
|
||||||
struct lp_build_context * base = &bld_base->base;
|
struct lp_build_context * base = &bld_base->base;
|
||||||
struct lp_build_context * uint = &bld_base->uint_bld;
|
struct lp_build_context * uint = &bld_base->uint_bld;
|
||||||
struct tgsi_shader_info *info = &shader->selector->info;
|
struct tgsi_shader_info *info = &shader->selector->info;
|
||||||
|
LLVMBuilderRef builder = base->gallivm->builder;
|
||||||
LLVMValueRef args[9];
|
LLVMValueRef args[9];
|
||||||
LLVMValueRef last_args[9] = { 0 };
|
LLVMValueRef last_args[9] = { 0 };
|
||||||
int depth_index = -1, stencil_index = -1, samplemask_index = -1;
|
int depth_index = -1, stencil_index = -1, samplemask_index = -1;
|
||||||
|
@ -2136,6 +2137,16 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
|
||||||
target = V_008DFC_SQ_EXP_MRT + semantic_index;
|
target = V_008DFC_SQ_EXP_MRT + semantic_index;
|
||||||
alpha_ptr = si_shader_ctx->radeon_bld.soa.outputs[i][3];
|
alpha_ptr = si_shader_ctx->radeon_bld.soa.outputs[i][3];
|
||||||
|
|
||||||
|
if (si_shader_ctx->shader->key.ps.clamp_color) {
|
||||||
|
for (int j = 0; j < 4; j++) {
|
||||||
|
LLVMValueRef ptr = si_shader_ctx->radeon_bld.soa.outputs[i][j];
|
||||||
|
LLVMValueRef result = LLVMBuildLoad(builder, ptr, "");
|
||||||
|
|
||||||
|
result = radeon_llvm_saturate(bld_base, result);
|
||||||
|
LLVMBuildStore(builder, result, ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (si_shader_ctx->shader->key.ps.alpha_to_one)
|
if (si_shader_ctx->shader->key.ps.alpha_to_one)
|
||||||
LLVMBuildStore(base->gallivm->builder,
|
LLVMBuildStore(base->gallivm->builder,
|
||||||
base->one, alpha_ptr);
|
base->one, alpha_ptr);
|
||||||
|
@ -2146,6 +2157,7 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
|
||||||
|
|
||||||
if (si_shader_ctx->shader->key.ps.poly_line_smoothing)
|
if (si_shader_ctx->shader->key.ps.poly_line_smoothing)
|
||||||
si_scale_alpha_by_sample_mask(bld_base, alpha_ptr);
|
si_scale_alpha_by_sample_mask(bld_base, alpha_ptr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
target = 0;
|
target = 0;
|
||||||
|
@ -4000,6 +4012,7 @@ void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f)
|
||||||
fprintf(f, " alpha_func = %u\n", key->ps.alpha_func);
|
fprintf(f, " alpha_func = %u\n", key->ps.alpha_func);
|
||||||
fprintf(f, " alpha_to_one = %u\n", key->ps.alpha_to_one);
|
fprintf(f, " alpha_to_one = %u\n", key->ps.alpha_to_one);
|
||||||
fprintf(f, " poly_stipple = %u\n", key->ps.poly_stipple);
|
fprintf(f, " poly_stipple = %u\n", key->ps.poly_stipple);
|
||||||
|
fprintf(f, " clamp_color = %u\n", key->ps.clamp_color);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -227,6 +227,7 @@ union si_shader_key {
|
||||||
unsigned alpha_to_one:1;
|
unsigned alpha_to_one:1;
|
||||||
unsigned poly_stipple:1;
|
unsigned poly_stipple:1;
|
||||||
unsigned poly_line_smoothing:1;
|
unsigned poly_line_smoothing:1;
|
||||||
|
unsigned clamp_color:1;
|
||||||
} ps;
|
} ps;
|
||||||
struct {
|
struct {
|
||||||
unsigned instance_divisors[SI_NUM_VERTEX_BUFFERS];
|
unsigned instance_divisors[SI_NUM_VERTEX_BUFFERS];
|
||||||
|
|
|
@ -694,7 +694,7 @@ static void *si_create_rs_state(struct pipe_context *ctx,
|
||||||
rs->poly_smooth = state->poly_smooth;
|
rs->poly_smooth = state->poly_smooth;
|
||||||
rs->uses_poly_offset = state->offset_point || state->offset_line ||
|
rs->uses_poly_offset = state->offset_point || state->offset_line ||
|
||||||
state->offset_tri;
|
state->offset_tri;
|
||||||
|
rs->clamp_fragment_color = state->clamp_fragment_color;
|
||||||
rs->flatshade = state->flatshade;
|
rs->flatshade = state->flatshade;
|
||||||
rs->sprite_coord_enable = state->sprite_coord_enable;
|
rs->sprite_coord_enable = state->sprite_coord_enable;
|
||||||
rs->pa_sc_line_stipple = state->line_stipple_enable ?
|
rs->pa_sc_line_stipple = state->line_stipple_enable ?
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct si_state_rasterizer {
|
||||||
bool line_smooth;
|
bool line_smooth;
|
||||||
bool poly_smooth;
|
bool poly_smooth;
|
||||||
bool uses_poly_offset;
|
bool uses_poly_offset;
|
||||||
|
bool clamp_fragment_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct si_dsa_stencil_ref_part {
|
struct si_dsa_stencil_ref_part {
|
||||||
|
|
|
@ -572,6 +572,7 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
|
||||||
key->ps.poly_line_smoothing = ((is_poly && rs->poly_smooth) ||
|
key->ps.poly_line_smoothing = ((is_poly && rs->poly_smooth) ||
|
||||||
(is_line && rs->line_smooth)) &&
|
(is_line && rs->line_smooth)) &&
|
||||||
sctx->framebuffer.nr_samples <= 1;
|
sctx->framebuffer.nr_samples <= 1;
|
||||||
|
key->ps.clamp_color = rs->clamp_fragment_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
key->ps.alpha_func = PIPE_FUNC_ALWAYS;
|
key->ps.alpha_func = PIPE_FUNC_ALWAYS;
|
||||||
|
|
Loading…
Reference in New Issue