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
const struct wined3d_gl_info *gl_info = context->gl_info;
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)
{
......@@ -1347,7 +1347,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3
}
ret->swapchain = swapchain;
ret->current_rt = (IWineD3DSurface *)target;
ret->current_rt = target;
ret->tid = GetCurrentThreadId();
ret->render_offscreen = surface_is_offscreen(target);
......@@ -1579,8 +1579,8 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
int i;
const struct StateEntry *StateTable = This->StateTable;
const struct wined3d_gl_info *gl_info = context->gl_info;
UINT width = ((IWineD3DSurfaceImpl *)context->current_rt)->currentDesc.Width;
UINT height = ((IWineD3DSurfaceImpl *)context->current_rt)->currentDesc.Height;
UINT width = context->current_rt->currentDesc.Width;
UINT height = context->current_rt->currentDesc.Height;
DWORD sampler;
TRACE("Setting up context %p for blitting\n", context);
......@@ -1822,7 +1822,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
&& current_context->current_rt
&& current_context->swapchain->device == This)
{
target = (IWineD3DSurfaceImpl *)current_context->current_rt;
target = current_context->current_rt;
}
else
{
......@@ -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);
return current_context;
......@@ -1875,7 +1875,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DSurfaceImpl *rt = (IWineD3DSurfaceImpl *)context->current_rt;
IWineD3DSurfaceImpl *rt = context->current_rt;
IWineD3DDeviceImpl *device;
device = rt->resource.device;
......@@ -1960,7 +1960,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct
{
/* Onscreen surfaces are always in a swapchain */
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 (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
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 */
IWineD3DSurface_LoadLocation(context->current_rt, SFLAG_INTEXTURE, NULL);
IWineD3DSurface_LoadLocation((IWineD3DSurface *)context->current_rt, SFLAG_INTEXTURE, NULL);
swapchain->render_to_fbo = TRUE;
context_set_render_offscreen(context, device->StateTable, TRUE);
}
......@@ -2003,11 +2003,11 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
if (context->render_offscreen)
{
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();
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);
LEAVE_GL();
} else {
......@@ -2097,7 +2097,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
const struct StateEntry *StateTable = device->StateTable;
if (!target) return;
else if ((IWineD3DSurfaceImpl *)context->current_rt == target) return;
else if (context->current_rt == target) return;
render_offscreen = surface_is_offscreen(target);
context_set_render_offscreen(context, StateTable, render_offscreen);
......@@ -2110,7 +2110,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
}
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;
if (old->format != new->format)
......@@ -2131,7 +2131,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
* has to be called with the old rendertarget active, otherwise a
* wrong drawable is read. */
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;
......@@ -2147,23 +2147,23 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
device->isInDraw = TRUE;
/* 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
{
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;
}
}
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) {
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. */
*width = surface->pow2Width;
*height = surface->pow2Height;
*width = context->current_rt->pow2Width;
*height = context->current_rt->pow2Height;
}
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,
correction_params[1] = 1.0f;
} else {
/* 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;
}
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
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;
ENTER_GL();
......@@ -136,7 +136,7 @@ enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_
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();
if (gl_info->supported[ARB_SYNC])
......@@ -195,7 +195,7 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDevice
}
else
{
context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
context = context_acquire(device, (IWineD3DSurface *)query->context->current_rt, CTXUSAGE_RESOURCELOAD);
}
}
else
......@@ -348,7 +348,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
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();
......@@ -490,7 +490,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
}
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();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
......@@ -525,7 +526,8 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
}
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();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
......
......@@ -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)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt;
/* The drawable size of an onscreen drawable is the surface size.
* (Actually: The window size, but the surface is created in window size) */
*width = surface->currentDesc.Width;
*height = surface->currentDesc.Height;
*width = context->current_rt->currentDesc.Width;
*height = context->current_rt->currentDesc.Height;
}
......@@ -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 */
IWineD3DSwapChainImpl *swapchain;
IWineD3DSurface *current_rt;
IWineD3DSurfaceImpl *current_rt;
DWORD tid; /* Thread ID which owns this context at the moment */
/* 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