summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/nine_ff.c
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2014-11-26 22:32:57 +0100
committerAxel Davy <[email protected]>2014-12-03 16:39:24 +0100
commit712a4c5438d0ce257344b5196c20ad7929b54a0e (patch)
tree32417a5c9f3fdb10182c7cd5264fb40ce1123b2d /src/gallium/state_trackers/nine/nine_ff.c
parent5d6d260833e374404f80d1c36bc0e1854369a069 (diff)
st/nine: Fix vertex declarations for non-standard (usage/index)
Nine code to match vertex declaration to vs inputs was limiting the number of possible combinations. Some sm3 games have issues with that, because arbitrary (usage/index) can be used. This patch does the following changes to fix the problem: . Change the numbers given to (usage/index) combinations to uint16 . Do not put limits on the indices when it doesn't make sense . change the conversion rule (usage/index) -> number to fit all combinations . Instead of having a table usage_map mapping a (usage/index) number to an input index, usage_map maps input indices to their (usage/index) Cc: "10.4" <[email protected]> Tested-by: Yaroslav Andrusyak <[email protected]> Acked-by: Ilia Mirkin <[email protected]> Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/nine_ff.c')
-rw-r--r--src/gallium/state_trackers/nine/nine_ff.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 184c4113026..a6bd360cf33 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -275,7 +275,7 @@ struct vs_build_ctx
struct ureg_program *ureg;
const struct nine_ff_vs_key *key;
- unsigned input[PIPE_MAX_ATTRIBS];
+ uint16_t input[PIPE_MAX_ATTRIBS];
unsigned num_inputs;
struct ureg_src aVtx;
@@ -304,7 +304,7 @@ get_texcoord_sn(struct pipe_screen *screen)
}
static INLINE struct ureg_src
-build_vs_add_input(struct vs_build_ctx *vs, unsigned ndecl)
+build_vs_add_input(struct vs_build_ctx *vs, uint16_t ndecl)
{
const unsigned i = vs->num_inputs++;
assert(i < PIPE_MAX_ATTRIBS);
@@ -370,10 +370,10 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
* (texture coordinates handled later)
*/
vs->aVtx = build_vs_add_input(vs,
- key->position_t ? NINE_DECLUSAGE_POSITIONT : NINE_DECLUSAGE_POSITION(0));
+ key->position_t ? NINE_DECLUSAGE_POSITIONT : NINE_DECLUSAGE_POSITION);
if (need_rNrm)
- vs->aNrm = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL(0));
+ vs->aNrm = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL);
vs->aCol[0] = ureg_imm1f(ureg, 1.0f);
vs->aCol[1] = ureg_imm1f(ureg, 1.0f);
@@ -382,9 +382,9 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
const unsigned mask = key->mtl_diffuse | key->mtl_specular |
key->mtl_ambient | key->mtl_emissive;
if ((mask & 0x1) && !key->color0in_one)
- vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(0));
+ vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 0));
if ((mask & 0x2) && !key->color1in_one)
- vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(1));
+ vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 1));
vs->mtlD = MATERIAL_CONST(1);
vs->mtlA = MATERIAL_CONST(2);
@@ -399,20 +399,20 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
if (key->mtl_emissive == 1) vs->mtlE = vs->aCol[0]; else
if (key->mtl_emissive == 2) vs->mtlE = vs->aCol[1];
} else {
- if (!key->color0in_one) vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(0));
- if (!key->color1in_one) vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(1));
+ if (!key->color0in_one) vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 0));
+ if (!key->color1in_one) vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 1));
}
if (key->vertexpointsize)
vs->aPsz = build_vs_add_input(vs, NINE_DECLUSAGE_PSIZE);
if (key->vertexblend_indexed)
- vs->aInd = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDINDICES(0));
+ vs->aInd = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDINDICES);
if (key->vertexblend)
- vs->aWgt = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDWEIGHT(0));
+ vs->aWgt = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDWEIGHT);
if (key->vertextween) {
- vs->aVtx1 = build_vs_add_input(vs, NINE_DECLUSAGE_POSITION(1));
- vs->aNrm1 = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL(1));
+ vs->aVtx1 = build_vs_add_input(vs, NINE_DECLUSAGE_i(POSITION,1));
+ vs->aNrm1 = build_vs_add_input(vs, NINE_DECLUSAGE_i(NORMAL,1));
}
/* Declare outputs:
@@ -596,7 +596,7 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
oTex[i] = ureg_DECL_output(ureg, texcoord_sn, i);
if (tci == NINED3DTSS_TCI_PASSTHRU)
- vs->aTex[idx] = build_vs_add_input(vs, NINE_DECLUSAGE_TEXCOORD(idx));
+ vs->aTex[idx] = build_vs_add_input(vs, NINE_DECLUSAGE_i(TEXCOORD,idx));
if (!dim) {
dst[c = 4] = oTex[i];
@@ -1374,7 +1374,7 @@ nine_ff_get_vs(struct NineDevice9 *device)
enum pipe_error err;
struct vs_build_ctx bld;
struct nine_ff_vs_key key;
- unsigned s;
+ unsigned s, i;
assert(sizeof(key) <= sizeof(key.value32));
@@ -1385,14 +1385,19 @@ nine_ff_get_vs(struct NineDevice9 *device)
/* FIXME: this shouldn't be NULL, but it is on init */
if (state->vdecl) {
- if (state->vdecl->usage_map[NINE_DECLUSAGE_POSITIONT] != 0xff)
- key.position_t = 1;
- if (state->vdecl->usage_map[NINE_DECLUSAGE_COLOR(0)] == 0xff)
- key.color0in_one = 1;
- if (state->vdecl->usage_map[NINE_DECLUSAGE_COLOR(1)] == 0xff)
- key.color1in_one = 1;
- if (state->vdecl->usage_map[NINE_DECLUSAGE_PSIZE] != 0xff)
- key.vertexpointsize = 1;
+ key.color0in_one = 1;
+ key.color1in_one = 1;
+ for (i = 0; i < state->vdecl->nelems; i++) {
+ uint16_t usage = state->vdecl->usage_map[i];
+ if (usage == NINE_DECLUSAGE_POSITIONT)
+ key.position_t = 1;
+ else if (usage == NINE_DECLUSAGE_i(COLOR, 0))
+ key.color0in_one = 0;
+ else if (usage == NINE_DECLUSAGE_i(COLOR, 1))
+ key.color1in_one = 0;
+ else if (usage == NINE_DECLUSAGE_PSIZE)
+ key.vertexpointsize = 1;
+ }
}
if (!key.vertexpointsize)
key.pointscale = !!state->rs[D3DRS_POINTSCALEENABLE];