1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +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:
Philip Rebohle 2018-03-29 12:32:20 +02:00
parent 108bf2194f
commit 6e27f12e22
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 22 additions and 63 deletions

View File

@ -6,8 +6,12 @@
namespace dxvk { namespace dxvk {
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device) DxvkContext::DxvkContext(
: m_device(device) { } const Rc<DxvkDevice>& device,
const Rc<DxvkPipelineCache>& pipelineCache)
: m_device (device),
m_pipeCache (pipelineCache),
m_pipeMgr (new DxvkPipelineManager(device.ptr())) { }
DxvkContext::~DxvkContext() { DxvkContext::~DxvkContext() {
@ -1372,8 +1376,8 @@ namespace dxvk {
m_flags.clr(DxvkContextFlag::CpDirtyPipeline); m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
m_state.cp.state.bsBindingState.clear(); m_state.cp.state.bsBindingState.clear();
m_state.cp.pipeline = m_device->createComputePipeline( m_state.cp.pipeline = m_pipeMgr->createComputePipeline(
m_state.cp.cs.shader); m_pipeCache, m_state.cp.cs.shader);
if (m_state.cp.pipeline != nullptr) if (m_state.cp.pipeline != nullptr)
m_cmd->trackResource(m_state.cp.pipeline); m_cmd->trackResource(m_state.cp.pipeline);
@ -1403,8 +1407,9 @@ namespace dxvk {
m_flags.clr(DxvkContextFlag::GpDirtyPipeline); m_flags.clr(DxvkContextFlag::GpDirtyPipeline);
m_state.gp.state.bsBindingState.clear(); m_state.gp.state.bsBindingState.clear();
m_state.gp.pipeline = m_device->createGraphicsPipeline( m_state.gp.pipeline = m_pipeMgr->createGraphicsPipeline(
m_state.gp.vs.shader, m_state.gp.tcs.shader, m_state.gp.tes.shader, 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); m_state.gp.gs.shader, m_state.gp.fs.shader);
if (m_state.gp.pipeline != nullptr) if (m_state.gp.pipeline != nullptr)

View File

@ -7,6 +7,8 @@
#include "dxvk_data.h" #include "dxvk_data.h"
#include "dxvk_event.h" #include "dxvk_event.h"
#include "dxvk_meta_resolve.h" #include "dxvk_meta_resolve.h"
#include "dxvk_pipecache.h"
#include "dxvk_pipemanager.h"
#include "dxvk_query.h" #include "dxvk_query.h"
#include "dxvk_query_pool.h" #include "dxvk_query_pool.h"
#include "dxvk_util.h" #include "dxvk_util.h"
@ -24,7 +26,9 @@ namespace dxvk {
public: public:
DxvkContext(const Rc<DxvkDevice>& device); DxvkContext(
const Rc<DxvkDevice>& device,
const Rc<DxvkPipelineCache>& pipelineCache);
~DxvkContext(); ~DxvkContext();
/** /**
@ -561,7 +565,9 @@ namespace dxvk {
private: 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; Rc<DxvkCommandList> m_cmd;
DxvkContextFlags m_flags; DxvkContextFlags m_flags;

View File

@ -15,7 +15,6 @@ namespace dxvk {
m_memory (new DxvkMemoryAllocator(adapter, vkd)), m_memory (new DxvkMemoryAllocator(adapter, vkd)),
m_renderPassPool (new DxvkRenderPassPool (vkd)), m_renderPassPool (new DxvkRenderPassPool (vkd)),
m_pipelineCache (new DxvkPipelineCache (vkd)), m_pipelineCache (new DxvkPipelineCache (vkd)),
m_pipelineManager (new DxvkPipelineManager(this)),
m_unboundResources(this), m_unboundResources(this),
m_submissionQueue (this) { m_submissionQueue (this) {
m_options.adjustAppOptions(env::getExeName()); m_options.adjustAppOptions(env::getExeName());
@ -103,7 +102,7 @@ namespace dxvk {
Rc<DxvkContext> DxvkDevice::createContext() { 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( Rc<DxvkSwapchain> DxvkDevice::createSwapchain(
const Rc<DxvkSurface>& surface, const Rc<DxvkSurface>& surface,
const DxvkSwapchainProperties& properties) { const DxvkSwapchainProperties& properties) {

View File

@ -246,33 +246,6 @@ namespace dxvk {
const DxvkInterfaceSlots& iface, const DxvkInterfaceSlots& iface,
const SpirvCodeBuffer& code); 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 * \brief Creates a swap chain
* *
@ -338,7 +311,6 @@ namespace dxvk {
Rc<DxvkMemoryAllocator> m_memory; Rc<DxvkMemoryAllocator> m_memory;
Rc<DxvkRenderPassPool> m_renderPassPool; Rc<DxvkRenderPassPool> m_renderPassPool;
Rc<DxvkPipelineCache> m_pipelineCache; Rc<DxvkPipelineCache> m_pipelineCache;
Rc<DxvkPipelineManager> m_pipelineManager;
DxvkUnboundResources m_unboundResources; DxvkUnboundResources m_unboundResources;
DxvkOptions m_options; DxvkOptions m_options;

View File

@ -55,14 +55,13 @@ namespace dxvk {
DxvkComputePipelineKey key; DxvkComputePipelineKey key;
key.cs = cs; key.cs = cs;
std::lock_guard<std::mutex> lock(m_mutex);
auto pair = m_computePipelines.find(key); auto pair = m_computePipelines.find(key);
if (pair != m_computePipelines.end()) if (pair != m_computePipelines.end())
return pair->second; return pair->second;
const Rc<DxvkComputePipeline> pipeline const Rc<DxvkComputePipeline> pipeline
= new DxvkComputePipeline(m_device, cache, cs); = new DxvkComputePipeline(m_device, cache, cs);
m_computePipelines.insert(std::make_pair(key, pipeline)); m_computePipelines.insert(std::make_pair(key, pipeline));
return pipeline; return pipeline;
} }
@ -85,14 +84,13 @@ namespace dxvk {
key.gs = gs; key.gs = gs;
key.fs = fs; key.fs = fs;
std::lock_guard<std::mutex> lock(m_mutex);
auto pair = m_graphicsPipelines.find(key); auto pair = m_graphicsPipelines.find(key);
if (pair != m_graphicsPipelines.end()) if (pair != m_graphicsPipelines.end())
return pair->second; return pair->second;
const Rc<DxvkGraphicsPipeline> pipeline const Rc<DxvkGraphicsPipeline> pipeline
= new DxvkGraphicsPipeline(m_device, cache, vs, tcs, tes, gs, fs); = new DxvkGraphicsPipeline(m_device, cache, vs, tcs, tes, gs, fs);
m_graphicsPipelines.insert(std::make_pair(key, pipeline)); m_graphicsPipelines.insert(std::make_pair(key, pipeline));
return pipeline; return pipeline;
} }

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <mutex>
#include <unordered_map> #include <unordered_map>
#include "dxvk_compute.h" #include "dxvk_compute.h"
@ -100,8 +99,6 @@ namespace dxvk {
const DxvkDevice* m_device; const DxvkDevice* m_device;
std::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkComputePipelineKey, DxvkComputePipelineKey,
Rc<DxvkComputePipeline>, Rc<DxvkComputePipeline>,