Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2019
- 73 participants
- 565 discussions
05 Jun '19
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 18 ++++--
libs/vkd3d/resource.c | 129 ++++++++++++++++++++++++++++++-------
libs/vkd3d/vkd3d_private.h | 3 +
3 files changed, 119 insertions(+), 31 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index ddec0f7cae67..e83b7fa9258c 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2780,14 +2780,20 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Device *iface,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
- const D3D12_CLEAR_VALUE *optimized_clear_value,
- REFIID riid, void **resource)
+ const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
{
- FIXME("iface %p, desc %p, initial_state %#x, optimized_clear_value %p, "
- "riid %s, resource %p stub!\n",
- iface, desc, initial_state, optimized_clear_value, debugstr_guid(riid), resource);
+ struct d3d12_device *device = impl_from_ID3D12Device(iface);
+ struct d3d12_resource *object;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("iface %p, desc %p, initial_state %#x, optimized_clear_value %p, iid %s, resource %p.\n",
+ iface, desc, initial_state, optimized_clear_value, debugstr_guid(iid), resource);
+
+ if (FAILED(hr = d3d12_reserved_resource_create(device,
+ desc, initial_state, optimized_clear_value, &object)))
+ return hr;
+
+ return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateSharedHandle(ID3D12Device *iface,
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index c3c92386da08..30ef9018d775 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -21,6 +21,8 @@
#define VKD3D_NULL_BUFFER_SIZE 16
#define VKD3D_NULL_VIEW_FORMAT DXGI_FORMAT_R8G8B8A8_UNORM
+#define VKD3D_HEAP_TYPE_INVALID ((D3D12_HEAP_TYPE)~0u)
+
static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32_t memory_type_mask,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
{
@@ -497,14 +499,25 @@ HRESULT vkd3d_create_buffer(struct d3d12_device *device,
const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+ const bool sparse_resource = !heap_properties;
VkBufferCreateInfo buffer_info;
+ D3D12_HEAP_TYPE heap_type;
VkResult vr;
+ heap_type = heap_properties ? heap_properties->Type : D3D12_HEAP_TYPE_DEFAULT;
+
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
buffer_info.pNext = NULL;
buffer_info.flags = 0;
buffer_info.size = desc->Width;
+ if (sparse_resource)
+ {
+ buffer_info.flags |= VK_BUFFER_CREATE_SPARSE_BINDING_BIT;
+ if (device->vk_info.sparse_properties.residencyNonResidentStrict)
+ buffer_info.flags |= VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT;
+ }
+
buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT
| VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
@@ -512,16 +525,15 @@ HRESULT vkd3d_create_buffer(struct d3d12_device *device,
| VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
| VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
- if (heap_properties->Type == D3D12_HEAP_TYPE_DEFAULT
- && device->vk_info.EXT_transform_feedback)
+ if (heap_type == D3D12_HEAP_TYPE_DEFAULT && device->vk_info.EXT_transform_feedback)
{
buffer_info.usage |= VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT
| VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT;
}
- if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD)
+ if (heap_type == D3D12_HEAP_TYPE_UPLOAD)
buffer_info.usage &= ~VK_BUFFER_USAGE_TRANSFER_DST_BIT;
- else if (heap_properties->Type == D3D12_HEAP_TYPE_READBACK)
+ else if (heap_type == D3D12_HEAP_TYPE_READBACK)
buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
if (desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
@@ -573,6 +585,7 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
const D3D12_RESOURCE_DESC *desc, VkImage *vk_image)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+ const bool sparse_resource = !heap_properties;
const struct vkd3d_format *format;
VkImageCreateInfo image_info;
VkResult vr;
@@ -595,6 +608,13 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
image_info.flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR;
+ if (sparse_resource)
+ {
+ image_info.flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT;
+ if (device->vk_info.sparse_properties.residencyNonResidentStrict)
+ image_info.flags |= VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
+ }
+
image_info.imageType = vk_image_type_from_d3d12_resource_dimension(desc->Dimension);
image_info.format = format->vk_format;
image_info.extent.width = desc->Width;
@@ -614,7 +634,17 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
image_info.mipLevels = min(desc->MipLevels, max_miplevel_count(desc));
image_info.samples = vk_samples_from_dxgi_sample_desc(&desc->SampleDesc);
- if (desc->Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN)
+ if (sparse_resource)
+ {
+ if (desc->Layout != D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE)
+ {
+ WARN("D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE must be used for reserved texture.\n");
+ return E_INVALIDARG;
+ }
+
+ image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
+ }
+ else if (desc->Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN)
{
image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
}
@@ -652,7 +682,7 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
image_info.pQueueFamilyIndices = NULL;
}
- image_info.initialLayout = is_cpu_accessible_heap(heap_properties) ?
+ image_info.initialLayout = heap_properties && is_cpu_accessible_heap(heap_properties) ?
VK_IMAGE_LAYOUT_PREINITIALIZED : VK_IMAGE_LAYOUT_UNDEFINED;
if ((vr = VK_CALL(vkCreateImage(device->vk_device, &image_info, NULL, vk_image))) < 0)
@@ -1155,6 +1185,12 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource
TRACE("iface %p, heap_properties %p, flags %p.\n",
iface, heap_properties, flags);
+ if (resource->heap_properties.Type == VKD3D_HEAP_TYPE_INVALID)
+ {
+ WARN("Cannot get heap properties for reserved resources.\n");
+ return E_INVALIDARG;
+ }
+
if (heap_properties)
*heap_properties = resource->heap_properties;
if (flags)
@@ -1255,46 +1291,55 @@ HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc)
return S_OK;
}
-static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12_device *device,
- const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
- const D3D12_CLEAR_VALUE *optimized_clear_value)
+static bool d3d12_resource_validate_heap_properties(const struct d3d12_resource *resource,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_RESOURCE_STATES initial_state)
{
- HRESULT hr;
-
- resource->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
- resource->refcount = 1;
- resource->internal_refcount = 1;
-
- resource->desc = *desc;
-
if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD
|| heap_properties->Type == D3D12_HEAP_TYPE_READBACK)
{
if (d3d12_resource_is_texture(resource))
{
WARN("Textures cannot be created on upload/readback heaps.\n");
- return E_INVALIDARG;
+ return false;
}
- if (desc->Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS))
+ if (resource->desc.Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS))
{
WARN("Render target and unordered access buffers cannot be created on upload/readback heaps.\n");
- return E_INVALIDARG;
+ return false;
}
}
if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD && initial_state != D3D12_RESOURCE_STATE_GENERIC_READ)
{
WARN("For D3D12_HEAP_TYPE_UPLOAD the state must be D3D12_RESOURCE_STATE_GENERIC_READ.\n");
- return E_INVALIDARG;
+ return false;
}
if (heap_properties->Type == D3D12_HEAP_TYPE_READBACK && initial_state != D3D12_RESOURCE_STATE_COPY_DEST)
{
WARN("For D3D12_HEAP_TYPE_READBACK the state must be D3D12_RESOURCE_STATE_COPY_DEST.\n");
- return E_INVALIDARG;
+ return false;
}
+ return true;
+}
+
+static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12_device *device,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
+ const D3D12_CLEAR_VALUE *optimized_clear_value)
+{
+ HRESULT hr;
+
+ resource->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl;
+ resource->refcount = 1;
+ resource->internal_refcount = 1;
+
+ resource->desc = *desc;
+
+ if (heap_properties && !d3d12_resource_validate_heap_properties(resource, heap_properties, initial_state))
+ return E_INVALIDARG;
+
if (!is_valid_resource_state(initial_state))
{
WARN("Invalid initial resource state %#x.\n", initial_state);
@@ -1351,8 +1396,18 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12
resource->map_count = 0;
resource->map_ptr = NULL;
- resource->heap_properties = *heap_properties;
- resource->heap_flags = heap_flags;
+ if (heap_properties)
+ {
+ resource->heap_properties = *heap_properties;
+ resource->heap_flags = heap_flags;
+ }
+ else
+ {
+ memset(&resource->heap_properties, 0, sizeof(resource->heap_properties));
+ resource->heap_properties.Type = VKD3D_HEAP_TYPE_INVALID;
+ resource->heap_flags = 0;
+ }
+
resource->initial_state = initial_state;
resource->heap = NULL;
@@ -1417,6 +1472,12 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
struct d3d12_resource *object;
HRESULT hr;
+ if (!heap_properties)
+ {
+ WARN("Heap properties are NULL.\n");
+ return E_INVALIDARG;
+ }
+
if (FAILED(hr = d3d12_resource_create(device, heap_properties, heap_flags,
desc, initial_state, optimized_clear_value, &object)))
return hr;
@@ -1503,6 +1564,24 @@ HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_h
return S_OK;
}
+HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
+ const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
+{
+ struct d3d12_resource *object;
+ HRESULT hr;
+
+ if (FAILED(hr = d3d12_resource_create(device, NULL, 0,
+ desc, initial_state, optimized_clear_value, &object)))
+ return hr;
+
+ TRACE("Created reserved resource %p.\n", object);
+
+ *resource = object;
+
+ return S_OK;
+}
+
HRESULT vkd3d_create_image_resource(ID3D12Device *device,
const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
{
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 71e05b245230..2d31cacc101e 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -402,6 +402,9 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, UINT64 heap_offset,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
+HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
+ const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface) DECLSPEC_HIDDEN;
HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer,
--
2.21.0
2
1
[PATCH 5/5] wined3d: Make the adapter responsible for acquiring and releasing contexts.
by Henri Verbeet 05 Jun '19
by Henri Verbeet 05 Jun '19
05 Jun '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/adapter_gl.c | 49 ++++-----------------------
dlls/wined3d/adapter_vk.c | 60 ++++++++++++++++++++-------------
dlls/wined3d/context.c | 75 ++++++++++++++++++------------------------
dlls/wined3d/device.c | 2 +-
dlls/wined3d/directx.c | 69 +++++++++++++++++++++++---------------
dlls/wined3d/query.c | 6 ++--
dlls/wined3d/surface.c | 2 +-
dlls/wined3d/swapchain.c | 39 ++++++++++++++++------
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/wined3d_private.h | 46 +++++++++++++++++++-------
10 files changed, 190 insertions(+), 160 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index 110771f8ea9..c8ebe346431 100644
--- a/dlls/wined3d/adapter_gl.c
+++ b/dlls/wined3d/adapter_gl.c
@@ -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,
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index b944b2fb32a..00098182c1a 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -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("swapchain %p, context %p.\n", swapchain, context);
+ TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
- if (!(context_vk = heap_alloc_zero(sizeof(*context_vk))))
- return E_OUTOFMEMORY;
-
- if (FAILED(hr = wined3d_context_vk_init(context_vk, swapchain)))
- {
- WARN("Failed to initialise context.\n");
- heap_free(context_vk);
- return hr;
- }
+ wined3d_from_cs(device->cs);
- TRACE("Created context %p.\n", context_vk);
- *context = context_vk;
+ if (!device->context_count)
+ return NULL;
- 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,
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 2a2b2e8a87c..9784a48f91f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -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);
+ TRACE("Destroying context %p.\n", context_gl);
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))
+ /* We delay destroying a context when it is active. The context_release()
+ * function invokes wined3d_context_gl_destroy() again while leaving the
+ * last level. */
+ if (context_gl->c.level)
{
- ERR("Failed to add the newly created context to the context list.\n");
- device->adapter->adapter_ops->adapter_destroy_context(context);
- return NULL;
+ 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_gl->c.swapchain = NULL;
+ return;
}
- TRACE("Created context %p.\n", context);
+ device_context_remove(device, &context_gl->c);
- return context;
-}
-
-void wined3d_context_destroy(struct wined3d_context *context)
-{
- struct wined3d_device *device = context->device;
-
- TRACE("Destroying ctx %p\n", context);
+ if (context_gl->c.current && context_gl->c.tid != GetCurrentThreadId())
+ {
+ struct wined3d_gl_info *gl_info;
- wined3d_from_cs(device->cs);
+ /* 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;
- /* 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)
- {
- TRACE("Delaying destruction of context %p.\n", context);
- context->destroy_delayed = 1;
- /* FIXME: Get rid of a pointer to swapchain from wined3d_context. */
- context->swapchain = NULL;
return;
}
- device_context_remove(device, context);
-
- device->adapter->adapter_ops->adapter_destroy_context(context);
+ 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;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 683401bd1da..ed77a6e144a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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]));
}
}
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 49fa3a35f74..313e522f4a5 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -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("swapchain %p, context %p.\n", swapchain, context);
-
- if (!(context_no3d = heap_alloc_zero(sizeof(*context_no3d))))
- return E_OUTOFMEMORY;
+ TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
- if (FAILED(wined3d_context_no3d_init(context_no3d, swapchain)))
- {
- WARN("Failed to initialise context.\n");
- heap_free(context_no3d);
- return E_FAIL;
- }
+ wined3d_from_cs(device->cs);
- TRACE("Created context %p.\n", context_no3d);
- *context = context_no3d;
+ if (!device->context_count)
+ return NULL;
- 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,
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 87c50eebe51..eeec8e25098 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -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;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a30605b912a..7d126420d17 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -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,
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 481b3b718ed..2c816218c8e 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -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 allocate context memory.\n");
+ return NULL;
+ }
+
+ if (FAILED(wined3d_context_gl_init(context_gl, swapchain)))
{
- ERR("Failed to create a new context for the swapchain\n");
+ WARN("Failed to initialise context.\n");
+ heap_free(context_gl);
return NULL;
}
- context_release(ctx);
+
+ 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;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index beda90093c3..dc60d874bd6 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -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;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 864476c6f07..89d3272a091 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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"
--
2.11.0
1
0
[PATCH 4/5] wined3d: Move the blit dimension fields from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 05 Jun '19
by Henri Verbeet 05 Jun '19
05 Jun '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 12 +++++-------
dlls/wined3d/wined3d_private.h | 4 ++--
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 86003610023..2a2b2e8a87c 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2791,12 +2791,11 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
if (context->last_was_blit)
{
- if (context->blit_w != rt_size.cx || context->blit_h != rt_size.cy)
+ if (context_gl->blit_size.cx != rt_size.cx || context_gl->blit_size.cy != rt_size.cy)
{
gl_info->gl_ops.gl.p_glViewport(0, 0, rt_size.cx, rt_size.cy);
context->viewport_count = WINED3D_MAX_VIEWPORTS;
- context->blit_w = rt_size.cx;
- context->blit_h = rt_size.cy;
+ context_gl->blit_size = rt_size;
/* No need to dirtify here, the states are still dirtified because
* they weren't applied since the last context_apply_blit_state()
* call. */
@@ -2870,8 +2869,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
device->shader_backend->shader_disable(device->shader_priv, context);
- context->blit_w = rt_size.cx;
- context->blit_h = rt_size.cy;
+ context_gl->blit_size = rt_size;
checkGLcall("blit state application");
}
@@ -2909,7 +2907,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
SIZE rt_size;
wined3d_context_gl_get_rt_size(context_gl, &rt_size);
- if (context->blit_w != rt_size.cx || context->blit_h != rt_size.cy)
+ if (context_gl->blit_size.cx != rt_size.cx || context_gl->blit_size.cy != rt_size.cy)
context_apply_blit_projection(context, rt_size.cx, rt_size.cy);
wined3d_context_gl_apply_blit_state(context_gl, device);
@@ -2964,7 +2962,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
gl_info->gl_ops.gl.p_glLoadIdentity();
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
- context_apply_blit_projection(context, context->blit_w, context->blit_h);
+ context_apply_blit_projection(context, context_gl->blit_size.cx, context_gl->blit_size.cy);
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
/* Other misc states. */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 4eddc55cd5b..864476c6f07 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1944,8 +1944,7 @@ struct wined3d_context
DWORD numbered_array_mask;
GLenum tracking_parm; /* Which source is tracking current colour */
GLenum untracked_materials[2];
- UINT blit_w, blit_h;
- enum fogsource fog_source;
+ enum fogsource fog_source;
UINT instance_count;
@@ -1982,6 +1981,7 @@ struct wined3d_context_gl
uint32_t default_attrib_value_set;
+ SIZE blit_size;
unsigned int active_texture;
GLenum *texture_type;
--
2.11.0
1
0
[PATCH 3/5] wined3d: Move the "active_texture" field from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 05 Jun '19
by Henri Verbeet 05 Jun '19
05 Jun '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 4 ++--
dlls/wined3d/texture.c | 4 ++--
dlls/wined3d/view.c | 6 +++---
dlls/wined3d/wined3d_private.h | 3 ++-
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 7988eb6dd9d..86003610023 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2520,7 +2520,7 @@ void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
{
GL_EXTCALL(glActiveTexture(GL_TEXTURE0 + unit));
checkGLcall("glActiveTexture");
- context_gl->c.active_texture = unit;
+ context_gl->active_texture = unit;
}
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name)
@@ -2545,7 +2545,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLen
else
target = GL_NONE;
- unit = context_gl->c.active_texture;
+ unit = context_gl->active_texture;
old_texture_type = context_gl->texture_type[unit];
if (old_texture_type != target)
{
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e3d9d54900c..beda90093c3 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1061,9 +1061,9 @@ void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
* called from sampler() in state.c. This means we can't touch anything
* other than whatever happens to be the currently active texture, or we
* would risk marking already applied sampler states dirty again. */
- if (context_gl->c.active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
+ if (context_gl->active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
{
- unsigned int active_sampler = context_gl->rev_tex_unit_map[context_gl->c.active_texture];
+ unsigned int active_sampler = context_gl->rev_tex_unit_map[context_gl->active_texture];
if (active_sampler != WINED3D_UNMAPPED_STAGE)
context_invalidate_state(&context_gl->c, STATE_SAMPLER(active_sampler));
}
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 1d61d09c25f..b43dcddcdf2 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -858,9 +858,9 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resource_view_gl *view_gl,
struct wined3d_context_gl *context_gl)
{
- if (context_gl->c.active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
+ if (context_gl->active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
{
- unsigned int active_sampler = context_gl->rev_tex_unit_map[context_gl->c.active_texture];
+ unsigned int active_sampler = context_gl->rev_tex_unit_map[context_gl->active_texture];
if (active_sampler != WINED3D_UNMAPPED_STAGE)
context_invalidate_state(&context_gl->c, STATE_SAMPLER(active_sampler));
}
@@ -912,7 +912,7 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *
}
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
- GL_EXTCALL(glBindSampler(context->active_texture, 0));
+ GL_EXTCALL(glBindSampler(context_gl->active_texture, 0));
gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, srgb);
if (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ec40e3bd48c..4eddc55cd5b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1946,7 +1946,6 @@ struct wined3d_context
GLenum untracked_materials[2];
UINT blit_w, blit_h;
enum fogsource fog_source;
- DWORD active_texture;
UINT instance_count;
@@ -1983,6 +1982,8 @@ struct wined3d_context_gl
uint32_t default_attrib_value_set;
+ unsigned int active_texture;
+
GLenum *texture_type;
/* The WGL context. */
--
2.11.0
1
0
[PATCH 2/5] wined3d: Pass a wined3d_context_gl structure to context_active_texture().
by Henri Verbeet 05 Jun '19
by Henri Verbeet 05 Jun '19
05 Jun '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/arb_program_shader.c | 2 +-
dlls/wined3d/ati_fragment_shader.c | 2 +-
dlls/wined3d/context.c | 15 ++++++++-------
dlls/wined3d/device.c | 2 +-
dlls/wined3d/glsl_shader.c | 4 ++--
dlls/wined3d/nvidia_texture_shader.c | 8 ++++----
dlls/wined3d/state.c | 22 +++++++++++++---------
dlls/wined3d/view.c | 2 +-
dlls/wined3d/wined3d_private.h | 4 ++--
9 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index e6546abf842..29908b8bae9 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7379,7 +7379,7 @@ static void arbfp_blitter_upload_palette(struct wined3d_arbfp_blitter *blitter,
}
/* Switch back to unit 0 in which the 2D texture will be stored. */
- context_active_texture(&context_gl->c, gl_info, 0);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 0);
}
/* Context activation is done by the caller. */
diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c
index 0a7b832c7f9..e166d99bf1f 100644
--- a/dlls/wined3d/ati_fragment_shader.c
+++ b/dlls/wined3d/ati_fragment_shader.c
@@ -1055,7 +1055,7 @@ static void set_tex_op_atifs(struct wined3d_context *context, const struct wined
mapped_stage = context_gl->tex_unit_map[i];
if (mapped_stage != WINED3D_UNMAPPED_STAGE)
{
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
texture_activate_dimensions(state->textures[i], gl_info);
}
}
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 9dbdd945f09..7988eb6dd9d 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2209,7 +2209,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
*/
for (i = 1; i < gl_info->limits.textures; ++i)
{
- context_active_texture(context, gl_info, i);
+ wined3d_context_gl_active_texture(context_gl, gl_info, i);
gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV,
GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + i - 1);
checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...");
@@ -2240,7 +2240,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
{
for (i = 0; i < gl_info->limits.textures; ++i)
{
- context_active_texture(context, gl_info, i);
+ wined3d_context_gl_active_texture(context_gl, gl_info, i);
gl_info->gl_ops.gl.p_glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
}
@@ -2515,11 +2515,12 @@ void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, G
}
/* Context activation is done by the caller. */
-void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
+void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
+ const struct wined3d_gl_info *gl_info, unsigned int unit)
{
GL_EXTCALL(glActiveTexture(GL_TEXTURE0 + unit));
checkGLcall("glActiveTexture");
- context->active_texture = unit;
+ context_gl->c.active_texture = unit;
}
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name)
@@ -2808,7 +2809,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
GL_EXTCALL(glBindSampler(0, 0));
- context_active_texture(context, gl_info, 0);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 0);
sampler = context_gl->rev_tex_unit_map[0];
if (sampler != WINED3D_UNMAPPED_STAGE)
@@ -2923,7 +2924,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
* from. */
for (i = gl_info->limits.textures - 1; i > 0 ; --i)
{
- context_active_texture(context, gl_info, i);
+ wined3d_context_gl_active_texture(context_gl, gl_info, i);
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
@@ -2943,7 +2944,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
}
}
- context_active_texture(context, gl_info, 0);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 0);
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 6cfc2b23d6c..683401bd1da 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -690,7 +690,7 @@ static void wined3d_device_gl_create_dummy_textures(struct wined3d_device_gl *de
* OpenGL will only allow that when a valid texture is bound.
* We emulate this by creating dummy textures and binding them
* to each texture stage when the currently set D3D texture is NULL. */
- context_active_texture(&context_gl->c, gl_info, 0);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 0);
gl_info->gl_ops.gl.p_glGenTextures(1, &textures->tex_1d);
TRACE("Dummy 1D texture given name %u.\n", textures->tex_1d);
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index fe8812bcbb5..ab62c1ca599 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -12779,7 +12779,7 @@ static void glsl_blitter_upload_palette(struct wined3d_glsl_blitter *blitter,
if (!blitter->palette_texture)
gl_info->gl_ops.gl.p_glGenTextures(1, &blitter->palette_texture);
- context_active_texture(&context_gl->c, gl_info, 1);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 1);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, blitter->palette_texture);
gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -12799,7 +12799,7 @@ static void glsl_blitter_upload_palette(struct wined3d_glsl_blitter *blitter,
GL_UNSIGNED_INT_8_8_8_8_REV, &black);
}
- context_active_texture(&context_gl->c, gl_info, 0);
+ wined3d_context_gl_active_texture(context_gl, gl_info, 0);
}
/* Context activation is done by the caller. */
diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c
index c95a6cb3539..f4b0791f47d 100644
--- a/dlls/wined3d/nvidia_texture_shader.c
+++ b/dlls/wined3d/nvidia_texture_shader.c
@@ -501,7 +501,7 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
FIXME("Attempt to enable unsupported stage!\n");
return;
}
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
}
if (context->lowest_disabled_stage > 0)
@@ -579,9 +579,9 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
BOOL usedBump = !!(context->texShaderBumpMap & 1u << (stage + 1));
if (usesBump != usedBump)
{
- context_active_texture(context, gl_info, mapped_stage + 1);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage + 1);
nvts_activate_dimensions(state, stage + 1, context);
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
}
}
}
@@ -639,7 +639,7 @@ static void nvts_bumpenvmat(struct wined3d_context *context, const struct wined3
*/
if (mapped_stage < gl_info->limits.textures)
{
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
/* We can't just pass a pointer to the state to GL due to the
* different matrix format (column major vs row major). */
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 08423e831fd..b2fcbddd57f 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -827,6 +827,7 @@ static void state_specularenable(struct wined3d_context *context, const struct w
static void state_texfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
+ struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_color color;
unsigned int i;
@@ -840,7 +841,7 @@ static void state_texfactor(struct wined3d_context *context, const struct wined3
{
/* Note the WINED3D_RS value applies to all textures, but GL has one
* per texture, so apply it now ready to be used! */
- context_active_texture(context, gl_info, i);
+ wined3d_context_gl_active_texture(context_gl, gl_info, i);
gl_info->gl_ops.gl.p_glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r);
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
@@ -3128,8 +3129,9 @@ static void set_tex_op(const struct wined3d_gl_info *gl_info, const struct wined
static void tex_colorop(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
unsigned int stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- unsigned int mapped_stage = wined3d_context_gl(context)->tex_unit_map[stage];
+ struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
BOOL tex_used = context->fixed_function_usage_map & (1u << stage);
+ unsigned int mapped_stage = context_gl->tex_unit_map[stage];
const struct wined3d_gl_info *gl_info = context->gl_info;
TRACE("Setting color op for stage %d\n", stage);
@@ -3146,7 +3148,7 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st
FIXME("Attempt to enable unsupported stage!\n");
return;
}
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
}
if (stage >= context->lowest_disabled_stage)
@@ -3189,8 +3191,9 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st
void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
unsigned int stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- unsigned int mapped_stage = wined3d_context_gl(context)->tex_unit_map[stage];
+ struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
BOOL tex_used = context->fixed_function_usage_map & (1u << stage);
+ unsigned int mapped_stage = context_gl->tex_unit_map[stage];
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD op, arg1, arg2, arg0;
@@ -3203,7 +3206,7 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
FIXME("Attempt to enable unsupported stage!\n");
return;
}
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
}
op = state->texture_states[stage][WINED3D_TSS_ALPHA_OP];
@@ -3288,7 +3291,8 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
static void transform_texture(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
unsigned int tex = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- unsigned int mapped_stage = wined3d_context_gl(context)->tex_unit_map[tex];
+ struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
+ unsigned int mapped_stage = context_gl->tex_unit_map[tex];
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_matrix mat;
@@ -3302,7 +3306,7 @@ static void transform_texture(struct wined3d_context *context, const struct wine
if (mapped_stage == WINED3D_UNMAPPED_STAGE) return;
if (mapped_stage >= gl_info->limits.textures) return;
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
checkGLcall("glMatrixMode(GL_TEXTURE)");
@@ -3335,7 +3339,7 @@ static void tex_coordindex(struct wined3d_context *context, const struct wined3d
WARN("stage %u not mapped to a valid texture unit (%u)\n", stage, mapped_stage);
return;
}
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
/* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
*
@@ -3613,7 +3617,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
if (mapped_stage >= gl_info->limits.graphics_samplers)
return;
- context_active_texture(context, gl_info, mapped_stage);
+ wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
if (state->textures[sampler_idx])
{
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index a8f319f06a1..1d61d09c25f 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -834,7 +834,7 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture_gl *texture_gl;
- context_active_texture(context, gl_info, unit);
+ wined3d_context_gl_active_texture(context_gl, gl_info, unit);
if (view_gl->gl_view.name)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a373cc97b9b..ec40e3bd48c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2056,6 +2056,8 @@ static inline const struct wined3d_context_gl *wined3d_context_gl_const(const st
return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
}
+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,
struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
@@ -2231,8 +2233,6 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP
struct wined3d_context *context_acquire(const struct wined3d_device *device,
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
-void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info,
- unsigned int unit) 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,
--
2.11.0
1
0
[PATCH 1/5] wined3d: Pass a wined3d_context_gl structure to shader_resource_view_gl_bind_and_dirtify().
by Henri Verbeet 05 Jun '19
by Henri Verbeet 05 Jun '19
05 Jun '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/view.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index f3de77022b6..a8f319f06a1 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -856,20 +856,18 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
/* Context activation is done by the caller. */
static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resource_view_gl *view_gl,
- struct wined3d_context *context)
+ struct wined3d_context_gl *context_gl)
{
- struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
-
- if (context->active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
+ if (context_gl->c.active_texture < ARRAY_SIZE(context_gl->rev_tex_unit_map))
{
- unsigned int active_sampler = context_gl->rev_tex_unit_map[context->active_texture];
+ unsigned int active_sampler = context_gl->rev_tex_unit_map[context_gl->c.active_texture];
if (active_sampler != WINED3D_UNMAPPED_STAGE)
- context_invalidate_state(context, STATE_SAMPLER(active_sampler));
+ context_invalidate_state(&context_gl->c, STATE_SAMPLER(active_sampler));
}
/* FIXME: Ideally we'd only do this when touching a binding that's used by
* a shader. */
- context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
- context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
+ context_invalidate_compute_state(&context_gl->c, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
+ context_invalidate_state(&context_gl->c, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
wined3d_context_gl_bind_texture(context_gl, view_gl->gl_view.target, view_gl->gl_view.name);
}
@@ -880,6 +878,7 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *
unsigned int i, j, layer_count, level_count, base_level, max_level;
const struct wined3d_gl_info *gl_info;
struct wined3d_texture_gl *texture_gl;
+ struct wined3d_context_gl *context_gl;
struct wined3d_context *context;
struct gl_texture *gl_tex;
DWORD location;
@@ -888,6 +887,7 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *
TRACE("view %p.\n", view);
context = context_acquire(view_gl->v.resource->device, NULL, 0);
+ context_gl = wined3d_context_gl(context);
gl_info = context->gl_info;
layer_count = view_gl->v.desc.u.texture.layer_count;
level_count = view_gl->v.desc.u.texture.level_count;
@@ -902,11 +902,11 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *
if (view_gl->gl_view.name)
{
- shader_resource_view_gl_bind_and_dirtify(view_gl, context);
+ shader_resource_view_gl_bind_and_dirtify(view_gl, context_gl);
}
else
{
- wined3d_texture_gl_bind_and_dirtify(texture_gl, wined3d_context_gl(context), srgb);
+ wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level);
gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, max_level);
}
--
2.11.0
1
0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/mf/tests/mf.c | 81 +++++++++++++++++++++++++++++++++--------
include/mftransform.idl | 5 +++
2 files changed, 71 insertions(+), 15 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index cc85221dc0..f55104c039 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -2062,7 +2062,8 @@ static void test_video_processor(void)
DWORD input_count, output_count, input_id, output_id, flags;
DWORD input_min, input_max, output_min, output_max, i, count;
IMFAttributes *attributes, *attributes2;
- IMFMediaType *media_type;
+ IMFMediaType *media_type, *media_type2;
+ MFT_INPUT_STREAM_INFO input_info;
IMFTransform *transform;
HRESULT hr;
GUID guid;
@@ -2123,20 +2124,6 @@ todo_wine
IMFAttributes_Release(attributes);
IMFAttributes_Release(attributes2);
- for (i = 0;;++i)
- {
- hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type);
- if (hr == MF_E_NO_MORE_TYPES)
- break;
- ok(hr == S_OK, "Failed to get supported input type, hr %#x.\n", hr);
-
- hr = IMFMediaType_GetMajorType(media_type, &guid);
- ok(hr == S_OK, "Failed to get major type, hr %#x.\n", hr);
- ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type.\n");
-
- IMFMediaType_Release(media_type);
- }
-
hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type);
ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
@@ -2152,11 +2139,33 @@ todo_wine
hr = IMFTransform_GetOutputCurrentType(transform, 1, &media_type);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
+ hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info);
+ ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info);
+ ok(hr == S_OK, "Failed to get stream info, hr %#x.\n", hr);
+ ok(input_info.dwFlags == 0, "Unexpected flag %#x.\n", input_info.dwFlags);
+ ok(input_info.cbSize == 0, "Unexpected size %u.\n", input_info.cbSize);
+ ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %u.\n", input_info.cbMaxLookahead);
+ ok(input_info.cbAlignment == 0, "Unexpected alignment %u.\n", input_info.cbAlignment);
+
/* Configure stream types. */
for (i = 0;;++i)
{
if (FAILED(hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type)))
+ {
+ ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
break;
+ }
+
+ hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type2);
+ ok(hr == S_OK, "Failed to get available type, hr %#x.\n", hr);
+ ok(media_type != media_type2, "Unexpected instance.\n");
+ IMFMediaType_Release(media_type2);
+
+ hr = IMFMediaType_GetMajorType(media_type, &guid);
+ ok(hr == S_OK, "Failed to get major type, hr %#x.\n", hr);
+ ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type.\n");
hr = IMFMediaType_GetCount(media_type, &count);
ok(hr == S_OK, "Failed to get attributes count, hr %#x.\n", hr);
@@ -2166,6 +2175,48 @@ todo_wine
ok(hr == S_OK, "Failed to get subtype, hr %#x.\n", hr);
ok(is_supported_video_type(&guid), "Unexpected media type %s.\n", wine_dbgstr_guid(&guid));
+ hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY);
+ ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+
+ hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
+ ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+
+ hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2);
+ ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
+
+ /* FIXME: figure out if those require additional attributes or simply advertised but not supported */
+ if (IsEqualGUID(&guid, &MFVideoFormat_L8) || IsEqualGUID(&guid, &MFVideoFormat_L16)
+ || IsEqualGUID(&guid, &MFVideoFormat_D16) || IsEqualGUID(&guid, &MFVideoFormat_420O)
+ || IsEqualGUID(&guid, &MFVideoFormat_A16B16G16R16F))
+ {
+ IMFMediaType_Release(media_type);
+ continue;
+ }
+
+ hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, ((UINT64)16 << 32) | 16);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY);
+ ok(hr == S_OK, "Failed to test input type %s, hr %#x.\n", wine_dbgstr_guid(&guid), hr);
+
+ hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
+ ok(hr == S_OK, "Failed to test input type, hr %#x.\n", hr);
+
+ hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type2);
+ ok(hr == S_OK, "Failed to get current type, hr %#x.\n", hr);
+ ok(media_type != media_type2, "Unexpected instance.\n");
+ IMFMediaType_Release(media_type2);
+
+ hr = IMFTransform_GetInputStatus(transform, 0, &flags);
+ ok(hr == S_OK, "Failed to get input status, hr %#x.\n", hr);
+ ok(flags == MFT_INPUT_STATUS_ACCEPT_DATA, "Unexpected input status %#x.\n", flags);
+
+ hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info);
+ ok(hr == S_OK, "Failed to get stream info, hr %#x.\n", hr);
+ ok(input_info.dwFlags == 0, "Unexpected flag %#x.\n", input_info.dwFlags);
+ ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %u.\n", input_info.cbMaxLookahead);
+ ok(input_info.cbAlignment == 0, "Unexpected alignment %u.\n", input_info.cbAlignment);
+
IMFMediaType_Release(media_type);
}
diff --git a/include/mftransform.idl b/include/mftransform.idl
index 4321d002be..ca2f781a6b 100644
--- a/include/mftransform.idl
+++ b/include/mftransform.idl
@@ -61,6 +61,11 @@ enum _MFT_SET_TYPE_FLAGS
MFT_SET_TYPE_TEST_ONLY = 0x00000001,
};
+enum _MFT_INPUT_STATUS_FLAGS
+{
+ MFT_INPUT_STATUS_ACCEPT_DATA = 0x00000001,
+};
+
[
object,
uuid(bf94c121-5b05-4e6f-8000-ba598961414d)
--
2.20.1
1
0
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
.../api-ms-win-dx-d3dkmt-l1-1-0.spec | 2 +-
dlls/d3d11/d3d11.spec | 2 +-
dlls/gdi32/driver.c | 29 +++++++++++++++++++
dlls/gdi32/gdi32.spec | 1 +
dlls/gdi32/tests/driver.c | 10 +++----
include/ddk/d3dkmthk.h | 1 +
6 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
index cb7935bbbc..43452cda74 100644
--- a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
+++ b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
@@ -22,7 +22,7 @@
@ stub D3DKMTDestroyAllocation
@ stub D3DKMTDestroyContext
@ stdcall D3DKMTDestroyDCFromMemory(ptr) gdi32.D3DKMTDestroyDCFromMemory
-@ stub D3DKMTDestroyDevice
+@ stdcall D3DKMTDestroyDevice(ptr) gdi32.D3DKMTDestroyDevice
@ stub D3DKMTDestroyKeyedMutex
@ stub D3DKMTDestroyOutputDupl
@ stub D3DKMTDestroyOverlay
diff --git a/dlls/d3d11/d3d11.spec b/dlls/d3d11/d3d11.spec
index e4692ace9c..01bc8bfebc 100644
--- a/dlls/d3d11/d3d11.spec
+++ b/dlls/d3d11/d3d11.spec
@@ -12,7 +12,7 @@
@ stub D3DKMTCreateSynchronizationObject
@ stub D3DKMTDestroyAllocation
@ stub D3DKMTDestroyContext
-@ stub D3DKMTDestroyDevice
+@ stdcall D3DKMTDestroyDevice(ptr) gdi32.D3DKMTDestroyDevice
@ stub D3DKMTDestroySynchronizationObject
@ stub D3DKMTEscape
@ stub D3DKMTGetContextSchedulingPriority
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index d5765af2a1..9208f6ecd5 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -1395,3 +1395,32 @@ NTSTATUS WINAPI D3DKMTCreateDevice( D3DKMT_CREATEDEVICE *desc )
LeaveCriticalSection( &driver_section );
return STATUS_SUCCESS;
}
+
+/******************************************************************************
+ * D3DKMTDestroyDevice [GDI32.@]
+ */
+NTSTATUS WINAPI D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE *desc )
+{
+ NTSTATUS status = STATUS_INVALID_PARAMETER;
+ struct d3dkmt_device *device;
+
+ TRACE("(%p)\n", desc);
+
+ if (!desc || !desc->hDevice)
+ return STATUS_INVALID_PARAMETER;
+
+ EnterCriticalSection( &driver_section );
+ LIST_FOR_EACH_ENTRY( device, &d3dkmt_devices, struct d3dkmt_device, entry )
+ {
+ if (device->handle == desc->hDevice)
+ {
+ list_remove( &device->entry );
+ heap_free( device );
+ status = STATUS_SUCCESS;
+ break;
+ }
+ }
+ LeaveCriticalSection( &driver_section );
+
+ return status;
+}
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 88fe846eb8..9abd82173c 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -84,6 +84,7 @@
@ stdcall D3DKMTCreateDCFromMemory(ptr)
@ stdcall D3DKMTCreateDevice(ptr)
@ stdcall D3DKMTDestroyDCFromMemory(ptr)
+@ stdcall D3DKMTDestroyDevice(ptr)
@ stdcall D3DKMTEscape(ptr)
@ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr)
@ stdcall D3DKMTOpenAdapterFromHdc(ptr)
diff --git a/dlls/gdi32/tests/driver.c b/dlls/gdi32/tests/driver.c
index f5c23dad76..b5f6f75a83 100644
--- a/dlls/gdi32/tests/driver.c
+++ b/dlls/gdi32/tests/driver.c
@@ -194,9 +194,9 @@ static void test_D3DKMTCreateDevice(void)
D3DKMT_DESTROYDEVICE destroy_device_desc;
NTSTATUS status;
- if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND || !pD3DKMTDestroyDevice)
+ if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND)
{
- skip("D3DKMTCreateDevice() or D3DKMTDestroyDevice() is unavailable.\n");
+ win_skip("D3DKMTCreateDevice() is unavailable.\n");
return;
}
@@ -240,17 +240,17 @@ static void test_D3DKMTDestroyDevice(void)
if (!pD3DKMTDestroyDevice || pD3DKMTDestroyDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND)
{
- skip("D3DKMTDestroyDevice() is unavailable.\n");
+ win_skip("D3DKMTDestroyDevice() is unavailable.\n");
return;
}
/* Invalid parameters */
status = pD3DKMTDestroyDevice(NULL);
- todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
+ ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
memset(&destroy_device_desc, 0, sizeof(destroy_device_desc));
status = pD3DKMTDestroyDevice(&destroy_device_desc);
- todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
+ ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
}
static void test_D3DKMTCheckVidPnExclusiveOwnership(void)
diff --git a/include/ddk/d3dkmthk.h b/include/ddk/d3dkmthk.h
index 90bf907e30..081758bf5d 100644
--- a/include/ddk/d3dkmthk.h
+++ b/include/ddk/d3dkmthk.h
@@ -169,6 +169,7 @@ NTSTATUS WINAPI D3DKMTCloseAdapter(const D3DKMT_CLOSEADAPTER *desc);
NTSTATUS WINAPI D3DKMTCreateDevice(D3DKMT_CREATEDEVICE *desc);
NTSTATUS WINAPI D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc);
NTSTATUS WINAPI D3DKMTDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc);
+NTSTATUS WINAPI D3DKMTDestroyDevice(const D3DKMT_DESTROYDEVICE *desc);
NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName(D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc);
#ifdef __cplusplus
--
2.20.1
3
2
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
.../api-ms-win-dx-d3dkmt-l1-1-0.spec | 2 +-
dlls/d3d11/d3d11.spec | 2 +-
dlls/gdi32/driver.c | 52 +++++++++++++++++++
dlls/gdi32/gdi32.spec | 1 +
dlls/gdi32/tests/driver.c | 2 +-
include/ddk/d3dkmthk.h | 1 +
6 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
index 43186e8fcc..cb7935bbbc 100644
--- a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
+++ b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec
@@ -12,7 +12,7 @@
@ stub D3DKMTCreateAllocation2
@ stub D3DKMTCreateContext
@ stdcall D3DKMTCreateDCFromMemory(ptr) gdi32.D3DKMTCreateDCFromMemory
-@ stub D3DKMTCreateDevice
+@ stdcall D3DKMTCreateDevice(ptr) gdi32.D3DKMTCreateDevice
@ stub D3DKMTCreateKeyedMutex
@ stub D3DKMTCreateKeyedMutex2
@ stub D3DKMTCreateOutputDupl
diff --git a/dlls/d3d11/d3d11.spec b/dlls/d3d11/d3d11.spec
index 87304b7c13..e4692ace9c 100644
--- a/dlls/d3d11/d3d11.spec
+++ b/dlls/d3d11/d3d11.spec
@@ -8,7 +8,7 @@
@ stdcall D3DKMTCloseAdapter(ptr) gdi32.D3DKMTCloseAdapter
@ stub D3DKMTCreateAllocation
@ stub D3DKMTCreateContext
-@ stub D3DKMTCreateDevice
+@ stdcall D3DKMTCreateDevice(ptr) gdi32.D3DKMTCreateDevice
@ stub D3DKMTCreateSynchronizationObject
@ stub D3DKMTDestroyAllocation
@ stub D3DKMTDestroyContext
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index e021856b0a..d5765af2a1 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -59,10 +59,17 @@ struct d3dkmt_adapter
struct list entry; /* List entry */
};
+struct d3dkmt_device
+{
+ D3DKMT_HANDLE handle; /* Kernel mode graphics device handle*/
+ struct list entry; /* List entry */
+};
+
static struct list drivers = LIST_INIT( drivers );
static struct graphics_driver *display_driver;
static struct list d3dkmt_adapters = LIST_INIT( d3dkmt_adapters );
+static struct list d3dkmt_devices = LIST_INIT( d3dkmt_devices );
const struct gdi_dc_funcs *font_driver = NULL;
@@ -1343,3 +1350,48 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI
LeaveCriticalSection( &driver_section );
return STATUS_SUCCESS;
}
+
+/******************************************************************************
+ * D3DKMTCreateDevice [GDI32.@]
+ */
+NTSTATUS WINAPI D3DKMTCreateDevice( D3DKMT_CREATEDEVICE *desc )
+{
+ static D3DKMT_HANDLE handle_start = 0;
+ struct d3dkmt_adapter *adapter;
+ struct d3dkmt_device *device;
+ BOOL found = FALSE;
+
+ TRACE("(%p)\n", desc);
+
+ if (!desc)
+ return STATUS_INVALID_PARAMETER;
+
+ EnterCriticalSection( &driver_section );
+ LIST_FOR_EACH_ENTRY( adapter, &d3dkmt_adapters, struct d3dkmt_adapter, entry )
+ {
+ if (adapter->handle == desc->hAdapter)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ LeaveCriticalSection( &driver_section );
+
+ if (!found)
+ return STATUS_INVALID_PARAMETER;
+
+ if (desc->Flags.LegacyMode || desc->Flags.RequestVSync || desc->Flags.DisableGpuTimeout)
+ FIXME("Flags unsupported.\n");
+
+ device = heap_alloc_zero( sizeof( *device ) );
+ if (!device)
+ return STATUS_NO_MEMORY;
+
+ device->handle = ++handle_start;
+ desc->hDevice = device->handle;
+
+ EnterCriticalSection( &driver_section );
+ list_add_tail( &d3dkmt_devices, &device->entry );
+ LeaveCriticalSection( &driver_section );
+ return STATUS_SUCCESS;
+}
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 5c17ed9ee8..88fe846eb8 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -82,6 +82,7 @@
@ stdcall CreateSolidBrush(long)
@ stdcall D3DKMTCloseAdapter(ptr)
@ stdcall D3DKMTCreateDCFromMemory(ptr)
+@ stdcall D3DKMTCreateDevice(ptr)
@ stdcall D3DKMTDestroyDCFromMemory(ptr)
@ stdcall D3DKMTEscape(ptr)
@ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr)
diff --git a/dlls/gdi32/tests/driver.c b/dlls/gdi32/tests/driver.c
index caded27aef..f5c23dad76 100644
--- a/dlls/gdi32/tests/driver.c
+++ b/dlls/gdi32/tests/driver.c
@@ -194,7 +194,7 @@ static void test_D3DKMTCreateDevice(void)
D3DKMT_DESTROYDEVICE destroy_device_desc;
NTSTATUS status;
- if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND)
+ if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND || !pD3DKMTDestroyDevice)
{
skip("D3DKMTCreateDevice() or D3DKMTDestroyDevice() is unavailable.\n");
return;
diff --git a/include/ddk/d3dkmthk.h b/include/ddk/d3dkmthk.h
index 5436cb6612..90bf907e30 100644
--- a/include/ddk/d3dkmthk.h
+++ b/include/ddk/d3dkmthk.h
@@ -166,6 +166,7 @@ extern "C"
#endif /* __cplusplus */
NTSTATUS WINAPI D3DKMTCloseAdapter(const D3DKMT_CLOSEADAPTER *desc);
+NTSTATUS WINAPI D3DKMTCreateDevice(D3DKMT_CREATEDEVICE *desc);
NTSTATUS WINAPI D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc);
NTSTATUS WINAPI D3DKMTDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc);
NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName(D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc);
--
2.20.1
3
2
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d11/d3d11.spec | 2 +-
dlls/gdi32/driver.c | 24 ++++++++++++++++++++++--
dlls/gdi32/tests/driver.c | 4 ++--
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d11/d3d11.spec b/dlls/d3d11/d3d11.spec
index 365e5d7c0c..87304b7c13 100644
--- a/dlls/d3d11/d3d11.spec
+++ b/dlls/d3d11/d3d11.spec
@@ -5,7 +5,7 @@
@ stdcall D3D11CreateDevice(ptr long ptr long ptr long long ptr ptr ptr)
@ stdcall D3D11CreateDeviceAndSwapChain(ptr long ptr long ptr long long ptr ptr ptr ptr ptr)
@ stdcall D3D11On12CreateDevice(ptr long ptr long ptr long long ptr ptr ptr)
-@ stub D3DKMTCloseAdapter
+@ stdcall D3DKMTCloseAdapter(ptr) gdi32.D3DKMTCloseAdapter
@ stub D3DKMTCreateAllocation
@ stub D3DKMTCreateContext
@ stub D3DKMTCreateDevice
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index fe66266e18..e021856b0a 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -1279,8 +1279,28 @@ NTSTATUS WINAPI D3DKMTEscape( const void *pData )
*/
NTSTATUS WINAPI D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER *desc )
{
- FIXME("(%p): stub\n", desc);
- return STATUS_SUCCESS;
+ NTSTATUS status = STATUS_INVALID_PARAMETER;
+ struct d3dkmt_adapter *adapter;
+
+ TRACE("(%p)\n", desc);
+
+ if (!desc || !desc->hAdapter)
+ return STATUS_INVALID_PARAMETER;
+
+ EnterCriticalSection( &driver_section );
+ LIST_FOR_EACH_ENTRY( adapter, &d3dkmt_adapters, struct d3dkmt_adapter, entry )
+ {
+ if (adapter->handle == desc->hAdapter)
+ {
+ list_remove( &adapter->entry );
+ heap_free( adapter );
+ status = STATUS_SUCCESS;
+ break;
+ }
+ }
+ LeaveCriticalSection( &driver_section );
+
+ return status;
}
/******************************************************************************
diff --git a/dlls/gdi32/tests/driver.c b/dlls/gdi32/tests/driver.c
index 067c162838..caded27aef 100644
--- a/dlls/gdi32/tests/driver.c
+++ b/dlls/gdi32/tests/driver.c
@@ -179,11 +179,11 @@ static void test_D3DKMTCloseAdapter(void)
/* Invalid parameters */
status = pD3DKMTCloseAdapter(NULL);
- todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
+ ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
memset(&close_adapter_desc, 0, sizeof(close_adapter_desc));
status = pD3DKMTCloseAdapter(&close_adapter_desc);
- todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
+ ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
}
static void test_D3DKMTCreateDevice(void)
--
2.20.1
3
2