[Mesa-stable] [PATCH v2 16/52] st/nine: Rework of boolean constants
Axel Davy
axel.davy at ens.fr
Sat Jan 10 02:37:45 PST 2015
Convert them to shader booleans at earlier stage.
Previous code is fine, but later patch will make
integers being converted at earlier stage, so do
the same for booleans
Signed-off-by: Axel Davy <axel.davy at ens.fr>
Cc: "10.4" <mesa-stable at lists.freedesktop.org>
---
src/gallium/state_trackers/nine/device9.c | 35 +++++++++++++---------------
src/gallium/state_trackers/nine/device9.h | 4 ++--
src/gallium/state_trackers/nine/nine_state.c | 20 +++++-----------
3 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 1d97688..56f03c8 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -293,13 +293,6 @@ NineDevice9_ctor( struct NineDevice9 *This,
return E_OUTOFMEMORY;
}
- This->vs_bool_true = pScreen->get_shader_param(pScreen,
- PIPE_SHADER_VERTEX,
- PIPE_SHADER_CAP_INTEGERS) ? 0xFFFFFFFF : fui(1.0f);
- This->ps_bool_true = pScreen->get_shader_param(pScreen,
- PIPE_SHADER_FRAGMENT,
- PIPE_SHADER_CAP_INTEGERS) ? 0xFFFFFFFF : fui(1.0f);
-
/* Allocate upload helper for drivers that suck (from st pov ;). */
{
unsigned bind = 0;
@@ -314,6 +307,8 @@ NineDevice9_ctor( struct NineDevice9 *This,
}
This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
+ This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS);
+ This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS);
nine_ff_init(This); /* initialize fixed function code */
@@ -2981,6 +2976,8 @@ NineDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
UINT BoolCount )
{
struct nine_state *state = This->update;
+ int i;
+ uint32_t bool_true = This->driver_caps.vs_integer ? 0xFFFFFFFF : fui(1.0f);
DBG("This=%p StartRegister=%u pConstantData=%p BoolCount=%u\n",
This, StartRegister, pConstantData, BoolCount);
@@ -2989,9 +2986,8 @@ NineDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(&state->vs_const_b[StartRegister],
- pConstantData,
- BoolCount * sizeof(state->vs_const_b[0]));
+ for (i = 0; i < BoolCount; i++)
+ state->vs_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
state->changed.vs_const_b |= ((1 << BoolCount) - 1) << StartRegister;
state->changed.group |= NINE_STATE_VS_CONST;
@@ -3006,14 +3002,14 @@ NineDevice9_GetVertexShaderConstantB( struct NineDevice9 *This,
UINT BoolCount )
{
const struct nine_state *state = &This->state;
+ int i;
user_assert(StartRegister < NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(pConstantData,
- &state->vs_const_b[StartRegister],
- BoolCount * sizeof(state->vs_const_b[0]));
+ for (i = 0; i < BoolCount; i++)
+ pConstantData[i] = state->vs_const_b[StartRegister + i] != 0 ? TRUE : FALSE;
return D3D_OK;
}
@@ -3286,6 +3282,8 @@ NineDevice9_SetPixelShaderConstantB( struct NineDevice9 *This,
UINT BoolCount )
{
struct nine_state *state = This->update;
+ int i;
+ uint32_t bool_true = This->driver_caps.ps_integer ? 0xFFFFFFFF : fui(1.0f);
DBG("This=%p StartRegister=%u pConstantData=%p BoolCount=%u\n",
This, StartRegister, pConstantData, BoolCount);
@@ -3294,9 +3292,8 @@ NineDevice9_SetPixelShaderConstantB( struct NineDevice9 *This,
user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(&state->ps_const_b[StartRegister],
- pConstantData,
- BoolCount * sizeof(state->ps_const_b[0]));
+ for (i = 0; i < BoolCount; i++)
+ state->ps_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
state->changed.ps_const_b |= ((1 << BoolCount) - 1) << StartRegister;
state->changed.group |= NINE_STATE_PS_CONST;
@@ -3311,14 +3308,14 @@ NineDevice9_GetPixelShaderConstantB( struct NineDevice9 *This,
UINT BoolCount )
{
const struct nine_state *state = &This->state;
+ int i;
user_assert(StartRegister < NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
user_assert(pConstantData, D3DERR_INVALIDCALL);
- memcpy(pConstantData,
- &state->ps_const_b[StartRegister],
- BoolCount * sizeof(state->ps_const_b[0]));
+ for (i = 0; i < BoolCount; i++)
+ pConstantData[i] = state->ps_const_b[StartRegister + i] ? TRUE : FALSE;
return D3D_OK;
}
diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h
index 3649e1b..9deea2c 100644
--- a/src/gallium/state_trackers/nine/device9.h
+++ b/src/gallium/state_trackers/nine/device9.h
@@ -79,8 +79,6 @@ struct NineDevice9
struct pipe_resource *constbuf_ps;
uint16_t max_vs_const_f;
uint16_t max_ps_const_f;
- uint32_t vs_bool_true;
- uint32_t ps_bool_true;
struct gen_mipmap_state *gen_mipmap;
@@ -111,6 +109,8 @@ struct NineDevice9
boolean user_vbufs;
boolean user_ibufs;
boolean window_space_position_support;
+ boolean vs_integer;
+ boolean ps_integer;
} driver_caps;
struct u_upload_mgr *upload;
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index e4e6788..2cd5140 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -347,12 +347,11 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
const int *const_i;
const BOOL *const_b;
uint32_t data_b[NINE_MAX_CONST_B];
- uint32_t b_true;
uint16_t dirty_i;
uint16_t dirty_b;
const unsigned usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE;
unsigned x = 0; /* silence warning */
- unsigned i, c, n;
+ unsigned i, c;
const struct nine_lconstf *lconstf;
struct nine_range *r, *p;
@@ -381,7 +380,6 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
dirty_b = device->state.changed.vs_const_b;
device->state.changed.vs_const_b = 0;
const_b = device->state.vs_const_b;
- b_true = device->vs_bool_true;
lconstf = &device->state.vs->lconstf;
device->state.ff.clobber.vs_const = TRUE;
@@ -406,7 +404,6 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
dirty_b = device->state.changed.ps_const_b;
device->state.changed.ps_const_b = 0;
const_b = device->state.ps_const_b;
- b_true = device->ps_bool_true;
lconstf = &device->state.ps->lconstf;
device->state.ff.clobber.ps_const = TRUE;
@@ -420,11 +417,10 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
i = ffs(dirty_b) - 1;
x = buf->width0 - (NINE_MAX_CONST_B - i) * 4;
c -= i;
- for (n = 0; n < c; ++n, ++i)
- data_b[n] = const_b[i] ? b_true : 0;
+ memcpy(data_b, &(const_b[i]), c * sizeof(uint32_t));
box.x = x;
- box.width = n * 4;
- DBG("upload ConstantB [%u .. %u]\n", x, x + n - 1);
+ box.width = c * 4;
+ DBG("upload ConstantB [%u .. %u]\n", x, x + c - 1);
pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data_b, 0, 0);
}
@@ -491,9 +487,7 @@ update_vs_constants_userbuf(struct NineDevice9 *device)
if (state->changed.vs_const_b) {
int *idst = (int *)&state->vs_const_f[4 * device->max_vs_const_f];
uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I];
- int i;
- for (i = 0; i < NINE_MAX_CONST_B; ++i)
- bdst[i] = state->vs_const_b[i] ? device->vs_bool_true : 0;
+ memcpy(bdst, state->vs_const_b, sizeof(state->vs_const_b));
state->changed.vs_const_b = 0;
}
@@ -557,9 +551,7 @@ update_ps_constants_userbuf(struct NineDevice9 *device)
if (state->changed.ps_const_b) {
int *idst = (int *)&state->ps_const_f[4 * device->max_ps_const_f];
uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I];
- int i;
- for (i = 0; i < NINE_MAX_CONST_B; ++i)
- bdst[i] = state->ps_const_b[i] ? device->ps_bool_true : 0;
+ memcpy(bdst, state->ps_const_b, sizeof(state->ps_const_b));
state->changed.ps_const_b = 0;
}
--
2.1.0
More information about the mesa-stable
mailing list