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

wined3d: Store a pointer to the framebuffer state in struct wined3d_state.

parent eeb3625d
......@@ -629,31 +629,31 @@ static void shader_arb_vs_local_constants(const struct arb_vs_compiled_shader *g
static void shader_arb_load_constants(const struct wined3d_context *context, char usePixelShader, char useVertexShader)
{
struct wined3d_device *device = context->swapchain->device;
struct wined3d_stateblock *stateBlock = device->stateBlock;
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct shader_arb_priv *priv = device->shader_priv;
if (useVertexShader)
{
struct wined3d_shader *vshader = stateBlock->state.vertex_shader;
struct wined3d_shader *vshader = state->vertex_shader;
const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
/* Load DirectX 9 float constants for vertex shader */
device->highest_dirty_vs_const = shader_arb_load_constantsF(vshader, gl_info, GL_VERTEX_PROGRAM_ARB,
device->highest_dirty_vs_const, stateBlock->state.vs_consts_f, context->vshader_const_dirty);
shader_arb_vs_local_constants(gl_shader, context, &stateBlock->state);
device->highest_dirty_vs_const, state->vs_consts_f, context->vshader_const_dirty);
shader_arb_vs_local_constants(gl_shader, context, state);
}
if (usePixelShader)
{
struct wined3d_shader *pshader = stateBlock->state.pixel_shader;
struct wined3d_shader *pshader = state->pixel_shader;
const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog;
UINT rt_height = device->fb.render_targets[0]->resource.height;
UINT rt_height = state->fb->render_targets[0]->resource.height;
/* Load DirectX 9 float constants for pixel shader */
device->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
device->highest_dirty_ps_const, stateBlock->state.ps_consts_f, context->pshader_const_dirty);
shader_arb_ps_local_constants(gl_shader, context, &stateBlock->state, rt_height);
device->highest_dirty_ps_const, state->ps_consts_f, context->pshader_const_dirty);
shader_arb_ps_local_constants(gl_shader, context, state, rt_height);
}
}
......@@ -4612,7 +4612,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
}
else
{
UINT rt_height = device->fb.render_targets[0]->resource.height;
UINT rt_height = state->fb->render_targets[0]->resource.height;
shader_arb_ps_local_constants(compiled, context, state, rt_height);
}
......
......@@ -2149,10 +2149,11 @@ BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_d
return TRUE;
}
static inline DWORD find_draw_buffers_mask(struct wined3d_context *context, struct wined3d_device *device)
static DWORD find_draw_buffers_mask(struct wined3d_context *context, struct wined3d_device *device)
{
struct wined3d_shader *ps = device->stateBlock->state.pixel_shader;
struct wined3d_surface **rts = device->fb.render_targets;
const struct wined3d_state *state = &device->stateBlock->state;
struct wined3d_surface **rts = state->fb->render_targets;
struct wined3d_shader *ps = state->pixel_shader;
DWORD rt_mask, rt_mask_bits;
unsigned int i;
......@@ -2176,10 +2177,11 @@ static inline DWORD find_draw_buffers_mask(struct wined3d_context *context, stru
}
/* GL locking and context activation are done by the caller */
void context_state_fb(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
void context_state_fb(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_state *state = &stateblock->state;
struct wined3d_device *device = stateblock->device;
const struct wined3d_fb_state *fb = &device->fb;
const struct wined3d_fb_state *fb = state->fb;
DWORD rt_mask = find_draw_buffers_mask(context, device);
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
......@@ -2222,8 +2224,9 @@ void context_state_drawbuf(DWORD state, struct wined3d_stateblock *stateblock, s
/* Context activation is done by the caller. */
BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device)
{
struct wined3d_stateblock *stateblock = device->stateBlock;
const struct StateEntry *state_table = device->StateTable;
const struct wined3d_fb_state *fb = &device->fb;
const struct wined3d_fb_state *fb = stateblock->state.fb;
unsigned int i;
if (!context_validate_rt_config(context->gl_info->limits.buffers,
......@@ -2250,7 +2253,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
DWORD idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
BYTE shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
context->isStateDirty[idx] &= ~(1 << shift);
state_table[rep].apply(rep, device->stateBlock, context);
state_table[rep].apply(rep, stateblock, context);
}
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
......
......@@ -1879,7 +1879,7 @@ void find_ps_compile_args(const struct wined3d_state *state,
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
if (state->render_states[WINED3DRS_SRGBWRITEENABLE])
{
struct wined3d_surface *rt = device->fb.render_targets[0];
const struct wined3d_surface *rt = state->fb->render_targets[0];
if (rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
}
......
......@@ -1099,6 +1099,8 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
memcpy(&state->transforms[WINED3DTS_WORLDMATRIX(i)], identity, sizeof(identity));
}
state->fb = &device->fb;
TRACE("Render states\n");
/* Render states: */
if (device->auto_depth_stencil)
......
......@@ -2787,7 +2787,7 @@ void gen_ffp_frag_op(const struct wined3d_device *device, const struct wined3d_s
unsigned int i;
DWORD ttff;
DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2;
const struct wined3d_surface *rt = device->fb.render_targets[0];
const struct wined3d_surface *rt = state->fb->render_targets[0];
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
for (i = 0; i < gl_info->limits.texture_stages; ++i)
......
......@@ -2238,6 +2238,8 @@ struct wined3d_stream_state
struct wined3d_state
{
const struct wined3d_fb_state *fb;
struct wined3d_vertex_declaration *vertex_declaration;
struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
BOOL user_stream;
......
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