mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Rework DxvkPipelineCache
This commit is contained in:
parent
dbcd0333d9
commit
8b645f8563
@ -111,7 +111,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||||
if (m_vkd->vkCreateComputePipelines(m_vkd->device(),
|
if (m_vkd->vkCreateComputePipelines(m_vkd->device(),
|
||||||
m_pipeMgr->m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) {
|
m_pipeMgr->m_cache.handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) {
|
||||||
Logger::err("DxvkComputePipeline: Failed to compile pipeline");
|
Logger::err("DxvkComputePipeline: Failed to compile pipeline");
|
||||||
Logger::err(str::format(" cs : ", m_shaders.cs->debugName()));
|
Logger::err(str::format(" cs : ", m_shaders.cs->debugName()));
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
|
@ -664,8 +664,7 @@ namespace dxvk {
|
|||||||
t0 = dxvk::high_resolution_clock::now();
|
t0 = dxvk::high_resolution_clock::now();
|
||||||
|
|
||||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||||
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(),
|
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(), m_pipeMgr->m_cache.handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) {
|
||||||
m_pipeMgr->m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) {
|
|
||||||
Logger::err("DxvkGraphicsPipeline: Failed to compile pipeline");
|
Logger::err("DxvkGraphicsPipeline: Failed to compile pipeline");
|
||||||
this->logPipelineState(LogLevel::Error, state);
|
this->logPipelineState(LogLevel::Error, state);
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
#include "dxvk_pipecache.h"
|
#include "dxvk_pipecache.h"
|
||||||
|
#include "dxvk_device.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxvkPipelineCache::DxvkPipelineCache(
|
DxvkPipelineCache::DxvkPipelineCache(DxvkDevice* device)
|
||||||
const Rc<vk::DeviceFn>& vkd)
|
: m_device(device) {
|
||||||
: m_vkd(vkd) {
|
auto vk = m_device->vkd();
|
||||||
VkPipelineCacheCreateInfo info;
|
|
||||||
info.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
|
// It's not critical if this fails since this is only an in-memory cache
|
||||||
info.pNext = nullptr;
|
VkPipelineCacheCreateInfo info = { VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO };
|
||||||
info.flags = 0;
|
|
||||||
info.initialDataSize = 0;
|
|
||||||
info.pInitialData = nullptr;
|
|
||||||
|
|
||||||
if (m_vkd->vkCreatePipelineCache(m_vkd->device(),
|
if (vk->vkCreatePipelineCache(vk->device(), &info, nullptr, &m_handle))
|
||||||
&info, nullptr, &m_handle) != VK_SUCCESS)
|
Logger::err("DxvkPipelineCache: Failed to create cache");
|
||||||
throw DxvkError("DxvkPipelineCache: Failed to create cache");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkPipelineCache::~DxvkPipelineCache() {
|
DxvkPipelineCache::~DxvkPipelineCache() {
|
||||||
m_vkd->vkDestroyPipelineCache(
|
auto vk = m_device->vkd();
|
||||||
m_vkd->device(), m_handle, nullptr);
|
|
||||||
|
vk->vkDestroyPipelineCache(vk->device(), m_handle, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "dxvk_include.h"
|
#include "dxvk_include.h"
|
||||||
|
|
||||||
#include "../util/sha1/sha1_util.h"
|
|
||||||
#include "../util/util_env.h"
|
|
||||||
#include "../util/util_time.h"
|
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
class DxvkDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Pipeline cache
|
* \brief Pipeline cache
|
||||||
*
|
*
|
||||||
* Allows the Vulkan implementation to
|
* Allows the Vulkan implementation to
|
||||||
* re-use previously compiled pipelines.
|
* re-use previously compiled pipelines.
|
||||||
*/
|
*/
|
||||||
class DxvkPipelineCache : public RcObject {
|
class DxvkPipelineCache {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DxvkPipelineCache(const Rc<vk::DeviceFn>& vkd);
|
DxvkPipelineCache(DxvkDevice* device);
|
||||||
~DxvkPipelineCache();
|
~DxvkPipelineCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +29,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
DxvkDevice* m_device;
|
||||||
VkPipelineCache m_handle;
|
VkPipelineCache m_handle = VK_NULL_HANDLE;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace dxvk {
|
|||||||
DxvkPipelineManager::DxvkPipelineManager(
|
DxvkPipelineManager::DxvkPipelineManager(
|
||||||
DxvkDevice* device)
|
DxvkDevice* device)
|
||||||
: m_device (device),
|
: m_device (device),
|
||||||
m_cache (new DxvkPipelineCache(device->vkd())) {
|
m_cache (device) {
|
||||||
std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE");
|
std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE");
|
||||||
|
|
||||||
if (useStateCache != "0" && device->config().enableStateCache)
|
if (useStateCache != "0" && device->config().enableStateCache)
|
||||||
@ -88,7 +88,7 @@ namespace dxvk {
|
|||||||
auto iter = m_vertexInputLibraries.emplace(
|
auto iter = m_vertexInputLibraries.emplace(
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::tuple(state),
|
std::tuple(state),
|
||||||
std::tuple(m_device, state, m_cache->handle()));
|
std::tuple(m_device, state, m_cache.handle()));
|
||||||
return &iter.first->second;
|
return &iter.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ namespace dxvk {
|
|||||||
auto iter = m_fragmentOutputLibraries.emplace(
|
auto iter = m_fragmentOutputLibraries.emplace(
|
||||||
std::piecewise_construct,
|
std::piecewise_construct,
|
||||||
std::tuple(state),
|
std::tuple(state),
|
||||||
std::tuple(m_device, state, m_cache->handle()));
|
std::tuple(m_device, state, m_cache.handle()));
|
||||||
return &iter.first->second;
|
return &iter.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DxvkDevice* m_device;
|
DxvkDevice* m_device;
|
||||||
Rc<DxvkPipelineCache> m_cache;
|
DxvkPipelineCache m_cache;
|
||||||
Rc<DxvkStateCache> m_stateCache;
|
Rc<DxvkStateCache> m_stateCache;
|
||||||
|
|
||||||
std::atomic<uint32_t> m_numComputePipelines = { 0 };
|
std::atomic<uint32_t> m_numComputePipelines = { 0 };
|
||||||
std::atomic<uint32_t> m_numGraphicsPipelines = { 0 };
|
std::atomic<uint32_t> m_numGraphicsPipelines = { 0 };
|
||||||
|
|
||||||
dxvk::mutex m_mutex;
|
dxvk::mutex m_mutex;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user