st/nine: Move vtxbuf to nine_context
Part of the refactor to move all gallium calls to nine_state.c, and have all internal states required for those calls in nine_context. Signed-off-by: Axel Davy <axel.davy@ens.fr>
This commit is contained in:
parent
aea7a019ef
commit
848ffc81e4
|
@ -3404,22 +3404,29 @@ NineDevice9_SetStreamSource( struct NineDevice9 *This,
|
||||||
user_assert(StreamNumber < This->caps.MaxStreams, D3DERR_INVALIDCALL);
|
user_assert(StreamNumber < This->caps.MaxStreams, D3DERR_INVALIDCALL);
|
||||||
user_assert(Stride <= This->caps.MaxStreamStride, D3DERR_INVALIDCALL);
|
user_assert(Stride <= This->caps.MaxStreamStride, D3DERR_INVALIDCALL);
|
||||||
|
|
||||||
if (likely(!This->is_recording)) {
|
if (unlikely(This->is_recording)) {
|
||||||
if (state->stream[i] == NineVertexBuffer9(pStreamData) &&
|
nine_bind(&state->stream[i], pStreamData);
|
||||||
state->vtxbuf[i].stride == Stride &&
|
state->changed.vtxbuf |= 1 << StreamNumber;
|
||||||
state->vtxbuf[i].buffer_offset == OffsetInBytes)
|
|
||||||
return D3D_OK;
|
|
||||||
}
|
|
||||||
nine_bind(&state->stream[i], pStreamData);
|
|
||||||
|
|
||||||
state->changed.vtxbuf |= 1 << StreamNumber;
|
|
||||||
|
|
||||||
if (pStreamData) {
|
|
||||||
state->vtxbuf[i].stride = Stride;
|
state->vtxbuf[i].stride = Stride;
|
||||||
state->vtxbuf[i].buffer_offset = OffsetInBytes;
|
state->vtxbuf[i].buffer_offset = OffsetInBytes;
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
pipe_resource_reference(&state->vtxbuf[i].buffer,
|
|
||||||
pStreamData ? NineVertexBuffer9_GetResource(pVBuf9) : NULL);
|
if (state->stream[i] == NineVertexBuffer9(pStreamData) &&
|
||||||
|
state->vtxbuf[i].stride == Stride &&
|
||||||
|
state->vtxbuf[i].buffer_offset == OffsetInBytes)
|
||||||
|
return D3D_OK;
|
||||||
|
|
||||||
|
state->vtxbuf[i].stride = Stride;
|
||||||
|
state->vtxbuf[i].buffer_offset = OffsetInBytes;
|
||||||
|
|
||||||
|
nine_bind(&state->stream[i], pStreamData);
|
||||||
|
|
||||||
|
nine_context_set_stream_source(This,
|
||||||
|
StreamNumber,
|
||||||
|
pVBuf9,
|
||||||
|
OffsetInBytes,
|
||||||
|
Stride);
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -668,9 +668,9 @@ update_vertex_elements(struct NineDevice9 *device)
|
||||||
|
|
||||||
if (context->dummy_vbo_bound_at != dummy_vbo_stream) {
|
if (context->dummy_vbo_bound_at != dummy_vbo_stream) {
|
||||||
if (context->dummy_vbo_bound_at >= 0)
|
if (context->dummy_vbo_bound_at >= 0)
|
||||||
state->changed.vtxbuf |= 1 << context->dummy_vbo_bound_at;
|
context->changed.vtxbuf |= 1 << context->dummy_vbo_bound_at;
|
||||||
if (dummy_vbo_stream >= 0) {
|
if (dummy_vbo_stream >= 0) {
|
||||||
state->changed.vtxbuf |= 1 << dummy_vbo_stream;
|
context->changed.vtxbuf |= 1 << dummy_vbo_stream;
|
||||||
context->vbo_bound_done = FALSE;
|
context->vbo_bound_done = FALSE;
|
||||||
}
|
}
|
||||||
context->dummy_vbo_bound_at = dummy_vbo_stream;
|
context->dummy_vbo_bound_at = dummy_vbo_stream;
|
||||||
|
@ -686,9 +686,8 @@ update_vertex_buffers(struct NineDevice9 *device)
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = device->pipe;
|
struct pipe_context *pipe = device->pipe;
|
||||||
struct nine_context *context = &device->context;
|
struct nine_context *context = &device->context;
|
||||||
struct nine_state *state = &device->state;
|
|
||||||
struct pipe_vertex_buffer dummy_vtxbuf;
|
struct pipe_vertex_buffer dummy_vtxbuf;
|
||||||
uint32_t mask = state->changed.vtxbuf;
|
uint32_t mask = context->changed.vtxbuf;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
DBG("mask=%x\n", mask);
|
DBG("mask=%x\n", mask);
|
||||||
|
@ -708,14 +707,14 @@ update_vertex_buffers(struct NineDevice9 *device)
|
||||||
|
|
||||||
for (i = 0; mask; mask >>= 1, ++i) {
|
for (i = 0; mask; mask >>= 1, ++i) {
|
||||||
if (mask & 1) {
|
if (mask & 1) {
|
||||||
if (state->vtxbuf[i].buffer)
|
if (context->vtxbuf[i].buffer)
|
||||||
pipe->set_vertex_buffers(pipe, i, 1, &state->vtxbuf[i]);
|
pipe->set_vertex_buffers(pipe, i, 1, &context->vtxbuf[i]);
|
||||||
else
|
else
|
||||||
pipe->set_vertex_buffers(pipe, i, 1, NULL);
|
pipe->set_vertex_buffers(pipe, i, 1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state->changed.vtxbuf = 0;
|
context->changed.vtxbuf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline boolean
|
static inline boolean
|
||||||
|
@ -1064,7 +1063,7 @@ nine_update_state(struct NineDevice9 *device)
|
||||||
prepare_ps_constants_userbuf(device);
|
prepare_ps_constants_userbuf(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->changed.vtxbuf)
|
if (context->changed.vtxbuf)
|
||||||
update_vertex_buffers(device);
|
update_vertex_buffers(device);
|
||||||
|
|
||||||
if (context->commit & NINE_STATE_COMMIT_BLEND)
|
if (context->commit & NINE_STATE_COMMIT_BLEND)
|
||||||
|
@ -1240,6 +1239,26 @@ nine_context_set_texture(struct NineDevice9 *device,
|
||||||
state->changed.group |= NINE_STATE_TEXTURE;
|
state->changed.group |= NINE_STATE_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nine_context_set_stream_source(struct NineDevice9 *device,
|
||||||
|
UINT StreamNumber,
|
||||||
|
struct NineVertexBuffer9 *pVBuf9,
|
||||||
|
UINT OffsetInBytes,
|
||||||
|
UINT Stride)
|
||||||
|
{
|
||||||
|
struct nine_context *context = &device->context;
|
||||||
|
const unsigned i = StreamNumber;
|
||||||
|
|
||||||
|
context->changed.vtxbuf |= 1 << StreamNumber;
|
||||||
|
|
||||||
|
if (pVBuf9) {
|
||||||
|
context->vtxbuf[i].stride = Stride;
|
||||||
|
context->vtxbuf[i].buffer_offset = OffsetInBytes;
|
||||||
|
}
|
||||||
|
pipe_resource_reference(&context->vtxbuf[i].buffer,
|
||||||
|
pVBuf9 ? NineVertexBuffer9_GetResource(pVBuf9) : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nine_context_apply_stateblock(struct NineDevice9 *device,
|
nine_context_apply_stateblock(struct NineDevice9 *device,
|
||||||
const struct nine_state *src)
|
const struct nine_state *src)
|
||||||
|
@ -1272,6 +1291,22 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
|
||||||
nine_bind(&context->texture[s], src->texture[s]);
|
nine_bind(&context->texture[s], src->texture[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Vertex buffers */
|
||||||
|
if (src->changed.vtxbuf | src->changed.stream_freq) {
|
||||||
|
uint32_t m = src->changed.vtxbuf | src->changed.stream_freq;
|
||||||
|
for (i = 0; m; ++i, m >>= 1) {
|
||||||
|
if (src->changed.vtxbuf & (1 << i)) {
|
||||||
|
if (src->stream[i]) {
|
||||||
|
context->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
|
||||||
|
pipe_resource_reference(&context->vtxbuf[i].buffer,
|
||||||
|
src->stream[i] ? NineVertexBuffer9_GetResource(src->stream[i]) : NULL);
|
||||||
|
context->vtxbuf[i].stride = src->vtxbuf[i].stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context->changed.vtxbuf |= src->changed.vtxbuf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1702,7 +1737,7 @@ void nine_state_restore_non_cso(struct NineDevice9 *device)
|
||||||
struct nine_context *context = &device->context;
|
struct nine_context *context = &device->context;
|
||||||
|
|
||||||
state->changed.group = NINE_STATE_ALL;
|
state->changed.group = NINE_STATE_ALL;
|
||||||
state->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
|
context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
|
||||||
state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
|
state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
|
||||||
context->commit |= NINE_STATE_COMMIT_CONST_VS | NINE_STATE_COMMIT_CONST_PS;
|
context->commit |= NINE_STATE_COMMIT_CONST_VS | NINE_STATE_COMMIT_CONST_PS;
|
||||||
}
|
}
|
||||||
|
@ -1749,7 +1784,7 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps,
|
||||||
/* Set changed flags to initialize driver.
|
/* Set changed flags to initialize driver.
|
||||||
*/
|
*/
|
||||||
state->changed.group = NINE_STATE_ALL;
|
state->changed.group = NINE_STATE_ALL;
|
||||||
state->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
|
context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
|
||||||
state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
|
state->changed.ucp = (1 << PIPE_MAX_CLIP_PLANES) - 1;
|
||||||
|
|
||||||
state->ff.changed.transform[0] = ~0;
|
state->ff.changed.transform[0] = ~0;
|
||||||
|
@ -1780,10 +1815,9 @@ nine_state_clear(struct nine_state *state, const boolean device)
|
||||||
nine_bind(&state->vs, NULL);
|
nine_bind(&state->vs, NULL);
|
||||||
nine_bind(&state->ps, NULL);
|
nine_bind(&state->ps, NULL);
|
||||||
nine_bind(&state->vdecl, NULL);
|
nine_bind(&state->vdecl, NULL);
|
||||||
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) {
|
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
|
||||||
nine_bind(&state->stream[i], NULL);
|
nine_bind(&state->stream[i], NULL);
|
||||||
pipe_resource_reference(&state->vtxbuf[i].buffer, NULL);
|
|
||||||
}
|
|
||||||
nine_bind(&state->idxbuf, NULL);
|
nine_bind(&state->idxbuf, NULL);
|
||||||
for (i = 0; i < NINE_MAX_SAMPLERS; ++i) {
|
for (i = 0; i < NINE_MAX_SAMPLERS; ++i) {
|
||||||
if (device &&
|
if (device &&
|
||||||
|
@ -1799,6 +1833,9 @@ nine_context_clear(struct nine_context *context)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
|
||||||
|
pipe_resource_reference(&context->vtxbuf[i].buffer, NULL);
|
||||||
|
|
||||||
for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
|
for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
|
||||||
nine_bind(&context->texture[i], NULL);
|
nine_bind(&context->texture[i], NULL);
|
||||||
}
|
}
|
||||||
|
@ -1922,11 +1959,12 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_
|
||||||
|
|
||||||
for (i = 0; mask; mask >>= 1, ++i) {
|
for (i = 0; mask; mask >>= 1, ++i) {
|
||||||
if (mask & 1) {
|
if (mask & 1) {
|
||||||
if (state->vtxbuf[i].buffer) {
|
if (state->stream[i]) {
|
||||||
struct pipe_resource *buf;
|
struct pipe_resource *buf;
|
||||||
struct pipe_box box;
|
struct pipe_box box;
|
||||||
|
|
||||||
vtxbuf = state->vtxbuf[i];
|
vtxbuf = state->vtxbuf[i];
|
||||||
|
vtxbuf.buffer = NineVertexBuffer9_GetResource(state->stream[i]);
|
||||||
|
|
||||||
DBG("Locking %p (offset %d, length %d)\n", vtxbuf.buffer,
|
DBG("Locking %p (offset %d, length %d)\n", vtxbuf.buffer,
|
||||||
vtxbuf.buffer_offset, num_vertices * vtxbuf.stride);
|
vtxbuf.buffer_offset, num_vertices * vtxbuf.stride);
|
||||||
|
|
|
@ -136,7 +136,7 @@ struct nine_state
|
||||||
struct {
|
struct {
|
||||||
uint32_t group;
|
uint32_t group;
|
||||||
uint32_t rs[(NINED3DRS_COUNT + 31) / 32]; /* stateblocks only */
|
uint32_t rs[(NINED3DRS_COUNT + 31) / 32]; /* stateblocks only */
|
||||||
uint32_t vtxbuf;
|
uint32_t vtxbuf; /* stateblocks only */
|
||||||
uint32_t stream_freq;
|
uint32_t stream_freq;
|
||||||
uint32_t texture; /* stateblocks only */
|
uint32_t texture; /* stateblocks only */
|
||||||
uint16_t sampler[NINE_MAX_SAMPLERS];
|
uint16_t sampler[NINE_MAX_SAMPLERS];
|
||||||
|
@ -178,7 +178,7 @@ struct nine_state
|
||||||
|
|
||||||
struct NineIndexBuffer9 *idxbuf;
|
struct NineIndexBuffer9 *idxbuf;
|
||||||
struct NineVertexBuffer9 *stream[PIPE_MAX_ATTRIBS];
|
struct NineVertexBuffer9 *stream[PIPE_MAX_ATTRIBS];
|
||||||
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
|
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; /* vtxbuf.buffer unused */
|
||||||
UINT stream_freq[PIPE_MAX_ATTRIBS];
|
UINT stream_freq[PIPE_MAX_ATTRIBS];
|
||||||
uint32_t stream_instancedata_mask; /* derived from stream_freq */
|
uint32_t stream_instancedata_mask; /* derived from stream_freq */
|
||||||
|
|
||||||
|
@ -215,6 +215,10 @@ struct nine_state
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nine_context {
|
struct nine_context {
|
||||||
|
struct {
|
||||||
|
uint32_t vtxbuf;
|
||||||
|
} changed;
|
||||||
|
|
||||||
uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
|
uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -224,6 +228,7 @@ struct nine_context {
|
||||||
|
|
||||||
uint8_t rt_mask;
|
uint8_t rt_mask;
|
||||||
|
|
||||||
|
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
|
||||||
uint32_t stream_usage_mask; /* derived from VS and vdecl */
|
uint32_t stream_usage_mask; /* derived from VS and vdecl */
|
||||||
|
|
||||||
DWORD rs[NINED3DRS_COUNT];
|
DWORD rs[NINED3DRS_COUNT];
|
||||||
|
@ -280,6 +285,13 @@ nine_context_set_texture(struct NineDevice9 *device,
|
||||||
DWORD Stage,
|
DWORD Stage,
|
||||||
struct NineBaseTexture9 *tex);
|
struct NineBaseTexture9 *tex);
|
||||||
|
|
||||||
|
void
|
||||||
|
nine_context_set_stream_source(struct NineDevice9 *device,
|
||||||
|
UINT StreamNumber,
|
||||||
|
struct NineVertexBuffer9 *pVBuf9,
|
||||||
|
UINT OffsetInBytes,
|
||||||
|
UINT Stride);
|
||||||
|
|
||||||
void
|
void
|
||||||
nine_context_apply_stateblock(struct NineDevice9 *device,
|
nine_context_apply_stateblock(struct NineDevice9 *device,
|
||||||
const struct nine_state *src);
|
const struct nine_state *src);
|
||||||
|
|
|
@ -276,7 +276,6 @@ nine_state_copy_common(struct NineDevice9 *device,
|
||||||
nine_bind(&dst->stream[i], src->stream[i]);
|
nine_bind(&dst->stream[i], src->stream[i]);
|
||||||
if (src->stream[i]) {
|
if (src->stream[i]) {
|
||||||
dst->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
|
dst->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
|
||||||
pipe_resource_reference(&dst->vtxbuf[i].buffer, src->vtxbuf[i].buffer);
|
|
||||||
dst->vtxbuf[i].stride = src->vtxbuf[i].stride;
|
dst->vtxbuf[i].stride = src->vtxbuf[i].stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +462,6 @@ nine_state_copy_common_all(struct NineDevice9 *device,
|
||||||
nine_bind(&dst->stream[i], src->stream[i]);
|
nine_bind(&dst->stream[i], src->stream[i]);
|
||||||
if (src->stream[i]) {
|
if (src->stream[i]) {
|
||||||
dst->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
|
dst->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
|
||||||
pipe_resource_reference(&dst->vtxbuf[i].buffer, src->vtxbuf[i].buffer);
|
|
||||||
dst->vtxbuf[i].stride = src->vtxbuf[i].stride;
|
dst->vtxbuf[i].stride = src->vtxbuf[i].stride;
|
||||||
}
|
}
|
||||||
dst->stream_freq[i] = src->stream_freq[i];
|
dst->stream_freq[i] = src->stream_freq[i];
|
||||||
|
|
Loading…
Reference in New Issue