Commit 74faebd6 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the current GLSL program per-context.

parent 98f3ecc3
......@@ -4779,7 +4779,7 @@ static void shader_arb_select(void *shader_priv, struct wined3d_context *context
/* Context activation is done by the caller. */
static void shader_arb_disable(void *shader_priv, const struct wined3d_context *context)
static void shader_arb_disable(void *shader_priv, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct shader_arb_priv *priv = shader_priv;
......@@ -4806,6 +4806,10 @@ static void shader_arb_disable(void *shader_priv, const struct wined3d_context *
checkGLcall("glClampColorARB");
priv->last_vs_color_unclamp = FALSE;
}
context->shader_update_mask = (1 << WINED3D_SHADER_TYPE_PIXEL)
| (1 << WINED3D_SHADER_TYPE_VERTEX)
| (1 << WINED3D_SHADER_TYPE_GEOMETRY);
}
/* Context activation is done by the caller. */
......@@ -5032,9 +5036,14 @@ static void shader_arb_free(struct wined3d_device *device)
HeapFree(GetProcessHeap(), 0, device->shader_priv);
}
static void shader_arb_context_destroyed(void *shader_priv, const struct wined3d_context *context)
static BOOL shader_arb_allocate_context_data(struct wined3d_context *context)
{
struct shader_arb_priv *priv = shader_priv;
return TRUE;
}
static void shader_arb_free_context_data(struct wined3d_context *context)
{
struct shader_arb_priv *priv = context->swapchain->device->shader_priv;
if (priv->last_context == context)
priv->last_context = NULL;
......@@ -5712,7 +5721,8 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend =
shader_arb_destroy,
shader_arb_alloc,
shader_arb_free,
shader_arb_context_destroyed,
shader_arb_allocate_context_data,
shader_arb_free_context_data,
shader_arb_get_caps,
shader_arb_color_fixup_supported,
shader_arb_has_ffp_proj_control,
......
......@@ -1345,6 +1345,12 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
list_init(&ret->fbo_list);
list_init(&ret->fbo_destroy_list);
if (!device->shader_backend->shader_allocate_context_data(ret))
{
ERR("Failed to allocate shader backend context data.\n");
goto out;
}
if (!(hdc = GetDC(swapchain->win_handle)))
{
WARN("Failed to retireve device context, trying swapchain backup.\n");
......@@ -1639,6 +1645,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
return ret;
out:
device->shader_backend->shader_free_context_data(ret);
HeapFree(GetProcessHeap(), 0, ret->free_event_queries);
HeapFree(GetProcessHeap(), 0, ret->free_occlusion_queries);
HeapFree(GetProcessHeap(), 0, ret->draw_buffers);
......@@ -1671,6 +1678,7 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont
destroy = FALSE;
}
device->shader_backend->shader_free_context_data(context);
HeapFree(GetProcessHeap(), 0, context->draw_buffers);
HeapFree(GetProcessHeap(), 0, context->blit_targets);
device_context_remove(device, context);
......@@ -1903,9 +1911,6 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
/* Disable shaders */
device->shader_backend->shader_disable(device->shader_priv, context);
context->shader_update_mask = (1 << WINED3D_SHADER_TYPE_PIXEL)
| (1 << WINED3D_SHADER_TYPE_VERTEX)
| (1 << WINED3D_SHADER_TYPE_GEOMETRY);
context->blit_w = rt_size.cx;
context->blit_h = rt_size.cy;
......
......@@ -1512,7 +1512,7 @@ static void shader_none_update_float_pixel_constants(struct wined3d_device *devi
static void shader_none_load_constants(void *shader_priv, struct wined3d_context *context,
const struct wined3d_state *state) {}
static void shader_none_destroy(struct wined3d_shader *shader) {}
static void shader_none_context_destroyed(void *shader_priv, const struct wined3d_context *context) {}
static void shader_none_free_context_data(struct wined3d_context *context) {}
/* Context activation is done by the caller. */
static void shader_none_select(void *shader_priv, struct wined3d_context *context,
......@@ -1526,13 +1526,17 @@ static void shader_none_select(void *shader_priv, struct wined3d_context *contex
}
/* Context activation is done by the caller. */
static void shader_none_disable(void *shader_priv, const struct wined3d_context *context)
static void shader_none_disable(void *shader_priv, struct wined3d_context *context)
{
struct shader_none_priv *priv = shader_priv;
const struct wined3d_gl_info *gl_info = context->gl_info;
priv->vertex_pipe->vp_enable(gl_info, FALSE);
priv->fragment_pipe->enable_extension(gl_info, FALSE);
context->shader_update_mask = (1 << WINED3D_SHADER_TYPE_PIXEL)
| (1 << WINED3D_SHADER_TYPE_VERTEX)
| (1 << WINED3D_SHADER_TYPE_GEOMETRY);
}
static HRESULT shader_none_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
......@@ -1581,6 +1585,11 @@ static void shader_none_free(struct wined3d_device *device)
HeapFree(GetProcessHeap(), 0, priv);
}
static BOOL shader_none_allocate_context_data(struct wined3d_context *context)
{
return TRUE;
}
static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
{
/* Set the shader caps to 0 for the none shader backend */
......@@ -1620,7 +1629,8 @@ const struct wined3d_shader_backend_ops none_shader_backend =
shader_none_destroy,
shader_none_alloc,
shader_none_free,
shader_none_context_destroyed,
shader_none_allocate_context_data,
shader_none_free_context_data,
shader_none_get_caps,
shader_none_color_fixup_supported,
shader_none_has_ffp_proj_control,
......
......@@ -810,7 +810,7 @@ struct wined3d_shader_backend_ops
void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
void (*shader_select)(void *shader_priv, struct wined3d_context *context,
const struct wined3d_state *state);
void (*shader_disable)(void *shader_priv, const struct wined3d_context *context);
void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
void (*shader_select_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info,
enum tex_types tex_type, const SIZE *ds_mask_size);
void (*shader_deselect_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info);
......@@ -822,7 +822,8 @@ struct wined3d_shader_backend_ops
HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
const struct fragment_pipeline *fragment_pipe);
void (*shader_free_private)(struct wined3d_device *device);
void (*shader_context_destroyed)(void *shader_priv, const struct wined3d_context *context);
BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
void (*shader_free_context_data)(struct wined3d_context *context);
void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
......@@ -1115,6 +1116,8 @@ struct wined3d_context
int pixel_format;
GLint aux_buffers;
void *shader_backend_data;
/* FBOs */
UINT fbo_entry_count;
struct list fbo_list;
......
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