diff --git a/Source/Core/VideoBackends/D3D/DXPipeline.cpp b/Source/Core/VideoBackends/D3D/DXPipeline.cpp index 3553e8d512..b17aeea59b 100644 --- a/Source/Core/VideoBackends/D3D/DXPipeline.cpp +++ b/Source/Core/VideoBackends/D3D/DXPipeline.cpp @@ -16,12 +16,12 @@ namespace DX11 { -DXPipeline::DXPipeline(ID3D11InputLayout* input_layout, ID3D11VertexShader* vertex_shader, - ID3D11GeometryShader* geometry_shader, ID3D11PixelShader* pixel_shader, - ID3D11RasterizerState* rasterizer_state, +DXPipeline::DXPipeline(const AbstractPipelineConfig& config, ID3D11InputLayout* input_layout, + ID3D11VertexShader* vertex_shader, ID3D11GeometryShader* geometry_shader, + ID3D11PixelShader* pixel_shader, ID3D11RasterizerState* rasterizer_state, ID3D11DepthStencilState* depth_state, ID3D11BlendState* blend_state, D3D11_PRIMITIVE_TOPOLOGY primitive_topology, bool use_logic_op) - : m_input_layout(input_layout), m_vertex_shader(vertex_shader), + : AbstractPipeline(config), m_input_layout(input_layout), m_vertex_shader(vertex_shader), m_geometry_shader(geometry_shader), m_pixel_shader(pixel_shader), m_rasterizer_state(rasterizer_state), m_depth_state(depth_state), m_blend_state(blend_state), m_primitive_topology(primitive_topology), m_use_logic_op(use_logic_op) @@ -57,7 +57,7 @@ std::unique_ptr DXPipeline::Create(const AbstractPipelineConfig& con const bool use_logic_op = config.blending_state.logicopenable && g_ActiveConfig.backend_info.bSupportsLogicOp; - return std::make_unique(input_layout, vertex_shader->GetD3DVertexShader(), + return std::make_unique(config, input_layout, vertex_shader->GetD3DVertexShader(), geometry_shader ? geometry_shader->GetD3DGeometryShader() : nullptr, pixel_shader->GetD3DPixelShader(), rasterizer_state, diff --git a/Source/Core/VideoBackends/D3D/DXPipeline.h b/Source/Core/VideoBackends/D3D/DXPipeline.h index 611f709ecc..cc9fb74d56 100644 --- a/Source/Core/VideoBackends/D3D/DXPipeline.h +++ b/Source/Core/VideoBackends/D3D/DXPipeline.h @@ -14,11 +14,11 @@ namespace DX11 class DXPipeline final : public AbstractPipeline { public: - DXPipeline(ID3D11InputLayout* input_layout, ID3D11VertexShader* vertex_shader, - ID3D11GeometryShader* geometry_shader, ID3D11PixelShader* pixel_shader, - ID3D11RasterizerState* rasterizer_state, ID3D11DepthStencilState* depth_state, - ID3D11BlendState* blend_state, D3D11_PRIMITIVE_TOPOLOGY primitive_topology, - bool use_logic_op); + DXPipeline(const AbstractPipelineConfig& config, ID3D11InputLayout* input_layout, + ID3D11VertexShader* vertex_shader, ID3D11GeometryShader* geometry_shader, + ID3D11PixelShader* pixel_shader, ID3D11RasterizerState* rasterizer_state, + ID3D11DepthStencilState* depth_state, ID3D11BlendState* blend_state, + D3D11_PRIMITIVE_TOPOLOGY primitive_topology, bool use_logic_op); ~DXPipeline() override; ID3D11InputLayout* GetInputLayout() const { return m_input_layout.Get(); } diff --git a/Source/Core/VideoBackends/D3D12/DX12Pipeline.cpp b/Source/Core/VideoBackends/D3D12/DX12Pipeline.cpp index bca820a2c3..9d908e0516 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Pipeline.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Pipeline.cpp @@ -14,11 +14,11 @@ namespace DX12 { -DXPipeline::DXPipeline(ID3D12PipelineState* pipeline, ID3D12RootSignature* root_signature, - AbstractPipelineUsage usage, D3D12_PRIMITIVE_TOPOLOGY primitive_topology, - bool use_integer_rtv) - : m_pipeline(pipeline), m_root_signature(root_signature), m_usage(usage), - m_primitive_topology(primitive_topology), m_use_integer_rtv(use_integer_rtv) +DXPipeline::DXPipeline(const AbstractPipelineConfig& config, ID3D12PipelineState* pipeline, + ID3D12RootSignature* root_signature, AbstractPipelineUsage usage, + D3D12_PRIMITIVE_TOPOLOGY primitive_topology, bool use_integer_rtv) + : AbstractPipeline(config), m_pipeline(pipeline), m_root_signature(root_signature), + m_usage(usage), m_primitive_topology(primitive_topology), m_use_integer_rtv(use_integer_rtv) { } @@ -218,7 +218,7 @@ std::unique_ptr DXPipeline::Create(const AbstractPipelineConfig& con const bool use_integer_rtv = !config.blending_state.blendenable && config.blending_state.logicopenable; - return std::make_unique(pso, desc.pRootSignature, config.usage, + return std::make_unique(config, pso, desc.pRootSignature, config.usage, GetD3DTopology(config.rasterization_state), use_integer_rtv); } diff --git a/Source/Core/VideoBackends/D3D12/DX12Pipeline.h b/Source/Core/VideoBackends/D3D12/DX12Pipeline.h index 3c79279e0d..0ac431380f 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Pipeline.h +++ b/Source/Core/VideoBackends/D3D12/DX12Pipeline.h @@ -13,9 +13,9 @@ namespace DX12 class DXPipeline final : public AbstractPipeline { public: - DXPipeline(ID3D12PipelineState* pipeline, ID3D12RootSignature* root_signature, - AbstractPipelineUsage usage, D3D12_PRIMITIVE_TOPOLOGY primitive_topology, - bool use_integer_rtv); + DXPipeline(const AbstractPipelineConfig& config, ID3D12PipelineState* pipeline, + ID3D12RootSignature* root_signature, AbstractPipelineUsage usage, + D3D12_PRIMITIVE_TOPOLOGY primitive_topology, bool use_integer_rtv); ~DXPipeline() override; static std::unique_ptr Create(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm index 593e71ed52..2a9387edeb 100644 --- a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm +++ b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm @@ -496,9 +496,10 @@ Metal::ObjectCache::CreatePipeline(const AbstractPipelineConfig& config) Internal::StoredPipeline pipeline = m_internal->GetOrCreatePipeline(config); if (!pipeline.first) return nullptr; - return std::make_unique( - std::move(pipeline.first), pipeline.second, Convert(config.rasterization_state.primitive), - Convert(config.rasterization_state.cullmode), config.depth_state, config.usage); + return std::make_unique(config, std::move(pipeline.first), pipeline.second, + Convert(config.rasterization_state.primitive), + Convert(config.rasterization_state.cullmode), + config.depth_state, config.usage); } void Metal::ObjectCache::ShaderDestroyed(const Shader* shader) diff --git a/Source/Core/VideoBackends/Metal/MTLPipeline.h b/Source/Core/VideoBackends/Metal/MTLPipeline.h index aa4fadbdbf..0d7c6b6650 100644 --- a/Source/Core/VideoBackends/Metal/MTLPipeline.h +++ b/Source/Core/VideoBackends/Metal/MTLPipeline.h @@ -27,7 +27,8 @@ struct PipelineReflection class Pipeline final : public AbstractPipeline { public: - explicit Pipeline(MRCOwned> pipeline, + explicit Pipeline(const AbstractPipelineConfig& config, + MRCOwned> pipeline, const PipelineReflection& reflection, MTLPrimitiveType prim, MTLCullMode cull, DepthState depth, AbstractPipelineUsage usage); diff --git a/Source/Core/VideoBackends/Metal/MTLPipeline.mm b/Source/Core/VideoBackends/Metal/MTLPipeline.mm index 5afaa477a1..cc99038859 100644 --- a/Source/Core/VideoBackends/Metal/MTLPipeline.mm +++ b/Source/Core/VideoBackends/Metal/MTLPipeline.mm @@ -53,11 +53,12 @@ Metal::PipelineReflection::PipelineReflection(MTLRenderPipelineReflection* refle GetArguments([reflection fragmentArguments], &textures, &samplers, &fragment_buffers); } -Metal::Pipeline::Pipeline(MRCOwned> pipeline, +Metal::Pipeline::Pipeline(const AbstractPipelineConfig& config, + MRCOwned> pipeline, const PipelineReflection& reflection, MTLPrimitiveType prim, MTLCullMode cull, DepthState depth, AbstractPipelineUsage usage) - : m_pipeline(std::move(pipeline)), m_prim(prim), m_cull(cull), m_depth_stencil(depth), - m_usage(usage), m_reflection(reflection) + : AbstractPipeline(config), m_pipeline(std::move(pipeline)), m_prim(prim), m_cull(cull), + m_depth_stencil(depth), m_usage(usage), m_reflection(reflection) { } diff --git a/Source/Core/VideoBackends/OGL/OGLPipeline.cpp b/Source/Core/VideoBackends/OGL/OGLPipeline.cpp index 3f9dea623f..b5837d409f 100644 --- a/Source/Core/VideoBackends/OGL/OGLPipeline.cpp +++ b/Source/Core/VideoBackends/OGL/OGLPipeline.cpp @@ -28,13 +28,13 @@ static GLenum MapToGLPrimitive(PrimitiveType primitive_type) return 0; } } -OGLPipeline::OGLPipeline(const GLVertexFormat* vertex_format, +OGLPipeline::OGLPipeline(const AbstractPipelineConfig& config, const GLVertexFormat* vertex_format, const RasterizationState& rasterization_state, const DepthState& depth_state, const BlendingState& blending_state, PipelineProgram* program, GLuint gl_primitive) - : m_vertex_format(vertex_format), m_rasterization_state(rasterization_state), - m_depth_state(depth_state), m_blending_state(blending_state), m_program(program), - m_gl_primitive(gl_primitive) + : AbstractPipeline(config), m_vertex_format(vertex_format), + m_rasterization_state(rasterization_state), m_depth_state(depth_state), + m_blending_state(blending_state), m_program(program), m_gl_primitive(gl_primitive) { } @@ -90,7 +90,7 @@ std::unique_ptr OGLPipeline::Create(const AbstractPipelineConfig& c const GLVertexFormat* vertex_format = static_cast(config.vertex_format); GLenum gl_primitive = MapToGLPrimitive(config.rasterization_state.primitive); - return std::make_unique(vertex_format, config.rasterization_state, + return std::make_unique(config, vertex_format, config.rasterization_state, config.depth_state, config.blending_state, program, gl_primitive); } diff --git a/Source/Core/VideoBackends/OGL/OGLPipeline.h b/Source/Core/VideoBackends/OGL/OGLPipeline.h index b7189a667c..5f4af83175 100644 --- a/Source/Core/VideoBackends/OGL/OGLPipeline.h +++ b/Source/Core/VideoBackends/OGL/OGLPipeline.h @@ -15,7 +15,7 @@ namespace OGL class OGLPipeline final : public AbstractPipeline { public: - explicit OGLPipeline(const GLVertexFormat* vertex_format, + explicit OGLPipeline(const AbstractPipelineConfig& config, const GLVertexFormat* vertex_format, const RasterizationState& rasterization_state, const DepthState& depth_state, const BlendingState& blending_state, PipelineProgram* program, GLenum gl_primitive); diff --git a/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp b/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp index 564f93d802..ad59ee89a7 100644 --- a/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp @@ -18,9 +18,10 @@ namespace Vulkan { -VKPipeline::VKPipeline(VkPipeline pipeline, VkPipelineLayout pipeline_layout, - AbstractPipelineUsage usage) - : m_pipeline(pipeline), m_pipeline_layout(pipeline_layout), m_usage(usage) +VKPipeline::VKPipeline(const AbstractPipelineConfig& config, VkPipeline pipeline, + VkPipelineLayout pipeline_layout, AbstractPipelineUsage usage) + : AbstractPipeline(config), m_pipeline(pipeline), m_pipeline_layout(pipeline_layout), + m_usage(usage) { } @@ -403,6 +404,6 @@ std::unique_ptr VKPipeline::Create(const AbstractPipelineConfig& con return VK_NULL_HANDLE; } - return std::make_unique(pipeline, pipeline_layout, config.usage); + return std::make_unique(config, pipeline, pipeline_layout, config.usage); } } // namespace Vulkan diff --git a/Source/Core/VideoBackends/Vulkan/VKPipeline.h b/Source/Core/VideoBackends/Vulkan/VKPipeline.h index f96983f24d..82bf1f22c7 100644 --- a/Source/Core/VideoBackends/Vulkan/VKPipeline.h +++ b/Source/Core/VideoBackends/Vulkan/VKPipeline.h @@ -13,8 +13,8 @@ namespace Vulkan class VKPipeline final : public AbstractPipeline { public: - explicit VKPipeline(VkPipeline pipeline, VkPipelineLayout pipeline_layout, - AbstractPipelineUsage usage); + explicit VKPipeline(const AbstractPipelineConfig& config, VkPipeline pipeline, + VkPipelineLayout pipeline_layout, AbstractPipelineUsage usage); ~VKPipeline() override; VkPipeline GetVkPipeline() const { return m_pipeline; } diff --git a/Source/Core/VideoCommon/AbstractPipeline.h b/Source/Core/VideoCommon/AbstractPipeline.h index 60381d0cd9..74b267242e 100644 --- a/Source/Core/VideoCommon/AbstractPipeline.h +++ b/Source/Core/VideoCommon/AbstractPipeline.h @@ -76,8 +76,11 @@ class AbstractPipeline { public: AbstractPipeline() = default; + explicit AbstractPipeline(const AbstractPipelineConfig& config) : m_config(config) {} virtual ~AbstractPipeline() = default; + AbstractPipelineConfig m_config; + // "Cache data" can be used to assist a driver with creating pipelines by using previously // compiled shader ISA. The abstract shaders and creation struct are still required to create // pipeline objects, the cache is optionally used by the driver to speed up compilation.