2017-10-13 03:19:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-23 08:32:56 +02:00
|
|
|
#include <atomic>
|
2018-05-01 16:45:28 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2018-09-17 10:40:57 +02:00
|
|
|
#include "dxvk_bind_mask.h"
|
2019-10-07 13:16:00 +02:00
|
|
|
#include "dxvk_graphics_state.h"
|
2018-01-13 22:18:32 +01:00
|
|
|
#include "dxvk_pipecache.h"
|
2017-12-07 09:38:31 +01:00
|
|
|
#include "dxvk_pipelayout.h"
|
2017-10-14 23:52:47 +02:00
|
|
|
#include "dxvk_resource.h"
|
2017-12-03 00:40:58 +01:00
|
|
|
#include "dxvk_shader.h"
|
2018-04-03 15:52:39 +02:00
|
|
|
#include "dxvk_stats.h"
|
2017-10-13 03:19:23 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-01-16 15:00:19 +01:00
|
|
|
class DxvkDevice;
|
2018-09-21 19:42:48 +02:00
|
|
|
class DxvkPipelineManager;
|
2018-01-16 15:00:19 +01:00
|
|
|
|
2019-07-23 12:41:09 +02:00
|
|
|
/**
|
|
|
|
* \brief Shaders used in compute pipelines
|
|
|
|
*/
|
|
|
|
struct DxvkComputePipelineShaders {
|
|
|
|
Rc<DxvkShader> cs;
|
2019-09-30 02:29:54 +02:00
|
|
|
|
|
|
|
bool eq(const DxvkComputePipelineShaders& other) const {
|
|
|
|
return cs == other.cs;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t hash() const {
|
|
|
|
return DxvkShader::getHash(cs);
|
|
|
|
}
|
2019-07-23 12:41:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-07-30 11:07:07 +02:00
|
|
|
/**
|
|
|
|
* \brief Compute pipeline instance
|
|
|
|
*/
|
|
|
|
class DxvkComputePipelineInstance {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxvkComputePipelineInstance()
|
|
|
|
: m_stateVector (),
|
|
|
|
m_pipeline (VK_NULL_HANDLE) { }
|
|
|
|
|
|
|
|
DxvkComputePipelineInstance(
|
|
|
|
const DxvkComputePipelineStateInfo& state,
|
|
|
|
VkPipeline pipe)
|
|
|
|
: m_stateVector (state),
|
|
|
|
m_pipeline (pipe) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Checks for matching pipeline state
|
|
|
|
*
|
|
|
|
* \param [in] stateVector Graphics pipeline state
|
|
|
|
* \param [in] renderPass Render pass handle
|
|
|
|
* \returns \c true if the specialization is compatible
|
|
|
|
*/
|
|
|
|
bool isCompatible(const DxvkComputePipelineStateInfo& state) const {
|
|
|
|
return m_stateVector == state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Retrieves pipeline
|
|
|
|
* \returns The pipeline handle
|
|
|
|
*/
|
|
|
|
VkPipeline pipeline() const {
|
|
|
|
return m_pipeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
DxvkComputePipelineStateInfo m_stateVector;
|
|
|
|
VkPipeline m_pipeline;
|
|
|
|
|
|
|
|
};
|
2018-02-14 17:54:35 +01:00
|
|
|
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
/**
|
|
|
|
* \brief Compute pipeline
|
|
|
|
*
|
2017-10-14 13:45:00 +02:00
|
|
|
* Stores a compute pipeline object and the corresponding
|
|
|
|
* pipeline layout. Unlike graphics pipelines, compute
|
|
|
|
* pipelines do not need to be recompiled against any sort
|
|
|
|
* of pipeline state.
|
2017-10-13 03:19:23 +02:00
|
|
|
*/
|
2019-07-23 13:15:06 +02:00
|
|
|
class DxvkComputePipeline {
|
2017-10-13 03:19:23 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
DxvkComputePipeline(
|
2019-07-23 12:48:11 +02:00
|
|
|
DxvkPipelineManager* pipeMgr,
|
|
|
|
DxvkComputePipelineShaders shaders);
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
~DxvkComputePipeline();
|
|
|
|
|
2019-09-30 01:54:49 +02:00
|
|
|
/**
|
|
|
|
* \brief Shaders used by the pipeline
|
|
|
|
* \returns Shaders used by the pipeline
|
|
|
|
*/
|
|
|
|
const DxvkComputePipelineShaders& shaders() const {
|
|
|
|
return m_shaders;
|
|
|
|
}
|
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
/**
|
2017-12-03 20:23:26 +01:00
|
|
|
* \brief Pipeline layout
|
2017-10-14 23:52:47 +02:00
|
|
|
*
|
2017-12-03 20:23:26 +01:00
|
|
|
* Stores the pipeline layout and the descriptor set
|
|
|
|
* layout, as well as information on the resource
|
|
|
|
* slots used by the pipeline.
|
|
|
|
* \returns Pipeline layout
|
2017-10-14 23:52:47 +02:00
|
|
|
*/
|
2018-06-22 00:33:47 +02:00
|
|
|
DxvkPipelineLayout* layout() const {
|
|
|
|
return m_layout.ptr();
|
2017-10-15 19:23:10 +02:00
|
|
|
}
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
/**
|
2019-07-30 12:14:52 +02:00
|
|
|
* \brief Retrieves pipeline handle
|
2018-02-14 17:54:35 +01:00
|
|
|
*
|
|
|
|
* \param [in] state Pipeline state
|
2017-10-13 03:19:23 +02:00
|
|
|
* \returns Pipeline handle
|
|
|
|
*/
|
2018-02-14 17:54:35 +01:00
|
|
|
VkPipeline getPipelineHandle(
|
2018-09-21 22:28:06 +02:00
|
|
|
const DxvkComputePipelineStateInfo& state);
|
2017-10-13 03:19:23 +02:00
|
|
|
|
2019-07-30 12:14:52 +02:00
|
|
|
/**
|
|
|
|
* \brief Compiles a pipeline
|
|
|
|
*
|
|
|
|
* Asynchronously compiles the given pipeline
|
|
|
|
* and stores the result for future use.
|
|
|
|
* \param [in] state Pipeline state
|
|
|
|
*/
|
|
|
|
void compilePipeline(
|
|
|
|
const DxvkComputePipelineStateInfo& state);
|
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
private:
|
|
|
|
|
2019-07-23 12:48:11 +02:00
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
|
|
|
DxvkPipelineManager* m_pipeMgr;
|
2019-04-03 19:46:28 +02:00
|
|
|
|
2019-07-23 12:48:11 +02:00
|
|
|
DxvkComputePipelineShaders m_shaders;
|
|
|
|
DxvkDescriptorSlotMapping m_slotMapping;
|
2018-01-16 15:00:19 +01:00
|
|
|
|
2019-07-23 12:48:11 +02:00
|
|
|
Rc<DxvkPipelineLayout> m_layout;
|
2017-10-14 23:52:47 +02:00
|
|
|
|
2019-07-30 11:07:07 +02:00
|
|
|
sync::Spinlock m_mutex;
|
|
|
|
std::vector<DxvkComputePipelineInstance> m_pipelines;
|
2018-03-16 01:24:03 +01:00
|
|
|
|
2019-07-30 12:14:52 +02:00
|
|
|
DxvkComputePipelineInstance* createInstance(
|
|
|
|
const DxvkComputePipelineStateInfo& state);
|
|
|
|
|
|
|
|
DxvkComputePipelineInstance* findInstance(
|
|
|
|
const DxvkComputePipelineStateInfo& state);
|
2018-05-01 16:45:28 +02:00
|
|
|
|
2019-07-30 09:41:22 +02:00
|
|
|
VkPipeline createPipeline(
|
2019-07-14 13:58:00 +02:00
|
|
|
const DxvkComputePipelineStateInfo& state) const;
|
2017-10-13 03:19:23 +02:00
|
|
|
|
2018-09-23 08:32:56 +02:00
|
|
|
void destroyPipeline(
|
|
|
|
VkPipeline pipeline);
|
|
|
|
|
|
|
|
void writePipelineStateToCache(
|
|
|
|
const DxvkComputePipelineStateInfo& state) const;
|
2017-12-07 09:38:31 +01:00
|
|
|
|
2017-10-13 03:19:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|