summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2015-01-02 13:42:11 +0100
committerEmil Velikov <[email protected]>2015-01-22 23:43:26 +0000
commit9a0647ba7f0cca79c1dc94c8fff53f7d6f48cdeb (patch)
tree6b338251267e655f8d8ccfd1fdd489de7894e9dc /src
parent669c5d6d4483b501b7b7aacc4c141261a40a9d7a (diff)
st/nine: Convert integer constants to floats before storing them when cards don't support integers
The shader code is already behaving as if they are floats when the the card doesn't support integers Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Axel Davy <[email protected]> Cc: "10.4" <[email protected]> (cherry picked from commit d08c7b0b880a4d5afdeac4dd5b26e2ad1c10e9da)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/nine/device9.c65
1 files changed, 52 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index ab6146da3a9..7fe1d14594c 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2933,6 +2933,7 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
UINT Vector4iCount )
{
struct nine_state *state = This->update;
+ int i;
DBG("This=%p StartRegister=%u pConstantData=%p Vector4iCount=%u\n",
This, StartRegister, pConstantData, Vector4iCount);
@@ -2941,9 +2942,18 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
user_assert(StartRegister + Vector4iCount <= NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(&state->vs_const_i[StartRegister][0],
- pConstantData,
- Vector4iCount * sizeof(state->vs_const_i[0]));
+ if (This->driver_caps.vs_integer) {
+ memcpy(&state->vs_const_i[StartRegister][0],
+ pConstantData,
+ Vector4iCount * sizeof(state->vs_const_i[0]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ state->vs_const_i[StartRegister+i][0] = fui((float)(pConstantData[4*i]));
+ state->vs_const_i[StartRegister+i][1] = fui((float)(pConstantData[4*i+1]));
+ state->vs_const_i[StartRegister+i][2] = fui((float)(pConstantData[4*i+2]));
+ state->vs_const_i[StartRegister+i][3] = fui((float)(pConstantData[4*i+3]));
+ }
+ }
state->changed.vs_const_i |= ((1 << Vector4iCount) - 1) << StartRegister;
state->changed.group |= NINE_STATE_VS_CONST;
@@ -2958,14 +2968,24 @@ NineDevice9_GetVertexShaderConstantI( struct NineDevice9 *This,
UINT Vector4iCount )
{
const struct nine_state *state = &This->state;
+ int i;
user_assert(StartRegister < NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(StartRegister + Vector4iCount <= NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(pConstantData,
- &state->vs_const_i[StartRegister][0],
- Vector4iCount * sizeof(state->vs_const_i[0]));
+ if (This->driver_caps.vs_integer) {
+ memcpy(pConstantData,
+ &state->vs_const_i[StartRegister][0],
+ Vector4iCount * sizeof(state->vs_const_i[0]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ pConstantData[4*i] = (int32_t) uif(state->vs_const_i[StartRegister+i][0]);
+ pConstantData[4*i+1] = (int32_t) uif(state->vs_const_i[StartRegister+i][1]);
+ pConstantData[4*i+2] = (int32_t) uif(state->vs_const_i[StartRegister+i][2]);
+ pConstantData[4*i+3] = (int32_t) uif(state->vs_const_i[StartRegister+i][3]);
+ }
+ }
return D3D_OK;
}
@@ -3239,6 +3259,7 @@ NineDevice9_SetPixelShaderConstantI( struct NineDevice9 *This,
UINT Vector4iCount )
{
struct nine_state *state = This->update;
+ int i;
DBG("This=%p StartRegister=%u pConstantData=%p Vector4iCount=%u\n",
This, StartRegister, pConstantData, Vector4iCount);
@@ -3247,10 +3268,18 @@ NineDevice9_SetPixelShaderConstantI( struct NineDevice9 *This,
user_assert(StartRegister + Vector4iCount <= NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(&state->ps_const_i[StartRegister][0],
- pConstantData,
- Vector4iCount * sizeof(state->ps_const_i[0]));
-
+ if (This->driver_caps.ps_integer) {
+ memcpy(&state->ps_const_i[StartRegister][0],
+ pConstantData,
+ Vector4iCount * sizeof(state->ps_const_i[0]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ state->ps_const_i[StartRegister+i][0] = fui((float)(pConstantData[4*i]));
+ state->ps_const_i[StartRegister+i][1] = fui((float)(pConstantData[4*i+1]));
+ state->ps_const_i[StartRegister+i][2] = fui((float)(pConstantData[4*i+2]));
+ state->ps_const_i[StartRegister+i][3] = fui((float)(pConstantData[4*i+3]));
+ }
+ }
state->changed.ps_const_i |= ((1 << Vector4iCount) - 1) << StartRegister;
state->changed.group |= NINE_STATE_PS_CONST;
@@ -3264,14 +3293,24 @@ NineDevice9_GetPixelShaderConstantI( struct NineDevice9 *This,
UINT Vector4iCount )
{
const struct nine_state *state = &This->state;
+ int i;
user_assert(StartRegister < NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(StartRegister + Vector4iCount <= NINE_MAX_CONST_I, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(pConstantData,
- &state->ps_const_i[StartRegister][0],
- Vector4iCount * sizeof(state->ps_const_i[0]));
+ if (This->driver_caps.ps_integer) {
+ memcpy(pConstantData,
+ &state->ps_const_i[StartRegister][0],
+ Vector4iCount * sizeof(state->ps_const_i[0]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ pConstantData[4*i] = (int32_t) uif(state->ps_const_i[StartRegister+i][0]);
+ pConstantData[4*i+1] = (int32_t) uif(state->ps_const_i[StartRegister+i][1]);
+ pConstantData[4*i+2] = (int32_t) uif(state->ps_const_i[StartRegister+i][2]);
+ pConstantData[4*i+3] = (int32_t) uif(state->ps_const_i[StartRegister+i][3]);
+ }
+ }
return D3D_OK;
}