Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 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
September 2018
- 70 participants
- 1549 messages
[PATCH vkd3d 9/9] tests: Add test for GetResourceAllocationInfo().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 61030104038d..69b9fe7f0284 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -19558,6 +19558,79 @@ static void test_combined_clip_and_cull_distances(void)
destroy_test_context(&context);
}
+static void test_resource_allocation_info(void)
+{
+ D3D12_RESOURCE_ALLOCATION_INFO info;
+ D3D12_RESOURCE_DESC desc;
+ ID3D12Device *device;
+ unsigned int i, j;
+ ULONG refcount;
+
+ static const unsigned int alignments[] =
+ {
+ 0,
+ D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
+ };
+ static const unsigned int buffer_sizes[] =
+ {
+ 1,
+ 16,
+ 256,
+ 1024,
+ D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT + 1,
+ D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT + 1,
+ D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT + 1,
+ };
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device.\n");
+ return;
+ }
+
+ desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
+ desc.Alignment = 0;
+ desc.Width = 32;
+ desc.Height = 1;
+ desc.DepthOrArraySize = 1;
+ desc.MipLevels = 1;
+ desc.Format = DXGI_FORMAT_UNKNOWN;
+ desc.SampleDesc.Count = 1;
+ desc.SampleDesc.Quality = 0;
+ desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
+ desc.Flags = 0;
+
+ for (i = 0; i < ARRAY_SIZE(alignments); ++i)
+ {
+ for (j = 0; j < ARRAY_SIZE(buffer_sizes); ++j)
+ {
+ desc.Alignment = alignments[i];
+ desc.Width = buffer_sizes[j];
+ info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc);
+ if (!desc.Alignment || desc.Alignment == D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
+ {
+ check_alignment(info.SizeInBytes, info.Alignment);
+ }
+ else
+ {
+ ok(info.SizeInBytes == ~(UINT64)0,
+ "Got unexpected size %"PRIu64".\n", info.SizeInBytes);
+ ok(info.Alignment == D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+ "Got unexpected alignment %"PRIu64".\n", info.Alignment);
+ }
+ }
+ }
+
+
+ refcount = ID3D12Device_Release(device);
+ ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
+}
+
static void test_suballocate_small_textures(void)
{
D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
@@ -19758,5 +19831,6 @@ START_TEST(d3d12)
run_test(test_cpu_descriptors_lifetime);
run_test(test_clip_distance);
run_test(test_combined_clip_and_cull_distances);
+ run_test(test_resource_allocation_info);
run_test(test_suballocate_small_textures);
}
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 8/9] tests: Add test for suballocation of small textures.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 5f2d2d8e50bf..61030104038d 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -193,6 +193,14 @@ static void check_heap_desc_(unsigned int line, const D3D12_HEAP_DESC *desc,
"Got flags %#x, expected %#x.\n", desc->Flags, expected.Flags);
}
+#define check_alignment(a, b) check_alignment_(__LINE__, a, b)
+static void check_alignment_(unsigned int line, uint64_t size, uint64_t alignment)
+{
+ uint64_t aligned_size = align(size, alignment);
+ ok_(line)(aligned_size == size, "Got unaligned size %"PRIu64", expected %"PRIu64".\n",
+ size, aligned_size);
+}
+
static void uav_barrier(ID3D12GraphicsCommandList *list, ID3D12Resource *resource)
{
D3D12_RESOURCE_BARRIER barrier;
@@ -19550,6 +19558,89 @@ static void test_combined_clip_and_cull_distances(void)
destroy_test_context(&context);
}
+static void test_suballocate_small_textures(void)
+{
+ D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
+ D3D12_RESOURCE_ALLOCATION_INFO info;
+ D3D12_RESOURCE_DESC resource_desc;
+ ID3D12Resource *textures[10];
+ D3D12_HEAP_DESC heap_desc;
+ ID3D12Device *device;
+ ID3D12Heap *heap;
+ unsigned int i;
+ ULONG refcount;
+ HRESULT hr;
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device.\n");
+ return;
+ }
+
+ resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
+ resource_desc.Alignment = 0;
+ resource_desc.Width = 32;
+ resource_desc.Height = 32;
+ resource_desc.DepthOrArraySize = 1;
+ resource_desc.MipLevels = 1;
+ resource_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ resource_desc.SampleDesc.Count = 1;
+ resource_desc.SampleDesc.Quality = 0;
+ resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
+ resource_desc.Flags = 0;
+
+ resource_desc.Alignment = D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT;
+
+ info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &resource_desc);
+ trace("Size %"PRIu64", alignment %"PRIu64".\n", info.SizeInBytes, info.Alignment);
+ check_alignment(info.SizeInBytes, info.Alignment);
+ if (info.Alignment != D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT)
+ {
+ resource_desc.Alignment = 0;
+ info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &resource_desc);
+ trace("Size %"PRIu64", alignment %"PRIu64".\n", info.SizeInBytes, info.Alignment);
+ check_alignment(info.SizeInBytes, info.Alignment);
+ }
+
+ heap_desc.SizeInBytes = ARRAY_SIZE(textures) * info.SizeInBytes;
+ memset(&heap_desc.Properties, 0, sizeof(heap_desc.Properties));
+ heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
+ heap_desc.Alignment = 0;
+ heap_desc.Flags = D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES;
+ hr = ID3D12Device_CreateHeap(device, &heap_desc, &IID_ID3D12Heap, (void **)&heap);
+ ok(hr == S_OK, "Failed to create heap, hr %#x.\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(textures); ++i)
+ {
+ hr = ID3D12Device_CreatePlacedResource(device, heap, i * info.SizeInBytes,
+ &resource_desc, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,
+ NULL, &IID_ID3D12Resource, (void **)&textures[i]);
+ ok(hr == S_OK, "Failed to create placed resource %u, hr %#x.\n", i, hr);
+
+ check_interface(textures[i], &IID_ID3D12Object, TRUE);
+ check_interface(textures[i], &IID_ID3D12DeviceChild, TRUE);
+ check_interface(textures[i], &IID_ID3D12Pageable, TRUE);
+ check_interface(textures[i], &IID_ID3D12Resource, TRUE);
+
+ gpu_address = ID3D12Resource_GetGPUVirtualAddress(textures[i]);
+ ok(!gpu_address, "Got unexpected GPU virtual address %#"PRIx64".\n", gpu_address);
+ }
+
+ refcount = get_refcount(heap);
+ ok(refcount == 1, "Got unexpected refcount %u.\n", (unsigned int)refcount);
+
+ for (i = 0; i < ARRAY_SIZE(textures); ++i)
+ {
+ refcount = ID3D12Resource_Release(textures[i]);
+ ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
+ }
+
+ refcount = ID3D12Heap_Release(heap);
+ ok(!refcount, "ID3D12Heap has %u references left.\n", (unsigned int)refcount);
+ refcount = ID3D12Device_Release(device);
+ ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
+}
+
START_TEST(d3d12)
{
bool enable_debug_layer = false;
@@ -19667,4 +19758,5 @@ START_TEST(d3d12)
run_test(test_cpu_descriptors_lifetime);
run_test(test_clip_distance);
run_test(test_combined_clip_and_cull_distances);
+ run_test(test_suballocate_small_textures);
}
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 7/9] vkd3d: Add WARN() for "out of device memory" errors.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index 682822e8b89a..05d15b2ccd62 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -387,8 +387,9 @@ HRESULT hresult_from_vk_result(VkResult vr)
{
case VK_SUCCESS:
return S_OK;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
+ WARN("Out of device memory.\n");
+ case VK_ERROR_OUT_OF_HOST_MEMORY:
return E_OUTOFMEMORY;
default:
FIXME("Unhandled VkResult %d.\n", vr);
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 6/9] vkd3d: Use heap memory for placed resources.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/resource.c | 95 ++++++++++++++++++++++++++++++++++++----------
libs/vkd3d/vkd3d_private.h | 1 +
2 files changed, 77 insertions(+), 19 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 272fa70585f7..f25ace3cdafc 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -57,7 +57,7 @@ static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32
static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- const VkMemoryRequirements *memory_requirements, VkDeviceMemory *vk_memory)
+ const VkMemoryRequirements *memory_requirements, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
VkMemoryAllocateInfo allocate_info;
@@ -88,6 +88,9 @@ static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device,
return hresult_from_vk_result(vr);
}
+ if (vk_memory_type)
+ *vk_memory_type = allocate_info.memoryTypeIndex;
+
return S_OK;
}
@@ -284,7 +287,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
memory_requirements.memoryTypeBits = ~(uint32_t)0;
if (FAILED(hr = vkd3d_allocate_device_memory(device, &heap->desc.Properties,
- heap->desc.Flags, &memory_requirements, &heap->vk_memory)))
+ heap->desc.Flags, &memory_requirements, &heap->vk_memory, &heap->vk_memory_type)))
return hr;
heap->device = device;
@@ -529,7 +532,7 @@ HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_bu
VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, vk_buffer, &memory_requirements));
if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags,
- &memory_requirements, vk_memory)))
+ &memory_requirements, vk_memory, NULL)))
return hr;
if ((vr = VK_CALL(vkBindBufferMemory(device->vk_device, vk_buffer, *vk_memory, 0))) < 0)
@@ -554,7 +557,7 @@ static HRESULT vkd3d_allocate_image_memory(struct d3d12_device *device, VkImage
VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, &memory_requirements));
if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags,
- &memory_requirements, vk_memory)))
+ &memory_requirements, vk_memory, NULL)))
return hr;
if ((vr = VK_CALL(vkBindImageMemory(device->vk_device, vk_image, *vk_memory, 0))) < 0)
@@ -1056,6 +1059,22 @@ static HRESULT d3d12_resource_create(struct d3d12_device *device,
return hr;
}
+static HRESULT vkd3d_allocate_resource_memory(
+ struct d3d12_device *device, struct d3d12_resource *resource,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
+{
+ if (d3d12_resource_is_buffer(resource))
+ {
+ return vkd3d_allocate_buffer_memory(device, resource->u.vk_buffer,
+ heap_properties, heap_flags, &resource->vk_memory);
+ }
+ else
+ {
+ return vkd3d_allocate_image_memory(device, resource->u.vk_image,
+ heap_properties, heap_flags, &resource->vk_memory);
+ }
+}
+
HRESULT d3d12_committed_resource_create(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,
@@ -1068,40 +1087,78 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
desc, initial_state, optimized_clear_value, &object)))
return hr;
- if (d3d12_resource_is_buffer(object))
+ if (FAILED(hr = vkd3d_allocate_resource_memory(device, object, heap_properties, heap_flags)))
{
- hr = vkd3d_allocate_buffer_memory(device, object->u.vk_buffer,
- heap_properties, heap_flags, &object->vk_memory);
+ d3d12_resource_Release(&object->ID3D12Resource_iface);
+ return hr;
}
+
+ TRACE("Created committed resource %p.\n", object);
+
+ *resource = object;
+
+ return S_OK;
+}
+
+static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
+ struct d3d12_resource *resource, struct d3d12_heap *heap, UINT64 heap_offset)
+{
+ const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+ VkDevice vk_device = device->vk_device;
+ VkMemoryRequirements requirements;
+ VkResult vr;
+
+ if (d3d12_resource_is_buffer(resource))
+ VK_CALL(vkGetBufferMemoryRequirements(vk_device, resource->u.vk_buffer, &requirements));
else
+ VK_CALL(vkGetImageMemoryRequirements(vk_device, resource->u.vk_image, &requirements));
+
+ if (heap_offset % requirements.alignment)
{
- hr = vkd3d_allocate_image_memory(device, object->u.vk_image,
- heap_properties, heap_flags, &object->vk_memory);
+ FIXME("Invalid heap offset %#"PRIx64".\n", heap_offset);
+ return E_INVALIDARG;
}
- if (FAILED(hr))
+ if (!(requirements.memoryTypeBits & (1u << heap->vk_memory_type)))
{
- d3d12_resource_Release(&object->ID3D12Resource_iface);
- return hr;
+ FIXME("Memory type %u cannot be bind to resource %p (allowed types %#x).\n",
+ heap->vk_memory_type, resource, requirements.memoryTypeBits);
+ return E_NOTIMPL;
}
- TRACE("Created committed resource %p.\n", object);
+ if (d3d12_resource_is_buffer(resource))
+ vr = VK_CALL(vkBindBufferMemory(vk_device, resource->u.vk_buffer, heap->vk_memory, heap_offset));
+ else
+ vr = VK_CALL(vkBindImageMemory(vk_device, resource->u.vk_image, heap->vk_memory, heap_offset));
- *resource = object;
+ if (vr < 0)
+ WARN("Failed to bind memory, vr %d.\n", vr);
- return S_OK;
+ return hresult_from_vk_result(vr);
}
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)
{
- const D3D12_HEAP_DESC *heap_desc = &heap->desc;
+ struct d3d12_resource *object;
+ HRESULT hr;
- FIXME("Ignoring heap %p, offset %"PRIu64".\n", heap, heap_offset);
+ if (FAILED(hr = d3d12_resource_create(device, &heap->desc.Properties, heap->desc.Flags,
+ desc, initial_state, optimized_clear_value, &object)))
+ return hr;
- return d3d12_committed_resource_create(device, &heap_desc->Properties, heap_desc->Flags,
- desc, initial_state, optimized_clear_value, resource);
+ if (FAILED(hr = vkd3d_bind_heap_memory(device, object, heap, heap_offset)))
+ {
+ d3d12_resource_Release(&object->ID3D12Resource_iface);
+ return hr;
+ }
+
+ TRACE("Created placed resource %p.\n", object);
+
+ *resource = object;
+
+ return S_OK;
}
HRESULT vkd3d_create_image_resource(ID3D12Device *device,
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 4865671dd0dc..aca0e5098b79 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -191,6 +191,7 @@ struct d3d12_heap
D3D12_HEAP_DESC desc;
VkDeviceMemory vk_memory;
+ uint32_t vk_memory_type;
struct d3d12_device *device;
};
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 5/9] vkd3d: Allocate device memory for heaps.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/resource.c | 158 ++++++++++++++++++++++++---------------------
libs/vkd3d/vkd3d_private.h | 2 +
2 files changed, 87 insertions(+), 73 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 82ff701037a3..272fa70585f7 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -18,6 +18,79 @@
#include "vkd3d_private.h"
+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)
+{
+ VkPhysicalDeviceMemoryProperties *memory_info = &device->memory_properties;
+ VkMemoryPropertyFlags required_flags;
+ unsigned int i;
+
+ switch (heap_properties->Type)
+ {
+ case D3D12_HEAP_TYPE_DEFAULT:
+ required_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
+ break;
+
+ case D3D12_HEAP_TYPE_CUSTOM:
+ FIXME("Custom heaps not supported yet.\n");
+ /* fall-through */
+ case D3D12_HEAP_TYPE_UPLOAD:
+ case D3D12_HEAP_TYPE_READBACK:
+ required_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
+ break;
+
+ default:
+ WARN("Invalid heap type %#x.\n", heap_properties->Type);
+ return ~0u;
+ }
+
+ for (i = 0; i < memory_info->memoryTypeCount; ++i)
+ {
+ if (!(memory_type_mask & (1u << i)))
+ continue;
+ if ((memory_info->memoryTypes[i].propertyFlags & required_flags) == required_flags)
+ return i;
+ }
+
+ return ~0u;
+}
+
+static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
+ const VkMemoryRequirements *memory_requirements, VkDeviceMemory *vk_memory)
+{
+ const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+ VkMemoryAllocateInfo allocate_info;
+ VkResult vr;
+
+ TRACE("Memory requirements: size %#"PRIx64", alignment %#"PRIx64".\n",
+ memory_requirements->size, memory_requirements->alignment);
+
+ allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ allocate_info.pNext = NULL;
+ allocate_info.allocationSize = memory_requirements->size;
+ allocate_info.memoryTypeIndex = vkd3d_select_memory_type(device,
+ memory_requirements->memoryTypeBits, heap_properties, heap_flags);
+
+ if (allocate_info.memoryTypeIndex == ~0u)
+ {
+ FIXME("Failed to find suitable memory type (allowed types %#x).\n", memory_requirements->memoryTypeBits);
+ *vk_memory = VK_NULL_HANDLE;
+ return E_FAIL;
+ }
+
+ TRACE("Allocating memory type %u.\n", allocate_info.memoryTypeIndex);
+
+ if ((vr = VK_CALL(vkAllocateMemory(device->vk_device, &allocate_info, NULL, vk_memory))) < 0)
+ {
+ WARN("Failed to allocate device memory, vr %d.\n", vr);
+ *vk_memory = VK_NULL_HANDLE;
+ return hresult_from_vk_result(vr);
+ }
+
+ return S_OK;
+}
+
/* ID3D12Heap */
static inline struct d3d12_heap *impl_from_ID3D12Heap(ID3D12Heap *iface)
{
@@ -66,6 +139,9 @@ static ULONG STDMETHODCALLTYPE d3d12_heap_Release(ID3D12Heap *iface)
if (!refcount)
{
struct d3d12_device *device = heap->device;
+ const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+
+ VK_CALL(vkFreeMemory(device->vk_device, heap->vk_memory, NULL));
vkd3d_free(heap);
@@ -181,6 +257,7 @@ static HRESULT validate_heap_desc(const D3D12_HEAP_DESC *desc)
static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
struct d3d12_device *device, const D3D12_HEAP_DESC *desc)
{
+ VkMemoryRequirements memory_requirements;
HRESULT hr;
heap->ID3D12Heap_iface.lpVtbl = &d3d12_heap_vtbl;
@@ -202,6 +279,14 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
if (FAILED(hr = validate_heap_desc(&heap->desc)))
return hr;
+ memory_requirements.size = heap->desc.SizeInBytes;
+ memory_requirements.alignment = heap->desc.Alignment;
+ memory_requirements.memoryTypeBits = ~(uint32_t)0;
+
+ if (FAILED(hr = vkd3d_allocate_device_memory(device, &heap->desc.Properties,
+ heap->desc.Flags, &memory_requirements, &heap->vk_memory)))
+ return hr;
+
heap->device = device;
ID3D12Device_AddRef(&device->ID3D12Device_iface);
@@ -433,79 +518,6 @@ HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
return hr;
}
-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)
-{
- VkPhysicalDeviceMemoryProperties *memory_info = &device->memory_properties;
- VkMemoryPropertyFlags required_flags;
- unsigned int i;
-
- switch (heap_properties->Type)
- {
- case D3D12_HEAP_TYPE_DEFAULT:
- required_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
- break;
-
- case D3D12_HEAP_TYPE_CUSTOM:
- FIXME("Custom heaps not supported yet.\n");
- /* fall-through */
- case D3D12_HEAP_TYPE_UPLOAD:
- case D3D12_HEAP_TYPE_READBACK:
- required_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
- break;
-
- default:
- WARN("Invalid heap type %#x.\n", heap_properties->Type);
- return ~0u;
- }
-
- for (i = 0; i < memory_info->memoryTypeCount; ++i)
- {
- if (!(memory_type_mask & (1u << i)))
- continue;
- if ((memory_info->memoryTypes[i].propertyFlags & required_flags) == required_flags)
- return i;
- }
-
- return ~0u;
-}
-
-static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device,
- const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- const VkMemoryRequirements *memory_requirements, VkDeviceMemory *vk_memory)
-{
- const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
- VkMemoryAllocateInfo allocate_info;
- VkResult vr;
-
- TRACE("Memory requirements: size %#"PRIx64", alignment %#"PRIx64".\n",
- memory_requirements->size, memory_requirements->alignment);
-
- allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- allocate_info.pNext = NULL;
- allocate_info.allocationSize = memory_requirements->size;
- allocate_info.memoryTypeIndex = vkd3d_select_memory_type(device,
- memory_requirements->memoryTypeBits, heap_properties, heap_flags);
-
- if (allocate_info.memoryTypeIndex == ~0u)
- {
- FIXME("Failed to find suitable memory type (allowed types %#x).\n", memory_requirements->memoryTypeBits);
- *vk_memory = VK_NULL_HANDLE;
- return E_FAIL;
- }
-
- TRACE("Allocating memory type %u.\n", allocate_info.memoryTypeIndex);
-
- if ((vr = VK_CALL(vkAllocateMemory(device->vk_device, &allocate_info, NULL, vk_memory))) < 0)
- {
- WARN("Failed to allocate device memory, vr %d.\n", vr);
- *vk_memory = VK_NULL_HANDLE;
- return hresult_from_vk_result(vr);
- }
-
- return S_OK;
-}
-
HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
VkDeviceMemory *vk_memory)
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 189ee4324ef5..4865671dd0dc 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -190,6 +190,8 @@ struct d3d12_heap
D3D12_HEAP_DESC desc;
+ VkDeviceMemory vk_memory;
+
struct d3d12_device *device;
};
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 4/9] vkd3d: Implement d3d12_device_GetResourceAllocationInfo() for textures.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
In Vulkan, we have to create an image to get its memory requirements.
It would be very helpful if we could get the memory requirements without
creating a resource.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
E.g. something along the lines of vkGetImageInfoMemoryRequirementsEXT().
---
libs/vkd3d/device.c | 38 ++++++++++++++++++++++++++++++++++----
libs/vkd3d/resource.c | 24 ++++++++++++++++++++++++
libs/vkd3d/vkd3d_private.h | 16 +++++++++-------
3 files changed, 67 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 54196acb83e8..8cc61420bab9 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2025,7 +2025,10 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
ID3D12Device *iface, D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask,
UINT count, const D3D12_RESOURCE_DESC *resource_descs)
{
+ UINT64 default_alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ struct d3d12_device *device = impl_from_ID3D12Device(iface);
const D3D12_RESOURCE_DESC *desc;
+ bool valid = true;
TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n",
iface, info, visible_mask, count, resource_descs);
@@ -2042,22 +2045,49 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
}
desc = &resource_descs[0];
+
+ if (FAILED(d3d12_resource_validate_desc(desc)))
+ {
+ WARN("Invalid resource desc.\n");
+ valid = false;
+ }
+
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
{
- info->SizeInBytes = align(desc->Width, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
+ info->SizeInBytes = desc->Width;
info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
}
else
{
- FIXME("Unhandled dimension %#x.\n", desc->Dimension);
+ if (desc->SampleDesc.Count != 1)
+ default_alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
+
+ if (valid && FAILED(vkd3d_get_image_allocation_info(device, desc, info)))
+ {
+ WARN("Failed to get allocation info for texture.\n");
+ valid = false;
+ }
}
- if (FAILED(d3d12_resource_validate_desc(desc)))
+ if (desc->Alignment % info->Alignment)
+ {
+ WARN("Invalid resource alignment %#"PRIx64" (required %#"PRIx64").\n",
+ desc->Alignment, info->Alignment);
+ valid = false;
+ }
+
+ if (valid)
+ {
+ info->SizeInBytes = align(info->SizeInBytes, info->Alignment);
+ }
+ else
{
- WARN("Invalid resource desc.\n");
info->SizeInBytes = ~(UINT64)0;
+ info->Alignment = default_alignment;
}
+ TRACE("Size %#"PRIx64", alignment %#"PRIx64".\n", info->SizeInBytes, info->Alignment);
+
return info;
}
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index d5690deebb8e..82ff701037a3 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -409,6 +409,30 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device,
return S_OK;
}
+HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info)
+{
+ static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT};
+ const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
+ VkMemoryRequirements requirements;
+ VkImage vk_image;
+ HRESULT hr;
+
+ assert(desc->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER);
+
+ /* XXX: We have to create an image to get its memory requirements. */
+ if (SUCCEEDED(hr = vkd3d_create_image(device, &heap_properties, 0, desc, &vk_image)))
+ {
+ VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, &requirements));
+ VK_CALL(vkDestroyImage(device->vk_device, vk_image, NULL));
+
+ allocation_info->SizeInBytes = requirements.size;
+ allocation_info->Alignment = requirements.alignment;
+ }
+
+ return hr;
+}
+
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)
{
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index c4d6dd531728..189ee4324ef5 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -251,6 +251,15 @@ HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_h
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,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
+ VkDeviceMemory *vk_memory) DECLSPEC_HIDDEN;
+HRESULT vkd3d_create_buffer(struct d3d12_device *device,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
+ const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer) DECLSPEC_HIDDEN;
+HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info) DECLSPEC_HIDDEN;
+
struct vkd3d_view
{
LONG refcount;
@@ -773,13 +782,6 @@ VkPipeline d3d12_device_find_cached_pipeline(struct d3d12_device *device,
bool d3d12_device_put_pipeline_to_cache(struct d3d12_device *device,
const struct vkd3d_pipeline_key *key, VkPipeline vk_pipeline, struct list *list) DECLSPEC_HIDDEN;
-HRESULT vkd3d_create_buffer(struct d3d12_device *device,
- const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer) DECLSPEC_HIDDEN;
-HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer,
- const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- VkDeviceMemory *vk_memory) DECLSPEC_HIDDEN;
-
/* utils */
struct vkd3d_format
{
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 3/9] vkd3d: Pass D3D12_RESOURCE_DESC and VkImage to vkd3d_create_image().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
For consistency with vkd3d_create_buffer().
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/resource.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 15804500681b..d5690deebb8e 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -321,17 +321,15 @@ static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC *desc)
return vkd3d_log2i(size) + 1;
}
-static HRESULT vkd3d_create_image(struct d3d12_resource *resource, struct d3d12_device *device,
- const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
+static HRESULT vkd3d_create_image(struct d3d12_device *device,
+ const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
+ const D3D12_RESOURCE_DESC *desc, VkImage *vk_image)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
const struct vkd3d_format *format;
- const D3D12_RESOURCE_DESC *desc;
VkImageCreateInfo image_info;
VkResult vr;
- desc = &resource->desc;
-
if (!(format = vkd3d_format_from_d3d12_resource_desc(desc, 0)))
{
WARN("Invalid DXGI format %#x.\n", desc->Format);
@@ -402,7 +400,7 @@ static HRESULT vkd3d_create_image(struct d3d12_resource *resource, struct d3d12_
image_info.initialLayout = 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, &resource->u.vk_image))) < 0)
+ if ((vr = VK_CALL(vkCreateImage(device->vk_device, &image_info, NULL, vk_image))) < 0)
{
WARN("Failed to create Vulkan image, vr %d.\n", vr);
return hresult_from_vk_result(vr);
@@ -976,7 +974,8 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12
if (!resource->desc.MipLevels)
resource->desc.MipLevels = max_miplevel_count(desc);
resource->flags |= VKD3D_RESOURCE_INITIAL_STATE_TRANSITION;
- if (FAILED(hr = vkd3d_create_image(resource, device, heap_properties, heap_flags)))
+ if (FAILED(hr = vkd3d_create_image(device, heap_properties, heap_flags,
+ &resource->desc, &resource->u.vk_image)))
return hr;
break;
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 2/9] vkd3d: Implement d3d12_device_GetResourceAllocationInfo() for buffers.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
In Direct3D12, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT is always used
for buffers. We could try to use a lower alignment when supported by
the Vulkan implementation, but there is no way to get buffer memory
requirements without creating a buffer in Vulkan.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index a3a00b92c241..54196acb83e8 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2022,16 +2022,43 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptorsSimple(ID3D12Device *i
}
static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo(
- ID3D12Device *iface, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info, UINT visible_mask,
- UINT resource_desc_count, const D3D12_RESOURCE_DESC *resource_descs)
+ ID3D12Device *iface, D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask,
+ UINT count, const D3D12_RESOURCE_DESC *resource_descs)
{
- FIXME("iface %p, allocation_info %p, visible_mask 0x%08x, resource_desc_count %u, "
- "resource_descs %p stub!\n",
- iface, allocation_info, visible_mask, resource_desc_count, resource_descs);
+ const D3D12_RESOURCE_DESC *desc;
+
+ TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n",
+ iface, info, visible_mask, count, resource_descs);
debug_ignored_node_mask(visible_mask);
- return allocation_info;
+ info->SizeInBytes = 0;
+ info->Alignment = 0;
+
+ if (count != 1)
+ {
+ FIXME("Multiple resource descriptions not supported.\n");
+ return info;
+ }
+
+ desc = &resource_descs[0];
+ if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
+ {
+ info->SizeInBytes = align(desc->Width, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
+ info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
+ }
+ else
+ {
+ FIXME("Unhandled dimension %#x.\n", desc->Dimension);
+ }
+
+ if (FAILED(d3d12_resource_validate_desc(desc)))
+ {
+ WARN("Invalid resource desc.\n");
+ info->SizeInBytes = ~(UINT64)0;
+ }
+
+ return info;
}
static D3D12_HEAP_PROPERTIES * STDMETHODCALLTYPE d3d12_device_GetCustomHeapProperties(ID3D12Device *iface,
--
2.16.4
Sept. 25, 2018
[PATCH vkd3d 1/9] vkd3d: Add support for fake placed resources.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Placed resources are not allocated from a given heap yet.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/device.c | 22 ++++++++++++++++------
libs/vkd3d/resource.c | 20 ++++++++++++++++++++
libs/vkd3d/vkd3d_private.h | 4 ++++
3 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index b57e3ceb99e5..a3a00b92c241 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2091,15 +2091,25 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device *iface,
static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device *iface,
ID3D12Heap *heap, UINT64 heap_offset,
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, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
- "optimized_clear_value %p, riid %s, resource %p stub!\n",
+ struct d3d12_device *device = impl_from_ID3D12Device(iface);
+ struct d3d12_heap *heap_object;
+ struct d3d12_resource *object;
+ HRESULT hr;
+
+ TRACE("iface %p, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
+ "optimized_clear_value %p, iid %s, resource %p.\n",
iface, heap, heap_offset, desc, initial_state,
- optimized_clear_value, debugstr_guid(riid), resource);
+ optimized_clear_value, debugstr_guid(iid), resource);
- return E_NOTIMPL;
+ heap_object = unsafe_impl_from_ID3D12Heap(heap);
+
+ if (FAILED(hr = d3d12_placed_resource_create(device, heap_object, heap_offset,
+ desc, initial_state, optimized_clear_value, &object)))
+ return hr;
+
+ return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Device *iface,
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 10f1d835e792..15804500681b 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -146,6 +146,14 @@ static const struct ID3D12HeapVtbl d3d12_heap_vtbl =
d3d12_heap_GetDesc,
};
+struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &d3d12_heap_vtbl);
+ return impl_from_ID3D12Heap(iface);
+}
+
static HRESULT validate_heap_desc(const D3D12_HEAP_DESC *desc)
{
if (!desc->SizeInBytes)
@@ -1049,6 +1057,18 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
return S_OK;
}
+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)
+{
+ const D3D12_HEAP_DESC *heap_desc = &heap->desc;
+
+ FIXME("Ignoring heap %p, offset %"PRIu64".\n", heap, heap_offset);
+
+ return d3d12_committed_resource_create(device, &heap_desc->Properties, heap_desc->Flags,
+ desc, initial_state, optimized_clear_value, resource);
+}
+
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 5aaa56505db0..c4d6dd531728 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -195,6 +195,7 @@ struct d3d12_heap
HRESULT d3d12_heap_create(struct d3d12_device *device,
const D3D12_HEAP_DESC *desc, struct d3d12_heap **heap) DECLSPEC_HIDDEN;
+struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface) DECLSPEC_HIDDEN;
#define VKD3D_RESOURCE_PUBLIC_FLAGS \
(VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION)
@@ -245,6 +246,9 @@ HRESULT d3d12_committed_resource_create(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, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
+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;
struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface) DECLSPEC_HIDDEN;
struct vkd3d_view
--
2.16.4
Sept. 25, 2018
[PATCH v2 8/8] shell32/autocomplete: Hide the auto-suggest listbox when ESC is pressed
by Gabriel Ivăncescu
When the listbox is visible, ESC should hide it. Only when it's not visible
should it be forwarded to the edit control. This matches Windows behavior.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
no_fwd_char is needed because we cannot send an ESC character in WM_CHAR
to the edit control, which clears the text. We have to handle it in KeyDown
though, just like VK_RETURN in previous patch.
dlls/shell32/autocomplete.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index e2ae8aa..f0b7f61 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -346,6 +346,15 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT
{
switch (wParam)
{
+ case VK_ESCAPE:
+ /* When pressing ESC, Windows hides the auto-suggest listbox, if visible */
+ if ((ac->options & ACO_AUTOSUGGEST) && IsWindowVisible(ac->hwndListBox))
+ {
+ ShowWindow(ac->hwndListBox, SW_HIDE);
+ ac->no_fwd_char = 0x1B; /* ESC char */
+ return 0;
+ }
+ break;
case VK_RETURN:
/* If quickComplete is set and control is pressed, replace the string */
if (ac->quickComplete && (GetKeyState(VK_CONTROL) & 0x8000))
--
1.9.1
Sept. 25, 2018