From: Axel Davy Date: Wed, 7 Jan 2015 09:27:23 +0000 (+0100) Subject: st/nine: Correctly handle when ff vs should have no texture coord input/output X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8751734613d3476f46ef1efe119a6892b3ecfa02;p=mesa.git st/nine: Correctly handle when ff vs should have no texture coord input/output Previous code semantic was: . if ff ps will not run a ff stage, then do not output texture coords for this stage for vs . if XYZRHW is used (position_t), use only the mode where input coordinates are copied to the outputs. Problem is when apps don't give texture inputs. When apps precise PASSTHRU, it means copy texture coord input to texture coord output if there is such input. The case where there is no texture coord input wasn't handled correctly. Drivers like r300 dislike when vs has inputs that are not fed. Moreover if the app uses ff vs with a programmable ps, we shouldn't look at what are the parameters of the ff ps to decide to output or not texture coordinates. The new code semantic is: . if XYZRHW is used, restrict to PASSTHRU . if PASSTHRU is used and no texture input is declared, then do not output texture coords for this stage The case where ff ps needs a texture coord input and ff vs doesn't output it is not handled, and should probably be a runtime error. This fixes 3Dmark05, which uses ff vs with programmable ps. Reviewed-by: Tiziano Bacocco Signed-off-by: Axel Davy --- diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index d2b30f83a8f..2e3470f92ef 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1377,11 +1377,13 @@ nine_ff_get_vs(struct NineDevice9 *device) struct vs_build_ctx bld; struct nine_ff_vs_key key; unsigned s, i; + char input_texture_coord[8]; assert(sizeof(key) <= sizeof(key.value32)); memset(&key, 0, sizeof(key)); memset(&bld, 0, sizeof(bld)); + memset(&input_texture_coord, 0, sizeof(input_texture_coord)); bld.key = &key; @@ -1399,6 +1401,13 @@ nine_ff_get_vs(struct NineDevice9 *device) key.color1in_one = 0; else if (usage == NINE_DECLUSAGE_PSIZE) key.vertexpointsize = 1; + else if (usage % NINE_DECLUSAGE_COUNT == NINE_DECLUSAGE_TEXCOORD) { + s = usage / NINE_DECLUSAGE_COUNT; + if (s < 8) + input_texture_coord[s] = 1; + else + DBG("FF given texture coordinate >= 8. Ignoring\n"); + } } } if (!key.vertexpointsize) @@ -1436,18 +1445,18 @@ nine_ff_get_vs(struct NineDevice9 *device) } for (s = 0; s < 8; ++s) { - if (state->ff.tex_stage[s][D3DTSS_COLOROP] == D3DTOP_DISABLE && - state->ff.tex_stage[s][D3DTSS_ALPHAOP] == D3DTOP_DISABLE) - break; + unsigned gen = (state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] >> 16) + 1; + unsigned dim = MIN2(state->ff.tex_stage[s][D3DTSS_TEXTURETRANSFORMFLAGS] & 0x7, 4); + + if (key.position_t && gen > NINED3DTSS_TCI_PASSTHRU) + gen = NINED3DTSS_TCI_PASSTHRU; + + if (!input_texture_coord[s] && gen == NINED3DTSS_TCI_PASSTHRU) + gen = NINED3DTSS_TCI_DISABLE; + + key.tc_gen |= gen << (s * 3); key.tc_idx |= (state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] & 7) << (s * 3); - if (!key.position_t) { - unsigned gen = (state->ff.tex_stage[s][D3DTSS_TEXCOORDINDEX] >> 16) + 1; - unsigned dim = MIN2(state->ff.tex_stage[s][D3DTSS_TEXTURETRANSFORMFLAGS] & 0x7, 4); - key.tc_gen |= gen << (s * 3); - key.tc_dim |= dim << (s * 3); - } else { - key.tc_gen |= NINED3DTSS_TCI_PASSTHRU << (s * 3); - } + key.tc_dim |= dim << (s * 3); } vs = util_hash_table_get(device->ff.ht_vs, &key);