mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Refactor the way render passes to pipeline compiler methods
This commit is contained in:
parent
13bc3df92f
commit
a7666aad82
@ -120,8 +120,8 @@ namespace dxvk {
|
|||||||
* \brief Retrieves render pass
|
* \brief Retrieves render pass
|
||||||
* \returns Render pass reference
|
* \returns Render pass reference
|
||||||
*/
|
*/
|
||||||
const DxvkRenderPass& getRenderPass() const {
|
DxvkRenderPass* getRenderPass() const {
|
||||||
return *m_renderPass;
|
return m_renderPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +96,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) {
|
const DxvkRenderPass* renderPass) {
|
||||||
DxvkGraphicsPipelineInstance* instance = nullptr;
|
DxvkGraphicsPipelineInstance* instance = nullptr;
|
||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||||
@ -112,14 +112,14 @@ namespace dxvk {
|
|||||||
if (!instance)
|
if (!instance)
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
|
|
||||||
this->writePipelineStateToCache(state, renderPass.format());
|
this->writePipelineStateToCache(state, renderPass->format());
|
||||||
return instance->pipeline();
|
return instance->pipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkGraphicsPipeline::compilePipeline(
|
void DxvkGraphicsPipeline::compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) {
|
const DxvkRenderPass* renderPass) {
|
||||||
std::lock_guard<sync::Spinlock> lock(m_mutex);
|
std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||||
|
|
||||||
if (!this->findInstance(state, renderPass))
|
if (!this->findInstance(state, renderPass))
|
||||||
@ -129,7 +129,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
|
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) {
|
const DxvkRenderPass* renderPass) {
|
||||||
// If the pipeline state vector is invalid, don't try
|
// If the pipeline state vector is invalid, don't try
|
||||||
// to create a new pipeline, it won't work anyway.
|
// to create a new pipeline, it won't work anyway.
|
||||||
if (!this->validatePipelineState(state))
|
if (!this->validatePipelineState(state))
|
||||||
@ -138,17 +138,15 @@ namespace dxvk {
|
|||||||
VkPipeline newPipelineHandle = this->createPipeline(state, renderPass);
|
VkPipeline newPipelineHandle = this->createPipeline(state, renderPass);
|
||||||
|
|
||||||
m_pipeMgr->m_numGraphicsPipelines += 1;
|
m_pipeMgr->m_numGraphicsPipelines += 1;
|
||||||
return &m_pipelines.emplace_back(state, renderPass.getDefaultHandle(), newPipelineHandle);
|
return &m_pipelines.emplace_back(state, renderPass, newPipelineHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance(
|
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) {
|
const DxvkRenderPass* renderPass) {
|
||||||
VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
|
|
||||||
|
|
||||||
for (auto& instance : m_pipelines) {
|
for (auto& instance : m_pipelines) {
|
||||||
if (instance.isCompatible(state, renderPassHandle))
|
if (instance.isCompatible(state, renderPass))
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,14 +156,14 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipeline DxvkGraphicsPipeline::createPipeline(
|
VkPipeline DxvkGraphicsPipeline::createPipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render pass format and image layouts
|
// Render pass format and image layouts
|
||||||
DxvkRenderPassFormat passFormat = renderPass.format();
|
DxvkRenderPassFormat passFormat = renderPass->format();
|
||||||
|
|
||||||
// Set up dynamic states as needed
|
// Set up dynamic states as needed
|
||||||
std::array<VkDynamicState, 6> dynamicStates;
|
std::array<VkDynamicState, 6> dynamicStates;
|
||||||
@ -432,7 +430,7 @@ namespace dxvk {
|
|||||||
info.pColorBlendState = &cbInfo;
|
info.pColorBlendState = &cbInfo;
|
||||||
info.pDynamicState = &dyInfo;
|
info.pDynamicState = &dyInfo;
|
||||||
info.layout = m_layout->pipelineLayout();
|
info.layout = m_layout->pipelineLayout();
|
||||||
info.renderPass = renderPass.getDefaultHandle();
|
info.renderPass = renderPass->getDefaultHandle();
|
||||||
info.subpass = 0;
|
info.subpass = 0;
|
||||||
info.basePipelineHandle = VK_NULL_HANDLE;
|
info.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
info.basePipelineIndex = -1;
|
info.basePipelineIndex = -1;
|
||||||
|
@ -155,7 +155,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkGraphicsPipelineInstance(
|
DxvkGraphicsPipelineInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkRenderPass rp,
|
const DxvkRenderPass* rp,
|
||||||
VkPipeline pipe)
|
VkPipeline pipe)
|
||||||
: m_stateVector (state),
|
: m_stateVector (state),
|
||||||
m_renderPass (rp),
|
m_renderPass (rp),
|
||||||
@ -170,7 +170,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
bool isCompatible(
|
bool isCompatible(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkRenderPass rp) const {
|
const DxvkRenderPass* rp) {
|
||||||
return m_stateVector == state
|
return m_stateVector == state
|
||||||
&& m_renderPass == rp;
|
&& m_renderPass == rp;
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ namespace dxvk {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
DxvkGraphicsPipelineStateInfo m_stateVector;
|
DxvkGraphicsPipelineStateInfo m_stateVector;
|
||||||
VkRenderPass m_renderPass;
|
const DxvkRenderPass* m_renderPass;
|
||||||
VkPipeline m_pipeline;
|
VkPipeline m_pipeline;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -251,7 +251,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
VkPipeline getPipelineHandle(
|
VkPipeline getPipelineHandle(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass);
|
const DxvkRenderPass* renderPass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compiles a pipeline
|
* \brief Compiles a pipeline
|
||||||
@ -263,7 +263,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void compilePipeline(
|
void compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass);
|
const DxvkRenderPass* renderPass);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -287,15 +287,15 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkGraphicsPipelineInstance* createInstance(
|
DxvkGraphicsPipelineInstance* createInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass);
|
const DxvkRenderPass* renderPass);
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* findInstance(
|
DxvkGraphicsPipelineInstance* findInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass);
|
const DxvkRenderPass* renderPass);
|
||||||
|
|
||||||
VkPipeline createPipeline(
|
VkPipeline createPipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
const DxvkRenderPass& renderPass) const;
|
const DxvkRenderPass* renderPass) const;
|
||||||
|
|
||||||
void destroyPipeline(
|
void destroyPipeline(
|
||||||
VkPipeline pipeline) const;
|
VkPipeline pipeline) const;
|
||||||
|
@ -262,7 +262,7 @@ namespace dxvk {
|
|||||||
const auto& entry = m_entries[e->second];
|
const auto& entry = m_entries[e->second];
|
||||||
|
|
||||||
auto rp = m_passManager->getRenderPass(entry.format);
|
auto rp = m_passManager->getRenderPass(entry.format);
|
||||||
pipeline->compilePipeline(entry.gpState, *rp);
|
pipeline->compilePipeline(entry.gpState, rp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto pipeline = m_pipeManager->createComputePipeline(item.cp);
|
auto pipeline = m_pipeManager->createComputePipeline(item.cp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user