2017-10-14 23:52:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <mutex>
|
2017-10-15 13:02:59 +02:00
|
|
|
#include <unordered_map>
|
2017-10-14 23:52:47 +02:00
|
|
|
|
2017-11-20 13:21:27 +01:00
|
|
|
#include "dxvk_constant_state.h"
|
2017-10-15 13:02:59 +02:00
|
|
|
#include "dxvk_hash.h"
|
2017-12-03 00:40:58 +01:00
|
|
|
#include "dxvk_pipeline.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"
|
2017-10-14 23:52:47 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2017-11-17 19:49:44 +01:00
|
|
|
/**
|
|
|
|
* \brief Graphics pipeline state info
|
|
|
|
*
|
2017-11-20 13:21:27 +01:00
|
|
|
* Stores all information that is required to create
|
|
|
|
* a graphics pipeline, except the shader objects
|
|
|
|
* themselves. Also used to identify pipelines using
|
|
|
|
* the current pipeline state vector.
|
2017-11-17 19:49:44 +01:00
|
|
|
*/
|
2017-10-15 17:56:06 +02:00
|
|
|
struct DxvkGraphicsPipelineStateInfo {
|
2017-11-20 13:38:24 +01:00
|
|
|
Rc<DxvkInputAssemblyState> inputAssemblyState;
|
2017-11-20 13:21:27 +01:00
|
|
|
Rc<DxvkInputLayout> inputLayout;
|
|
|
|
Rc<DxvkRasterizerState> rasterizerState;
|
|
|
|
Rc<DxvkMultisampleState> multisampleState;
|
|
|
|
Rc<DxvkDepthStencilState> depthStencilState;
|
|
|
|
Rc<DxvkBlendState> blendState;
|
|
|
|
|
|
|
|
VkRenderPass renderPass;
|
|
|
|
uint32_t viewportCount;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
|
|
|
size_t hash() const;
|
|
|
|
|
2017-10-15 17:56:06 +02:00
|
|
|
bool operator == (const DxvkGraphicsPipelineStateInfo& other) const;
|
|
|
|
bool operator != (const DxvkGraphicsPipelineStateInfo& other) const;
|
2017-10-15 13:02:59 +02:00
|
|
|
};
|
|
|
|
|
2017-11-17 19:49:44 +01:00
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
/**
|
|
|
|
* \brief Graphics pipeline
|
|
|
|
*
|
|
|
|
* Stores the pipeline layout as well as methods to
|
|
|
|
* recompile the graphics pipeline against a given
|
|
|
|
* pipeline state vector.
|
|
|
|
*/
|
|
|
|
class DxvkGraphicsPipeline : public DxvkResource {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxvkGraphicsPipeline(
|
2017-12-03 00:40:58 +01:00
|
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
|
|
const Rc<DxvkBindingLayout>& layout,
|
|
|
|
const Rc<DxvkShader>& vs,
|
|
|
|
const Rc<DxvkShader>& tcs,
|
|
|
|
const Rc<DxvkShader>& tes,
|
|
|
|
const Rc<DxvkShader>& gs,
|
|
|
|
const Rc<DxvkShader>& fs);
|
2017-10-14 23:52:47 +02:00
|
|
|
~DxvkGraphicsPipeline();
|
|
|
|
|
2017-11-20 14:11:09 +01:00
|
|
|
/**
|
|
|
|
* \brief Descriptor set layout
|
|
|
|
*
|
|
|
|
* The descriptor set layout for this pipeline.
|
|
|
|
* Use this to allocate new descriptor sets.
|
|
|
|
* \returns The descriptor set layout
|
|
|
|
*/
|
2017-10-15 13:02:59 +02:00
|
|
|
VkDescriptorSetLayout descriptorSetLayout() const {
|
2017-12-03 00:40:58 +01:00
|
|
|
return m_layout->descriptorSetLayout();
|
2017-10-15 13:02:59 +02:00
|
|
|
}
|
|
|
|
|
2017-11-20 14:11:09 +01:00
|
|
|
/**
|
2017-12-03 00:40:58 +01:00
|
|
|
* \brief Pipeline layout
|
2017-11-20 14:11:09 +01:00
|
|
|
*
|
|
|
|
* The pipeline layout for this pipeline.
|
|
|
|
* Use this to bind descriptor sets.
|
|
|
|
* \returns The descriptor set layout
|
|
|
|
*/
|
|
|
|
VkPipelineLayout pipelineLayout() const {
|
2017-12-03 00:40:58 +01:00
|
|
|
return m_layout->pipelineLayout();
|
2017-11-20 14:11:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Pipeline handle
|
|
|
|
* \returns Pipeline handle
|
|
|
|
*/
|
2017-10-15 13:02:59 +02:00
|
|
|
VkPipeline getPipelineHandle(
|
2017-10-15 17:56:06 +02:00
|
|
|
const DxvkGraphicsPipelineStateInfo& state);
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
private:
|
|
|
|
|
2017-10-15 13:02:59 +02:00
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
2017-12-03 00:40:58 +01:00
|
|
|
Rc<DxvkBindingLayout> m_layout;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-12-03 00:40:58 +01:00
|
|
|
Rc<DxvkShader> m_vs;
|
|
|
|
Rc<DxvkShader> m_tcs;
|
|
|
|
Rc<DxvkShader> m_tes;
|
|
|
|
Rc<DxvkShader> m_gs;
|
|
|
|
Rc<DxvkShader> m_fs;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
std::mutex m_mutex;
|
|
|
|
|
2017-10-15 13:02:59 +02:00
|
|
|
std::unordered_map<
|
2017-10-15 17:56:06 +02:00
|
|
|
DxvkGraphicsPipelineStateInfo,
|
2017-10-15 13:02:59 +02:00
|
|
|
VkPipeline, DxvkHash> m_pipelines;
|
|
|
|
|
|
|
|
VkPipeline compilePipeline(
|
2017-10-15 17:56:06 +02:00
|
|
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-11-20 14:11:09 +01:00
|
|
|
void destroyPipelines();
|
2017-11-20 14:03:00 +01:00
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|