summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2015-01-02 13:42:11 +0100
committerEmil Velikov <[email protected]>2015-01-22 22:16:19 +0000
commitd08c7b0b880a4d5afdeac4dd5b26e2ad1c10e9da (patch)
tree59074a3b8099363a8213b60708d83473e349b85d
parentd9d18fe39f7b4f628af23b78576e961fd452921f (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]>
-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 56f03c8e323..4d6ae60e3f8 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2932,6 +2932,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);
@@ -2940,9 +2941,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;
@@ -2957,14 +2967,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;
}
@@ -3238,6 +3258,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);
@@ -3246,10 +3267,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;
@@ -3263,14 +3292,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;
}