Commit 18ec2525 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the swapchain instead of the surface in the context.

parent b281f23e
......@@ -576,7 +576,7 @@ static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
/* GL locking is done by the caller (state handler) */
static void shader_arb_load_constants(const struct wined3d_context *context, char usePixelShader, char useVertexShader)
{
IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
IWineD3DDeviceImpl *device = context->swapchain->device;
IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
const struct wined3d_gl_info *gl_info = context->gl_info;
......@@ -606,7 +606,7 @@ static void shader_arb_update_float_vertex_constants(IWineD3DDevice *iface, UINT
/* 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 || ((IWineD3DSurfaceImpl *)context->surface)->resource.device != This) return;
if (!context || context->swapchain->device != This) return;
memset(context->vshader_const_dirty + start, 1, sizeof(*context->vshader_const_dirty) * count);
This->highest_dirty_vs_const = max(This->highest_dirty_vs_const, start + count);
......@@ -619,7 +619,7 @@ static void shader_arb_update_float_pixel_constants(IWineD3DDevice *iface, UINT
/* 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 || ((IWineD3DSurfaceImpl *)context->surface)->resource.device != This) return;
if (!context || context->swapchain->device != This) return;
memset(context->pshader_const_dirty + start, 1, sizeof(*context->pshader_const_dirty) * count);
This->highest_dirty_ps_const = max(This->highest_dirty_ps_const, start + count);
......@@ -4339,7 +4339,7 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW
/* GL locking is done by the caller */
static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
{
IWineD3DDeviceImpl *This = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
IWineD3DDeviceImpl *This = context->swapchain->device;
struct shader_arb_priv *priv = This->shader_priv;
const struct wined3d_gl_info *gl_info = context->gl_info;
int i;
......
......@@ -6442,8 +6442,7 @@ HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *
}
target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
context = context_create(This, target, swapchain->win_handle, &swapchain->presentParms);
if (!context)
if (!(context = context_create(swapchain, target)))
{
WARN("Failed to create context.\n");
HeapFree(GetProcessHeap(), 0, swapchain->context);
......@@ -7155,13 +7154,12 @@ void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *h
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->surface;
IWineD3DSwapChainImpl *swapchain = context->swapchain;
/* The drawable size of a backbuffer / aux buffer offscreen target is the size of the
* current context's drawable, which is the size of the back buffer of the swapchain
* the active context belongs to. The back buffer of the swapchain is stored as the
* surface the context belongs to. */
*width = surface->currentDesc.Width;
*height = surface->currentDesc.Height;
* the active context belongs to. */
*width = swapchain->presentParms.BackBufferWidth;
*height = swapchain->presentParms.BackBufferHeight;
}
LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
......
......@@ -719,8 +719,8 @@ static void shader_glsl_load_np2fixup_constants(
static void shader_glsl_load_constants(const struct wined3d_context *context,
char usePixelShader, char useVertexShader)
{
IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DDeviceImpl *device = context->swapchain->device;
IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
struct shader_glsl_priv *priv = device->shader_priv;
......@@ -4530,8 +4530,8 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info,
/* GL locking is done by the caller */
static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
{
IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DDeviceImpl *device = context->swapchain->device;
struct shader_glsl_priv *priv = device->shader_priv;
GLhandleARB program_id = 0;
GLenum old_vertex_color_clamp, current_vertex_color_clamp;
......
......@@ -546,8 +546,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapCh
IWineD3DSurface_UnlockRect(This->backBuffer[0]);
context_destroy(This->device, This->context[0]);
This->context[0] = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
This->win_handle, &This->presentParms);
This->context[0] = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer);
context_release(This->context[0]);
IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
......@@ -816,9 +815,7 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
if (surface_type == SURFACE_OPENGL)
{
swapchain->context[0] = context_create(device, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
window, present_parameters);
if (!swapchain->context[0])
if (!(swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer)))
{
WARN("Failed to create context.\n");
hr = WINED3DERR_NOTAVAILABLE;
......@@ -935,9 +932,7 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *i
TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
ctx = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
This->context[0]->win_handle, &This->presentParms);
if (!ctx)
if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer)))
{
ERR("Failed to create a new context for the swapchain\n");
return NULL;
......
......@@ -1051,7 +1051,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 */
IWineD3DSurface *surface;
IWineD3DSwapChainImpl *swapchain;
IWineD3DSurface *current_rt;
DWORD tid; /* Thread ID which owns this context at the moment */
......@@ -1199,8 +1199,7 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context,
GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
void context_attach_surface_fbo(const struct wined3d_context *context,
GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target,
HWND win, const WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target) DECLSPEC_HIDDEN;
void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
......
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