Commit 7bf2a345 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Pass a texture instead of a surface to context_create().

parent 72e373d2
...@@ -1559,7 +1559,7 @@ HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, ...@@ -1559,7 +1559,7 @@ HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc,
} }
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
struct wined3d_surface *target, const struct wined3d_format *ds_format) struct wined3d_texture *target, const struct wined3d_format *ds_format)
{ {
struct wined3d_device *device = swapchain->device; struct wined3d_device *device = swapchain->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
...@@ -1659,7 +1659,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1659,7 +1659,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
} }
} }
color_format = target->container->resource.format; color_format = target->resource.format;
/* In case of ORM_BACKBUFFER, make sure to request an alpha component for /* In case of ORM_BACKBUFFER, make sure to request an alpha component for
* X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */ * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
...@@ -1771,10 +1771,10 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, ...@@ -1771,10 +1771,10 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
} }
ret->swapchain = swapchain; ret->swapchain = swapchain;
ret->current_rt = target; ret->current_rt = target->sub_resources[0].u.surface;
ret->tid = GetCurrentThreadId(); ret->tid = GetCurrentThreadId();
ret->render_offscreen = wined3d_resource_is_offscreen(&target->container->resource); ret->render_offscreen = wined3d_resource_is_offscreen(&target->resource);
ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK); ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
ret->valid = 1; ret->valid = 1;
......
...@@ -4554,7 +4554,7 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d ...@@ -4554,7 +4554,7 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d
static HRESULT create_primary_opengl_context(struct wined3d_device *device, struct wined3d_swapchain *swapchain) static HRESULT create_primary_opengl_context(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{ {
struct wined3d_context *context; struct wined3d_context *context;
struct wined3d_surface *target; struct wined3d_texture *target;
HRESULT hr; HRESULT hr;
if (FAILED(hr = device->shader_backend->shader_alloc_private(device, if (FAILED(hr = device->shader_backend->shader_alloc_private(device,
...@@ -4581,9 +4581,7 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru ...@@ -4581,9 +4581,7 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
target = swapchain->back_buffers target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer;
? surface_from_resource(wined3d_texture_get_sub_resource(swapchain->back_buffers[0], 0))
: surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0));
if (!(context = context_create(swapchain, target, swapchain->ds_format))) if (!(context = context_create(swapchain, target, swapchain->ds_format)))
{ {
WARN("Failed to create context.\n"); WARN("Failed to create context.\n");
......
...@@ -983,7 +983,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 ...@@ -983,7 +983,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
for (i = 0; i < (sizeof(formats) / sizeof(*formats)); i++) for (i = 0; i < (sizeof(formats) / sizeof(*formats)); i++)
{ {
swapchain->ds_format = wined3d_get_format(gl_info, formats[i]); swapchain->ds_format = wined3d_get_format(gl_info, formats[i]);
swapchain->context[0] = context_create(swapchain, front_buffer, swapchain->ds_format); swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format);
if (swapchain->context[0]) break; if (swapchain->context[0]) break;
TRACE("Depth stencil format %s is not supported, trying next format\n", TRACE("Depth stencil format %s is not supported, trying next format\n",
debug_d3dformat(formats[i])); debug_d3dformat(formats[i]));
...@@ -1145,9 +1145,7 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain ...@@ -1145,9 +1145,7 @@ static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain
TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId()); TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
if (!(ctx = context_create(swapchain, if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)),
swapchain->ds_format)))
{ {
ERR("Failed to create a new context for the swapchain\n"); ERR("Failed to create a new context for the swapchain\n");
return NULL; return NULL;
......
...@@ -1515,7 +1515,7 @@ void context_active_texture(struct wined3d_context *context, const struct wined3 ...@@ -1515,7 +1515,7 @@ void context_active_texture(struct wined3d_context *context, const struct wined3
unsigned int unit) DECLSPEC_HIDDEN; unsigned int unit) DECLSPEC_HIDDEN;
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name) DECLSPEC_HIDDEN; void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name) DECLSPEC_HIDDEN;
void context_check_fbo_status(const struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN; void context_check_fbo_status(const struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_surface *target, struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_texture *target,
const struct wined3d_format *ds_format) DECLSPEC_HIDDEN; const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN; HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
void context_destroy(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN; void context_destroy(struct wined3d_device *device, struct wined3d_context *context) 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