1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxvk/dxvk_graphics.h

146 lines
4.8 KiB
C
Raw Normal View History

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
#include "dxvk_binding.h"
#include "dxvk_constant_state.h"
2017-10-15 13:02:59 +02:00
#include "dxvk_hash.h"
#include "dxvk_pipelayout.h"
2017-10-14 23:52:47 +02:00
#include "dxvk_resource.h"
#include "dxvk_shader.h"
2017-10-14 23:52:47 +02:00
namespace dxvk {
/**
* \brief Graphics pipeline state info
*
* 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.
*/
struct DxvkGraphicsPipelineStateInfo {
DxvkGraphicsPipelineStateInfo();
DxvkGraphicsPipelineStateInfo(
const DxvkGraphicsPipelineStateInfo& other);
DxvkGraphicsPipelineStateInfo& operator = (
const DxvkGraphicsPipelineStateInfo& other);
2017-10-15 13:02:59 +02:00
bool operator == (const DxvkGraphicsPipelineStateInfo& other) const;
bool operator != (const DxvkGraphicsPipelineStateInfo& other) const;
DxvkBindingState bsBindingState;
VkPrimitiveTopology iaPrimitiveTopology;
VkBool32 iaPrimitiveRestart;
2017-10-15 13:02:59 +02: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;
VkPipelineColorBlendAttachmentState omBlendAttachments[DxvkLimits::MaxNumRenderTargets];
};
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);
2017-10-14 23:52:47 +02:00
~DxvkGraphicsPipeline();
/**
* \brief Pipeline layout
*
* Stores the pipeline layout and the descriptor set
* layout, as well as information on the resource
* slots used by the pipeline.
* \returns Pipeline layout
*/
Rc<DxvkBindingLayout> layout() const {
return m_layout;
}
/**
* \brief Pipeline handle
* \returns Pipeline handle
*/
2017-10-15 13:02:59 +02:00
VkPipeline getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state);
2017-10-15 13:02:59 +02:00
2017-10-14 23:52:47 +02:00
private:
struct PipelineStruct {
DxvkGraphicsPipelineStateInfo stateVector;
VkPipeline pipeline;
};
2017-10-15 13:02:59 +02:00
Rc<vk::DeviceFn> m_vkd;
Rc<DxvkBindingLayout> m_layout;
2017-10-15 13:02:59 +02: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
std::mutex m_mutex;
std::vector<PipelineStruct> m_pipelines;
2017-10-15 13:02:59 +02:00
VkPipeline m_basePipeline = VK_NULL_HANDLE;
2017-10-15 13:02:59 +02:00
VkPipeline compilePipeline(
const DxvkGraphicsPipelineStateInfo& state,
VkPipeline baseHandle) const;
void destroyPipelines();
2017-10-14 23:52:47 +02:00
};
}