1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxvk/dxvk_pipemanager.cpp
Philip Rebohle 35a8cedbc2 [dxvk] Move shader set hash/eq functions into respective structs
Makes it easier to use them outside the pipeline manager.
2019-09-30 03:42:20 +02:00

83 lines
2.2 KiB
C++

#include "dxvk_device.h"
#include "dxvk_pipemanager.h"
#include "dxvk_state_cache.h"
namespace dxvk {
DxvkPipelineManager::DxvkPipelineManager(
const DxvkDevice* device,
DxvkRenderPassPool* passManager)
: m_device (device),
m_cache (new DxvkPipelineCache(device->vkd())) {
std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE");
if (useStateCache != "0" && device->config().enableStateCache)
m_stateCache = new DxvkStateCache(device, this, passManager);
}
DxvkPipelineManager::~DxvkPipelineManager() {
}
DxvkComputePipeline* DxvkPipelineManager::createComputePipeline(
const DxvkComputePipelineShaders& shaders) {
if (shaders.cs == nullptr)
return nullptr;
std::lock_guard<std::mutex> lock(m_mutex);
auto pair = m_computePipelines.find(shaders);
if (pair != m_computePipelines.end())
return &pair->second;
auto iter = m_computePipelines.emplace(
std::piecewise_construct,
std::tuple(shaders),
std::tuple(this, shaders));
return &iter.first->second;
}
DxvkGraphicsPipeline* DxvkPipelineManager::createGraphicsPipeline(
const DxvkGraphicsPipelineShaders& shaders) {
if (shaders.vs == nullptr)
return nullptr;
std::lock_guard<std::mutex> lock(m_mutex);
auto pair = m_graphicsPipelines.find(shaders);
if (pair != m_graphicsPipelines.end())
return &pair->second;
auto iter = m_graphicsPipelines.emplace(
std::piecewise_construct,
std::tuple(shaders),
std::tuple(this, shaders));
return &iter.first->second;
}
void DxvkPipelineManager::registerShader(
const Rc<DxvkShader>& shader) {
if (m_stateCache != nullptr)
m_stateCache->registerShader(shader);
}
DxvkPipelineCount DxvkPipelineManager::getPipelineCount() const {
DxvkPipelineCount result;
result.numComputePipelines = m_numComputePipelines.load();
result.numGraphicsPipelines = m_numGraphicsPipelines.load();
return result;
}
bool DxvkPipelineManager::isCompilingShaders() const {
return m_stateCache != nullptr
&& m_stateCache->isCompilingShaders();
}
}