Commit d6e2f650 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the context's current rendertarget as a texture and sub-resource index.

parent 5f05acfc
......@@ -58,7 +58,7 @@ static enum wined3d_event_query_result wined3d_event_query_test(const struct win
return WINED3D_EVENT_QUERY_WRONG_THREAD;
}
context = context_acquire(device, query->context->current_rt);
context = context_acquire(device, context_get_rt_surface(query->context));
gl_info = context->gl_info;
if (gl_info->supported[ARB_SYNC])
......@@ -132,7 +132,7 @@ enum wined3d_event_query_result wined3d_event_query_finish(const struct wined3d_
return WINED3D_EVENT_QUERY_WRONG_THREAD;
}
context = context_acquire(device, query->context->current_rt);
context = context_acquire(device, context_get_rt_surface(query->context));
if (gl_info->supported[ARB_SYNC])
{
......@@ -192,7 +192,7 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, const struct w
}
else
{
context = context_acquire(device, query->context->current_rt);
context = context_acquire(device, context_get_rt_surface(query->context));
}
}
else
......@@ -348,7 +348,7 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
return S_OK;
}
context = context_acquire(query->device, oq->context->current_rt);
context = context_acquire(device, context_get_rt_surface(oq->context));
GL_EXTCALL(glGetQueryObjectuiv(oq->id, GL_QUERY_RESULT_AVAILABLE, &available));
checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)");
......@@ -490,7 +490,7 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
}
else
{
context = context_acquire(query->device, oq->context->current_rt);
context = context_acquire(device, context_get_rt_surface(oq->context));
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
checkGLcall("glEndQuery()");
......@@ -522,7 +522,7 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
}
else
{
context = context_acquire(query->device, oq->context->current_rt);
context = context_acquire(device, context_get_rt_surface(oq->context));
GL_EXTCALL(glEndQuery(GL_SAMPLES_PASSED));
checkGLcall("glEndQuery()");
......@@ -578,7 +578,7 @@ static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query,
return S_OK;
}
context = context_acquire(query->device, tq->context->current_rt);
context = context_acquire(device, context_get_rt_surface(tq->context));
GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available));
checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)");
......
......@@ -108,8 +108,8 @@ void surface_get_drawable_size(const struct wined3d_surface *surface, const stru
/* The drawable size of an onscreen drawable is the surface size.
* (Actually: The window size, but the surface is created in window
* size.) */
*width = context->current_rt->resource.width;
*height = context->current_rt->resource.height;
*width = context->current_rt.texture->resource.width;
*height = context->current_rt.texture->resource.height;
}
else if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
......@@ -123,10 +123,13 @@ void surface_get_drawable_size(const struct wined3d_surface *surface, const stru
}
else
{
struct wined3d_surface *rt;
/* The drawable size of an FBO target is the OpenGL texture size,
* which is the power of two size. */
*width = context->current_rt->pow2Width;
*height = context->current_rt->pow2Height;
rt = context->current_rt.texture->sub_resources[context->current_rt.sub_resource_idx].u.surface;
*width = rt->pow2Width;
*height = rt->pow2Height;
}
}
......@@ -675,11 +678,11 @@ static void surface_blt_fbo(const struct wined3d_device *device,
else if (dst_location == WINED3D_LOCATION_DRAWABLE) required_rt = dst_surface;
else required_rt = NULL;
if (required_rt && required_rt != old_ctx->current_rt)
{
restore_rt = old_ctx->current_rt;
restore_rt = context_get_rt_surface(old_ctx);
if (restore_rt != required_rt)
context = context_acquire(device, required_rt);
}
else
restore_rt = NULL;
if (!context->valid)
{
......@@ -1852,11 +1855,11 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
surface_get_memory(surface, &data, dst_location);
if (surface != old_ctx->current_rt)
{
restore_rt = old_ctx->current_rt;
restore_rt = context_get_rt_surface(old_ctx);
if (restore_rt != surface)
context = context_acquire(device, surface);
}
else
restore_rt = NULL;
context_apply_blit_state(context, device);
gl_info = context->gl_info;
......@@ -1962,11 +1965,11 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct
struct wined3d_context *context = old_ctx;
struct wined3d_surface *restore_rt = NULL;
if (old_ctx->current_rt != surface)
{
restore_rt = old_ctx->current_rt;
restore_rt = context_get_rt_surface(old_ctx);
if (restore_rt != surface)
context = context_acquire(device, surface);
}
else
restore_rt = NULL;
gl_info = context->gl_info;
device_invalidate_state(device, STATE_FRAMEBUFFER);
......@@ -2485,12 +2488,11 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
src_rect = *src_rect_in;
dst_rect = *dst_rect_in;
if (old_ctx->current_rt != dst_surface)
{
restore_rt = old_ctx->current_rt;
restore_rt = context_get_rt_surface(old_ctx);
if (restore_rt != dst_surface)
context = context_acquire(device, dst_surface);
}
else
restore_rt = NULL;
gl_info = context->gl_info;
......
......@@ -1282,7 +1282,11 @@ struct wined3d_context
DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
struct wined3d_swapchain *swapchain;
struct wined3d_surface *current_rt;
struct
{
struct wined3d_texture *texture;
unsigned int sub_resource_idx;
} current_rt;
DWORD tid; /* Thread ID which owns this context at the moment */
/* Stores some information about the context state for optimization */
......@@ -3473,6 +3477,15 @@ static inline BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info
&& !is_scaling_fixup(format->color_fixup);
}
static inline struct wined3d_surface *context_get_rt_surface(const struct wined3d_context *context)
{
struct wined3d_texture *texture = context->current_rt.texture;
if (!texture)
return NULL;
return texture->sub_resources[context->current_rt.sub_resource_idx].u.surface;
}
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
......
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