Commit 79787263 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Store pointer to device in wined3d_context.

parent 7756d6ba
...@@ -732,7 +732,8 @@ static void shader_arb_update_float_vertex_constants(struct wined3d_device *devi ...@@ -732,7 +732,8 @@ static void shader_arb_update_float_vertex_constants(struct wined3d_device *devi
/* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
* context. On a context switch the old context will be fully dirtified */ * context. On a context switch the old context will be fully dirtified */
if (!context || context->swapchain->device != device) return; if (!context || context->device != device)
return;
memset(priv->vshader_const_dirty + start, 1, sizeof(*priv->vshader_const_dirty) * count); memset(priv->vshader_const_dirty + start, 1, sizeof(*priv->vshader_const_dirty) * count);
priv->highest_dirty_vs_const = max(priv->highest_dirty_vs_const, start + count); priv->highest_dirty_vs_const = max(priv->highest_dirty_vs_const, start + count);
...@@ -745,7 +746,8 @@ static void shader_arb_update_float_pixel_constants(struct wined3d_device *devic ...@@ -745,7 +746,8 @@ static void shader_arb_update_float_pixel_constants(struct wined3d_device *devic
/* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
* context. On a context switch the old context will be fully dirtified */ * context. On a context switch the old context will be fully dirtified */
if (!context || context->swapchain->device != device) return; if (!context || context->device != device)
return;
memset(priv->pshader_const_dirty + start, 1, sizeof(*priv->pshader_const_dirty) * count); memset(priv->pshader_const_dirty + start, 1, sizeof(*priv->pshader_const_dirty) * count);
priv->highest_dirty_ps_const = max(priv->highest_dirty_ps_const, start + count); priv->highest_dirty_ps_const = max(priv->highest_dirty_ps_const, start + count);
...@@ -5051,10 +5053,7 @@ static void shader_arb_free_context_data(struct wined3d_context *context) ...@@ -5051,10 +5053,7 @@ static void shader_arb_free_context_data(struct wined3d_context *context)
{ {
struct shader_arb_priv *priv; struct shader_arb_priv *priv;
if (!context->swapchain) priv = context->device->shader_priv;
return;
priv = context->swapchain->device->shader_priv;
if (priv->last_context == context) if (priv->last_context == context)
priv->last_context = NULL; priv->last_context = NULL;
} }
...@@ -5948,8 +5947,8 @@ static DWORD arbfp_get_emul_mask(const struct wined3d_gl_info *gl_info) ...@@ -5948,8 +5947,8 @@ static DWORD arbfp_get_emul_mask(const struct wined3d_gl_info *gl_info)
static void state_texfactor_arbfp(struct wined3d_context *context, static void state_texfactor_arbfp(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) const struct wined3d_state *state, DWORD state_id)
{ {
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
struct wined3d_color color; struct wined3d_color color;
if (device->shader_backend == &arb_program_shader_backend) if (device->shader_backend == &arb_program_shader_backend)
...@@ -5975,8 +5974,8 @@ static void state_tss_constant_arbfp(struct wined3d_context *context, ...@@ -5975,8 +5974,8 @@ static void state_tss_constant_arbfp(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) const struct wined3d_state *state, DWORD state_id)
{ {
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
struct wined3d_color color; struct wined3d_color color;
if (device->shader_backend == &arb_program_shader_backend) if (device->shader_backend == &arb_program_shader_backend)
...@@ -6002,8 +6001,8 @@ static void state_tss_constant_arbfp(struct wined3d_context *context, ...@@ -6002,8 +6001,8 @@ static void state_tss_constant_arbfp(struct wined3d_context *context,
static void state_arb_specularenable(struct wined3d_context *context, static void state_arb_specularenable(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) const struct wined3d_state *state, DWORD state_id)
{ {
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
float col[4]; float col[4];
if (device->shader_backend == &arb_program_shader_backend) if (device->shader_backend == &arb_program_shader_backend)
...@@ -6037,8 +6036,8 @@ static void state_arb_specularenable(struct wined3d_context *context, ...@@ -6037,8 +6036,8 @@ static void state_arb_specularenable(struct wined3d_context *context,
static void set_bumpmat_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void set_bumpmat_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
float mat[2][2]; float mat[2][2];
context->constant_update_mask |= WINED3D_SHADER_CONST_PS_BUMP_ENV; context->constant_update_mask |= WINED3D_SHADER_CONST_PS_BUMP_ENV;
...@@ -6068,8 +6067,8 @@ static void tex_bumpenvlum_arbfp(struct wined3d_context *context, ...@@ -6068,8 +6067,8 @@ static void tex_bumpenvlum_arbfp(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id) const struct wined3d_state *state, DWORD state_id)
{ {
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
float param[4]; float param[4];
context->constant_update_mask |= WINED3D_SHADER_CONST_PS_BUMP_ENV; context->constant_update_mask |= WINED3D_SHADER_CONST_PS_BUMP_ENV;
...@@ -6127,10 +6126,10 @@ static void alpha_test_arbfp(struct wined3d_context *context, const struct wined ...@@ -6127,10 +6126,10 @@ static void alpha_test_arbfp(struct wined3d_context *context, const struct wined
static void color_key_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void color_key_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
struct wined3d_device *device = context->swapchain->device; const struct wined3d_texture *texture = state->textures[0];
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
struct wined3d_color float_key[2]; struct wined3d_color float_key[2];
const struct wined3d_texture *texture = state->textures[0];
if (!texture) if (!texture)
return; return;
...@@ -6682,8 +6681,8 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, con ...@@ -6682,8 +6681,8 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, con
static void fragment_prog_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void fragment_prog_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
const struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_device *device = context->device;
struct shader_arb_priv *priv = device->fragment_priv; struct shader_arb_priv *priv = device->fragment_priv;
BOOL use_pshader = use_ps(state); BOOL use_pshader = use_ps(state);
struct ffp_frag_settings settings; struct ffp_frag_settings settings;
......
...@@ -1012,7 +1012,7 @@ static void atifs_stage_constant(struct wined3d_context *context, const struct w ...@@ -1012,7 +1012,7 @@ static void atifs_stage_constant(struct wined3d_context *context, const struct w
static void set_tex_op_atifs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void set_tex_op_atifs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
const struct wined3d_device *device = context->swapchain->device; const struct wined3d_device *device = context->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info; const struct wined3d_d3d_info *d3d_info = context->d3d_info;
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data; struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
......
...@@ -1827,6 +1827,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1827,6 +1827,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
context_invalidate_state(ret, state); context_invalidate_state(ret, state);
} }
ret->device = device;
ret->swapchain = swapchain; ret->swapchain = swapchain;
ret->current_rt.texture = target; ret->current_rt.texture = target;
ret->current_rt.sub_resource_idx = 0; ret->current_rt.sub_resource_idx = 0;
...@@ -2380,7 +2381,7 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint ...@@ -2380,7 +2381,7 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint
if (old_texture_type != target) if (old_texture_type != target)
{ {
const struct wined3d_device *device = context->swapchain->device; const struct wined3d_device *device = context->device;
switch (old_texture_type) switch (old_texture_type)
{ {
...@@ -3307,8 +3308,8 @@ static void context_load_shader_resources(struct wined3d_context *context, const ...@@ -3307,8 +3308,8 @@ static void context_load_shader_resources(struct wined3d_context *context, const
static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state) static void context_bind_shader_resources(struct wined3d_context *context, const struct wined3d_state *state)
{ {
const struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_device *device = context->device;
struct wined3d_shader_sampler_map_entry *entry; struct wined3d_shader_sampler_map_entry *entry;
struct wined3d_shader_resource_view *view; struct wined3d_shader_resource_view *view;
struct wined3d_sampler *sampler; struct wined3d_sampler *sampler;
...@@ -3536,7 +3537,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str ...@@ -3536,7 +3537,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
{ {
if (current_context if (current_context
&& current_context->current_rt.texture && current_context->current_rt.texture
&& current_context->swapchain->device == device) && current_context->device == device)
{ {
target_texture = current_context->current_rt.texture; target_texture = current_context->current_rt.texture;
target_sub_resource_idx = current_context->current_rt.sub_resource_idx; target_sub_resource_idx = current_context->current_rt.sub_resource_idx;
...@@ -3569,7 +3570,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str ...@@ -3569,7 +3570,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
/* Stay with the current context if possible. Otherwise use the /* Stay with the current context if possible. Otherwise use the
* context for the primary swapchain. */ * context for the primary swapchain. */
if (current_context && current_context->swapchain->device == device) if (current_context && current_context->device == device)
context = current_context; context = current_context;
else else
context = swapchain_get_context(device->swapchains[0]); context = swapchain_get_context(device->swapchains[0]);
......
...@@ -1160,7 +1160,7 @@ static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_con ...@@ -1160,7 +1160,7 @@ static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_con
return; return;
get_modelview_matrix(context, state, 0, &mv); get_modelview_matrix(context, state, 0, &mv);
if (context->swapchain->device->wined3d->flags & WINED3D_LEGACY_FFP_LIGHTING) if (context->device->wined3d->flags & WINED3D_LEGACY_FFP_LIGHTING)
invert_matrix_3d(&mv, &mv); invert_matrix_3d(&mv, &mv);
else else
invert_matrix(&mv, &mv); invert_matrix(&mv, &mv);
......
...@@ -1712,7 +1712,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3 ...@@ -1712,7 +1712,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL); gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL);
checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)"); checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
if (context->swapchain->device->wined3d->flags & WINED3D_LEGACY_DEPTH_BIAS) if (context->device->wined3d->flags & WINED3D_LEGACY_DEPTH_BIAS)
{ {
float bias = -(float)const_bias.d; float bias = -(float)const_bias.d;
gl_info->gl_ops.gl.p_glPolygonOffset(bias, bias); gl_info->gl_ops.gl.p_glPolygonOffset(bias, bias);
...@@ -3620,7 +3620,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state ...@@ -3620,7 +3620,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
} }
else else
{ {
struct wined3d_device *device = context->swapchain->device; struct wined3d_device *device = context->device;
struct wined3d_sampler *sampler; struct wined3d_sampler *sampler;
struct wine_rb_entry *entry; struct wine_rb_entry *entry;
...@@ -3841,8 +3841,8 @@ static void state_vertexblend_w(struct wined3d_context *context, const struct wi ...@@ -3841,8 +3841,8 @@ static void state_vertexblend_w(struct wined3d_context *context, const struct wi
static void state_vertexblend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void state_vertexblend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
enum wined3d_vertex_blend_flags val = state->render_states[WINED3D_RS_VERTEXBLEND]; enum wined3d_vertex_blend_flags val = state->render_states[WINED3D_RS_VERTEXBLEND];
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
static unsigned int once; static unsigned int once;
switch (val) switch (val)
...@@ -3934,7 +3934,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d ...@@ -3934,7 +3934,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d
transform_world(context, state, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))); transform_world(context, state, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
/* Avoid looping over a number of matrices if the app never used the functionality */ /* Avoid looping over a number of matrices if the app never used the functionality */
if (context->swapchain->device->vertexBlendUsed) if (context->device->vertexBlendUsed)
{ {
for (k = 1; k < gl_info->limits.blends; ++k) for (k = 1; k < gl_info->limits.blends; ++k)
{ {
...@@ -4653,7 +4653,7 @@ static void viewport_miscpart_cc(struct wined3d_context *context, ...@@ -4653,7 +4653,7 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
{ {
const struct wined3d_rendertarget_view *depth_stencil = state->fb->depth_stencil; const struct wined3d_rendertarget_view *depth_stencil = state->fb->depth_stencil;
const struct wined3d_rendertarget_view *target = state->fb->render_targets[0]; const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
float pixel_center_offset = context->swapchain->device->wined3d->flags float pixel_center_offset = context->device->wined3d->flags
& WINED3D_PIXEL_CENTER_INTEGER ? 0.5f : 0.0f; & WINED3D_PIXEL_CENTER_INTEGER ? 0.5f : 0.0f;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_viewport vp = state->viewport; struct wined3d_viewport vp = state->viewport;
...@@ -5870,15 +5870,15 @@ static unsigned int num_handlers(const APPLYSTATEFUNC *funcs) ...@@ -5870,15 +5870,15 @@ static unsigned int num_handlers(const APPLYSTATEFUNC *funcs)
static void multistate_apply_2(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void multistate_apply_2(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
context->swapchain->device->multistate_funcs[state_id][0](context, state, state_id); context->device->multistate_funcs[state_id][0](context, state, state_id);
context->swapchain->device->multistate_funcs[state_id][1](context, state, state_id); context->device->multistate_funcs[state_id][1](context, state, state_id);
} }
static void multistate_apply_3(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) static void multistate_apply_3(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{ {
context->swapchain->device->multistate_funcs[state_id][0](context, state, state_id); context->device->multistate_funcs[state_id][0](context, state, state_id);
context->swapchain->device->multistate_funcs[state_id][1](context, state, state_id); context->device->multistate_funcs[state_id][1](context, state, state_id);
context->swapchain->device->multistate_funcs[state_id][2](context, state, state_id); context->device->multistate_funcs[state_id][2](context, state, state_id);
} }
static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info, static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info,
......
...@@ -4513,7 +4513,7 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w ...@@ -4513,7 +4513,7 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w
* driver, but small enough to prevent it from interfering with any * driver, but small enough to prevent it from interfering with any
* anti-aliasing. */ * anti-aliasing. */
if (!clip_control && context->swapchain->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER) if (!clip_control && context->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER)
center_offset = 63.0f / 64.0f; center_offset = 63.0f / 64.0f;
else else
center_offset = -1.0f / 64.0f; center_offset = -1.0f / 64.0f;
...@@ -4682,7 +4682,7 @@ static void compute_texture_matrix(const struct wined3d_gl_info *gl_info, const ...@@ -4682,7 +4682,7 @@ static void compute_texture_matrix(const struct wined3d_gl_info *gl_info, const
void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state, void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
unsigned int tex, struct wined3d_matrix *mat) unsigned int tex, struct wined3d_matrix *mat)
{ {
const struct wined3d_device *device = context->swapchain->device; const struct wined3d_device *device = context->device;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000) BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000)
!= WINED3DTSS_TCI_PASSTHRU; != WINED3DTSS_TCI_PASSTHRU;
......
...@@ -1462,6 +1462,7 @@ struct wined3d_context ...@@ -1462,6 +1462,7 @@ struct wined3d_context
DWORD numDirtyEntries; DWORD numDirtyEntries;
DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */ DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
struct wined3d_device *device;
struct wined3d_swapchain *swapchain; struct wined3d_swapchain *swapchain;
struct struct
{ {
...@@ -3522,7 +3523,7 @@ static inline void shader_get_position_fixup(const struct wined3d_context *conte ...@@ -3522,7 +3523,7 @@ static inline void shader_get_position_fixup(const struct wined3d_context *conte
{ {
float center_offset; float center_offset;
if (context->swapchain->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER) if (context->device->wined3d->flags & WINED3D_PIXEL_CENTER_INTEGER)
center_offset = 63.0f / 64.0f; center_offset = 63.0f / 64.0f;
else else
center_offset = -1.0f / 64.0f; center_offset = -1.0f / 64.0f;
......
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