[dxvk] Perform validation on render pass formats read from state cache

This commit is contained in:
Philip Rebohle 2022-05-06 16:05:43 +02:00
parent 80e125a130
commit 6d3ba1b7d7
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 54 additions and 6 deletions

View File

@ -269,7 +269,7 @@ namespace dxvk {
DxvkRenderPassPool::DxvkRenderPassPool(const DxvkDevice* device)
: m_vkd(device->vkd()) {
: m_device(device) {
}
@ -288,8 +288,45 @@ namespace dxvk {
auto result = m_renderPasses.emplace(std::piecewise_construct,
std::tuple(fmt),
std::tuple(m_vkd, fmt));
std::tuple(m_device->vkd(), fmt));
return &result.first->second;
}
bool DxvkRenderPassPool::validateRenderPassFormat(
const DxvkRenderPassFormat& fmt) {
Rc<DxvkAdapter> adapter = m_device->adapter();
if (fmt.depth.format) {
VkFormatProperties depthInfo = adapter->formatProperties(fmt.depth.format);
VkFormatFeatureFlags depthFlags = depthInfo.linearTilingFeatures | depthInfo.optimalTilingFeatures;
if (!(depthFlags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
return false;
if (fmt.depth.layout != VK_IMAGE_LAYOUT_GENERAL
&& fmt.depth.layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
&& fmt.depth.layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
&& fmt.depth.layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
&& fmt.depth.layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL)
return false;
}
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
if (fmt.color[i].format) {
VkFormatProperties colorInfo = adapter->formatProperties(fmt.color[i].format);
VkFormatFeatureFlags colorFlags = colorInfo.linearTilingFeatures | colorInfo.optimalTilingFeatures;
if (!(colorFlags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
return false;
if (fmt.color[i].layout != VK_IMAGE_LAYOUT_GENERAL
&& fmt.color[i].layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
return false;
}
}
return true;
}
}

View File

@ -219,10 +219,19 @@ namespace dxvk {
*/
DxvkRenderPass* getRenderPass(
const DxvkRenderPassFormat& fmt);
/**
* \brief Validates render pass format
*
* \param [in] fmt The render pass format
* \returns \c true if the format is supported
*/
bool validateRenderPassFormat(
const DxvkRenderPassFormat& fmt);
private:
const Rc<vk::DeviceFn> m_vkd;
const DxvkDevice* m_device;
dxvk::mutex m_mutex;
std::unordered_map<

View File

@ -371,8 +371,10 @@ namespace dxvk {
for (auto e = entries.first; e != entries.second; e++) {
const auto& entry = m_entries[e->second];
auto rp = m_passManager->getRenderPass(entry.format);
pipeline->compilePipeline(entry.gpState, rp);
if (m_passManager->validateRenderPassFormat(entry.format)) {
auto rp = m_passManager->getRenderPass(entry.format);
pipeline->compilePipeline(entry.gpState, rp);
}
}
} else {
auto pipeline = m_pipeManager->createComputePipeline(item.cp);