#pragma once #include #include #include "dxvk_constant_state.h" #include "dxvk_hash.h" #include "dxvk_pipeline.h" #include "dxvk_resource.h" #include "dxvk_shader.h" 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 { Rc inputAssemblyState; Rc inputLayout; Rc rasterizerState; Rc multisampleState; Rc depthStencilState; Rc blendState; VkRenderPass renderPass; uint32_t viewportCount; size_t hash() const; bool operator == (const DxvkGraphicsPipelineStateInfo& other) const; bool operator != (const DxvkGraphicsPipelineStateInfo& other) const; }; /** * \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& vkd, const Rc& layout, const Rc& vs, const Rc& tcs, const Rc& tes, const Rc& gs, const Rc& fs); ~DxvkGraphicsPipeline(); /** * \brief Descriptor set layout * * The descriptor set layout for this pipeline. * Use this to allocate new descriptor sets. * \returns The descriptor set layout */ VkDescriptorSetLayout descriptorSetLayout() const { return m_layout->descriptorSetLayout(); } /** * \brief Pipeline layout * * The pipeline layout for this pipeline. * Use this to bind descriptor sets. * \returns The descriptor set layout */ VkPipelineLayout pipelineLayout() const { return m_layout->pipelineLayout(); } /** * \brief Pipeline handle * \returns Pipeline handle */ VkPipeline getPipelineHandle( const DxvkGraphicsPipelineStateInfo& state); private: Rc m_vkd; Rc m_layout; Rc m_vs; Rc m_tcs; Rc m_tes; Rc m_gs; Rc m_fs; std::mutex m_mutex; std::unordered_map< DxvkGraphicsPipelineStateInfo, VkPipeline, DxvkHash> m_pipelines; VkPipeline compilePipeline( const DxvkGraphicsPipelineStateInfo& state) const; void destroyPipelines(); }; }