Skip to content
Snippets Groups Projects

vkd3d: Implement ID3D12Device8.

Merged Conor McCarthy requested to merge cmccarthy/vkd3d:device8 into master
1 file
+ 28
0
Compare changes
  • Side-by-side
  • Inline
+ 142
3
@@ -1507,12 +1507,15 @@ static void test_create_committed_resource(void)
@@ -1507,12 +1507,15 @@ static void test_create_committed_resource(void)
ID3D12ProtectedResourceSession *protected_session;
ID3D12ProtectedResourceSession *protected_session;
D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
D3D12_HEAP_PROPERTIES heap_properties;
D3D12_HEAP_PROPERTIES heap_properties;
 
D3D12_RESOURCE_DESC1 resource_desc1;
D3D12_RESOURCE_DESC resource_desc;
D3D12_RESOURCE_DESC resource_desc;
ID3D12Device *device, *tmp_device;
ID3D12Device *device, *tmp_device;
D3D12_CLEAR_VALUE clear_value;
D3D12_CLEAR_VALUE clear_value;
D3D12_RESOURCE_STATES state;
D3D12_RESOURCE_STATES state;
 
ID3D12Resource2 *resource2;
ID3D12Resource1 *resource1;
ID3D12Resource1 *resource1;
ID3D12Resource *resource;
ID3D12Resource *resource;
 
ID3D12Device8 *device8;
ID3D12Device4 *device4;
ID3D12Device4 *device4;
unsigned int i;
unsigned int i;
ULONG refcount;
ULONG refcount;
@@ -1858,6 +1861,32 @@ static void test_create_committed_resource(void)
@@ -1858,6 +1861,32 @@ static void test_create_committed_resource(void)
ID3D12Device4_Release(device4);
ID3D12Device4_Release(device4);
}
}
 
if (SUCCEEDED(ID3D12Device_QueryInterface(device, &IID_ID3D12Device8, (void **)&device8)))
 
{
 
resource_desc1.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
 
resource_desc1.Alignment = 0;
 
resource_desc1.Width = 32;
 
resource_desc1.Height = 32;
 
resource_desc1.DepthOrArraySize = 1;
 
resource_desc1.MipLevels = 1;
 
resource_desc1.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
 
resource_desc1.SampleDesc.Count = 1;
 
resource_desc1.SampleDesc.Quality = 0;
 
resource_desc1.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
 
resource_desc1.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
 
memset(&resource_desc1.SamplerFeedbackMipRegion, 0, sizeof(resource_desc1.SamplerFeedbackMipRegion));
 
 
hr = ID3D12Device8_CreateCommittedResource2(device8, &heap_properties, D3D12_HEAP_FLAG_NONE,
 
&resource_desc1, D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value, NULL,
 
&IID_ID3D12Resource2, (void **)&resource2);
 
ok(hr == S_OK, "Failed to create committed resource, hr %#x.\n", hr);
 
 
check_interface(resource2, &IID_ID3D12Resource2, true);
 
 
ID3D12Resource2_Release(resource2);
 
ID3D12Device8_Release(device8);
 
}
 
