2018-05-09 14:26:45 +02:00
|
|
|
#include "dxvk_device.h"
|
2017-12-07 09:38:31 +01:00
|
|
|
#include "dxvk_pipemanager.h"
|
2018-09-21 23:23:43 +02:00
|
|
|
#include "dxvk_state_cache.h"
|
2017-12-07 09:38:31 +01:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-09-21 23:23:43 +02:00
|
|
|
DxvkPipelineManager::DxvkPipelineManager(
|
|
|
|
const DxvkDevice* device,
|
|
|
|
DxvkRenderPassPool* passManager)
|
|
|
|
: m_device (device),
|
|
|
|
m_cache (new DxvkPipelineCache(device->vkd())) {
|
2018-11-15 17:12:09 -05:00
|
|
|
std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE");
|
2018-09-13 21:39:56 +02:00
|
|
|
|
2018-11-24 20:04:21 +01:00
|
|
|
if (useStateCache != "0" && device->config().enableStateCache)
|
2018-11-15 09:24:11 +01:00
|
|
|
m_stateCache = new DxvkStateCache(device, this, passManager);
|
2018-01-13 22:18:32 +01:00
|
|
|
}
|
2017-12-07 09:38:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
DxvkPipelineManager::~DxvkPipelineManager() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-23 13:15:06 +02:00
|
|
|
DxvkComputePipeline* DxvkPipelineManager::createComputePipeline(
|
2019-07-23 12:54:25 +02:00
|
|
|
const DxvkComputePipelineShaders& shaders) {
|
|
|
|
if (shaders.cs == nullptr)
|
2017-12-07 09:38:31 +01:00
|
|
|
return nullptr;
|
|
|
|
|
2018-05-01 16:45:28 +02:00
|
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
|
|
|
|
2019-07-23 12:54:25 +02:00
|
|
|
auto pair = m_computePipelines.find(shaders);
|
2017-12-07 09:38:31 +01:00
|
|
|
if (pair != m_computePipelines.end())
|
2019-07-23 13:15:06 +02:00
|
|
|
return &pair->second;
|
2017-12-07 09:38:31 +01:00
|
|
|
|
2019-07-23 13:15:06 +02:00
|
|
|
auto iter = m_computePipelines.emplace(
|
|
|
|
std::piecewise_construct,
|
|
|
|
std::tuple(shaders),
|
|
|
|
std::tuple(this, shaders));
|
|
|
|
return &iter.first->second;
|
2017-12-07 09:38:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-23 13:15:06 +02:00
|
|
|
DxvkGraphicsPipeline* DxvkPipelineManager::createGraphicsPipeline(
|
2019-07-23 12:54:25 +02:00
|
|
|
const DxvkGraphicsPipelineShaders& shaders) {
|
|
|
|
if (shaders.vs == nullptr)
|
2017-12-07 09:38:31 +01:00
|
|
|
return nullptr;
|
|
|
|
|
2018-05-01 16:45:28 +02:00
|
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
|
|
|
|
2019-07-23 12:54:25 +02:00
|
|
|
auto pair = m_graphicsPipelines.find(shaders);
|
2017-12-07 09:38:31 +01:00
|
|
|
if (pair != m_graphicsPipelines.end())
|
2019-07-23 13:15:06 +02:00
|
|
|
return &pair->second;
|
2018-03-29 12:32:20 +02:00
|
|
|
|
2019-07-23 13:15:06 +02:00
|
|
|
auto iter = m_graphicsPipelines.emplace(
|
|
|
|
std::piecewise_construct,
|
|
|
|
std::tuple(shaders),
|
|
|
|
std::tuple(this, shaders));
|
|
|
|
return &iter.first->second;
|
2017-12-07 09:38:31 +01:00
|
|
|
}
|
2018-09-21 22:28:06 +02:00
|
|
|
|
2018-09-21 23:23:43 +02:00
|
|
|
|
|
|
|
void DxvkPipelineManager::registerShader(
|
|
|
|
const Rc<DxvkShader>& shader) {
|
|
|
|
if (m_stateCache != nullptr)
|
|
|
|
m_stateCache->registerShader(shader);
|
|
|
|
}
|
|
|
|
|
2018-09-21 22:28:06 +02:00
|
|
|
|
|
|
|
DxvkPipelineCount DxvkPipelineManager::getPipelineCount() const {
|
|
|
|
DxvkPipelineCount result;
|
|
|
|
result.numComputePipelines = m_numComputePipelines.load();
|
|
|
|
result.numGraphicsPipelines = m_numGraphicsPipelines.load();
|
|
|
|
return result;
|
|
|
|
}
|
2019-04-14 12:15:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
bool DxvkPipelineManager::isCompilingShaders() const {
|
|
|
|
return m_stateCache != nullptr
|
|
|
|
&& m_stateCache->isCompilingShaders();
|
|
|
|
}
|
2017-12-07 09:38:31 +01:00
|
|
|
|
2018-11-15 17:12:09 -05:00
|
|
|
}
|