diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 2dfec692e..407a5c18a 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1417,7 +1417,7 @@ namespace dxvk { // D3D may legally query non-power-of-two sample counts as well VkSampleCountFlagBits sampleCountFlag = VK_SAMPLE_COUNT_1_BIT; - if (FAILED(GetSampleCount(SampleCount, &sampleCountFlag))) + if (FAILED(DecodeSampleCount(SampleCount, &sampleCountFlag))) return E_INVALIDARG; // Check if the device supports the given combination of format diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index b65fb05dd..1bfb0e6bd 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -28,8 +28,7 @@ namespace dxvk { imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.layout = VK_IMAGE_LAYOUT_GENERAL; - if (FAILED(GetSampleCount(m_desc.SampleDesc.Count, &imageInfo.sampleCount))) - throw DxvkError(str::format("D3D11: Invalid sample count: ", m_desc.SampleDesc.Count)); + DecodeSampleCount(m_desc.SampleDesc.Count, &imageInfo.sampleCount); // Adjust image flags based on the corresponding D3D flags if (m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) { @@ -154,7 +153,12 @@ namespace dxvk { HRESULT D3D11CommonTexture::NormalizeTextureProperties(D3D11_COMMON_TEXTURE_DESC* pDesc) { - uint32_t maxMipLevelCount = pDesc->SampleDesc.Count <= 1 + if (FAILED(DecodeSampleCount(pDesc->SampleDesc.Count, nullptr))) + return E_INVALIDARG; + + // Use the maximum possible mip level count if the supplied + // mip level count is either unspecified (0) or invalid + const uint32_t maxMipLevelCount = pDesc->SampleDesc.Count <= 1 ? util::computeMipLevelCount({ pDesc->Width, pDesc->Height, pDesc->Depth }) : 1u; diff --git a/src/d3d11/d3d11_util.cpp b/src/d3d11/d3d11_util.cpp index 10473bf5f..a537b6f13 100644 --- a/src/d3d11/d3d11_util.cpp +++ b/src/d3d11/d3d11_util.cpp @@ -2,16 +2,22 @@ namespace dxvk { - HRESULT GetSampleCount(UINT Count, VkSampleCountFlagBits* pCount) { + HRESULT DecodeSampleCount(UINT Count, VkSampleCountFlagBits* pCount) { + VkSampleCountFlagBits flag; + switch (Count) { - case 1: *pCount = VK_SAMPLE_COUNT_1_BIT; return S_OK; - case 2: *pCount = VK_SAMPLE_COUNT_2_BIT; return S_OK; - case 4: *pCount = VK_SAMPLE_COUNT_4_BIT; return S_OK; - case 8: *pCount = VK_SAMPLE_COUNT_8_BIT; return S_OK; - case 16: *pCount = VK_SAMPLE_COUNT_16_BIT; return S_OK; + case 1: flag = VK_SAMPLE_COUNT_1_BIT; break; + case 2: flag = VK_SAMPLE_COUNT_2_BIT; break; + case 4: flag = VK_SAMPLE_COUNT_4_BIT; break; + case 8: flag = VK_SAMPLE_COUNT_8_BIT; break; + case 16: flag = VK_SAMPLE_COUNT_16_BIT; break; + default: return E_INVALIDARG; } - return E_INVALIDARG; + if (pCount != nullptr) { + *pCount = flag; + return S_OK; + } return S_FALSE; } diff --git a/src/d3d11/d3d11_util.h b/src/d3d11/d3d11_util.h index f688aa8f2..aa029a2d5 100644 --- a/src/d3d11/d3d11_util.h +++ b/src/d3d11/d3d11_util.h @@ -8,7 +8,7 @@ namespace dxvk { - HRESULT GetSampleCount( + HRESULT DecodeSampleCount( UINT Count, VkSampleCountFlagBits* pCount);