mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-29 04:06:24 +01:00
[dxvk] Bump state cache version to v12
And remove its reliance on the old render pass format struct.
This commit is contained in:
parent
39a2b1cb7a
commit
e3a63d4faa
@ -51,7 +51,7 @@ namespace dxvk {
|
|||||||
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass* renderPass) {
|
const DxvkRenderPass* renderPass) {
|
||||||
DxvkGraphicsPipelineInstance* instance = this->findInstance(state, renderPass);
|
DxvkGraphicsPipelineInstance* instance = this->findInstance(state);
|
||||||
|
|
||||||
if (unlikely(!instance)) {
|
if (unlikely(!instance)) {
|
||||||
// Exit early if the state vector is invalid
|
// Exit early if the state vector is invalid
|
||||||
@ -60,13 +60,13 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Prevent other threads from adding new instances and check again
|
// Prevent other threads from adding new instances and check again
|
||||||
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
instance = this->findInstance(state, renderPass);
|
instance = this->findInstance(state);
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
// Keep pipeline object locked, at worst we're going to stall
|
// Keep pipeline object locked, at worst we're going to stall
|
||||||
// a state cache worker and the current thread needs priority.
|
// a state cache worker and the current thread needs priority.
|
||||||
instance = this->createInstance(state, renderPass);
|
instance = this->createInstance(state);
|
||||||
this->writePipelineStateToCache(state, renderPass->format());
|
this->writePipelineStateToCache(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +75,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkGraphicsPipeline::compilePipeline(
|
void DxvkGraphicsPipeline::compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) {
|
||||||
const DxvkRenderPass* renderPass) {
|
|
||||||
// Exit early if the state vector is invalid
|
// Exit early if the state vector is invalid
|
||||||
if (!this->validatePipelineState(state, false))
|
if (!this->validatePipelineState(state, false))
|
||||||
return;
|
return;
|
||||||
@ -85,26 +84,24 @@ namespace dxvk {
|
|||||||
// similar pipelines concurrently is fragile on some drivers
|
// similar pipelines concurrently is fragile on some drivers
|
||||||
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (!this->findInstance(state, renderPass))
|
if (!this->findInstance(state))
|
||||||
this->createInstance(state, renderPass);
|
this->createInstance(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
|
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) {
|
||||||
const DxvkRenderPass* renderPass) {
|
VkPipeline pipeline = this->createPipeline(state);
|
||||||
VkPipeline pipeline = this->createPipeline(state, renderPass);
|
|
||||||
|
|
||||||
m_pipeMgr->m_numGraphicsPipelines += 1;
|
m_pipeMgr->m_numGraphicsPipelines += 1;
|
||||||
return &(*m_pipelines.emplace(state, renderPass, pipeline));
|
return &(*m_pipelines.emplace(state, pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance(
|
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) {
|
||||||
const DxvkRenderPass* renderPass) {
|
|
||||||
for (auto& instance : m_pipelines) {
|
for (auto& instance : m_pipelines) {
|
||||||
if (instance.isCompatible(state, renderPass))
|
if (instance.isCompatible(state))
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +110,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
VkPipeline DxvkGraphicsPipeline::createPipeline(
|
VkPipeline DxvkGraphicsPipeline::createPipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) const {
|
||||||
const DxvkRenderPass* renderPass) const {
|
|
||||||
if (Logger::logLevel() <= LogLevel::Debug) {
|
if (Logger::logLevel() <= LogLevel::Debug) {
|
||||||
Logger::debug("Compiling graphics pipeline...");
|
Logger::debug("Compiling graphics pipeline...");
|
||||||
this->logPipelineState(LogLevel::Debug, state);
|
this->logPipelineState(LogLevel::Debug, state);
|
||||||
@ -551,8 +547,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkGraphicsPipeline::writePipelineStateToCache(
|
void DxvkGraphicsPipeline::writePipelineStateToCache(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) const {
|
||||||
const DxvkRenderPassFormat& format) const {
|
|
||||||
if (m_pipeMgr->m_stateCache == nullptr)
|
if (m_pipeMgr->m_stateCache == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -563,7 +558,7 @@ namespace dxvk {
|
|||||||
if (m_shaders.gs != nullptr) key.gs = m_shaders.gs->getShaderKey();
|
if (m_shaders.gs != nullptr) key.gs = m_shaders.gs->getShaderKey();
|
||||||
if (m_shaders.fs != nullptr) key.fs = m_shaders.fs->getShaderKey();
|
if (m_shaders.fs != nullptr) key.fs = m_shaders.fs->getShaderKey();
|
||||||
|
|
||||||
m_pipeMgr->m_stateCache->addGraphicsPipeline(key, state, format);
|
m_pipeMgr->m_stateCache->addGraphicsPipeline(key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,15 +94,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkGraphicsPipelineInstance()
|
DxvkGraphicsPipelineInstance()
|
||||||
: m_stateVector (),
|
: m_stateVector (),
|
||||||
m_renderPass (nullptr),
|
|
||||||
m_pipeline (VK_NULL_HANDLE) { }
|
m_pipeline (VK_NULL_HANDLE) { }
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance(
|
DxvkGraphicsPipelineInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass* rp,
|
|
||||||
VkPipeline pipe)
|
VkPipeline pipe)
|
||||||
: m_stateVector (state),
|
: m_stateVector (state),
|
||||||
m_renderPass (rp),
|
|
||||||
m_pipeline (pipe) { }
|
m_pipeline (pipe) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,10 +110,8 @@ namespace dxvk {
|
|||||||
* \returns \c true if the specialization is compatible
|
* \returns \c true if the specialization is compatible
|
||||||
*/
|
*/
|
||||||
bool isCompatible(
|
bool isCompatible(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) {
|
||||||
const DxvkRenderPass* rp) {
|
return m_stateVector == state;
|
||||||
return m_renderPass == rp
|
|
||||||
&& m_stateVector == state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +125,6 @@ namespace dxvk {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
DxvkGraphicsPipelineStateInfo m_stateVector;
|
DxvkGraphicsPipelineStateInfo m_stateVector;
|
||||||
const DxvkRenderPass* m_renderPass;
|
|
||||||
VkPipeline m_pipeline;
|
VkPipeline m_pipeline;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -212,11 +206,9 @@ namespace dxvk {
|
|||||||
* Asynchronously compiles the given pipeline
|
* Asynchronously compiles the given pipeline
|
||||||
* and stores the result for future use.
|
* and stores the result for future use.
|
||||||
* \param [in] state Pipeline state vector
|
* \param [in] state Pipeline state vector
|
||||||
* \param [in] renderPass The render pass
|
|
||||||
*/
|
*/
|
||||||
void compilePipeline(
|
void compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state);
|
||||||
const DxvkRenderPass* renderPass);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -238,16 +230,13 @@ namespace dxvk {
|
|||||||
sync::List<DxvkGraphicsPipelineInstance> m_pipelines;
|
sync::List<DxvkGraphicsPipelineInstance> m_pipelines;
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* createInstance(
|
DxvkGraphicsPipelineInstance* createInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state);
|
||||||
const DxvkRenderPass* renderPass);
|
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* findInstance(
|
DxvkGraphicsPipelineInstance* findInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state);
|
||||||
const DxvkRenderPass* renderPass);
|
|
||||||
|
|
||||||
VkPipeline createPipeline(
|
VkPipeline createPipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
||||||
const DxvkRenderPass* renderPass) const;
|
|
||||||
|
|
||||||
void destroyPipeline(
|
void destroyPipeline(
|
||||||
VkPipeline pipeline) const;
|
VkPipeline pipeline) const;
|
||||||
@ -264,8 +253,7 @@ namespace dxvk {
|
|||||||
bool trusted) const;
|
bool trusted) const;
|
||||||
|
|
||||||
void writePipelineStateToCache(
|
void writePipelineStateToCache(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
||||||
const DxvkRenderPassFormat& format) const;
|
|
||||||
|
|
||||||
void logPipelineState(
|
void logPipelineState(
|
||||||
LogLevel level,
|
LogLevel level,
|
||||||
|
@ -62,6 +62,14 @@ namespace dxvk {
|
|||||||
return read(data);
|
return read(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool read(DxvkRtInfo& data, uint32_t version) {
|
||||||
|
// v12 introduced this field
|
||||||
|
if (version < 12)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return read(data);
|
||||||
|
}
|
||||||
|
|
||||||
bool read(DxvkIlBinding& data, uint32_t version) {
|
bool read(DxvkIlBinding& data, uint32_t version) {
|
||||||
if (version < 10) {
|
if (version < 10) {
|
||||||
DxvkIlBindingV9 v9;
|
DxvkIlBindingV9 v9;
|
||||||
@ -76,6 +84,34 @@ namespace dxvk {
|
|||||||
return read(data);
|
return read(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool read(DxvkRenderPassFormatV11& data, uint32_t version) {
|
||||||
|
uint8_t sampleCount = 0;
|
||||||
|
uint8_t imageFormat = 0;
|
||||||
|
uint8_t imageLayout = 0;
|
||||||
|
|
||||||
|
if (!read(sampleCount)
|
||||||
|
|| !read(imageFormat)
|
||||||
|
|| !read(imageLayout))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
data.sampleCount = VkSampleCountFlagBits(sampleCount);
|
||||||
|
data.depth.format = VkFormat(imageFormat);
|
||||||
|
data.depth.layout = unpackImageLayoutV11(imageLayout);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||||
|
if (!read(imageFormat)
|
||||||
|
|| !read(imageLayout))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
data.color[i].format = VkFormat(imageFormat);
|
||||||
|
data.color[i].layout = unpackImageLayoutV11(imageLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool write(const T& data) {
|
bool write(const T& data) {
|
||||||
if (m_size + sizeof(T) > MaxSize)
|
if (m_size + sizeof(T) > MaxSize)
|
||||||
@ -114,6 +150,15 @@ namespace dxvk {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VkImageLayout unpackImageLayoutV11(
|
||||||
|
uint8_t layout) {
|
||||||
|
switch (layout) {
|
||||||
|
case 0x80: return VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
|
case 0x81: return VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
|
||||||
|
default: return VkImageLayout(layout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -199,8 +244,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkStateCache::addGraphicsPipeline(
|
void DxvkStateCache::addGraphicsPipeline(
|
||||||
const DxvkStateCacheKey& shaders,
|
const DxvkStateCacheKey& shaders,
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state) {
|
||||||
const DxvkRenderPassFormat& format) {
|
|
||||||
if (shaders.vs.eq(g_nullShaderKey))
|
if (shaders.vs.eq(g_nullShaderKey))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -210,7 +254,7 @@ namespace dxvk {
|
|||||||
for (auto e = entries.first; e != entries.second; e++) {
|
for (auto e = entries.first; e != entries.second; e++) {
|
||||||
const DxvkStateCacheEntry& entry = m_entries[e->second];
|
const DxvkStateCacheEntry& entry = m_entries[e->second];
|
||||||
|
|
||||||
if (entry.format.eq(format) && entry.gpState == state)
|
if (entry.gpState == state)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,8 +262,7 @@ namespace dxvk {
|
|||||||
std::unique_lock<dxvk::mutex> lock(m_writerLock);
|
std::unique_lock<dxvk::mutex> lock(m_writerLock);
|
||||||
|
|
||||||
m_writerQueue.push({ shaders, state,
|
m_writerQueue.push({ shaders, state,
|
||||||
DxvkComputePipelineStateInfo(),
|
DxvkComputePipelineStateInfo(), g_nullHash });
|
||||||
format, g_nullHash });
|
|
||||||
m_writerCond.notify_one();
|
m_writerCond.notify_one();
|
||||||
|
|
||||||
createWriter();
|
createWriter();
|
||||||
@ -244,8 +287,7 @@ namespace dxvk {
|
|||||||
std::unique_lock<dxvk::mutex> lock(m_writerLock);
|
std::unique_lock<dxvk::mutex> lock(m_writerLock);
|
||||||
|
|
||||||
m_writerQueue.push({ shaders,
|
m_writerQueue.push({ shaders,
|
||||||
DxvkGraphicsPipelineStateInfo(), state,
|
DxvkGraphicsPipelineStateInfo(), state, g_nullHash });
|
||||||
DxvkRenderPassFormat(), g_nullHash });
|
|
||||||
m_writerCond.notify_one();
|
m_writerCond.notify_one();
|
||||||
|
|
||||||
createWriter();
|
createWriter();
|
||||||
@ -360,11 +402,7 @@ 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];
|
||||||
|
pipeline->compilePipeline(entry.gpState);
|
||||||
if (m_passManager->validateRenderPassFormat(entry.format)) {
|
|
||||||
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);
|
||||||
@ -504,31 +542,12 @@ namespace dxvk {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Read packed render pass format
|
// Read packed render pass format
|
||||||
uint8_t sampleCount = 0;
|
if (version < 12) {
|
||||||
uint8_t imageFormat = 0;
|
DxvkRenderPassFormatV11 v11;
|
||||||
uint8_t imageLayout = 0;
|
data.read(v11, version);
|
||||||
|
entry.gpState.rt = v11.convert();
|
||||||
if (!data.read(sampleCount, version)
|
|
||||||
|| !data.read(imageFormat, version)
|
|
||||||
|| !data.read(imageLayout, version))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
entry.format.sampleCount = VkSampleCountFlagBits(sampleCount);
|
|
||||||
entry.format.depth.format = VkFormat(imageFormat);
|
|
||||||
entry.format.depth.layout = unpackImageLayout(imageLayout);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
|
||||||
if (!data.read(imageFormat, version)
|
|
||||||
|| !data.read(imageLayout, version))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
entry.format.color[i].format = VkFormat(imageFormat);
|
|
||||||
entry.format.color[i].layout = unpackImageLayout(imageLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateRenderPassFormat(entry.format))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Read common pipeline state
|
// Read common pipeline state
|
||||||
if (!data.read(dummyBindingMask, version)
|
if (!data.read(dummyBindingMask, version)
|
||||||
|| !data.read(entry.gpState.ia, version)
|
|| !data.read(entry.gpState.ia, version)
|
||||||
@ -537,6 +556,7 @@ namespace dxvk {
|
|||||||
|| !data.read(entry.gpState.ms, version)
|
|| !data.read(entry.gpState.ms, version)
|
||||||
|| !data.read(entry.gpState.ds, version)
|
|| !data.read(entry.gpState.ds, version)
|
||||||
|| !data.read(entry.gpState.om, version)
|
|| !data.read(entry.gpState.om, version)
|
||||||
|
|| !data.read(entry.gpState.rt, version)
|
||||||
|| !data.read(entry.gpState.dsFront, version)
|
|| !data.read(entry.gpState.dsFront, version)
|
||||||
|| !data.read(entry.gpState.dsBack, version))
|
|| !data.read(entry.gpState.dsBack, version))
|
||||||
return false;
|
return false;
|
||||||
@ -608,16 +628,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(stageMask & VK_SHADER_STAGE_COMPUTE_BIT)) {
|
if (!(stageMask & VK_SHADER_STAGE_COMPUTE_BIT)) {
|
||||||
// Pack render pass format
|
|
||||||
data.write(uint8_t(entry.format.sampleCount));
|
|
||||||
data.write(uint8_t(entry.format.depth.format));
|
|
||||||
data.write(packImageLayout(entry.format.depth.layout));
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
|
||||||
data.write(uint8_t(entry.format.color[i].format));
|
|
||||||
data.write(packImageLayout(entry.format.color[i].layout));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write out common pipeline state
|
// Write out common pipeline state
|
||||||
data.write(entry.gpState.ia);
|
data.write(entry.gpState.ia);
|
||||||
data.write(entry.gpState.il);
|
data.write(entry.gpState.il);
|
||||||
@ -625,6 +635,7 @@ namespace dxvk {
|
|||||||
data.write(entry.gpState.ms);
|
data.write(entry.gpState.ms);
|
||||||
data.write(entry.gpState.ds);
|
data.write(entry.gpState.ds);
|
||||||
data.write(entry.gpState.om);
|
data.write(entry.gpState.om);
|
||||||
|
data.write(entry.gpState.rt);
|
||||||
data.write(entry.gpState.dsFront);
|
data.write(entry.gpState.dsFront);
|
||||||
data.write(entry.gpState.dsBack);
|
data.write(entry.gpState.dsBack);
|
||||||
|
|
||||||
@ -785,47 +796,4 @@ namespace dxvk {
|
|||||||
return env::getEnvVar("DXVK_STATE_CACHE_PATH");
|
return env::getEnvVar("DXVK_STATE_CACHE_PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t DxvkStateCache::packImageLayout(
|
|
||||||
VkImageLayout layout) {
|
|
||||||
switch (layout) {
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL: return 0x80;
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL: return 0x81;
|
|
||||||
default: return uint8_t(layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkImageLayout DxvkStateCache::unpackImageLayout(
|
|
||||||
uint8_t layout) {
|
|
||||||
switch (layout) {
|
|
||||||
case 0x80: return VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
|
|
||||||
case 0x81: return VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
|
|
||||||
default: return VkImageLayout(layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool DxvkStateCache::validateRenderPassFormat(
|
|
||||||
const DxvkRenderPassFormat& format) {
|
|
||||||
bool valid = true;
|
|
||||||
|
|
||||||
if (format.depth.format) {
|
|
||||||
valid &= format.depth.layout == VK_IMAGE_LAYOUT_GENERAL
|
|
||||||
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
|
|
||||||
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
|
|
||||||
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
|
|
||||||
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets && valid; i++) {
|
|
||||||
if (format.color[i].format) {
|
|
||||||
valid &= format.color[i].layout == VK_IMAGE_LAYOUT_GENERAL
|
|
||||||
|| format.color[i].layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void addGraphicsPipeline(
|
void addGraphicsPipeline(
|
||||||
const DxvkStateCacheKey& shaders,
|
const DxvkStateCacheKey& shaders,
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state);
|
||||||
const DxvkRenderPassFormat& format);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a compute pipeline to the cache
|
* Adds a compute pipeline to the cache
|
||||||
@ -170,15 +169,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::string getCacheDir() const;
|
std::string getCacheDir() const;
|
||||||
|
|
||||||
static uint8_t packImageLayout(
|
|
||||||
VkImageLayout layout);
|
|
||||||
|
|
||||||
static VkImageLayout unpackImageLayout(
|
|
||||||
uint8_t layout);
|
|
||||||
|
|
||||||
static bool validateRenderPassFormat(
|
|
||||||
const DxvkRenderPassFormat& format);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ namespace dxvk {
|
|||||||
DxvkStateCacheKey shaders;
|
DxvkStateCacheKey shaders;
|
||||||
DxvkGraphicsPipelineStateInfo gpState;
|
DxvkGraphicsPipelineStateInfo gpState;
|
||||||
DxvkComputePipelineStateInfo cpState;
|
DxvkComputePipelineStateInfo cpState;
|
||||||
DxvkRenderPassFormat format;
|
|
||||||
Sha1Hash hash;
|
Sha1Hash hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +51,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
struct DxvkStateCacheHeader {
|
struct DxvkStateCacheHeader {
|
||||||
char magic[4] = { 'D', 'X', 'V', 'K' };
|
char magic[4] = { 'D', 'X', 'V', 'K' };
|
||||||
uint32_t version = 11;
|
uint32_t version = 12;
|
||||||
uint32_t entrySize = 0; /* no longer meaningful */
|
uint32_t entrySize = 0; /* no longer meaningful */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,4 +88,39 @@ namespace dxvk {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Old attachment format struct
|
||||||
|
*/
|
||||||
|
struct DxvkAttachmentFormatV11 {
|
||||||
|
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||||
|
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Old render pass format struct
|
||||||
|
*/
|
||||||
|
struct DxvkRenderPassFormatV11 {
|
||||||
|
VkSampleCountFlagBits sampleCount;
|
||||||
|
DxvkAttachmentFormatV11 depth;
|
||||||
|
DxvkAttachmentFormatV11 color[MaxNumRenderTargets];
|
||||||
|
|
||||||
|
DxvkRtInfo convert() const {
|
||||||
|
VkImageAspectFlags readOnlyAspects = 0;
|
||||||
|
auto depthFormatInfo = imageFormatInfo(depth.format);
|
||||||
|
|
||||||
|
if (depth.format && depthFormatInfo) {
|
||||||
|
readOnlyAspects = depthFormatInfo->aspectMask
|
||||||
|
& ~vk::getWritableAspectsForLayout(depth.layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<VkFormat, MaxNumRenderTargets> colorFormats;
|
||||||
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++)
|
||||||
|
colorFormats[i] = color[i].format;
|
||||||
|
|
||||||
|
return DxvkRtInfo(MaxNumRenderTargets, colorFormats.data(),
|
||||||
|
depth.format, readOnlyAspects);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user