st/nine: Rework rasterizer states

Separate state preparation and state commit

Signed-off-by: Axel Davy <axel.davy@ens.fr>
This commit is contained in:
Axel Davy 2015-03-24 10:16:59 +01:00
parent 71616d0c50
commit 5a2302b5ec
4 changed files with 22 additions and 12 deletions

View file

@ -69,13 +69,12 @@ nine_convert_dsa_state(struct pipe_depth_stencil_alpha_state *dsa_state,
*dsa_state = dsa;
}
/* TODO: Keep a static copy in device so we don't have to memset every time ? */
void
nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs)
nine_convert_rasterizer_state(struct pipe_rasterizer_state *rast_state, const DWORD *rs)
{
struct pipe_rasterizer_state rast;
memset(&rast, 0, sizeof(rast)); /* memcmp safety */
memset(&rast, 0, sizeof(rast));
rast.flatshade = rs[D3DRS_SHADEMODE] == D3DSHADE_FLAT;
/* rast.light_twoside = 0; */
@ -122,7 +121,7 @@ nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs)
rast.offset_scale = asfloat(rs[D3DRS_SLOPESCALEDEPTHBIAS]);
/* rast.offset_clamp = 0.0f; */
cso_set_rasterizer(ctx, &rast);
*rast_state = rast;
}
static inline void

View file

@ -38,7 +38,7 @@ extern const enum pipe_format nine_d3d9_to_pipe_format_map[120];
extern const D3DFORMAT nine_pipe_to_d3d9_format_map[PIPE_FORMAT_COUNT];
void nine_convert_dsa_state(struct pipe_depth_stencil_alpha_state *, const DWORD *);
void nine_convert_rasterizer_state(struct cso_context *, const DWORD *);
void nine_convert_rasterizer_state(struct pipe_rasterizer_state *, const DWORD *);
void nine_convert_blend_state(struct cso_context *, const DWORD *);
void nine_convert_sampler_state(struct cso_context *, int idx, const DWORD *);

View file

@ -46,6 +46,13 @@ prepare_dsa(struct NineDevice9 *device)
device->state.commit |= NINE_STATE_COMMIT_DSA;
}
static inline void
prepare_rasterizer(struct NineDevice9 *device)
{
nine_convert_rasterizer_state(&device->state.pipe.rast, device->state.rs);
device->state.commit |= NINE_STATE_COMMIT_RASTERIZER;
}
/* State preparation incremental */
/* State preparation + State commit */
@ -195,12 +202,6 @@ update_blend(struct NineDevice9 *device)
nine_convert_blend_state(device->cso, device->state.rs);
}
static inline void
update_rasterizer(struct NineDevice9 *device)
{
nine_convert_rasterizer_state(device->cso, device->state.rs);
}
/* Loop through VS inputs and pick the vertex elements with the declared
* usage from the vertex declaration, then insert the instance divisor from
* the stream source frequency setting.
@ -858,6 +859,12 @@ commit_scissor(struct NineDevice9 *device)
pipe->set_scissor_states(pipe, 0, 1, &device->state.scissor);
}
static inline void
commit_rasterizer(struct NineDevice9 *device)
{
cso_set_rasterizer(device->cso, &device->state.pipe.rast);
}
static inline void
commit_index_buffer(struct NineDevice9 *device)
{
@ -958,7 +965,7 @@ nine_update_state(struct NineDevice9 *device)
group |= update_vs(device);
if (group & NINE_STATE_RASTERIZER)
update_rasterizer(device);
prepare_rasterizer(device);
if (group & NINE_STATE_PS)
group |= update_ps(device);
@ -1012,6 +1019,8 @@ nine_update_state(struct NineDevice9 *device)
if (state->commit & NINE_STATE_COMMIT_DSA)
commit_dsa(device);
if (state->commit & NINE_STATE_COMMIT_RASTERIZER)
commit_rasterizer(device);
state->commit = 0;

View file

@ -79,6 +79,7 @@
#define NINE_STATE_UNHANDLED (1 << 24)
#define NINE_STATE_COMMIT_DSA (1 << 0)
#define NINE_STATE_COMMIT_RASTERIZER (1 << 1)
#define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4
@ -214,6 +215,7 @@ struct nine_state
uint32_t commit;
struct {
struct pipe_depth_stencil_alpha_state dsa;
struct pipe_rasterizer_state rast;
} pipe;
};