[Mesa-dev] [PATCH 8/8] nine: allow fragment shader POSITION and FACE to be system values
Marek Olšák
maraeo at gmail.com
Fri Jan 8 08:30:58 PST 2016
On Fri, Jan 8, 2016 at 12:25 PM, Axel Davy <axel.davy at ens.fr> wrote:
> On 08/01/2016 02:29, Marek Olšák wrote:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> ---
>> src/gallium/state_trackers/nine/nine_ff.c | 10 +++++-
>> src/gallium/state_trackers/nine/nine_shader.c | 48
>> +++++++++++++++++++++------
>> 2 files changed, 46 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/nine/nine_ff.c
>> b/src/gallium/state_trackers/nine/nine_ff.c
>> index fe26086..0feaeab 100644
>> --- a/src/gallium/state_trackers/nine/nine_ff.c
>> +++ b/src/gallium/state_trackers/nine/nine_ff.c
>> @@ -1391,7 +1391,15 @@ nine_ff_build_ps(struct NineDevice9 *device, struct
>> nine_ff_ps_key *key)
>> /* Fog.
>> */
>> if (key->fog_mode) {
>> - struct ureg_src vPos = ureg_DECL_fs_input(ureg,
>> TGSI_SEMANTIC_POSITION, 0, TGSI_INTERPOLATE_LINEAR);
>> + struct ureg_src vPos;
>> + if (device->screen->get_param(device->screen,
>> +
>> PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL)) {
>> + vPos = ureg_DECL_system_value(ureg, TGSI_SEMANTIC_POSITION,
>> 0);
>> + } else {
>> + vPos = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, 0,
>> + TGSI_INTERPOLATE_LINEAR);
>> + }
>> +
>> struct ureg_dst rFog = ureg_writemask(ps.rTmp,
>> TGSI_WRITEMASK_X);
>> if (key->fog_mode == D3DFOG_EXP) {
>> ureg_MUL(ureg, rFog, _ZZZZ(vPos), _ZZZZ(_CONST(22)));
>> diff --git a/src/gallium/state_trackers/nine/nine_shader.c
>> b/src/gallium/state_trackers/nine/nine_shader.c
>> index 28f2787..311897d 100644
>> --- a/src/gallium/state_trackers/nine/nine_shader.c
>> +++ b/src/gallium/state_trackers/nine/nine_shader.c
>> @@ -462,6 +462,8 @@ struct shader_translator
>> boolean lower_preds;
>> boolean want_texcoord;
>> boolean shift_wpos;
>> + boolean wpos_is_sysval;
>> + boolean face_is_sysval_integer;
>> unsigned texcoord_sn;
>> struct sm1_instruction insn; /* current instruction */
>> @@ -945,10 +947,16 @@ tx_src_param(struct shader_translator *tx, const
>> struct sm1_src_param *param)
>> case D3DSPR_MISCTYPE:
>> switch (param->idx) {
>> case D3DSMO_POSITION:
>> - if (ureg_src_is_undef(tx->regs.vPos))
>> - tx->regs.vPos = ureg_DECL_fs_input(ureg,
>> - TGSI_SEMANTIC_POSITION,
>> 0,
>> -
>> TGSI_INTERPOLATE_LINEAR);
>> + if (ureg_src_is_undef(tx->regs.vPos)) {
>> + if (tx->wpos_is_sysval) {
>> + tx->regs.vPos =
>> + ureg_DECL_system_value(ureg,
>> TGSI_SEMANTIC_POSITION, 0);
>> + } else {
>> + tx->regs.vPos =
>> + ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, 0,
>> + TGSI_INTERPOLATE_LINEAR);
>> + }
>> + }
>> if (tx->shift_wpos) {
>> /* TODO: do this only once */
>> struct ureg_dst wpos = tx_scratch(tx);
>> @@ -961,9 +969,20 @@ tx_src_param(struct shader_translator *tx, const
>> struct sm1_src_param *param)
>> break;
>> case D3DSMO_FACE:
>> if (ureg_src_is_undef(tx->regs.vFace)) {
>> - tx->regs.vFace = ureg_DECL_fs_input(ureg,
>> - TGSI_SEMANTIC_FACE, 0,
>> -
>> TGSI_INTERPOLATE_CONSTANT);
>> + if (tx->face_is_sysval_integer) {
>> + tmp = tx_scratch(tx);
>> + tx->regs.vFace =
>> + ureg_DECL_system_value(ureg, TGSI_SEMANTIC_FACE,
>> 0);
>> +
>> + /* convert bool to float */
>> + ureg_UCMP(ureg, tmp, ureg_scalar(tx->regs.vFace,
>> TGSI_SWIZZLE_X),
>> + ureg_imm1f(ureg, 1), ureg_imm1f(ureg, 0));
>
>
> This looks wrong. It should be -1.0 for the backface and 1.0 for the
> frontface.
With 0 changed to -1, would it be Reviewed-by: you?
Marek
More information about the mesa-dev
mailing list