vkd3d: Implement ID3D12Resource2.
Merge request reports
Activity
3654 3671 3672 static void d3d12_device_get_resource_allocation_info(struct d3d12_device *device, 3673 D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC *resource_descs, 3674 D3D12_RESOURCE_ALLOCATION_INFO *result) 3675 { 3676 D3D12_RESOURCE_DESC1 resource_descs1[4]; 3677 D3D12_RESOURCE_DESC1 *descs1 = NULL; 3678 unsigned int i; 3679 3680 if (count > ARRAY_SIZE(resource_descs1)) 3681 { 3682 if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) 3683 { 3684 ERR("Failed to allocate %u resource descriptions.\n", count); 3685 memset(&infos1[ARRAY_SIZE(resource_descs1)], 0, (count - ARRAY_SIZE(resource_descs1)) * sizeof(*infos1)); 3686 count = ARRAY_SIZE(resource_descs1); - Comment on lines +3684 to +3686
It seems that Microsoft allows declaring an error: "If an error occurs, then D3D12_RESOURCE_ALLOCATION_INFO::SizeInBytes equals UINT64_MAX". Maybe we should do that instead of silently (WRT the application) truncate the input.
changed this line in version 2 of the diff
+void d3d12_resource_desc_promote(D3D12_RESOURCE_DESC1 *dst_desc, const D3D12_RESOURCE_DESC *src_desc) +{ + dst_desc->Dimension = src_desc->Dimension; + dst_desc->Alignment = src_desc->Alignment; + dst_desc->Width = src_desc->Width; + dst_desc->Height = src_desc->Height; + dst_desc->DepthOrArraySize = src_desc->DepthOrArraySize; + dst_desc->MipLevels = src_desc->MipLevels; + dst_desc->Format = src_desc->Format; + dst_desc->SampleDesc = src_desc->SampleDesc; + dst_desc->Layout = src_desc->Layout; + dst_desc->Flags = src_desc->Flags; + dst_desc->SamplerFeedbackMipRegion.Width = 0; + dst_desc->SamplerFeedbackMipRegion.Height = 0; + dst_desc->SamplerFeedbackMipRegion.Depth = 0; +}
This is not used outside device.c. We'd typically implemented that like this:
static void d3d12_resource_desc1_from_desc(D3D12_RESOURCE_DESC1 *desc1, const D3D12_RESOURCE_DESC *desc) { memcpy(desc1, desc, sizeof(*desc)) desc1->SamplerFeedbackMipRegion.Width = 0; desc1->SamplerFeedbackMipRegion.Height = 0; desc1->SamplerFeedbackMipRegion.Depth = 0; }
+static void d3d12_device_get_resource_allocation_info(struct d3d12_device *device, + D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC *resource_descs, + D3D12_RESOURCE_ALLOCATION_INFO *result) +{ + D3D12_RESOURCE_DESC1 resource_descs1[4]; + D3D12_RESOURCE_DESC1 *descs1 = NULL; + unsigned int i; + + if (count > ARRAY_SIZE(resource_descs1)) + { + if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) + { + ERR("Failed to allocate %u resource descriptions.\n", count); + result->SizeInBytes = UINT64_MAX; + result->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + return; + } + } + + if (!descs1) + descs1 = resource_descs1;
I.e.,
{ D3D12_RESOURCE_DESC1 resource_descs1[4]; D3D12_RESOURCE_DESC1 *descs1; unsigned int i; if (count <= ARRAY_SIZE(resource_descs1)) { descs1 = resource_descs1; } else if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) { ... return; } ... if (descs1 != resource_descs1) vkd3d_free(descs1); }
right?
-static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource1 *iface, +static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource2 *iface, D3D12_RESOURCE_DESC *resource_desc) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); + const D3D12_RESOURCE_DESC1 *desc1 = &resource->desc; TRACE("iface %p, resource_desc %p.\n", iface, resource_desc); - *resource_desc = resource->desc; + resource_desc->Dimension = desc1->Dimension; + resource_desc->Alignment = desc1->Alignment; + resource_desc->Width = desc1->Width; + resource_desc->Height = desc1->Height; + resource_desc->DepthOrArraySize = desc1->DepthOrArraySize; + resource_desc->MipLevels = desc1->MipLevels; + resource_desc->Format = desc1->Format; + resource_desc->SampleDesc = desc1->SampleDesc; + resource_desc->Layout = desc1->Layout; + resource_desc->Flags = desc1->Flags; return resource_desc; }
Somewhat like above, we'd normally just use "memcpy(resource_desc, &resource->desc, sizeof(*resource_desc))" here.
added 19 commits
-
d1d19b4d...7f87a3e5 - 15 commits from branch
wine:master
- 9a43f246 - tests/d3d12: Add tests for GetProtectedResourceSession().
- 8f30c783 - vkd3d: Return DXGI_ERROR_NOT_FOUND from GetProtectedResourceSession().
- 3e06fe3f - tests/d3d12: Add a test for zero description count in test_resource_allocation_info().
- 285e62f5 - vkd3d: Implement ID3D12Resource2.
Toggle commit list-
d1d19b4d...7f87a3e5 - 15 commits from branch
mentioned in merge request !626 (merged)
@@ -1723,9 +1723,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource1 *iface, REFIID iid, void **session) { - FIXME("iface %p, iid %s, session %p stub!\n", iface, debugstr_guid(iid), session); + TRACE("iface %p, iid %s, session %p.\n", iface, debugstr_guid(iid), session);
Is changing the FIXME to a TRACE really warranted? Sure, it'll return the right result now, but that's only because we don't implement creating protected resources.
+static void d3d12_resource_desc_promote(D3D12_RESOURCE_DESC1 *desc1, const D3D12_RESOURCE_DESC *desc) +{ + memcpy(desc1, desc, sizeof(*desc)); + desc1->SamplerFeedbackMipRegion.Width = 0; + desc1->SamplerFeedbackMipRegion.Height = 0; + desc1->SamplerFeedbackMipRegion.Depth = 0; +}
Could we call that "d3d12_resource_desc1_from_desc()", please?
added 56 commits
-
4bbef5a2...628acb6b - 52 commits from branch
wine:master
- e38f3995 - tests/d3d12: Add tests for GetProtectedResourceSession().
- 46682718 - vkd3d: Return DXGI_ERROR_NOT_FOUND from GetProtectedResourceSession().
- 99947dee - tests/d3d12: Add a test for zero description count in test_resource_allocation_info().
- 6d4782ed - vkd3d: Implement ID3D12Resource2.
Toggle commit list-
4bbef5a2...628acb6b - 52 commits from branch