summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2014-11-25 00:38:10 +0100
committerEmil Velikov <[email protected]>2014-12-03 22:59:28 +0000
commit72a802a9c28671f34e5407de0069705d8596d515 (patch)
treea3f418a68d60f3525b347b3202155343aa3fab3b /src
parentcfbc474d8024662cc67f7da990d30711e89b68a3 (diff)
st/nine: Fix setting of the shift modifier in nine_shader
It is an sint_4, but it was stored in a uint_8... The code using it was acting as if it was signed. Problem found thanks to Coverity Cc: "10.4" <[email protected]> Tested-by: David Heidelberg <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Axel Davy <[email protected]> (cherry picked from commit d52328fc398aae4c3582172516b0ad98f0677b58)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/nine/nine_shader.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index c5b1ccbc5cd..77aa82e1036 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -239,7 +239,7 @@ struct sm1_dst_param
BYTE file;
BYTE mask;
BYTE mod;
- BYTE shift; /* sint4 */
+ int8_t shift; /* sint4 */
BYTE type;
};
@@ -2535,6 +2535,7 @@ sm1_parse_get_param(struct shader_translator *tx, DWORD *reg, DWORD *rel)
static void
sm1_parse_dst_param(struct sm1_dst_param *dst, DWORD tok)
{
+ uint8_t shift;
dst->file =
(tok & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT |
(tok & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2;
@@ -2543,7 +2544,8 @@ sm1_parse_dst_param(struct sm1_dst_param *dst, DWORD tok)
dst->rel = NULL;
dst->mask = (tok & NINED3DSP_WRITEMASK_MASK) >> NINED3DSP_WRITEMASK_SHIFT;
dst->mod = (tok & D3DSP_DSTMOD_MASK) >> D3DSP_DSTMOD_SHIFT;
- dst->shift = (tok & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT;
+ shift = (tok & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT;
+ dst->shift = (shift & 0x8) ? -(shift & 0x7) : shift & 0x7;
}
static void