1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Refactor pipeline object constructors

This way we don't need to pass everything to the pipeline objects.
This commit is contained in:
Philip Rebohle 2018-09-21 19:42:48 +02:00
parent 9284081180
commit 5410680401
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 33 additions and 35 deletions

View File

@ -3,6 +3,7 @@
#include "dxvk_compute.h"
#include "dxvk_device.h"
#include "dxvk_pipemanager.h"
#include "dxvk_spec_const.h"
namespace dxvk {
@ -18,17 +19,16 @@ namespace dxvk {
DxvkComputePipeline::DxvkComputePipeline(
const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache,
DxvkPipelineManager* pipeMgr,
const Rc<DxvkShader>& cs)
: m_device(device), m_vkd(device->vkd()),
m_cache(cache) {
: m_vkd(pipeMgr->m_device->vkd()),
m_pipeMgr(pipeMgr) {
DxvkDescriptorSlotMapping slotMapping;
cs->defineResourceSlots(slotMapping);
slotMapping.makeDescriptorsDynamic(
device->options().maxNumDynamicUniformBuffers,
device->options().maxNumDynamicStorageBuffers);
m_pipeMgr->m_device->options().maxNumDynamicUniformBuffers,
m_pipeMgr->m_device->options().maxNumDynamicStorageBuffers);
m_layout = new DxvkPipelineLayout(m_vkd,
slotMapping.bindingCount(),
@ -131,7 +131,7 @@ namespace dxvk {
VkPipeline pipeline = VK_NULL_HANDLE;
if (m_vkd->vkCreateComputePipelines(m_vkd->device(),
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(str::format(" cs : ", m_cs->shader()->debugName()));
return VK_NULL_HANDLE;

View File

@ -12,6 +12,7 @@
namespace dxvk {
class DxvkDevice;
class DxvkPipelineManager;
/**
* \brief Compute pipeline state info
@ -37,8 +38,7 @@ namespace dxvk {
public:
DxvkComputePipeline(
const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache,
DxvkPipelineManager* pipeMgr,
const Rc<DxvkShader>& cs);
~DxvkComputePipeline();
@ -71,10 +71,9 @@ namespace dxvk {
VkPipeline pipeline;
};
const DxvkDevice* const m_device;
const Rc<vk::DeviceFn> m_vkd;
Rc<vk::DeviceFn> m_vkd;
DxvkPipelineManager* m_pipeMgr;
Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_cs;

View File

@ -3,6 +3,7 @@
#include "dxvk_device.h"
#include "dxvk_graphics.h"
#include "dxvk_pipemanager.h"
#include "dxvk_spec_const.h"
namespace dxvk {
@ -36,14 +37,13 @@ namespace dxvk {
DxvkGraphicsPipeline::DxvkGraphicsPipeline(
const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache,
DxvkPipelineManager* pipeMgr,
const Rc<DxvkShader>& vs,
const Rc<DxvkShader>& tcs,
const Rc<DxvkShader>& tes,
const Rc<DxvkShader>& gs,
const Rc<DxvkShader>& fs)
: m_device(device), m_vkd(device->vkd()), m_cache(cache) {
: m_vkd(pipeMgr->m_device->vkd()), m_pipeMgr(pipeMgr) {
DxvkDescriptorSlotMapping slotMapping;
if (vs != nullptr) vs ->defineResourceSlots(slotMapping);
if (tcs != nullptr) tcs->defineResourceSlots(slotMapping);
@ -52,8 +52,8 @@ namespace dxvk {
if (fs != nullptr) fs ->defineResourceSlots(slotMapping);
slotMapping.makeDescriptorsDynamic(
device->options().maxNumDynamicUniformBuffers,
device->options().maxNumDynamicStorageBuffers);
pipeMgr->m_device->options().maxNumDynamicUniformBuffers,
pipeMgr->m_device->options().maxNumDynamicStorageBuffers);
m_layout = new DxvkPipelineLayout(m_vkd,
slotMapping.bindingCount(),
@ -237,7 +237,7 @@ namespace dxvk {
viInfo.pNext = viDivisorInfo.pNext;
// TODO remove this once the extension is widely supported
if (!m_device->extensions().extVertexAttributeDivisor)
if (!m_pipeMgr->m_device->extensions().extVertexAttributeDivisor)
viInfo.pNext = viDivisorInfo.pNext;
VkPipelineInputAssemblyStateCreateInfo iaInfo;
@ -354,7 +354,7 @@ namespace dxvk {
VkPipeline pipeline = VK_NULL_HANDLE;
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(),
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");
this->logPipelineState(LogLevel::Error, state);
return VK_NULL_HANDLE;

View File

@ -14,6 +14,7 @@
namespace dxvk {
class DxvkDevice;
class DxvkPipelineManager;
/**
* \brief Graphics pipeline state info
@ -147,8 +148,7 @@ namespace dxvk {
public:
DxvkGraphicsPipeline(
const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache,
DxvkPipelineManager* pipeMgr,
const Rc<DxvkShader>& vs,
const Rc<DxvkShader>& tcs,
const Rc<DxvkShader>& tes,
@ -191,17 +191,15 @@ namespace dxvk {
VkPipeline pipeline;
};
const DxvkDevice* const m_device;
const Rc<vk::DeviceFn> m_vkd;
Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_vs;
Rc<DxvkShaderModule> m_tcs;
Rc<DxvkShaderModule> m_tes;
Rc<DxvkShaderModule> m_gs;
Rc<DxvkShaderModule> m_fs;
Rc<vk::DeviceFn> m_vkd;
DxvkPipelineManager* m_pipeMgr;
Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_vs;
Rc<DxvkShaderModule> m_tcs;
Rc<DxvkShaderModule> m_tes;
Rc<DxvkShaderModule> m_gs;
Rc<DxvkShaderModule> m_fs;
uint32_t m_vsIn = 0;
uint32_t m_fsOut = 0;

View File

@ -65,7 +65,7 @@ namespace dxvk {
return pair->second;
const Rc<DxvkComputePipeline> pipeline
= new DxvkComputePipeline(m_device, m_cache, cs);
= new DxvkComputePipeline(this, cs);
m_computePipelines.insert(std::make_pair(key, pipeline));
return pipeline;
@ -95,7 +95,7 @@ namespace dxvk {
return pair->second;
Rc<DxvkGraphicsPipeline> pipeline = new DxvkGraphicsPipeline(
m_device, m_cache, vs, tcs, tes, gs, fs);
this, vs, tcs, tes, gs, fs);
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
return pipeline;

View File

@ -56,7 +56,8 @@ namespace dxvk {
* pipeline objects to the client API.
*/
class DxvkPipelineManager : public RcObject {
friend class DxvkComputePipeline;
friend class DxvkGraphicsPipeline;
public:
DxvkPipelineManager(const DxvkDevice* device);