[PATCH vkd3d 1/3] tests: Introduce struct bundle_context.
Conor McCarthy
cmccarthy at codeweavers.com
Wed Sep 8 08:21:46 CDT 2021
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
tests/d3d12.c | 26 +++++++++-----------------
tests/d3d12_test_utils.h | 23 +++++++++++++++++++++++
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index f723dbaa..eddd6cbf 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -7372,11 +7372,10 @@ static void test_bundle_state_inheritance(void)
{
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
ID3D12GraphicsCommandList *command_list, *bundle;
- ID3D12CommandAllocator *bundle_allocator;
+ struct bundle_context bundle_context;
struct test_context context;
struct resource_readback rb;
ID3D12CommandQueue *queue;
- ID3D12Device *device;
unsigned int x, y;
HRESULT hr;
@@ -7388,16 +7387,10 @@ static void test_bundle_state_inheritance(void)
if (!init_test_context(&context, NULL))
return;
- device = context.device;
command_list = context.list;
queue = context.queue;
-
- hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_BUNDLE,
- &IID_ID3D12CommandAllocator, (void **)&bundle_allocator);
- ok(SUCCEEDED(hr), "Failed to create command allocator, hr %#x.\n", hr);
- hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_BUNDLE,
- bundle_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&bundle);
- ok(SUCCEEDED(hr), "Failed to create command list, hr %#x.\n", hr);
+ init_bundle_context(context.device, &bundle_context);
+ bundle = bundle_context.list;
/* A bundle does not inherit the current pipeline state. */
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
@@ -7431,7 +7424,7 @@ static void test_bundle_state_inheritance(void)
release_resource_readback(&rb);
reset_command_list(command_list, context.allocator);
- reset_command_list(bundle, bundle_allocator);
+ reset_command_list(bundle, bundle_context.allocator);
/* A bundle sets to null the pipeline state in the executing command list. */
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
@@ -7466,7 +7459,7 @@ static void test_bundle_state_inheritance(void)
release_resource_readback(&rb);
reset_command_list(command_list, context.allocator);
- reset_command_list(bundle, bundle_allocator);
+ reset_command_list(bundle, bundle_context.allocator);
/* A bundle does not inherit the current primitive topology. */
transition_resource_state(command_list, context.render_target,
@@ -7503,7 +7496,7 @@ static void test_bundle_state_inheritance(void)
release_resource_readback(&rb);
reset_command_list(command_list, context.allocator);
- reset_command_list(bundle, bundle_allocator);
+ reset_command_list(bundle, bundle_context.allocator);
/* A bundle sets to undefined the primitive topology in the executing command list. */
transition_resource_state(command_list, context.render_target,
@@ -7540,7 +7533,7 @@ static void test_bundle_state_inheritance(void)
release_resource_readback(&rb);
reset_command_list(command_list, context.allocator);
- reset_command_list(bundle, bundle_allocator);
+ reset_command_list(bundle, bundle_context.allocator);
/* A bundle inherit all other states. */
transition_resource_state(command_list, context.render_target,
@@ -7566,7 +7559,7 @@ static void test_bundle_state_inheritance(void)
check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff00ff00, 0);
reset_command_list(command_list, context.allocator);
- reset_command_list(bundle, bundle_allocator);
+ reset_command_list(bundle, bundle_context.allocator);
/* All state that is set in a bundle affects a command list. */
transition_resource_state(command_list, context.render_target,
@@ -7591,8 +7584,7 @@ static void test_bundle_state_inheritance(void)
todo
check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff00ff00, 0);
- ID3D12CommandAllocator_Release(bundle_allocator);
- ID3D12GraphicsCommandList_Release(bundle);
+ destroy_bundle_context(&bundle_context);
destroy_test_context(&context);
}
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h
index 0374d8d1..5cf2c130 100644
--- a/tests/d3d12_test_utils.h
+++ b/tests/d3d12_test_utils.h
@@ -1008,6 +1008,29 @@ static inline void destroy_test_context_(unsigned int line, struct test_context
ok_(line)(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
+struct bundle_context
+{
+ ID3D12CommandAllocator *allocator;
+ ID3D12GraphicsCommandList *list;
+};
+
+#define init_bundle_context(device, context) init_bundle_context_(__LINE__, device, context)
+static inline void init_bundle_context_(unsigned int line, ID3D12Device *device, struct bundle_context *bundle)
+{
+ HRESULT hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_BUNDLE,
+ &IID_ID3D12CommandAllocator, (void **)&bundle->allocator);
+ ok_(line)(SUCCEEDED(hr), "Failed to create bundle command allocator, hr %#x.\n", hr);
+ hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_BUNDLE,
+ bundle->allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&bundle->list);
+ ok(SUCCEEDED(hr), "Failed to create bundle command list, hr %#x.\n", hr);
+}
+
+static inline void destroy_bundle_context(struct bundle_context *bundle)
+{
+ ID3D12CommandAllocator_Release(bundle->allocator);
+ ID3D12GraphicsCommandList_Release(bundle->list);
+}
+
static inline D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_handle(ID3D12Device *device,
ID3D12DescriptorHeap *heap, D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int offset)
{
--
2.32.0
More information about the wine-devel
mailing list