2017-10-14 23:52:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-29 16:36:31 +02:00
|
|
|
#include <vector>
|
2017-10-14 23:52:47 +02:00
|
|
|
|
2018-01-10 11:44:40 +01:00
|
|
|
#include "dxvk_binding.h"
|
2017-11-20 13:21:27 +01:00
|
|
|
#include "dxvk_constant_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"
|
2017-10-14 23:52:47 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-01-16 15:00:19 +01:00
|
|
|
class DxvkDevice;
|
|
|
|
|
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-12-07 21:47:38 +01:00
|
|
|
DxvkGraphicsPipelineStateInfo();
|
|
|
|
DxvkGraphicsPipelineStateInfo(
|
|
|
|
const DxvkGraphicsPipelineStateInfo& other);
|
2017-11-20 13:21:27 +01:00
|
|
|
|
2017-12-07 21:47:38 +01:00
|
|
|
DxvkGraphicsPipelineStateInfo& operator = (
|
|
|
|
const DxvkGraphicsPipelineStateInfo& other);
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2018-01-10 21:28:20 +01:00
|
|
|
bool operator == (const DxvkGraphicsPipelineStateInfo& other) const;
|
|
|
|
bool operator != (const DxvkGraphicsPipelineStateInfo& other) const;
|
|
|
|
|
2018-01-10 11:44:40 +01:00
|
|
|
DxvkBindingState bsBindingState;
|
|
|
|
|
2017-12-07 21:47:38 +01:00
|
|
|
VkPrimitiveTopology iaPrimitiveTopology;
|
|
|
|
VkBool32 iaPrimitiveRestart;
|
2018-01-29 11:31:00 +01:00
|
|
|
uint32_t iaPatchVertexCount;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-12-07 21:47:38 +01:00
|
|
|
uint32_t ilAttributeCount;
|
|
|
|
uint32_t ilBindingCount;
|
|
|
|
VkVertexInputAttributeDescription ilAttributes[DxvkLimits::MaxNumVertexAttributes];
|
|
|
|
VkVertexInputBindingDescription ilBindings[DxvkLimits::MaxNumVertexBindings];
|
|
|
|
|
|
|
|
VkBool32 rsEnableDepthClamp;
|
|
|
|
VkBool32 rsEnableDiscard;
|
|
|
|
VkPolygonMode rsPolygonMode;
|
|
|
|
VkCullModeFlags rsCullMode;
|
|
|
|
VkFrontFace rsFrontFace;
|
|
|
|
VkBool32 rsDepthBiasEnable;
|
|
|
|
float rsDepthBiasConstant;
|
|
|
|
float rsDepthBiasClamp;
|
|
|
|
float rsDepthBiasSlope;
|
|
|
|
uint32_t rsViewportCount;
|
|
|
|
|
|
|
|
VkSampleCountFlagBits msSampleCount;
|
|
|
|
uint32_t msSampleMask;
|
|
|
|
VkBool32 msEnableAlphaToCoverage;
|
|
|
|
VkBool32 msEnableAlphaToOne;
|
|
|
|
VkBool32 msEnableSampleShading;
|
|
|
|
float msMinSampleShading;
|
|
|
|
|
|
|
|
VkBool32 dsEnableDepthTest;
|
|
|
|
VkBool32 dsEnableDepthWrite;
|
|
|
|
VkBool32 dsEnableDepthBounds;
|
|
|
|
VkBool32 dsEnableStencilTest;
|
|
|
|
VkCompareOp dsDepthCompareOp;
|
|
|
|
VkStencilOpState dsStencilOpFront;
|
|
|
|
VkStencilOpState dsStencilOpBack;
|
|
|
|
float dsDepthBoundsMin;
|
|
|
|
float dsDepthBoundsMax;
|
|
|
|
|
|
|
|
VkBool32 omEnableLogicOp;
|
|
|
|
VkLogicOp omLogicOp;
|
|
|
|
VkRenderPass omRenderPass;
|
2018-01-16 15:00:19 +01:00
|
|
|
VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets];
|
2017-12-07 21:47:38 +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(
|
2018-01-16 15:00:19 +01:00
|
|
|
const DxvkDevice* device,
|
2018-01-13 22:18:32 +01:00
|
|
|
const Rc<DxvkPipelineCache>& cache,
|
|
|
|
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
|
|
|
/**
|
2017-12-03 00:40:58 +01:00
|
|
|
* \brief Pipeline layout
|
2017-11-20 14:11:09 +01: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-11-20 14:11:09 +01:00
|
|
|
*/
|
2018-01-23 17:40:36 +01:00
|
|
|
Rc<DxvkPipelineLayout> layout() const {
|
2017-12-03 20:23:26 +01:00
|
|
|
return m_layout;
|
2017-11-20 14:11:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Pipeline handle
|
2018-01-13 22:18:32 +01:00
|
|
|
*
|
|
|
|
* Retrieves a pipeline handle for the given pipeline
|
|
|
|
* state. If necessary, a new pipeline will be created.
|
|
|
|
* \param [in] state Pipeline state vector
|
2017-11-20 14:11:09 +01:00
|
|
|
* \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:
|
|
|
|
|
2018-01-10 21:28:20 +01:00
|
|
|
struct PipelineStruct {
|
|
|
|
DxvkGraphicsPipelineStateInfo stateVector;
|
|
|
|
VkPipeline pipeline;
|
|
|
|
};
|
|
|
|
|
2018-01-16 15:00:19 +01:00
|
|
|
const DxvkDevice* const m_device;
|
|
|
|
const Rc<vk::DeviceFn> m_vkd;
|
|
|
|
|
2018-01-13 22:18:32 +01:00
|
|
|
Rc<DxvkPipelineCache> m_cache;
|
2018-01-23 17:40:36 +01:00
|
|
|
Rc<DxvkPipelineLayout> m_layout;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2017-12-07 09:38:31 +01:00
|
|
|
Rc<DxvkShaderModule> m_vs;
|
|
|
|
Rc<DxvkShaderModule> m_tcs;
|
|
|
|
Rc<DxvkShaderModule> m_tes;
|
|
|
|
Rc<DxvkShaderModule> m_gs;
|
|
|
|
Rc<DxvkShaderModule> m_fs;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2018-01-12 14:25:26 +01:00
|
|
|
uint32_t m_vsIn = 0;
|
|
|
|
uint32_t m_fsOut = 0;
|
|
|
|
|
2018-01-10 21:28:20 +01:00
|
|
|
std::vector<PipelineStruct> m_pipelines;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2018-01-10 22:54:00 +01:00
|
|
|
VkPipeline m_basePipeline = VK_NULL_HANDLE;
|
2017-10-15 13:02:59 +02:00
|
|
|
|
2018-01-10 22:54:00 +01:00
|
|
|
VkPipeline compilePipeline(
|
|
|
|
const DxvkGraphicsPipelineStateInfo& state,
|
|
|
|
VkPipeline baseHandle) const;
|
2018-01-12 14:25:26 +01:00
|
|
|
|
2017-11-20 14:11:09 +01:00
|
|
|
void destroyPipelines();
|
2017-11-20 14:03:00 +01:00
|
|
|
|
2018-01-12 14:25:26 +01:00
|
|
|
bool validatePipelineState(
|
|
|
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
|
|
|
|
2018-01-16 15:00:19 +01:00
|
|
|
VkRasterizationOrderAMD pickRasterizationOrder(
|
|
|
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
|
|
|
|
2018-02-07 16:44:30 +01:00
|
|
|
void logPipelineState(
|
2018-04-02 19:05:41 +02:00
|
|
|
LogLevel level,
|
2018-02-07 16:44:30 +01:00
|
|
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
|
|
|
|
2017-10-14 23:52:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|