Some vulkan implementation report 2 memory types with the same VkMemoryPropertyFlags for a device. So check property flags to determine if UMA and CacheCoherentUMA are actually supported by the device.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- libs/vkd3d/device.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index a754077..c1992e6 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2098,6 +2098,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device * D3D12_FEATURE feature, void *feature_data, UINT feature_data_size) { struct d3d12_device *device = impl_from_ID3D12Device(iface); + uint32_t i;
TRACE("iface %p, feature %#x, feature_data %p, feature_data_size %u.\n", iface, feature, feature_data, feature_data_size); @@ -2138,18 +2139,16 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device * FIXME("Assuming device does not support tile based rendering.\n"); data->TileBasedRenderer = FALSE;
- if (device->memory_properties.memoryTypeCount == 1) + data->UMA = FALSE; + data->CacheCoherentUMA = FALSE; + for (i = 0; i < device->memory_properties.memoryTypeCount; i++) { - TRACE("Assuming cache coherent UMA.\n"); - data->UMA = TRUE; - data->CacheCoherentUMA = TRUE; - } - else - { - FIXME("Assuming NUMA.\n"); - data->UMA = FALSE; - data->CacheCoherentUMA = FALSE; + if (device->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + data->UMA = TRUE; + if (device->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) + data->CacheCoherentUMA = TRUE; } + TRACE("UMA:%d CacheCoherentUMA:%d\n", data->UMA, data->CacheCoherentUMA); return S_OK; }
On Wed, Apr 3, 2019 at 10:40 AM Zhiyi Zhang zzhang@codeweavers.com wrote:
struct d3d12_device *device = impl_from_ID3D12Device(iface);
- uint32_t i;
I think that "unsigned int" is preferred.
if (device->memory_properties.memoryTypeCount == 1)
data->UMA = FALSE;
data->CacheCoherentUMA = FALSE;
for (i = 0; i < device->memory_properties.memoryTypeCount; i++) {
TRACE("Assuming cache coherent UMA.\n");
data->UMA = TRUE;
data->CacheCoherentUMA = TRUE;
}
else
{
FIXME("Assuming NUMA.\n");
data->UMA = FALSE;
data->CacheCoherentUMA = FALSE;
if (device->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
data->UMA = TRUE;
if (device->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
data->CacheCoherentUMA = TRUE; }
This detects most of Vulkan implementations as cache coherent UMA. A better heuristic would be to check that all memory types are host visible or cache coherent.
TRACE("UMA:%d CacheCoherentUMA:%d\n", data->UMA, data->CacheCoherentUMA);
In d3d code, we tend to trace BOOL value using "%#x". Also, please put a space before "%" and a period at the end of TRACE() message.