mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 10:54:16 +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
|
||||
* \returns Render pass reference
|
||||
*/
|
||||
const DxvkRenderPass& getRenderPass() const {
|
||||
return *m_renderPass;
|
||||
DxvkRenderPass* getRenderPass() const {
|
||||
return m_renderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ namespace dxvk {
|
||||
|
||||
VkPipeline DxvkGraphicsPipeline::getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) {
|
||||
const DxvkRenderPass* renderPass) {
|
||||
DxvkGraphicsPipelineInstance* instance = nullptr;
|
||||
|
||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||
@ -112,14 +112,14 @@ namespace dxvk {
|
||||
if (!instance)
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
this->writePipelineStateToCache(state, renderPass.format());
|
||||
this->writePipelineStateToCache(state, renderPass->format());
|
||||
return instance->pipeline();
|
||||
}
|
||||
|
||||
|
||||
void DxvkGraphicsPipeline::compilePipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) {
|
||||
const DxvkRenderPass* renderPass) {
|
||||
std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||
|
||||
if (!this->findInstance(state, renderPass))
|
||||
@ -129,7 +129,7 @@ namespace dxvk {
|
||||
|
||||
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) {
|
||||
const DxvkRenderPass* renderPass) {
|
||||
// If the pipeline state vector is invalid, don't try
|
||||
// to create a new pipeline, it won't work anyway.
|
||||
if (!this->validatePipelineState(state))
|
||||
@ -138,17 +138,15 @@ namespace dxvk {
|
||||
VkPipeline newPipelineHandle = this->createPipeline(state, renderPass);
|
||||
|
||||
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(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) {
|
||||
VkRenderPass renderPassHandle = renderPass.getDefaultHandle();
|
||||
|
||||
const DxvkRenderPass* renderPass) {
|
||||
for (auto& instance : m_pipelines) {
|
||||
if (instance.isCompatible(state, renderPassHandle))
|
||||
if (instance.isCompatible(state, renderPass))
|
||||
return &instance;
|
||||
}
|
||||
|
||||
@ -158,14 +156,14 @@ namespace dxvk {
|
||||
|
||||
VkPipeline DxvkGraphicsPipeline::createPipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) const {
|
||||
const DxvkRenderPass* renderPass) const {
|
||||
if (Logger::logLevel() <= LogLevel::Debug) {
|
||||
Logger::debug("Compiling graphics pipeline...");
|
||||
this->logPipelineState(LogLevel::Debug, state);
|
||||
}
|
||||
|
||||
// Render pass format and image layouts
|
||||
DxvkRenderPassFormat passFormat = renderPass.format();
|
||||
DxvkRenderPassFormat passFormat = renderPass->format();
|
||||
|
||||
// Set up dynamic states as needed
|
||||
std::array<VkDynamicState, 6> dynamicStates;
|
||||
@ -432,7 +430,7 @@ namespace dxvk {
|
||||
info.pColorBlendState = &cbInfo;
|
||||
info.pDynamicState = &dyInfo;
|
||||
info.layout = m_layout->pipelineLayout();
|
||||
info.renderPass = renderPass.getDefaultHandle();
|
||||
info.renderPass = renderPass->getDefaultHandle();
|
||||
info.subpass = 0;
|
||||
info.basePipelineHandle = VK_NULL_HANDLE;
|
||||
info.basePipelineIndex = -1;
|
||||
|
@ -155,7 +155,7 @@ namespace dxvk {
|
||||
|
||||
DxvkGraphicsPipelineInstance(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
VkRenderPass rp,
|
||||
const DxvkRenderPass* rp,
|
||||
VkPipeline pipe)
|
||||
: m_stateVector (state),
|
||||
m_renderPass (rp),
|
||||
@ -170,7 +170,7 @@ namespace dxvk {
|
||||
*/
|
||||
bool isCompatible(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
VkRenderPass rp) const {
|
||||
const DxvkRenderPass* rp) {
|
||||
return m_stateVector == state
|
||||
&& m_renderPass == rp;
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace dxvk {
|
||||
private:
|
||||
|
||||
DxvkGraphicsPipelineStateInfo m_stateVector;
|
||||
VkRenderPass m_renderPass;
|
||||
const DxvkRenderPass* m_renderPass;
|
||||
VkPipeline m_pipeline;
|
||||
|
||||
};
|
||||
@ -251,7 +251,7 @@ namespace dxvk {
|
||||
*/
|
||||
VkPipeline getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass);
|
||||
const DxvkRenderPass* renderPass);
|
||||
|
||||
/**
|
||||
* \brief Compiles a pipeline
|
||||
@ -263,7 +263,7 @@ namespace dxvk {
|
||||
*/
|
||||
void compilePipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass);
|
||||
const DxvkRenderPass* renderPass);
|
||||
|
||||
private:
|
||||
|
||||
@ -287,15 +287,15 @@ namespace dxvk {
|
||||
|
||||
DxvkGraphicsPipelineInstance* createInstance(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass);
|
||||
const DxvkRenderPass* renderPass);
|
||||
|
||||
DxvkGraphicsPipelineInstance* findInstance(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass);
|
||||
const DxvkRenderPass* renderPass);
|
||||
|
||||
VkPipeline createPipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
const DxvkRenderPass& renderPass) const;
|
||||
const DxvkRenderPass* renderPass) const;
|
||||
|
||||
void destroyPipeline(
|
||||
VkPipeline pipeline) const;
|
||||
|
@ -262,7 +262,7 @@ namespace dxvk {
|
||||
const auto& entry = m_entries[e->second];
|
||||
|
||||
auto rp = m_passManager->getRenderPass(entry.format);
|
||||
pipeline->compilePipeline(entry.gpState, *rp);
|
||||
pipeline->compilePipeline(entry.gpState, rp);
|
||||
}
|
||||
} else {
|
||||
auto pipeline = m_pipeManager->createComputePipeline(item.cp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user