refcount = ID3D12Device_Release(device);
refcount = ID3D12Device_Release(device);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
}
@@ -2109,13 +2138,16 @@ static void test_create_placed_resource(void)
@@ -2109,13 +2138,16 @@ static void test_create_placed_resource(void)
{
{
ID3D12ProtectedResourceSession *protected_session;
ID3D12ProtectedResourceSession *protected_session;
D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
D3D12_GPU_VIRTUAL_ADDRESS gpu_address;
ID3D12Resource *resource, *resource2;
ID3D12Resource *resource, *resource_2;
 
D3D12_RESOURCE_DESC1 resource_desc1;
D3D12_RESOURCE_DESC resource_desc;
D3D12_RESOURCE_DESC resource_desc;
ID3D12Device *device, *tmp_device;
ID3D12Device *device, *tmp_device;
D3D12_CLEAR_VALUE clear_value;
D3D12_CLEAR_VALUE clear_value;
D3D12_RESOURCE_STATES state;
D3D12_RESOURCE_STATES state;
 
ID3D12Resource2 *resource2;
ID3D12Resource1 *resource1;
ID3D12Resource1 *resource1;
D3D12_HEAP_DESC heap_desc;
D3D12_HEAP_DESC heap_desc;
 
ID3D12Device8 *device8;
ID3D12Heap *heap;
ID3D12Heap *heap;
unsigned int i;
unsigned int i;
ULONG refcount;
ULONG refcount;
@@ -2206,6 +2238,31 @@ static void test_create_placed_resource(void)
@@ -2206,6 +2238,31 @@ static void test_create_placed_resource(void)
refcount = ID3D12Resource_Release(resource);
refcount = ID3D12Resource_Release(resource);
ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
 
if (SUCCEEDED(ID3D12Device_QueryInterface(device, &IID_ID3D12Device8, (void **)&device8)))
 
{
 
resource_desc1.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
 
resource_desc1.Alignment = 0;
 
resource_desc1.Width = 32;
 
resource_desc1.Height = 1;
 
resource_desc1.DepthOrArraySize = 1;
 
resource_desc1.MipLevels = 1;
 
resource_desc1.Format = DXGI_FORMAT_UNKNOWN;
 
resource_desc1.SampleDesc.Count = 1;
 
resource_desc1.SampleDesc.Quality = 0;
 
resource_desc1.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
 
resource_desc1.Flags = 0;
 
memset(&resource_desc1.SamplerFeedbackMipRegion, 0, sizeof(resource_desc1.SamplerFeedbackMipRegion));
 
 
hr = ID3D12Device8_CreatePlacedResource1(device8, heap, 0,
 
&resource_desc1, D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource2, (void **)&resource2);
 
ok(hr == S_OK, "Failed to create placed resource, hr %#x.\n", hr);
 
 
check_interface(resource2, &IID_ID3D12Resource2, true);
 
 
ID3D12Resource2_Release(resource2);
 
ID3D12Device8_Release(device8);
 
}
 
/* The clear value must be NULL for buffers. */
/* The clear value must be NULL for buffers. */
hr = ID3D12Device_CreatePlacedResource(device, heap, 0,
hr = ID3D12Device_CreatePlacedResource(device, heap, 0,
&resource_desc, D3D12_RESOURCE_STATE_COMMON, &clear_value,
&resource_desc, D3D12_RESOURCE_STATE_COMMON, &clear_value,
@@ -2228,11 +2285,11 @@ static void test_create_placed_resource(void)
@@ -2228,11 +2285,11 @@ static void test_create_placed_resource(void)
ok(!refcount, "Got unexpected refcount %u.\n", (unsigned int)refcount);
ok(!refcount, "Got unexpected refcount %u.\n", (unsigned int)refcount);
hr = ID3D12Device_CreatePlacedResource(device, heap, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
hr = ID3D12Device_CreatePlacedResource(device, heap, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
&resource_desc, D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, (void **)&resource2);
&resource_desc, D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, (void **)&resource_2);
ok(hr == S_OK, "Failed to create placed resource, hr %#x.\n", hr);
ok(hr == S_OK, "Failed to create placed resource, hr %#x.\n", hr);
ID3D12Resource_Release(resource);
ID3D12Resource_Release(resource);
ID3D12Resource_Release(resource2);
ID3D12Resource_Release(resource_2);
for (i = 0; i < ARRAY_SIZE(invalid_buffer_desc_tests); ++i)
for (i = 0; i < ARRAY_SIZE(invalid_buffer_desc_tests); ++i)
{
{
@@ -20003,9 +20060,11 @@ static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_D
@@ -20003,9 +20060,11 @@ static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_D
static void test_get_copyable_footprints(void)
static void test_get_copyable_footprints(void)
{
{
D3D12_PLACED_SUBRESOURCE_FOOTPRINT layouts[10];
D3D12_PLACED_SUBRESOURCE_FOOTPRINT layouts[10];
 
D3D12_RESOURCE_DESC1 resource_desc1;
uint64_t row_sizes[10], total_size;
uint64_t row_sizes[10], total_size;
D3D12_RESOURCE_DESC resource_desc;
D3D12_RESOURCE_DESC resource_desc;
unsigned int sub_resource_count;
unsigned int sub_resource_count;
 
ID3D12Device8 *device8;
unsigned int i, j, k;
unsigned int i, j, k;
ID3D12Device *device;
ID3D12Device *device;
UINT row_counts[10];
UINT row_counts[10];
@@ -20243,6 +20302,31 @@ static void test_get_copyable_footprints(void)
@@ -20243,6 +20302,31 @@ static void test_get_copyable_footprints(void)
check_copyable_footprints(&resource_desc, 0, 1, 0,
check_copyable_footprints(&resource_desc, 0, 1, 0,
layouts, row_counts, row_sizes, &total_size);
layouts, row_counts, row_sizes, &total_size);
 
if (SUCCEEDED(ID3D12Device_QueryInterface(device, &IID_ID3D12Device8, (void **)&device8)))
 
{
 
resource_desc1.Dimension = resource_desc.Dimension;
 
resource_desc1.Alignment = resource_desc.Alignment;
 
resource_desc1.Width = resource_desc.Width;
 
resource_desc1.Height = resource_desc.Height;
 
resource_desc1.DepthOrArraySize = resource_desc.DepthOrArraySize;
 
resource_desc1.MipLevels = resource_desc.MipLevels;
 
resource_desc1.Format = resource_desc.Format;
 
resource_desc1.SampleDesc.Count = resource_desc.SampleDesc.Count;
 
resource_desc1.SampleDesc.Quality = resource_desc.SampleDesc.Quality;
 
resource_desc1.Flags = resource_desc.Flags;
 
memset(&resource_desc1.SamplerFeedbackMipRegion, 0, sizeof(resource_desc1.SamplerFeedbackMipRegion));
 
memset(layouts, 0, sizeof(layouts));
 
memset(row_counts, 0, sizeof(row_counts));
 
memset(row_sizes, 0, sizeof(row_sizes));
 
total_size = 0;
 
ID3D12Device8_GetCopyableFootprints1(device8, &resource_desc1, 0, 1, 0,
 
layouts, row_counts, row_sizes, &total_size);
 
check_copyable_footprints(&resource_desc, 0, 1, 0,
 
layouts, row_counts, row_sizes, &total_size);
 
 
ID3D12Device8_Release(device8);
 
}
 
for (i = 0; i < ARRAY_SIZE(invalid_descs); ++i)
for (i = 0; i < ARRAY_SIZE(invalid_descs); ++i)
{
{
resource_desc = invalid_descs[i].resource_desc;
resource_desc = invalid_descs[i].resource_desc;
@@ -32114,6 +32198,7 @@ static void test_resource_allocation_info(void)
@@ -32114,6 +32198,7 @@ static void test_resource_allocation_info(void)
{
{
D3D12_RESOURCE_ALLOCATION_INFO info;
D3D12_RESOURCE_ALLOCATION_INFO info;
D3D12_RESOURCE_DESC desc;
D3D12_RESOURCE_DESC desc;
 
ID3D12Device8 *device8;
ID3D12Device4 *device4;
ID3D12Device4 *device4;
ID3D12Device *device;
ID3D12Device *device;
uint64_t total = 0;
uint64_t total = 0;
@@ -32164,6 +32249,7 @@ static void test_resource_allocation_info(void)
@@ -32164,6 +32249,7 @@ static void test_resource_allocation_info(void)
{260, 512, 1, 1, DXGI_FORMAT_BC1_UNORM},
{260, 512, 1, 1, DXGI_FORMAT_BC1_UNORM},
};
};
D3D12_RESOURCE_ALLOCATION_INFO1 infos1[ARRAY_SIZE(texture_tests)] = {0};
D3D12_RESOURCE_ALLOCATION_INFO1 infos1[ARRAY_SIZE(texture_tests)] = {0};
 
D3D12_RESOURCE_DESC1 desc_array1[ARRAY_SIZE(texture_tests)];
D3D12_RESOURCE_DESC desc_array[ARRAY_SIZE(texture_tests)];
D3D12_RESOURCE_DESC desc_array[ARRAY_SIZE(texture_tests)];
uint64_t sizes[ARRAY_SIZE(texture_tests)];
uint64_t sizes[ARRAY_SIZE(texture_tests)];
@@ -32309,6 +32395,59 @@ static void test_resource_allocation_info(void)
@@ -32309,6 +32395,59 @@ static void test_resource_allocation_info(void)
ID3D12Device4_Release(device4);
ID3D12Device4_Release(device4);
}
}
 
if (FAILED(ID3D12Device_QueryInterface(device, &IID_ID3D12Device8, (void **)&device8)))
 
{
 
skip("ID3D12Device8 not available; skipping GetResourceAllocationInfo2() tests.");
 
goto release;
 
}
 
 
for (i = 0; i < ARRAY_SIZE(texture_tests); ++i)
 
{
 
desc_array1[i].Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
 
desc_array1[i].Alignment = (i < 6) ? D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT
 
: D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
 
desc_array1[i].Width = texture_tests[i].width;
 
desc_array1[i].Height = texture_tests[i].height;
 
desc_array1[i].DepthOrArraySize = texture_tests[i].array_size;
 
desc_array1[i].MipLevels = texture_tests[i].miplevels;
 
desc_array1[i].Format = texture_tests[i].format;
 
desc_array1[i].SampleDesc.Count = 1;
 
desc_array1[i].SampleDesc.Quality = 0;
 
desc_array1[i].Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
 
desc_array1[i].Flags = 0;
 
memset(&desc_array1[i].SamplerFeedbackMipRegion, 0, sizeof(desc_array1[i].SamplerFeedbackMipRegion));
 
}
 
 
info = ID3D12Device8_GetResourceAllocationInfo2(device8, 0, ARRAY_SIZE(desc_array1), desc_array1, infos1);
 
ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
 
"Got unexpected alignment %"PRIu64".\n", info.Alignment);
 
check_alignment(info.SizeInBytes, info.Alignment);
 
ok(info.SizeInBytes >= total, "Got unexpected size %"PRIu64".\n", info.SizeInBytes);
 
ok(!infos1[0].Offset, "Got unexpected offset %"PRIu64".\n", infos1[0].Offset);
 
 
for (i = 0; i < ARRAY_SIZE(infos1); ++i)
 
{
 
vkd3d_test_push_context("Test %u", i);
 
 
ok(infos1[i].Alignment >= desc_array1[i].Alignment,
 
"Got unexpected alignment %"PRIu64".\n", infos1[i].Alignment);
 
check_alignment(infos1[i].Offset, infos1[i].Alignment);
 
check_alignment(infos1[i].SizeInBytes, infos1[i].Alignment);
 
ok(infos1[i].SizeInBytes == sizes[i], "Got unexpected size %"PRIu64".\n", infos1[i].SizeInBytes);
 
 
if (!i)
 
continue;
 
 
ok(infos1[i].Offset - infos1[i - 1].Offset >= infos1[i - 1].SizeInBytes,
 
"Got unexpected prev size %"PRIu64", prev offset %"PRIu64", offset %"PRIu64".\n",
 
infos1[i - 1].SizeInBytes, infos1[i - 1].Offset, infos1[i].Offset);
 
 
vkd3d_test_pop_context();
 
}
 
 
ID3D12Device8_Release(device8);
 
 
release:
refcount = ID3D12Device_Release(device);
refcount = ID3D12Device_Release(device);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
}
Loading