Commit b85c2a74 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Replace the "stateBlock" wined3d_device field with a wined3d_state structure.

parent fc5f9d47
......@@ -306,7 +306,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
struct wined3d_device *device = This->resource.device;
const struct wined3d_adapter *adapter = device->adapter;
const struct wined3d_stream_info *si = &device->stream_info;
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_state *state = &device->state;
BOOL support_d3dcolor = adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA];
BOOL support_xyzrhw = adapter->d3d_info.xyzrhw;
UINT stride_this_run = 0;
......
......@@ -2276,7 +2276,7 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const struct wined3d_device *device)
{
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_state *state = &device->state;
struct wined3d_surface **rts = state->fb->render_targets;
struct wined3d_shader *ps = state->pixel_shader;
DWORD rt_mask, rt_mask_bits;
......@@ -2350,7 +2350,7 @@ void context_state_drawbuf(struct wined3d_context *context, const struct wined3d
/* Context activation is done by the caller. */
BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device)
{
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_state *state = &device->state;
const struct StateEntry *state_table = context->state_table;
const struct wined3d_fb_state *fb = state->fb;
unsigned int i;
......
......@@ -91,7 +91,7 @@ static void drawStridedSlow(const struct wined3d_device *device, const struct wi
const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL;
UINT vx_index;
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_state *state = &device->state;
LONG SkipnStrides = startIdx;
BOOL pixelShader = use_ps(state);
BOOL specular_fog = FALSE;
......@@ -584,7 +584,7 @@ static void remove_vbos(const struct wined3d_gl_info *gl_info,
void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count,
UINT start_instance, UINT instance_count, BOOL indexed)
{
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_state *state = &device->state;
const struct wined3d_stream_info *stream_info;
struct wined3d_event_query *ib_query = NULL;
struct wined3d_stream_info si_emulated;
......
......@@ -1016,7 +1016,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
const struct wined3d_shader_reg_maps *reg_maps, const struct shader_glsl_ctx_priv *ctx_priv)
{
const struct wined3d_shader_version *version = &reg_maps->shader_version;
const struct wined3d_state *state = &shader->device->stateBlock->state;
const struct wined3d_state *state = &shader->device->state;
const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_fb_state *fb = &shader->device->fb;
......
......@@ -577,7 +577,7 @@ void state_unbind_resources(struct wined3d_state *state)
}
}
static void state_cleanup(struct wined3d_state *state)
void state_cleanup(struct wined3d_state *state)
{
unsigned int counter;
......@@ -598,7 +598,7 @@ static void state_cleanup(struct wined3d_state *state)
HeapFree(GetProcessHeap(), 0, state->ps_consts_f);
}
static HRESULT state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
HRESULT state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
{
unsigned int i;
......@@ -700,7 +700,7 @@ static void wined3d_state_record_lights(struct wined3d_state *dst_state, const s
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
{
const struct wined3d_state *src_state = &stateblock->device->stateBlock->state;
const struct wined3d_state *src_state = &stateblock->device->state;
unsigned int i;
DWORD map;
......@@ -1155,12 +1155,12 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
wined3d_device_set_clip_plane(device, i, &stateblock->state.clip_planes[i]);
}
stateblock->device->stateBlock->state.lowest_disabled_stage = MAX_TEXTURES - 1;
stateblock->device->state.lowest_disabled_stage = MAX_TEXTURES - 1;
for (i = 0; i < MAX_TEXTURES - 1; ++i)
{
if (stateblock->device->stateBlock->state.texture_states[i][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_DISABLE)
if (stateblock->device->state.texture_states[i][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_DISABLE)
{
stateblock->device->stateBlock->state.lowest_disabled_stage = i;
stateblock->device->state.lowest_disabled_stage = i;
break;
}
}
......@@ -1432,17 +1432,15 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
return hr;
}
/* The WINED3D_SBT_INIT stateblock type is used during initialization to
* produce a placeholder stateblock so other functions called can update a
* state block. */
if (type == WINED3D_SBT_INIT || type == WINED3D_SBT_RECORDED) return WINED3D_OK;
if (type == WINED3D_SBT_RECORDED)
return WINED3D_OK;
TRACE("Updating changed flags appropriate for type %#x.\n", type);
switch (type)
{
case WINED3D_SBT_ALL:
stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_init_lights(stateblock, device->state.light_map);
stateblock_savedstates_set_all(&stateblock->changed,
d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
break;
......@@ -1453,7 +1451,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
break;
case WINED3D_SBT_VERTEX_STATE:
stateblock_init_lights(stateblock, device->stateBlock->state.light_map);
stateblock_init_lights(stateblock, device->state.light_map);
stateblock_savedstates_set_vertex(&stateblock->changed,
d3d_info->limits.vs_uniform_count);
break;
......
......@@ -1779,6 +1779,72 @@ HRESULT wined3d_init(struct wined3d *wined3d, UINT version, DWORD flags) DECLSPE
BOOL wined3d_register_window(HWND window, struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
struct wined3d_stream_output
{
struct wined3d_buffer *buffer;
UINT offset;
};
struct wined3d_stream_state
{
struct wined3d_buffer *buffer;
UINT offset;
UINT stride;
UINT frequency;
UINT flags;
};
struct wined3d_state
{
const struct wined3d_fb_state *fb;
struct wined3d_vertex_declaration *vertex_declaration;
struct wined3d_stream_output stream_output[MAX_STREAM_OUT];
struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
struct wined3d_buffer *index_buffer;
enum wined3d_format_id index_format;
INT base_vertex_index;
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
GLenum gl_primitive_type;
struct wined3d_shader *vertex_shader;
struct wined3d_buffer *vs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS];
BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
struct wined3d_shader *geometry_shader;
struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS];
struct wined3d_shader *pixel_shader;
struct wined3d_buffer *ps_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS];
BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4];
float *ps_consts_f;
struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
DWORD lowest_disabled_stage;
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
struct wined3d_vec4 clip_planes[MAX_CLIPPLANES];
struct wined3d_material material;
struct wined3d_viewport viewport;
RECT scissor_rect;
/* Light hashmap. Collisions are handled using linked lists. */
#define LIGHTMAP_SIZE 43
#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
struct list light_map[LIGHTMAP_SIZE];
const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS];
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
};
/*****************************************************************************
* IWineD3DDevice implementation structure
*/
......@@ -1831,8 +1897,7 @@ struct wined3d_device
#define D3D8_PITCH_ALIGNMENT 4
unsigned char surface_alignment; /* Line Alignment of surfaces */
/* State block related */
struct wined3d_stateblock *stateBlock;
struct wined3d_state state;
struct wined3d_state *update_state;
struct wined3d_stateblock *recording;
......@@ -2354,72 +2419,6 @@ struct StageState {
DWORD state;
};
struct wined3d_stream_output
{
struct wined3d_buffer *buffer;
UINT offset;
};
struct wined3d_stream_state
{
struct wined3d_buffer *buffer;
UINT offset;
UINT stride;
UINT frequency;
UINT flags;
};
struct wined3d_state
{
const struct wined3d_fb_state *fb;
struct wined3d_vertex_declaration *vertex_declaration;
struct wined3d_stream_output stream_output[MAX_STREAM_OUT];
struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
struct wined3d_buffer *index_buffer;
enum wined3d_format_id index_format;
INT base_vertex_index;
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
GLenum gl_primitive_type;
struct wined3d_shader *vertex_shader;
struct wined3d_buffer *vs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS];
BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
struct wined3d_shader *geometry_shader;
struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS];
struct wined3d_shader *pixel_shader;
struct wined3d_buffer *ps_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS];
BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4];
float *ps_consts_f;
struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
DWORD lowest_disabled_stage;
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
struct wined3d_vec4 clip_planes[MAX_CLIPPLANES];
struct wined3d_material material;
struct wined3d_viewport viewport;
RECT scissor_rect;
/* Light hashmap . Collisions are handled using standard wine double linked lists */
#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
struct list light_map[LIGHTMAP_SIZE]; /* Hash map containing the lights */
const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
};
struct wined3d_stateblock
{
LONG ref; /* Note: Ref counting not required */
......@@ -2454,6 +2453,8 @@ struct wined3d_stateblock
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
HRESULT state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
void state_init_default(struct wined3d_state *state, struct wined3d_device *device) DECLSPEC_HIDDEN;
void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
......
......@@ -713,7 +713,6 @@ enum wined3d_query_type
enum wined3d_stateblock_type
{
WINED3D_SBT_INIT = 0,
WINED3D_SBT_ALL = 1,
WINED3D_SBT_PIXEL_STATE = 2,
WINED3D_SBT_VERTEX_STATE = 3,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment