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

wined3d: Allow textures as swapchain surfaces.

parent 48d470f6
...@@ -7245,8 +7245,8 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context, ...@@ -7245,8 +7245,8 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
GLenum textype; GLenum textype;
if (surface->container.type == WINED3D_CONTAINER_TEXTURE) if (surface->container)
textype = surface->container.u.texture->target; textype = surface->container->target;
else else
textype = surface->texture_target; textype = surface->texture_target;
...@@ -7429,8 +7429,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, ...@@ -7429,8 +7429,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
arbfp_blit_unset(context->gl_info); arbfp_blit_unset(context->gl_info);
if (wined3d_settings.strict_draw_ordering if (wined3d_settings.strict_draw_ordering
|| (dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN || (dst_surface->swapchain && (dst_surface->swapchain->front_buffer == dst_surface)))
&& (dst_surface->container.u.swapchain->front_buffer == dst_surface)))
context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
......
...@@ -1705,8 +1705,7 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz ...@@ -1705,8 +1705,7 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz
{ {
const struct wined3d_surface *rt = context->current_rt; const struct wined3d_surface *rt = context->current_rt;
if (rt->container.type == WINED3D_CONTAINER_SWAPCHAIN if (rt->swapchain && rt->swapchain->front_buffer == rt)
&& rt->container.u.swapchain->front_buffer == rt)
{ {
RECT window_size; RECT window_size;
...@@ -2086,7 +2085,7 @@ static void context_validate_onscreen_formats(struct wined3d_context *context, ...@@ -2086,7 +2085,7 @@ static void context_validate_onscreen_formats(struct wined3d_context *context,
const struct wined3d_surface *depth_stencil) const struct wined3d_surface *depth_stencil)
{ {
/* Onscreen surfaces are always in a swapchain */ /* Onscreen surfaces are always in a swapchain */
struct wined3d_swapchain *swapchain = context->current_rt->container.u.swapchain; struct wined3d_swapchain *swapchain = context->current_rt->swapchain;
if (context->render_offscreen || !depth_stencil) return; if (context->render_offscreen || !depth_stencil) return;
if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format)) return; if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format)) return;
...@@ -2107,7 +2106,7 @@ static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_device *device ...@@ -2107,7 +2106,7 @@ static DWORD context_generate_rt_mask_no_fbo(const struct wined3d_device *device
{ {
if (!rt || rt->resource.format->id == WINED3DFMT_NULL) if (!rt || rt->resource.format->id == WINED3DFMT_NULL)
return 0; return 0;
else if (rt->container.type == WINED3D_CONTAINER_SWAPCHAIN) else if (rt->swapchain)
return context_generate_rt_mask_from_surface(rt); return context_generate_rt_mask_from_surface(rt);
else else
return context_generate_rt_mask(device->offscreenBuffer); return context_generate_rt_mask(device->offscreenBuffer);
...@@ -2497,11 +2496,11 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str ...@@ -2497,11 +2496,11 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
{ {
context = current_context; context = current_context;
} }
else if (target->container.type == WINED3D_CONTAINER_SWAPCHAIN) else if (target->swapchain)
{ {
TRACE("Rendering onscreen.\n"); TRACE("Rendering onscreen.\n");
context = swapchain_get_context(target->container.u.swapchain); context = swapchain_get_context(target->swapchain);
} }
else else
{ {
......
...@@ -715,8 +715,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c ...@@ -715,8 +715,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
} }
if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET
&& target->container.type == WINED3D_CONTAINER_SWAPCHAIN && target->swapchain && target->swapchain->front_buffer == target))
&& target->container.u.swapchain->front_buffer == target))
gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
context_release(context); context_release(context);
......
...@@ -42,8 +42,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) ...@@ -42,8 +42,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
* is the last buffer to be destroyed, FindContext() depends on that. */ * is the last buffer to be destroyed, FindContext() depends on that. */
if (swapchain->front_buffer) if (swapchain->front_buffer)
{ {
if (swapchain->front_buffer->container.type == WINED3D_CONTAINER_SWAPCHAIN) surface_set_swapchain(swapchain->front_buffer, NULL);
surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_NONE, NULL);
if (wined3d_surface_decref(swapchain->front_buffer)) if (wined3d_surface_decref(swapchain->front_buffer))
WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer); WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer);
swapchain->front_buffer = NULL; swapchain->front_buffer = NULL;
...@@ -55,8 +54,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) ...@@ -55,8 +54,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
while (i--) while (i--)
{ {
if (swapchain->back_buffers[i]->container.type == WINED3D_CONTAINER_SWAPCHAIN) surface_set_swapchain(swapchain->back_buffers[i], NULL);
surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_NONE, NULL);
if (wined3d_surface_decref(swapchain->back_buffers[i])) if (wined3d_surface_decref(swapchain->back_buffers[i]))
WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]); WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
} }
...@@ -898,8 +896,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 ...@@ -898,8 +896,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
goto err; goto err;
} }
if (swapchain->front_buffer->container.type == WINED3D_CONTAINER_NONE) surface_set_swapchain(swapchain->front_buffer, swapchain);
surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_SWAPCHAIN, swapchain);
if (!(device->wined3d->flags & WINED3D_NO3D)) if (!(device->wined3d->flags & WINED3D_NO3D))
surface_modify_location(swapchain->front_buffer, SFLAG_INDRAWABLE, TRUE); surface_modify_location(swapchain->front_buffer, SFLAG_INDRAWABLE, TRUE);
...@@ -1007,8 +1004,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 ...@@ -1007,8 +1004,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
WARN("Failed to create back buffer %u, hr %#x.\n", i, hr); WARN("Failed to create back buffer %u, hr %#x.\n", i, hr);
goto err; goto err;
} }
if (swapchain->back_buffers[i]->container.type == WINED3D_CONTAINER_NONE) surface_set_swapchain(swapchain->back_buffers[i], swapchain);
surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_SWAPCHAIN, swapchain);
} }
} }
...@@ -1027,8 +1023,6 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 ...@@ -1027,8 +1023,6 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
WARN("Failed to create the auto depth stencil, hr %#x.\n", hr); WARN("Failed to create the auto depth stencil, hr %#x.\n", hr);
goto err; goto err;
} }
surface_set_container(device->auto_depth_stencil, WINED3D_CONTAINER_NONE, NULL);
} }
} }
...@@ -1059,7 +1053,7 @@ err: ...@@ -1059,7 +1053,7 @@ err:
{ {
if (swapchain->back_buffers[i]) if (swapchain->back_buffers[i])
{ {
surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_NONE, NULL); surface_set_swapchain(swapchain->back_buffers[i], NULL);
wined3d_surface_decref(swapchain->back_buffers[i]); wined3d_surface_decref(swapchain->back_buffers[i]);
} }
} }
...@@ -1079,7 +1073,7 @@ err: ...@@ -1079,7 +1073,7 @@ err:
if (swapchain->front_buffer) if (swapchain->front_buffer)
{ {
surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_NONE, NULL); surface_set_swapchain(swapchain->front_buffer, NULL);
wined3d_surface_decref(swapchain->front_buffer); wined3d_surface_decref(swapchain->front_buffer);
} }
......
...@@ -715,7 +715,7 @@ static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource ...@@ -715,7 +715,7 @@ static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource
surface_set_texture_name(surface, 0, TRUE); surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE); surface_set_texture_name(surface, 0, FALSE);
surface_set_texture_target(surface, 0, 0); surface_set_texture_target(surface, 0, 0);
surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL); surface_set_container(surface, NULL);
wined3d_surface_decref(surface); wined3d_surface_decref(surface);
} }
...@@ -864,7 +864,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt ...@@ -864,7 +864,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
return hr; return hr;
} }
surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture); surface_set_container(surface, texture);
surface_set_texture_target(surface, cube_targets[j], i); surface_set_texture_target(surface, cube_targets[j], i);
texture->sub_resources[idx] = &surface->resource; texture->sub_resources[idx] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface); TRACE("Created surface level %u @ %p.\n", i, surface);
...@@ -1024,7 +1024,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he ...@@ -1024,7 +1024,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
return hr; return hr;
} }
surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture); surface_set_container(surface, texture);
surface_set_texture_target(surface, texture->target, i); surface_set_texture_target(surface, texture->target, i);
texture->sub_resources[i] = &surface->resource; texture->sub_resources[i] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface); TRACE("Created surface level %u @ %p.\n", i, surface);
......
...@@ -2076,24 +2076,6 @@ struct fbo_entry ...@@ -2076,24 +2076,6 @@ struct fbo_entry
GLuint id; GLuint id;
}; };
enum wined3d_container_type
{
WINED3D_CONTAINER_NONE = 0,
WINED3D_CONTAINER_SWAPCHAIN,
WINED3D_CONTAINER_TEXTURE,
};
struct wined3d_subresource_container
{
enum wined3d_container_type type;
union
{
struct wined3d_swapchain *swapchain;
struct wined3d_texture *texture;
void *base;
} u;
};
struct wined3d_surface_ops struct wined3d_surface_ops
{ {
HRESULT (*surface_private_setup)(struct wined3d_surface *surface); HRESULT (*surface_private_setup)(struct wined3d_surface *surface);
...@@ -2106,7 +2088,8 @@ struct wined3d_surface ...@@ -2106,7 +2088,8 @@ struct wined3d_surface
{ {
struct wined3d_resource resource; struct wined3d_resource resource;
const struct wined3d_surface_ops *surface_ops; const struct wined3d_surface_ops *surface_ops;
struct wined3d_subresource_container container; struct wined3d_texture *container;
struct wined3d_swapchain *swapchain;
struct wined3d_palette *palette; /* D3D7 style palette handling */ struct wined3d_palette *palette; /* D3D7 style palette handling */
DWORD draw_binding; DWORD draw_binding;
...@@ -2188,8 +2171,8 @@ void surface_prepare_texture(struct wined3d_surface *surface, ...@@ -2188,8 +2171,8 @@ void surface_prepare_texture(struct wined3d_surface *surface,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
const struct wined3d_surface *rt) DECLSPEC_HIDDEN; const struct wined3d_surface *rt) DECLSPEC_HIDDEN;
void surface_set_container(struct wined3d_surface *surface, void surface_set_container(struct wined3d_surface *surface, struct wined3d_texture *container) DECLSPEC_HIDDEN;
enum wined3d_container_type type, void *container) DECLSPEC_HIDDEN; void surface_set_swapchain(struct wined3d_surface *surface, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN; void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN; void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN;
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN; void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) 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