wined3d: Store pointer to device in wined3d_context.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-10-05 11:17:03 +02:00 committed by Alexandre Julliard
parent 7756d6ba9b
commit 79787263cc
7 changed files with 35 additions and 34 deletions

View File

@ -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
* 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);
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
/* 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 */
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);
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)
{
struct shader_arb_priv *priv;
if (!context->swapchain)
return;
priv = context->swapchain->device->shader_priv;
priv = context->device->shader_priv;
if (priv->last_context == context)
priv->last_context = NULL;
}
@ -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,
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;
struct wined3d_device *device = context->device;
struct wined3d_color color;
if (device->shader_backend == &arb_program_shader_backend)
@ -5975,8 +5974,8 @@ static void state_tss_constant_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);
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
struct wined3d_color color;
if (device->shader_backend == &arb_program_shader_backend)
@ -6002,8 +6001,8 @@ static void state_tss_constant_arbfp(struct wined3d_context *context,
static void state_arb_specularenable(struct wined3d_context *context,
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;
struct wined3d_device *device = context->device;
float col[4];
if (device->shader_backend == &arb_program_shader_backend)
@ -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)
{
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;
struct wined3d_device *device = context->device;
float mat[2][2];
context->constant_update_mask |= WINED3D_SHADER_CONST_PS_BUMP_ENV;
@ -6068,8 +6067,8 @@ static void tex_bumpenvlum_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);
struct wined3d_device *device = context->swapchain->device;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
float param[4];
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
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_gl_info *gl_info = context->gl_info;
struct wined3d_color float_key[2];
const struct wined3d_texture *texture = state->textures[0];
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->device;
struct wined3d_color float_key[2];
if (!texture)
return;
@ -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)
{
const struct wined3d_device *device = context->swapchain->device;
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;
BOOL use_pshader = use_ps(state);
struct ffp_frag_settings settings;

View File

@ -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)
{
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_d3d_info *d3d_info = context->d3d_info;
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;

View File

@ -1827,6 +1827,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
context_invalidate_state(ret, state);
}
ret->device = device;
ret->swapchain = swapchain;
ret->current_rt.texture = target;
ret->current_rt.sub_resource_idx = 0;
@ -2380,7 +2381,7 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint
if (old_texture_type != target)
{
const struct wined3d_device *device = context->swapchain->device;
const struct wined3d_device *device = context->device;
switch (old_texture_type)
{
@ -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)
{
const struct wined3d_device *device = context->swapchain->device;
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_resource_view *view;
struct wined3d_sampler *sampler;
@ -3536,7 +3537,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
{
if (current_context
&& current_context->current_rt.texture
&& current_context->swapchain->device == device)
&& current_context->device == device)
{
target_texture = current_context->current_rt.texture;
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
/* Stay with the current context if possible. Otherwise use the
* context for the primary swapchain. */
if (current_context && current_context->swapchain->device == device)
if (current_context && current_context->device == device)
context = current_context;
else
context = swapchain_get_context(device->swapchains[0]);

View File

@ -1160,7 +1160,7 @@ static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_con
return;
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);
else
invert_matrix(&mv, &mv);

View File

@ -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);
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;
gl_info->gl_ops.gl.p_glPolygonOffset(bias, bias);
@ -3620,7 +3620,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
}
else
{
struct wined3d_device *device = context->swapchain->device;
struct wined3d_device *device = context->device;
struct wined3d_sampler *sampler;
struct wine_rb_entry *entry;
@ -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)
{
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;
struct wined3d_device *device = context->device;
static unsigned int once;
switch (val)
@ -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)));
/* 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)
{
@ -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 *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;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_viewport vp = state->viewport;
@ -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)
{
context->swapchain->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][0](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)
{
context->swapchain->device->multistate_funcs[state_id][0](context, state, state_id);
context->swapchain->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][0](context, state, state_id);
context->device->multistate_funcs[state_id][1](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,

View File

@ -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
* 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;
else
center_offset = -1.0f / 64.0f;
@ -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,
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;
BOOL generated = (state->texture_states[tex][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000)
!= WINED3DTSS_TCI_PASSTHRU;

View File

@ -1462,6 +1462,7 @@ struct wined3d_context
DWORD numDirtyEntries;
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
{
@ -3522,7 +3523,7 @@ static inline void shader_get_position_fixup(const struct wined3d_context *conte
{
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;
else
center_offset = -1.0f / 64.0f;