=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: tests: Move more helpers to d3d12_test_utils.h.
Alexandre Julliard
julliard at winehq.org
Tue Dec 4 13:22:16 CST 2018
Module: vkd3d
Branch: master
Commit: 8477606e1c41e1766d2ef8482be222d51e6a0201
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=8477606e1c41e1766d2ef8482be222d51e6a0201
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Dec 4 15:55:59 2018 +0100
tests: Move more helpers to d3d12_test_utils.h.
We should move the implementation to a C file.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tests/d3d12.c | 40 ----------------------------------------
tests/d3d12_test_utils.h | 46 +++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 8f9e2c6..e48750b 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -173,18 +173,6 @@ static void uav_barrier(ID3D12GraphicsCommandList *list, ID3D12Resource *resourc
ID3D12GraphicsCommandList_ResourceBarrier(list, 1, &barrier);
}
-#define reset_command_list(a, b) reset_command_list_(__LINE__, a, b)
-static void reset_command_list_(unsigned int line,
- ID3D12GraphicsCommandList *list, ID3D12CommandAllocator *allocator)
-{
- HRESULT hr;
-
- hr = ID3D12CommandAllocator_Reset(allocator);
- ok_(line)(SUCCEEDED(hr), "Failed to reset command allocator, hr %#x.\n", hr);
- hr = ID3D12GraphicsCommandList_Reset(list, allocator, NULL);
- ok_(line)(SUCCEEDED(hr), "Failed to reset command list, hr %#x.\n", hr);
-}
-
#ifdef _WIN32
static HANDLE create_event(void)
{
@@ -354,21 +342,6 @@ static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12Comm
ID3D12Fence_Release(fence);
}
-#define update_buffer_data(a, b, c, d) update_buffer_data_(__LINE__, a, b, c, d)
-static void update_buffer_data_(unsigned int line, ID3D12Resource *buffer,
- size_t offset, size_t size, const void *data)
-{
- D3D12_RANGE range;
- HRESULT hr;
- void *ptr;
-
- range.Begin = range.End = 0;
- hr = ID3D12Resource_Map(buffer, 0, &range, &ptr);
- ok_(line)(SUCCEEDED(hr), "Failed to map buffer, hr %#x.\n", hr);
- memcpy((BYTE *)ptr + offset, data, size);
- ID3D12Resource_Unmap(buffer, 0, NULL);
-}
-
#define create_default_buffer(a, b, c, d) create_default_buffer_(__LINE__, a, b, c, d)
static ID3D12Resource *create_default_buffer_(unsigned int line, ID3D12Device *device,
size_t size, D3D12_RESOURCE_FLAGS resource_flags, D3D12_RESOURCE_STATES initial_resource_state)
@@ -377,19 +350,6 @@ static ID3D12Resource *create_default_buffer_(unsigned int line, ID3D12Device *d
resource_flags, initial_resource_state);
}
-#define create_upload_buffer(a, b, c) create_upload_buffer_(__LINE__, a, b, c)
-static ID3D12Resource *create_upload_buffer_(unsigned int line, ID3D12Device *device,
- size_t size, const void *data)
-{
- ID3D12Resource *buffer;
-
- buffer = create_buffer_(line, device, D3D12_HEAP_TYPE_UPLOAD, size,
- D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ);
- if (data)
- update_buffer_data_(line, buffer, 0, size, data);
- return buffer;
-}
-
static void copy_sub_resource_data(const D3D12_MEMCPY_DEST *dst, const D3D12_SUBRESOURCE_DATA *src,
unsigned int row_count, unsigned int slice_count, size_t row_size)
{
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index 02c5a74..d4265fc 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -81,6 +81,18 @@ static void exec_command_list(ID3D12CommandQueue *queue, ID3D12GraphicsCommandLi
ID3D12CommandQueue_ExecuteCommandLists(queue, 1, lists);
}
+#define reset_command_list(a, b) reset_command_list_(__LINE__, a, b)
+static inline void reset_command_list_(unsigned int line,
+ ID3D12GraphicsCommandList *list, ID3D12CommandAllocator *allocator)
+{
+ HRESULT hr;
+
+ hr = ID3D12CommandAllocator_Reset(allocator);
+ ok_(line)(SUCCEEDED(hr), "Failed to reset command allocator, hr %#x.\n", hr);
+ hr = ID3D12GraphicsCommandList_Reset(list, allocator, NULL);
+ ok_(line)(SUCCEEDED(hr), "Failed to reset command list, hr %#x.\n", hr);
+}
+
#define create_buffer(a, b, c, d, e) create_buffer_(__LINE__, a, b, c, d, e)
static ID3D12Resource *create_buffer_(unsigned int line, ID3D12Device *device,
D3D12_HEAP_TYPE heap_type, size_t size, D3D12_RESOURCE_FLAGS resource_flags,
@@ -121,6 +133,34 @@ static ID3D12Resource *create_readback_buffer_(unsigned int line, ID3D12Device *
D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST);
}
+#define update_buffer_data(a, b, c, d) update_buffer_data_(__LINE__, a, b, c, d)
+static inline void update_buffer_data_(unsigned int line, ID3D12Resource *buffer,
+ size_t offset, size_t size, const void *data)
+{
+ D3D12_RANGE range;
+ HRESULT hr;
+ void *ptr;
+
+ range.Begin = range.End = 0;
+ hr = ID3D12Resource_Map(buffer, 0, &range, &ptr);
+ ok_(line)(hr == S_OK, "Failed to map buffer, hr %#x.\n", hr);
+ memcpy((BYTE *)ptr + offset, data, size);
+ ID3D12Resource_Unmap(buffer, 0, NULL);
+}
+
+#define create_upload_buffer(a, b, c) create_upload_buffer_(__LINE__, a, b, c)
+static inline ID3D12Resource *create_upload_buffer_(unsigned int line, ID3D12Device *device,
+ size_t size, const void *data)
+{
+ ID3D12Resource *buffer;
+
+ buffer = create_buffer_(line, device, D3D12_HEAP_TYPE_UPLOAD, size,
+ D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ);
+ if (data)
+ update_buffer_data_(line, buffer, 0, size, data);
+ return buffer;
+}
+
#define create_cpu_descriptor_heap(a, b, c) create_cpu_descriptor_heap_(__LINE__, a, b, c)
static inline ID3D12DescriptorHeap *create_cpu_descriptor_heap_(unsigned int line, ID3D12Device *device,
D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int descriptor_count)
@@ -377,7 +417,7 @@ static void check_readback_data_uint_(unsigned int line, struct resource_readbac
}
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f)
-static void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
+static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
unsigned int expected, unsigned int max_diff)
{
@@ -617,7 +657,7 @@ static void create_render_target_(unsigned int line, struct test_context *contex
}
#define init_test_context(context, desc) init_test_context_(__LINE__, context, desc)
-static bool init_test_context_(unsigned int line, struct test_context *context,
+static inline bool init_test_context_(unsigned int line, struct test_context *context,
const struct test_context_desc *desc)
{
D3D12_COMMAND_QUEUE_DESC command_queue_desc;
@@ -687,7 +727,7 @@ static bool init_test_context_(unsigned int line, struct test_context *context,
}
#define destroy_test_context(context) destroy_test_context_(__LINE__, context)
-static void destroy_test_context_(unsigned int line, struct test_context *context)
+static inline void destroy_test_context_(unsigned int line, struct test_context *context)
{
ULONG refcount;
More information about the wine-cvs
mailing list