mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-28 11:19:21 +01:00
[dxvk] Introduce DxvkGraphicsPipelineHandle
This commit is contained in:
parent
31529b8bab
commit
12c98161ba
@ -6048,15 +6048,15 @@ namespace dxvk {
|
||||
// Retrieve and bind actual Vulkan pipeline handle
|
||||
auto pipelineInfo = m_state.gp.pipeline->getPipelineHandle(m_state.gp.state);
|
||||
|
||||
if (unlikely(!pipelineInfo.first))
|
||||
if (unlikely(!pipelineInfo.handle))
|
||||
return false;
|
||||
|
||||
m_cmd->cmdBindPipeline(DxvkCmdBuffer::ExecBuffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineInfo.first);
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineInfo.handle);
|
||||
|
||||
// For pipelines created from graphics pipeline libraries, we need to
|
||||
// apply a bunch of dynamic state that is otherwise static or unused
|
||||
if (pipelineInfo.second == DxvkGraphicsPipelineType::BasePipeline) {
|
||||
if (pipelineInfo.type == DxvkGraphicsPipelineType::BasePipeline) {
|
||||
m_flags.set(
|
||||
DxvkContextFlag::GpDynamicDepthStencilState,
|
||||
DxvkContextFlag::GpDynamicDepthBias,
|
||||
|
@ -1057,14 +1057,14 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
std::pair<VkPipeline, DxvkGraphicsPipelineType> DxvkGraphicsPipeline::getPipelineHandle(
|
||||
DxvkGraphicsPipelineHandle DxvkGraphicsPipeline::getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state) {
|
||||
DxvkGraphicsPipelineInstance* instance = this->findInstance(state);
|
||||
|
||||
if (unlikely(!instance)) {
|
||||
// Exit early if the state vector is invalid
|
||||
if (!this->validatePipelineState(state, true))
|
||||
return std::make_pair(VK_NULL_HANDLE, DxvkGraphicsPipelineType::FastPipeline);
|
||||
return DxvkGraphicsPipelineHandle();
|
||||
|
||||
// Prevent other threads from adding new instances and check again
|
||||
std::unique_lock<dxvk::mutex> lock(m_mutex);
|
||||
@ -1091,14 +1091,7 @@ namespace dxvk {
|
||||
}
|
||||
}
|
||||
|
||||
// Find a pipeline handle to use. If no optimized pipeline has
|
||||
// been compiled yet, use the slower base pipeline instead.
|
||||
VkPipeline fastHandle = instance->fastHandle.load();
|
||||
|
||||
if (likely(fastHandle != VK_NULL_HANDLE))
|
||||
return std::make_pair(fastHandle, DxvkGraphicsPipelineType::FastPipeline);
|
||||
|
||||
return std::make_pair(instance->baseHandle.load(), DxvkGraphicsPipelineType::BasePipeline);
|
||||
return instance->getHandle();
|
||||
}
|
||||
|
||||
|
||||
|
@ -345,6 +345,15 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Graphics pipeline handle
|
||||
*/
|
||||
struct DxvkGraphicsPipelineHandle {
|
||||
VkPipeline handle = VK_NULL_HANDLE;
|
||||
DxvkGraphicsPipelineType type = DxvkGraphicsPipelineType::FastPipeline;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Graphics pipeline instance
|
||||
*
|
||||
@ -366,6 +375,21 @@ namespace dxvk {
|
||||
std::atomic<VkPipeline> baseHandle = { VK_NULL_HANDLE };
|
||||
std::atomic<VkPipeline> fastHandle = { VK_NULL_HANDLE };
|
||||
std::atomic<VkBool32> isCompiling = { VK_FALSE };
|
||||
|
||||
DxvkGraphicsPipelineHandle getHandle() const {
|
||||
// Find a pipeline handle to use. If no optimized pipeline has
|
||||
// been compiled yet, use the slower base pipeline instead.
|
||||
DxvkGraphicsPipelineHandle result;
|
||||
result.handle = fastHandle.load(std::memory_order_acquire);
|
||||
result.type = DxvkGraphicsPipelineType::FastPipeline;
|
||||
|
||||
if (likely(fastHandle))
|
||||
return result;
|
||||
|
||||
result.handle = baseHandle.load(std::memory_order_acquire);
|
||||
result.type = DxvkGraphicsPipelineType::BasePipeline;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -529,7 +553,7 @@ namespace dxvk {
|
||||
* \param [in] state Pipeline state vector
|
||||
* \returns Pipeline handle and handle type
|
||||
*/
|
||||
std::pair<VkPipeline, DxvkGraphicsPipelineType> getPipelineHandle(
|
||||
DxvkGraphicsPipelineHandle getPipelineHandle(
|
||||
const DxvkGraphicsPipelineStateInfo& state);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user