mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-13 16:08:50 +01:00
[dxvk] Perform validation on render pass formats read from state cache
This commit is contained in:
parent
80e125a130
commit
6d3ba1b7d7
@ -269,7 +269,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxvkRenderPassPool::DxvkRenderPassPool(const DxvkDevice* device)
|
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,
|
auto result = m_renderPasses.emplace(std::piecewise_construct,
|
||||||
std::tuple(fmt),
|
std::tuple(fmt),
|
||||||
std::tuple(m_vkd, fmt));
|
std::tuple(m_device->vkd(), fmt));
|
||||||
return &result.first->second;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -219,10 +219,19 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
DxvkRenderPass* getRenderPass(
|
DxvkRenderPass* getRenderPass(
|
||||||
const DxvkRenderPassFormat& fmt);
|
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:
|
private:
|
||||||
|
|
||||||
const Rc<vk::DeviceFn> m_vkd;
|
const DxvkDevice* m_device;
|
||||||
|
|
||||||
dxvk::mutex m_mutex;
|
dxvk::mutex m_mutex;
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
|
@ -371,8 +371,10 @@ namespace dxvk {
|
|||||||
for (auto e = entries.first; e != entries.second; e++) {
|
for (auto e = entries.first; e != entries.second; e++) {
|
||||||
const auto& entry = m_entries[e->second];
|
const auto& entry = m_entries[e->second];
|
||||||
|
|
||||||
auto rp = m_passManager->getRenderPass(entry.format);
|
if (m_passManager->validateRenderPassFormat(entry.format)) {
|
||||||
pipeline->compilePipeline(entry.gpState, rp);
|
auto rp = m_passManager->getRenderPass(entry.format);
|
||||||
|
pipeline->compilePipeline(entry.gpState, rp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto pipeline = m_pipeManager->createComputePipeline(item.cp);
|
auto pipeline = m_pipeManager->createComputePipeline(item.cp);
|
||||||
|
Loading…
Reference in New Issue
Block a user