mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxvk] Move DxvkPipelineManager object to DxvkContext
Since we create only one DxvkContext per D3D11Device, rather than per D3D11DeviceContext as originally planned, there is no need to keep the pipeline manager as a global thread-safe object. This may slightly reduce CPU overhead.
This commit is contained in:
parent
108bf2194f
commit
6e27f12e22
@ -6,8 +6,12 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device)
|
||||
: m_device(device) { }
|
||||
DxvkContext::DxvkContext(
|
||||
const Rc<DxvkDevice>& device,
|
||||
const Rc<DxvkPipelineCache>& pipelineCache)
|
||||
: m_device (device),
|
||||
m_pipeCache (pipelineCache),
|
||||
m_pipeMgr (new DxvkPipelineManager(device.ptr())) { }
|
||||
|
||||
|
||||
DxvkContext::~DxvkContext() {
|
||||
@ -1372,8 +1376,8 @@ namespace dxvk {
|
||||
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
|
||||
|
||||
m_state.cp.state.bsBindingState.clear();
|
||||
m_state.cp.pipeline = m_device->createComputePipeline(
|
||||
m_state.cp.cs.shader);
|
||||
m_state.cp.pipeline = m_pipeMgr->createComputePipeline(
|
||||
m_pipeCache, m_state.cp.cs.shader);
|
||||
|
||||
if (m_state.cp.pipeline != nullptr)
|
||||
m_cmd->trackResource(m_state.cp.pipeline);
|
||||
@ -1403,8 +1407,9 @@ namespace dxvk {
|
||||
m_flags.clr(DxvkContextFlag::GpDirtyPipeline);
|
||||
|
||||
m_state.gp.state.bsBindingState.clear();
|
||||
m_state.gp.pipeline = m_device->createGraphicsPipeline(
|
||||
m_state.gp.vs.shader, m_state.gp.tcs.shader, m_state.gp.tes.shader,
|
||||
m_state.gp.pipeline = m_pipeMgr->createGraphicsPipeline(
|
||||
m_pipeCache, m_state.gp.vs.shader,
|
||||
m_state.gp.tcs.shader, m_state.gp.tes.shader,
|
||||
m_state.gp.gs.shader, m_state.gp.fs.shader);
|
||||
|
||||
if (m_state.gp.pipeline != nullptr)
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "dxvk_data.h"
|
||||
#include "dxvk_event.h"
|
||||
#include "dxvk_meta_resolve.h"
|
||||
#include "dxvk_pipecache.h"
|
||||
#include "dxvk_pipemanager.h"
|
||||
#include "dxvk_query.h"
|
||||
#include "dxvk_query_pool.h"
|
||||
#include "dxvk_util.h"
|
||||
@ -24,7 +26,9 @@ namespace dxvk {
|
||||
|
||||
public:
|
||||
|
||||
DxvkContext(const Rc<DxvkDevice>& device);
|
||||
DxvkContext(
|
||||
const Rc<DxvkDevice>& device,
|
||||
const Rc<DxvkPipelineCache>& pipelineCache);
|
||||
~DxvkContext();
|
||||
|
||||
/**
|
||||
@ -561,7 +565,9 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
const Rc<DxvkDevice> m_device;
|
||||
const Rc<DxvkDevice> m_device;
|
||||
const Rc<DxvkPipelineCache> m_pipeCache;
|
||||
const Rc<DxvkPipelineManager> m_pipeMgr;
|
||||
|
||||
Rc<DxvkCommandList> m_cmd;
|
||||
DxvkContextFlags m_flags;
|
||||
|
@ -15,7 +15,6 @@ namespace dxvk {
|
||||
m_memory (new DxvkMemoryAllocator(adapter, vkd)),
|
||||
m_renderPassPool (new DxvkRenderPassPool (vkd)),
|
||||
m_pipelineCache (new DxvkPipelineCache (vkd)),
|
||||
m_pipelineManager (new DxvkPipelineManager(this)),
|
||||
m_unboundResources(this),
|
||||
m_submissionQueue (this) {
|
||||
m_options.adjustAppOptions(env::getExeName());
|
||||
@ -103,7 +102,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
Rc<DxvkContext> DxvkDevice::createContext() {
|
||||
return new DxvkContext(this);
|
||||
return new DxvkContext(this, m_pipelineCache);
|
||||
}
|
||||
|
||||
|
||||
@ -172,24 +171,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
Rc<DxvkComputePipeline> DxvkDevice::createComputePipeline(
|
||||
const Rc<DxvkShader>& cs) {
|
||||
return m_pipelineManager->createComputePipeline(
|
||||
m_pipelineCache, cs);
|
||||
}
|
||||
|
||||
|
||||
Rc<DxvkGraphicsPipeline> DxvkDevice::createGraphicsPipeline(
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs) {
|
||||
return m_pipelineManager->createGraphicsPipeline(
|
||||
m_pipelineCache, vs, tcs, tes, gs, fs);
|
||||
}
|
||||
|
||||
|
||||
Rc<DxvkSwapchain> DxvkDevice::createSwapchain(
|
||||
const Rc<DxvkSurface>& surface,
|
||||
const DxvkSwapchainProperties& properties) {
|
||||
|
@ -246,33 +246,6 @@ namespace dxvk {
|
||||
const DxvkInterfaceSlots& iface,
|
||||
const SpirvCodeBuffer& code);
|
||||
|
||||
/**
|
||||
* \brief Retrieves a compute pipeline
|
||||
*
|
||||
* \param [in] layout Pipeline binding layout
|
||||
* \param [in] cs Compute shader
|
||||
* \returns The compute pipeline
|
||||
*/
|
||||
Rc<DxvkComputePipeline> createComputePipeline(
|
||||
const Rc<DxvkShader>& cs);
|
||||
|
||||
/**
|
||||
* \brief Retrieves a graphics pipeline object
|
||||
*
|
||||
* \param [in] vs Vertex shader
|
||||
* \param [in] tcs Tessellation control shader
|
||||
* \param [in] tes Tessellation evaluation shader
|
||||
* \param [in] gs Geometry shader
|
||||
* \param [in] fs Fragment shader
|
||||
* \returns The graphics pipeline
|
||||
*/
|
||||
Rc<DxvkGraphicsPipeline> createGraphicsPipeline(
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs);
|
||||
|
||||
/**
|
||||
* \brief Creates a swap chain
|
||||
*
|
||||
@ -338,7 +311,6 @@ namespace dxvk {
|
||||
Rc<DxvkMemoryAllocator> m_memory;
|
||||
Rc<DxvkRenderPassPool> m_renderPassPool;
|
||||
Rc<DxvkPipelineCache> m_pipelineCache;
|
||||
Rc<DxvkPipelineManager> m_pipelineManager;
|
||||
|
||||
DxvkUnboundResources m_unboundResources;
|
||||
DxvkOptions m_options;
|
||||
|
@ -55,14 +55,13 @@ namespace dxvk {
|
||||
DxvkComputePipelineKey key;
|
||||
key.cs = cs;
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
auto pair = m_computePipelines.find(key);
|
||||
|
||||
if (pair != m_computePipelines.end())
|
||||
return pair->second;
|
||||
|
||||
const Rc<DxvkComputePipeline> pipeline
|
||||
= new DxvkComputePipeline(m_device, cache, cs);
|
||||
|
||||
m_computePipelines.insert(std::make_pair(key, pipeline));
|
||||
return pipeline;
|
||||
}
|
||||
@ -85,14 +84,13 @@ namespace dxvk {
|
||||
key.gs = gs;
|
||||
key.fs = fs;
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
auto pair = m_graphicsPipelines.find(key);
|
||||
|
||||
if (pair != m_graphicsPipelines.end())
|
||||
return pair->second;
|
||||
|
||||
const Rc<DxvkGraphicsPipeline> pipeline
|
||||
= new DxvkGraphicsPipeline(m_device, cache, vs, tcs, tes, gs, fs);
|
||||
|
||||
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
|
||||
return pipeline;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "dxvk_compute.h"
|
||||
@ -100,8 +99,6 @@ namespace dxvk {
|
||||
|
||||
const DxvkDevice* m_device;
|
||||
|
||||
std::mutex m_mutex;
|
||||
|
||||
std::unordered_map<
|
||||
DxvkComputePipelineKey,
|
||||
Rc<DxvkComputePipeline>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user