Commit 1c403e44 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the current render target as an IWineD3DSurfaceImpl pointer in the context.

parent 95fb8eaa
...@@ -620,7 +620,7 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource ...@@ -620,7 +620,7 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct fbo_entry *entry, *entry2; struct fbo_entry *entry, *entry2;
if (context->current_rt == (IWineD3DSurface *)resource) context->current_rt = NULL; if (context->current_rt == (IWineD3DSurfaceImpl *)resource) context->current_rt = NULL;
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry) LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry)
{ {
...@@ -1347,7 +1347,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3 ...@@ -1347,7 +1347,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3
} }
ret->swapchain = swapchain; ret->swapchain = swapchain;
ret->current_rt = (IWineD3DSurface *)target; ret->current_rt = target;
ret->tid = GetCurrentThreadId(); ret->tid = GetCurrentThreadId();
ret->render_offscreen = surface_is_offscreen(target); ret->render_offscreen = surface_is_offscreen(target);
...@@ -1579,8 +1579,8 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte ...@@ -1579,8 +1579,8 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
int i; int i;
const struct StateEntry *StateTable = This->StateTable; const struct StateEntry *StateTable = This->StateTable;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
UINT width = ((IWineD3DSurfaceImpl *)context->current_rt)->currentDesc.Width; UINT width = context->current_rt->currentDesc.Width;
UINT height = ((IWineD3DSurfaceImpl *)context->current_rt)->currentDesc.Height; UINT height = context->current_rt->currentDesc.Height;
DWORD sampler; DWORD sampler;
TRACE("Setting up context %p for blitting\n", context); TRACE("Setting up context %p for blitting\n", context);
...@@ -1822,7 +1822,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur ...@@ -1822,7 +1822,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
&& current_context->current_rt && current_context->current_rt
&& current_context->swapchain->device == This) && current_context->swapchain->device == This)
{ {
target = (IWineD3DSurfaceImpl *)current_context->current_rt; target = current_context->current_rt;
} }
else else
{ {
...@@ -1832,7 +1832,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur ...@@ -1832,7 +1832,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
} }
} }
if (current_context && (IWineD3DSurfaceImpl *)current_context->current_rt == target) if (current_context && current_context->current_rt == target)
{ {
context_validate(current_context); context_validate(current_context);
return current_context; return current_context;
...@@ -1875,7 +1875,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur ...@@ -1875,7 +1875,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit) static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DSurfaceImpl *rt = (IWineD3DSurfaceImpl *)context->current_rt; IWineD3DSurfaceImpl *rt = context->current_rt;
IWineD3DDeviceImpl *device; IWineD3DDeviceImpl *device;
device = rt->resource.device; device = rt->resource.device;
...@@ -1960,7 +1960,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct ...@@ -1960,7 +1960,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct
{ {
/* Onscreen surfaces are always in a swapchain */ /* Onscreen surfaces are always in a swapchain */
IWineD3DSurfaceImpl *depth_stencil = device->depth_stencil; IWineD3DSurfaceImpl *depth_stencil = device->depth_stencil;
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)((IWineD3DSurfaceImpl *)context->current_rt)->container; IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)context->current_rt->container;
if (!depth_stencil) return; if (!depth_stencil) return;
if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format_desc)) return; if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format_desc)) return;
...@@ -1971,7 +1971,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct ...@@ -1971,7 +1971,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct
WARN("Depth stencil format is not supported by WGL, rendering the backbuffer in an FBO\n"); WARN("Depth stencil format is not supported by WGL, rendering the backbuffer in an FBO\n");
/* The currently active context is the necessary context to access the swapchain's onscreen buffers */ /* The currently active context is the necessary context to access the swapchain's onscreen buffers */
IWineD3DSurface_LoadLocation(context->current_rt, SFLAG_INTEXTURE, NULL); IWineD3DSurface_LoadLocation((IWineD3DSurface *)context->current_rt, SFLAG_INTEXTURE, NULL);
swapchain->render_to_fbo = TRUE; swapchain->render_to_fbo = TRUE;
context_set_render_offscreen(context, device->StateTable, TRUE); context_set_render_offscreen(context, device->StateTable, TRUE);
} }
...@@ -2003,11 +2003,11 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI ...@@ -2003,11 +2003,11 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
if (context->render_offscreen) if (context->render_offscreen)
{ {
FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n"); FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n");
surface_internal_preload(context->current_rt, SRGB_RGB); surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_RGB);
ENTER_GL(); ENTER_GL();
context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo); context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)context->current_rt); context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, context->current_rt);
context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE); context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE);
LEAVE_GL(); LEAVE_GL();
} else { } else {
...@@ -2097,7 +2097,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device, ...@@ -2097,7 +2097,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
const struct StateEntry *StateTable = device->StateTable; const struct StateEntry *StateTable = device->StateTable;
if (!target) return; if (!target) return;
else if ((IWineD3DSurfaceImpl *)context->current_rt == target) return; else if (context->current_rt == target) return;
render_offscreen = surface_is_offscreen(target); render_offscreen = surface_is_offscreen(target);
context_set_render_offscreen(context, StateTable, render_offscreen); context_set_render_offscreen(context, StateTable, render_offscreen);
...@@ -2110,7 +2110,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device, ...@@ -2110,7 +2110,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
} }
else else
{ {
const struct wined3d_format_desc *old = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.format_desc; const struct wined3d_format_desc *old = context->current_rt->resource.format_desc;
const struct wined3d_format_desc *new = target->resource.format_desc; const struct wined3d_format_desc *new = target->resource.format_desc;
if (old->format != new->format) if (old->format != new->format)
...@@ -2131,7 +2131,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device, ...@@ -2131,7 +2131,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
* has to be called with the old rendertarget active, otherwise a * has to be called with the old rendertarget active, otherwise a
* wrong drawable is read. */ * wrong drawable is read. */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& old_render_offscreen && (IWineD3DSurfaceImpl *)context->current_rt != target) && old_render_offscreen && context->current_rt != target)
{ {
BOOL oldInDraw = device->isInDraw; BOOL oldInDraw = device->isInDraw;
...@@ -2147,23 +2147,23 @@ static void context_setup_target(IWineD3DDeviceImpl *device, ...@@ -2147,23 +2147,23 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
device->isInDraw = TRUE; device->isInDraw = TRUE;
/* Read the back buffer of the old drawable into the destination texture. */ /* Read the back buffer of the old drawable into the destination texture. */
if (((IWineD3DSurfaceImpl *)context->current_rt)->texture_name_srgb) if (context->current_rt->texture_name_srgb)
{ {
surface_internal_preload(context->current_rt, SRGB_BOTH); surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_BOTH);
} }
else else
{ {
surface_internal_preload(context->current_rt, SRGB_RGB); surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_RGB);
} }
IWineD3DSurface_ModifyLocation(context->current_rt, SFLAG_INDRAWABLE, FALSE); IWineD3DSurface_ModifyLocation((IWineD3DSurface *)context->current_rt, SFLAG_INDRAWABLE, FALSE);
device->isInDraw = oldInDraw; device->isInDraw = oldInDraw;
} }
} }
context->draw_buffer_dirty = TRUE; context->draw_buffer_dirty = TRUE;
context->current_rt = (IWineD3DSurface *)target; context->current_rt = target;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -7069,10 +7069,9 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) { ...@@ -7069,10 +7069,9 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height)
{ {
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt;
/* The drawable size of a fbo target is the opengl texture size, which is the power of two size. */ /* The drawable size of a fbo target is the opengl texture size, which is the power of two size. */
*width = surface->pow2Width; *width = context->current_rt->pow2Width;
*height = surface->pow2Height; *height = context->current_rt->pow2Height;
} }
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height)
......
...@@ -807,7 +807,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context, ...@@ -807,7 +807,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
correction_params[1] = 1.0f; correction_params[1] = 1.0f;
} else { } else {
/* position is window relative, not viewport relative */ /* position is window relative, not viewport relative */
correction_params[0] = ((IWineD3DSurfaceImpl *)context->current_rt)->currentDesc.Height; correction_params[0] = context->current_rt->currentDesc.Height;
correction_params[1] = -1.0f; correction_params[1] = -1.0f;
} }
GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params)); GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params));
......
...@@ -59,7 +59,7 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu ...@@ -59,7 +59,7 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu
return WINED3D_EVENT_QUERY_WRONG_THREAD; return WINED3D_EVENT_QUERY_WRONG_THREAD;
} }
context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(device, (IWineD3DSurface *)query->context->current_rt, CTXUSAGE_RESOURCELOAD);
gl_info = context->gl_info; gl_info = context->gl_info;
ENTER_GL(); ENTER_GL();
...@@ -136,7 +136,7 @@ enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_ ...@@ -136,7 +136,7 @@ enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_
return WINED3D_EVENT_QUERY_WRONG_THREAD; return WINED3D_EVENT_QUERY_WRONG_THREAD;
} }
context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(device, (IWineD3DSurface *)query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL(); ENTER_GL();
if (gl_info->supported[ARB_SYNC]) if (gl_info->supported[ARB_SYNC])
...@@ -195,7 +195,7 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDevice ...@@ -195,7 +195,7 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDevice
} }
else else
{ {
context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(device, (IWineD3DSurface *)query->context->current_rt, CTXUSAGE_RESOURCELOAD);
} }
} }
else else
...@@ -348,7 +348,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, ...@@ -348,7 +348,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
return S_OK; return S_OK;
} }
context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(This->device, (IWineD3DSurface *)query->context->current_rt, CTXUSAGE_RESOURCELOAD);
ENTER_GL(); ENTER_GL();
...@@ -490,7 +490,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D ...@@ -490,7 +490,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
} }
else else
{ {
context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(This->device, (IWineD3DSurface *)query->context->current_rt,
CTXUSAGE_RESOURCELOAD);
ENTER_GL(); ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB)); GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
...@@ -525,7 +526,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D ...@@ -525,7 +526,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
} }
else else
{ {
context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); context = context_acquire(This->device, (IWineD3DSurface *)query->context->current_rt,
CTXUSAGE_RESOURCELOAD);
ENTER_GL(); ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB)); GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
......
...@@ -957,9 +957,8 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *i ...@@ -957,9 +957,8 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *i
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height)
{ {
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt;
/* The drawable size of an onscreen drawable is the surface size. /* The drawable size of an onscreen drawable is the surface size.
* (Actually: The window size, but the surface is created in window size) */ * (Actually: The window size, but the surface is created in window size) */
*width = surface->currentDesc.Width; *width = context->current_rt->currentDesc.Width;
*height = surface->currentDesc.Height; *height = context->current_rt->currentDesc.Height;
} }
...@@ -1054,7 +1054,7 @@ struct wined3d_context ...@@ -1054,7 +1054,7 @@ struct wined3d_context
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 */
IWineD3DSwapChainImpl *swapchain; IWineD3DSwapChainImpl *swapchain;
IWineD3DSurface *current_rt; IWineD3DSurfaceImpl *current_rt;
DWORD tid; /* Thread ID which owns this context at the moment */ DWORD tid; /* Thread ID which owns this context at the moment */
/* Stores some information about the context state for optimization */ /* Stores some information about the context state for optimization */
......
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