[Mesa-dev] [PATCH 2/2] radeonsi: move POSITION and FACE fragment shader inputs to system values
Marek Olšák
maraeo at gmail.com
Thu Jan 7 17:30:15 PST 2016
From: Marek Olšák <marek.olsak at amd.com>
And FACE becomes integer instead of float.
---
src/gallium/drivers/radeonsi/si_pipe.c | 4 +-
src/gallium/drivers/radeonsi/si_shader.c | 58 ++++++++++---------------
src/gallium/drivers/radeonsi/si_state_shaders.c | 8 +---
3 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index e30911d..6bde37c 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -301,6 +301,8 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TXQS:
case PIPE_CAP_FORCE_PERSAMPLE_INTERP:
case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
+ case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
+ case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
return 1;
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -342,8 +344,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_CLEAR_TEXTURE:
case PIPE_CAP_DRAW_PARAMETERS:
case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
- case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
- case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
return 0;
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 561efa2..8f4872c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -911,36 +911,6 @@ static void declare_input_fs(
unsigned chan;
- if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
- for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
- unsigned soa_index =
- radeon_llvm_reg_index_soa(input_index, chan);
- radeon_bld->inputs[soa_index] =
- LLVMGetParam(main_fn, SI_PARAM_POS_X_FLOAT + chan);
-
- if (chan == 3)
- /* RCP for fragcoord.w */
- radeon_bld->inputs[soa_index] =
- LLVMBuildFDiv(gallivm->builder,
- lp_build_const_float(gallivm, 1.0f),
- radeon_bld->inputs[soa_index],
- "");
- }
- return;
- }
-
- if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
- radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 0)] =
- LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
- radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 1)] =
- radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 2)] =
- lp_build_const_float(gallivm, 0.0f);
- radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 3)] =
- lp_build_const_float(gallivm, 1.0f);
-
- return;
- }
-
shader->ps_input_param_offset[input_index] = shader->nparam++;
attr_number = lp_build_const_int32(gallivm,
shader->ps_input_param_offset[input_index]);
@@ -975,10 +945,8 @@ static void declare_input_fs(
face = LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
- is_face_positive = LLVMBuildFCmp(gallivm->builder,
- LLVMRealOGT, face,
- lp_build_const_float(gallivm, 0.0f),
- "");
+ is_face_positive = LLVMBuildICmp(gallivm->builder, LLVMIntNE,
+ face, uint->zero, "");
args[2] = params;
args[3] = interp_param;
@@ -1129,6 +1097,24 @@ static void declare_system_value(
assert(!"INVOCATIONID not implemented");
break;
+ case TGSI_SEMANTIC_POSITION:
+ {
+ LLVMValueRef pos[4] = {
+ LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_X_FLOAT),
+ LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_Y_FLOAT),
+ LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_Z_FLOAT),
+ lp_build_emit_llvm_unary(&radeon_bld->soa.bld_base, TGSI_OPCODE_RCP,
+ LLVMGetParam(radeon_bld->main_fn,
+ SI_PARAM_POS_W_FLOAT)),
+ };
+ value = lp_build_gather_values(gallivm, pos, 4);
+ break;
+ }
+
+ case TGSI_SEMANTIC_FACE:
+ value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_FRONT_FACE);
+ break;
+
case TGSI_SEMANTIC_SAMPLEID:
value = get_sample_id(radeon_bld);
break;
@@ -3506,7 +3492,7 @@ static void create_function(struct si_shader_context *si_shader_ctx)
params[SI_PARAM_POS_Y_FLOAT] = f32;
params[SI_PARAM_POS_Z_FLOAT] = f32;
params[SI_PARAM_POS_W_FLOAT] = f32;
- params[SI_PARAM_FRONT_FACE] = f32;
+ params[SI_PARAM_FRONT_FACE] = i32;
params[SI_PARAM_ANCILLARY] = i32;
params[SI_PARAM_SAMPLE_COVERAGE] = f32;
params[SI_PARAM_POS_FIXED_PT] = f32;
@@ -4067,7 +4053,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
if (poly_stipple) {
tokens = util_pstipple_create_fragment_shader(tokens, NULL,
SI_POLY_STIPPLE_SAMPLER,
- TGSI_FILE_INPUT);
+ TGSI_FILE_SYSTEM_VALUE);
tgsi_scan_shader(tokens, &stipple_shader_info);
}
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 460dda5..35b226f 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -390,7 +390,7 @@ static void si_shader_ps(struct si_shader *shader)
unsigned spi_shader_col_format = 0, cb_shader_mask = 0;
unsigned colors_written, export_16bpc;
unsigned num_sgprs, num_user_sgprs;
- unsigned spi_baryc_cntl = 0;
+ unsigned spi_baryc_cntl = S_0286E0_FRONT_FACE_ALL_BITS(1);
uint64_t va;
bool has_centroid;
@@ -979,12 +979,6 @@ static void si_emit_spi_map(struct si_context *sctx, struct r600_atom *atom)
unsigned index = psinfo->input_semantic_index[i];
unsigned interpolate = psinfo->input_interpolate[i];
unsigned param_offset = ps->ps_input_param_offset[i];
-
- if (name == TGSI_SEMANTIC_POSITION ||
- name == TGSI_SEMANTIC_FACE)
- /* Read from preloaded VGPRs, not parameters */
- continue;
-
bcolor:
tmp = 0;
--
2.1.4
More information about the mesa-dev
mailing list