wined3d: Make the adapter responsible for acquiring and releasing contexts.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
02e8841d2f
commit
6937b98700
|
@ -4338,50 +4338,15 @@ static void adapter_gl_destroy_device(struct wined3d_device *device)
|
|||
heap_free(device_gl);
|
||||
}
|
||||
|
||||
static HRESULT adapter_gl_create_context(struct wined3d_swapchain *swapchain, struct wined3d_context **context)
|
||||
struct wined3d_context *adapter_gl_acquire_context(struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
{
|
||||
struct wined3d_context_gl *context_gl;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("swapchain %p, context %p.\n", swapchain, context);
|
||||
|
||||
if (!(context_gl = heap_alloc_zero(sizeof(*context_gl))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = wined3d_context_gl_init(context_gl, swapchain)))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
heap_free(context_gl);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created context %p.\n", context_gl);
|
||||
*context = &context_gl->c;
|
||||
|
||||
return WINED3D_OK;
|
||||
return wined3d_context_gl_acquire(device, texture, sub_resource_idx);
|
||||
}
|
||||
|
||||
static void adapter_gl_destroy_context(struct wined3d_context *context)
|
||||
void adapter_gl_release_context(struct wined3d_context *context)
|
||||
{
|
||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||
|
||||
if (context_gl->c.current && context_gl->c.tid != GetCurrentThreadId())
|
||||
{
|
||||
struct wined3d_gl_info *gl_info;
|
||||
|
||||
/* Make a copy of gl_info for wined3d_context_gl_cleanup() use, the
|
||||
* one in wined3d_adapter may go away in the meantime. */
|
||||
gl_info = heap_alloc(sizeof(*gl_info));
|
||||
*gl_info = *context_gl->c.gl_info;
|
||||
context_gl->c.gl_info = gl_info;
|
||||
context_gl->c.destroyed = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
wined3d_context_gl_cleanup(context_gl);
|
||||
TlsSetValue(context_get_tls_idx(), NULL);
|
||||
heap_free(context_gl);
|
||||
return wined3d_context_gl_release(wined3d_context_gl(context));
|
||||
}
|
||||
|
||||
static void adapter_gl_get_wined3d_caps(const struct wined3d_adapter *adapter, struct wined3d_caps *caps)
|
||||
|
@ -4672,8 +4637,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
|
|||
adapter_gl_destroy,
|
||||
adapter_gl_create_device,
|
||||
adapter_gl_destroy_device,
|
||||
adapter_gl_create_context,
|
||||
adapter_gl_destroy_context,
|
||||
adapter_gl_acquire_context,
|
||||
adapter_gl_release_context,
|
||||
adapter_gl_get_wined3d_caps,
|
||||
adapter_gl_check_format,
|
||||
adapter_gl_init_3d,
|
||||
|
|
|
@ -28,6 +28,8 @@ struct wined3d_device_vk
|
|||
{
|
||||
struct wined3d_device d;
|
||||
|
||||
struct wined3d_context context_vk;
|
||||
|
||||
VkDevice vk_device;
|
||||
VkQueue vk_queue;
|
||||
|
||||
|
@ -288,33 +290,22 @@ static void adapter_vk_destroy_device(struct wined3d_device *device)
|
|||
heap_free(device_vk);
|
||||
}
|
||||
|
||||
static HRESULT adapter_vk_create_context(struct wined3d_swapchain *swapchain, struct wined3d_context **context)
|
||||
struct wined3d_context *adapter_vk_acquire_context(struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
{
|
||||
struct wined3d_context *context_vk;
|
||||
HRESULT hr;
|
||||
TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
|
||||
|
||||
TRACE("swapchain %p, context %p.\n", swapchain, context);
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
if (!(context_vk = heap_alloc_zero(sizeof(*context_vk))))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!device->context_count)
|
||||
return NULL;
|
||||
|
||||
if (FAILED(hr = wined3d_context_vk_init(context_vk, swapchain)))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
heap_free(context_vk);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created context %p.\n", context_vk);
|
||||
*context = context_vk;
|
||||
|
||||
return WINED3D_OK;
|
||||
return &wined3d_device_vk(device)->context_vk;
|
||||
}
|
||||
|
||||
static void adapter_vk_destroy_context(struct wined3d_context *context)
|
||||
void adapter_vk_release_context(struct wined3d_context *context)
|
||||
{
|
||||
wined3d_context_cleanup(context);
|
||||
heap_free(context);
|
||||
TRACE("context %p.\n", context);
|
||||
}
|
||||
|
||||
static void adapter_vk_get_wined3d_caps(const struct wined3d_adapter *adapter, struct wined3d_caps *caps)
|
||||
|
@ -425,14 +416,39 @@ static BOOL adapter_vk_check_format(const struct wined3d_adapter *adapter,
|
|||
|
||||
static HRESULT adapter_vk_init_3d(struct wined3d_device *device)
|
||||
{
|
||||
struct wined3d_context *context_vk;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("device %p.\n", device);
|
||||
|
||||
context_vk = &wined3d_device_vk(device)->context_vk;
|
||||
if (FAILED(hr = wined3d_context_vk_init(context_vk, device->swapchains[0])))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (!device_context_add(device, context_vk))
|
||||
{
|
||||
ERR("Failed to add the newly created context to the context list.\n");
|
||||
wined3d_context_cleanup(context_vk);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
TRACE("Initialised context %p.\n", context_vk);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
static void adapter_vk_uninit_3d(struct wined3d_device *device)
|
||||
{
|
||||
struct wined3d_context *context_vk;
|
||||
|
||||
TRACE("device %p.\n", device);
|
||||
|
||||
context_vk = &wined3d_device_vk(device)->context_vk;
|
||||
device_context_remove(device, context_vk);
|
||||
wined3d_context_cleanup(context_vk);
|
||||
}
|
||||
|
||||
static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
|
||||
|
@ -440,8 +456,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
|
|||
adapter_vk_destroy,
|
||||
adapter_vk_create_device,
|
||||
adapter_vk_destroy_device,
|
||||
adapter_vk_create_context,
|
||||
adapter_vk_destroy_context,
|
||||
adapter_vk_acquire_context,
|
||||
adapter_vk_release_context,
|
||||
adapter_vk_get_wined3d_caps,
|
||||
adapter_vk_check_format,
|
||||
adapter_vk_init_3d,
|
||||
|
|
|
@ -1328,7 +1328,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
|
|||
{
|
||||
}
|
||||
|
||||
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
|
||||
static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
|
||||
{
|
||||
struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
|
||||
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
|
||||
|
@ -1566,9 +1566,9 @@ BOOL context_set_current(struct wined3d_context *ctx)
|
|||
return TlsSetValue(wined3d_context_tls_idx, ctx);
|
||||
}
|
||||
|
||||
void context_release(struct wined3d_context *context)
|
||||
void wined3d_context_gl_release(struct wined3d_context_gl *context_gl)
|
||||
{
|
||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||
struct wined3d_context *context = &context_gl->c;
|
||||
|
||||
TRACE("Releasing context %p, level %u.\n", context_gl, context->level);
|
||||
|
||||
|
@ -1594,8 +1594,8 @@ void context_release(struct wined3d_context *context)
|
|||
|
||||
if (context->destroy_delayed)
|
||||
{
|
||||
TRACE("Destroying context %p.\n", context);
|
||||
wined3d_context_destroy(context);
|
||||
TRACE("Destroying context %p.\n", context_gl);
|
||||
wined3d_context_gl_destroy(context_gl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2302,54 +2302,45 @@ HRESULT wined3d_context_vk_init(struct wined3d_context *context_vk, struct wined
|
|||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain)
|
||||
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
|
||||
{
|
||||
struct wined3d_device *device = swapchain->device;
|
||||
struct wined3d_context *context;
|
||||
HRESULT hr;
|
||||
struct wined3d_device *device = context_gl->c.device;
|
||||
|
||||
TRACE("swapchain %p.\n", swapchain);
|
||||
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
if (FAILED(hr = device->adapter->adapter_ops->adapter_create_context(swapchain, &context)))
|
||||
return NULL;
|
||||
|
||||
if (!device_context_add(device, context))
|
||||
{
|
||||
ERR("Failed to add the newly created context to the context list.\n");
|
||||
device->adapter->adapter_ops->adapter_destroy_context(context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRACE("Created context %p.\n", context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
void wined3d_context_destroy(struct wined3d_context *context)
|
||||
{
|
||||
struct wined3d_device *device = context->device;
|
||||
|
||||
TRACE("Destroying ctx %p\n", context);
|
||||
TRACE("Destroying context %p.\n", context_gl);
|
||||
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
/* We delay destroying a context when it is active. The context_release()
|
||||
* function invokes wined3d_context_destroy() again while leaving the last
|
||||
* level. */
|
||||
if (context->level)
|
||||
* function invokes wined3d_context_gl_destroy() again while leaving the
|
||||
* last level. */
|
||||
if (context_gl->c.level)
|
||||
{
|
||||
TRACE("Delaying destruction of context %p.\n", context);
|
||||
context->destroy_delayed = 1;
|
||||
TRACE("Delaying destruction of context %p.\n", context_gl);
|
||||
context_gl->c.destroy_delayed = 1;
|
||||
/* FIXME: Get rid of a pointer to swapchain from wined3d_context. */
|
||||
context->swapchain = NULL;
|
||||
context_gl->c.swapchain = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
device_context_remove(device, context);
|
||||
device_context_remove(device, &context_gl->c);
|
||||
|
||||
device->adapter->adapter_ops->adapter_destroy_context(context);
|
||||
if (context_gl->c.current && context_gl->c.tid != GetCurrentThreadId())
|
||||
{
|
||||
struct wined3d_gl_info *gl_info;
|
||||
|
||||
/* Make a copy of gl_info for wined3d_context_gl_cleanup() use, the
|
||||
* one in wined3d_adapter may go away in the meantime. */
|
||||
gl_info = heap_alloc(sizeof(*gl_info));
|
||||
*gl_info = *context_gl->c.gl_info;
|
||||
context_gl->c.gl_info = gl_info;
|
||||
context_gl->c.destroyed = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
wined3d_context_gl_cleanup(context_gl);
|
||||
TlsSetValue(context_get_tls_idx(), NULL);
|
||||
heap_free(context_gl);
|
||||
}
|
||||
|
||||
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
|
||||
|
@ -4206,7 +4197,7 @@ static void wined3d_context_gl_activate(struct wined3d_context_gl *context_gl,
|
|||
}
|
||||
}
|
||||
|
||||
struct wined3d_context *context_acquire(const struct wined3d_device *device,
|
||||
struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
{
|
||||
struct wined3d_context *current_context = context_get_current();
|
||||
|
@ -4215,8 +4206,6 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device,
|
|||
|
||||
TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
|
||||
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
if (current_context && current_context->destroyed)
|
||||
current_context = NULL;
|
||||
|
||||
|
@ -4270,7 +4259,7 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device,
|
|||
return context;
|
||||
}
|
||||
|
||||
struct wined3d_context *context_reacquire(const struct wined3d_device *device,
|
||||
struct wined3d_context *context_reacquire(struct wined3d_device *device,
|
||||
struct wined3d_context *context)
|
||||
{
|
||||
struct wined3d_context *acquired_context;
|
||||
|
|
|
@ -1075,7 +1075,7 @@ void wined3d_device_delete_opengl_contexts_cs(void *object)
|
|||
if (device->contexts[0]->swapchain)
|
||||
swapchain_destroy_contexts(device->contexts[0]->swapchain);
|
||||
else
|
||||
wined3d_context_destroy(device->contexts[0]);
|
||||
wined3d_context_gl_destroy(wined3d_context_gl(device->contexts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2233,21 +2233,22 @@ static HRESULT adapter_no3d_create_device(struct wined3d *wined3d, const struct
|
|||
const enum wined3d_feature_level *levels, unsigned int level_count,
|
||||
struct wined3d_device_parent *device_parent, struct wined3d_device **device)
|
||||
{
|
||||
struct wined3d_device *object;
|
||||
struct wined3d_device_no3d *device_no3d;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(object = heap_alloc_zero(sizeof(*object))))
|
||||
if (!(device_no3d = heap_alloc_zero(sizeof(*device_no3d))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = wined3d_device_init(object, wined3d, adapter->ordinal, device_type,
|
||||
if (FAILED(hr = wined3d_device_init(&device_no3d->d, wined3d, adapter->ordinal, device_type,
|
||||
focus_window, flags, surface_alignment, levels, level_count, device_parent)))
|
||||
{
|
||||
WARN("Failed to initialize device, hr %#x.\n", hr);
|
||||
heap_free(object);
|
||||
heap_free(device_no3d);
|
||||
return hr;
|
||||
}
|
||||
|
||||
*device = object;
|
||||
*device = &device_no3d->d;
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
@ -2257,32 +2258,22 @@ static void adapter_no3d_destroy_device(struct wined3d_device *device)
|
|||
heap_free(device);
|
||||
}
|
||||
|
||||
static HRESULT adapter_no3d_create_context(struct wined3d_swapchain *swapchain, struct wined3d_context **context)
|
||||
struct wined3d_context *adapter_no3d_acquire_context(struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
{
|
||||
struct wined3d_context *context_no3d;
|
||||
TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
|
||||
|
||||
TRACE("swapchain %p, context %p.\n", swapchain, context);
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
if (!(context_no3d = heap_alloc_zero(sizeof(*context_no3d))))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!device->context_count)
|
||||
return NULL;
|
||||
|
||||
if (FAILED(wined3d_context_no3d_init(context_no3d, swapchain)))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
heap_free(context_no3d);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
TRACE("Created context %p.\n", context_no3d);
|
||||
*context = context_no3d;
|
||||
|
||||
return WINED3D_OK;
|
||||
return &wined3d_device_no3d(device)->context_no3d;
|
||||
}
|
||||
|
||||
static void adapter_no3d_destroy_context(struct wined3d_context *context)
|
||||
void adapter_no3d_release_context(struct wined3d_context *context)
|
||||
{
|
||||
wined3d_context_cleanup(context);
|
||||
heap_free(context);
|
||||
TRACE("context %p.\n", context);
|
||||
}
|
||||
|
||||
static void adapter_no3d_get_wined3d_caps(const struct wined3d_adapter *adapter, struct wined3d_caps *caps)
|
||||
|
@ -2298,11 +2289,32 @@ static BOOL adapter_no3d_check_format(const struct wined3d_adapter *adapter,
|
|||
|
||||
static HRESULT adapter_no3d_init_3d(struct wined3d_device *device)
|
||||
{
|
||||
struct wined3d_context *context_no3d;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("device %p.\n", device);
|
||||
|
||||
context_no3d = &wined3d_device_no3d(device)->context_no3d;
|
||||
if (FAILED(hr = wined3d_context_no3d_init(context_no3d, device->swapchains[0])))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (!device_context_add(device, context_no3d))
|
||||
{
|
||||
ERR("Failed to add the newly created context to the context list.\n");
|
||||
wined3d_context_cleanup(context_no3d);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
TRACE("Initialised context %p.\n", context_no3d);
|
||||
|
||||
if (!(device->blitter = wined3d_cpu_blitter_create()))
|
||||
{
|
||||
ERR("Failed to create CPU blitter.\n");
|
||||
device_context_remove(device, context_no3d);
|
||||
wined3d_context_cleanup(context_no3d);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
@ -2311,9 +2323,14 @@ static HRESULT adapter_no3d_init_3d(struct wined3d_device *device)
|
|||
|
||||
static void adapter_no3d_uninit_3d(struct wined3d_device *device)
|
||||
{
|
||||
struct wined3d_context *context_no3d;
|
||||
|
||||
TRACE("device %p.\n", device);
|
||||
|
||||
context_no3d = &wined3d_device_no3d(device)->context_no3d;
|
||||
device->blitter->ops->blitter_destroy(device->blitter, NULL);
|
||||
device_context_remove(device, context_no3d);
|
||||
wined3d_context_cleanup(context_no3d);
|
||||
}
|
||||
|
||||
static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
|
||||
|
@ -2321,8 +2338,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
|
|||
adapter_no3d_destroy,
|
||||
adapter_no3d_create_device,
|
||||
adapter_no3d_destroy_device,
|
||||
adapter_no3d_create_context,
|
||||
adapter_no3d_destroy_context,
|
||||
adapter_no3d_acquire_context,
|
||||
adapter_no3d_release_context,
|
||||
adapter_no3d_get_wined3d_caps,
|
||||
adapter_no3d_check_format,
|
||||
adapter_no3d_init_3d,
|
||||
|
|
|
@ -180,7 +180,7 @@ static BOOL wined3d_fence_supported(const struct wined3d_gl_info *gl_info)
|
|||
}
|
||||
|
||||
static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence,
|
||||
const struct wined3d_device *device, DWORD flags)
|
||||
struct wined3d_device *device, DWORD flags)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
|
@ -258,7 +258,7 @@ static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *
|
|||
}
|
||||
|
||||
enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
|
||||
const struct wined3d_device *device)
|
||||
struct wined3d_device *device)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
|
@ -332,7 +332,7 @@ enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device)
|
||||
void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device)
|
||||
{
|
||||
struct wined3d_context *context = NULL;
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
|
|
|
@ -149,7 +149,7 @@ static BOOL is_multisample_location(const struct wined3d_texture_gl *texture_gl,
|
|||
|
||||
/* Blit between surface locations. Onscreen on different swapchains is not supported.
|
||||
* Depth / stencil is not supported. Context activation is done by the caller. */
|
||||
static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3d_context *context,
|
||||
static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *context,
|
||||
enum wined3d_texture_filter_type filter, struct wined3d_texture *src_texture,
|
||||
unsigned int src_sub_resource_idx, DWORD src_location, const RECT *src_rect,
|
||||
struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location,
|
||||
|
|
|
@ -1059,32 +1059,51 @@ HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, struct win
|
|||
|
||||
static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain *swapchain)
|
||||
{
|
||||
struct wined3d_device *device = swapchain->device;
|
||||
struct wined3d_context_gl *context_gl;
|
||||
struct wined3d_context **ctx_array;
|
||||
struct wined3d_context *ctx;
|
||||
|
||||
TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
|
||||
|
||||
if (!(ctx = context_create(swapchain)))
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
if (!(context_gl = heap_alloc_zero(sizeof(*context_gl))))
|
||||
{
|
||||
ERR("Failed to create a new context for the swapchain\n");
|
||||
ERR("Failed to allocate context memory.\n");
|
||||
return NULL;
|
||||
}
|
||||
context_release(ctx);
|
||||
|
||||
if (FAILED(wined3d_context_gl_init(context_gl, swapchain)))
|
||||
{
|
||||
WARN("Failed to initialise context.\n");
|
||||
heap_free(context_gl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!device_context_add(device, &context_gl->c))
|
||||
{
|
||||
ERR("Failed to add the newly created context to the context list.\n");
|
||||
wined3d_context_gl_destroy(context_gl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRACE("Created context %p.\n", context_gl);
|
||||
|
||||
context_release(&context_gl->c);
|
||||
|
||||
if (!(ctx_array = heap_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
|
||||
{
|
||||
ERR("Out of memory when trying to allocate a new context array\n");
|
||||
wined3d_context_destroy(ctx);
|
||||
ERR("Failed to allocate new context array memory.\n");
|
||||
wined3d_context_gl_destroy(context_gl);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(ctx_array, swapchain->context, sizeof(*ctx_array) * swapchain->num_contexts);
|
||||
heap_free(swapchain->context);
|
||||
ctx_array[swapchain->num_contexts] = ctx;
|
||||
ctx_array[swapchain->num_contexts] = &context_gl->c;
|
||||
swapchain->context = ctx_array;
|
||||
swapchain->num_contexts++;
|
||||
|
||||
TRACE("Returning context %p\n", ctx);
|
||||
return ctx;
|
||||
return &context_gl->c;
|
||||
}
|
||||
|
||||
void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain)
|
||||
|
@ -1093,7 +1112,7 @@ void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain)
|
|||
|
||||
for (i = 0; i < swapchain->num_contexts; ++i)
|
||||
{
|
||||
wined3d_context_destroy(swapchain->context[i]);
|
||||
wined3d_context_gl_destroy(wined3d_context_gl(swapchain->context[i]));
|
||||
}
|
||||
heap_free(swapchain->context);
|
||||
swapchain->num_contexts = 0;
|
||||
|
|
|
@ -490,7 +490,7 @@ static void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture
|
|||
static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
|
||||
{
|
||||
unsigned int sub_count = texture->level_count * texture->layer_count;
|
||||
const struct wined3d_device *device = texture->resource.device;
|
||||
struct wined3d_device *device = texture->resource.device;
|
||||
DWORD map_binding = texture->update_map_binding;
|
||||
struct wined3d_context *context = NULL;
|
||||
unsigned int i;
|
||||
|
|
|
@ -1733,9 +1733,9 @@ struct wined3d_fence
|
|||
|
||||
HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
|
||||
void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
|
||||
void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
|
||||
const struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
|
||||
/* Direct3D terminology with little modifications. We do not have an issued
|
||||
* state because only the driver knows about it, but we have a created state
|
||||
|
@ -2057,6 +2057,8 @@ static inline const struct wined3d_context_gl *wined3d_context_gl_const(const st
|
|||
return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
|
||||
}
|
||||
|
||||
struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
|
||||
const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
|
||||
|
@ -2081,7 +2083,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
|
|||
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
|
||||
GLenum target, GLuint name) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
|
||||
|
@ -2094,6 +2096,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
|
|||
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
|
||||
const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
|
||||
const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
|
||||
|
@ -2232,16 +2235,12 @@ void wined3d_raw_blitter_create(struct wined3d_blitter **next,
|
|||
|
||||
BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
|
||||
|
||||
struct wined3d_context *context_acquire(const struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
|
||||
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
|
||||
void context_bind_dummy_textures(const struct wined3d_context *context) DECLSPEC_HIDDEN;
|
||||
void context_copy_bo_address(struct wined3d_context *context,
|
||||
const struct wined3d_bo_address *dst, GLenum dst_binding,
|
||||
const struct wined3d_bo_address *src, GLenum src_binding, size_t size) DECLSPEC_HIDDEN;
|
||||
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
|
||||
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
|
||||
void wined3d_context_destroy(struct wined3d_context *context) DECLSPEC_HIDDEN;
|
||||
void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_texture_gl *texture_gl,
|
||||
unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
|
||||
enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
|
||||
|
@ -2258,9 +2257,8 @@ void context_invalidate_compute_state(struct wined3d_context *context, DWORD sta
|
|||
void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
|
||||
void *context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data,
|
||||
size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
|
||||
struct wined3d_context *context_reacquire(const struct wined3d_device *device,
|
||||
struct wined3d_context *context_reacquire(struct wined3d_device *device,
|
||||
struct wined3d_context *context) DECLSPEC_HIDDEN;
|
||||
void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
|
||||
void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
|
||||
unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
|
||||
|
@ -2745,8 +2743,9 @@ struct wined3d_adapter_ops
|
|||
BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
|
||||
struct wined3d_device_parent *device_parent, struct wined3d_device **device);
|
||||
void (*adapter_destroy_device)(struct wined3d_device *device);
|
||||
HRESULT (*adapter_create_context)(struct wined3d_swapchain *swapchain, struct wined3d_context **context);
|
||||
void (*adapter_destroy_context)(struct wined3d_context *context);
|
||||
struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx);
|
||||
void (*adapter_release_context)(struct wined3d_context *context);
|
||||
void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
|
||||
BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
|
||||
const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
|
||||
|
@ -3240,6 +3239,18 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
|
|||
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
|
||||
void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
|
||||
struct wined3d_device_no3d
|
||||
{
|
||||
struct wined3d_device d;
|
||||
|
||||
struct wined3d_context context_no3d;
|
||||
};
|
||||
|
||||
static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
|
||||
{
|
||||
return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
|
||||
}
|
||||
|
||||
struct wined3d_device_gl
|
||||
{
|
||||
struct wined3d_device d;
|
||||
|
@ -4899,6 +4910,19 @@ BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) D
|
|||
void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
|
||||
const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx)
|
||||
{
|
||||
wined3d_from_cs(device->cs);
|
||||
|
||||
return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
|
||||
}
|
||||
|
||||
static inline void context_release(struct wined3d_context *context)
|
||||
{
|
||||
context->device->adapter->adapter_ops->adapter_release_context(context);
|
||||
}
|
||||
|
||||
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
|
||||
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
|
||||
|
||||
|
|
Loading…
Reference in New Issue