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-10-14 23:52:47 +02:00
|
|
|
#include "dxvk_shader.h"
|
|
|
|
#include "dxvk_resource.h"
|
|
|
|
|
|
|
|
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(
|
|
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
|
|
const Rc<DxvkShader>& vs,
|
|
|
|
const Rc<DxvkShader>& tcs,
|
|
|
|
const Rc<DxvkShader>& tes,
|
|
|
|
const Rc<DxvkShader>& gs,
|
|
|
|
const Rc<DxvkShader>& fs);
|
|
|
|
~DxvkGraphicsPipeline();
|
|
|
|
|
2017-10-15 13:02:59 +02:00
|
|
|
VkDescriptorSetLayout descriptorSetLayout() const {
|
|
|
|
return m_descriptorSetLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
Rc<DxvkShader> m_vs;
|
|
|
|
Rc<DxvkShader> m_tcs;
|
|
|
|
Rc<DxvkShader> m_tes;
|
|
|
|
Rc<DxvkShader> m_gs;
|
|
|
|
Rc<DxvkShader> m_fs;
|
|
|
|
|
|
|
|
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
|
|
|
|
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
|
|
|
|
|
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-10-14 23:52:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|