Debian Codegraph @

Source/Core/VideoCommon/AbstractPipeline.h

raw symbols SCIP
1 // Copyright 2017 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <cstddef>
7 #include <string>
8 #include <utility>
9 #include <vector>
10
11 #include "Common/CommonTypes.h"
12 #include "VideoCommon/RenderState.h"
13 #include "VideoCommon/TextureConfig.h"
14
15 class AbstractShader;
16 class NativeVertexFormat;
17
18 // We use three pipeline usages:
19 // - GX
20 // - Per-stage UBO (VS/GS/PS, VS constants accessible from PS)
21 // - 8 combined image samplers (accessible from PS)
22 // - 1 SSBO, accessible from PS if bounding box is enabled
23 // - GX Uber
24 // - Same as GX, plus one VS SSBO for vertices if dynamic vertex loading is enabled
25 // - Utility
26 // - Single UBO, accessible from all stages [set=0, binding=1]
27 // - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
28 // - 1 texel buffer, accessible from PS [set=2, binding=0]
29 // - Compute
30 // - 1 uniform buffer [set=0, binding=1]
31 // - 8 combined image samplers [set=1, binding=0-7]
32 // - 1 texel buffer [set=2, binding=0]
33 // - 1 storage image [set=3, binding=0]
34 enum class AbstractPipelineUsage
35 {
36 GX,
37 GXUber,
38 Utility
39 };
40
41 struct AbstractPipelineConfig
42 {
43 const NativeVertexFormat* vertex_format = nullptr;
44 const AbstractShader* vertex_shader = nullptr;
45 const AbstractShader* geometry_shader = nullptr;
46 const AbstractShader* pixel_shader = nullptr;
47 RasterizationState rasterization_state;
48 DepthState depth_state;
49 BlendingState blending_state;
50 FramebufferState framebuffer_state;
51
52 AbstractPipelineUsage usage = AbstractPipelineUsage::GX;
53
54 bool operator==(const AbstractPipelineConfig& rhs) const
55 {
56 return std::tie(vertex_format, vertex_shader, geometry_shader, pixel_shader,
57 rasterization_state.hex, depth_state.hex, blending_state.hex,
58 framebuffer_state.hex, usage) ==
59 std::tie(rhs.vertex_format, rhs.vertex_shader, rhs.geometry_shader, rhs.pixel_shader,
60 rhs.rasterization_state.hex, rhs.depth_state.hex, rhs.blending_state.hex,
61 rhs.framebuffer_state.hex, rhs.usage);
62 }
63 bool operator<(const AbstractPipelineConfig& rhs) const
64 {
65 return std::tie(vertex_format, vertex_shader, geometry_shader, pixel_shader,
66 rasterization_state.hex, depth_state.hex, blending_state.hex,
67 framebuffer_state.hex, usage) <
68 std::tie(rhs.vertex_format, rhs.vertex_shader, rhs.geometry_shader, rhs.pixel_shader,
69 rhs.rasterization_state.hex, rhs.depth_state.hex, rhs.blending_state.hex,
70 rhs.framebuffer_state.hex, rhs.usage);
71 }
72 };
73
74 class AbstractPipeline
75 {
76 public:
77 AbstractPipeline() = default;
78 explicit AbstractPipeline(const AbstractPipelineConfig& config) : m_config(config) {}
79 virtual ~AbstractPipeline() = default;
80
81 AbstractPipelineConfig m_config;
82
83 // "Cache data" can be used to assist a driver with creating pipelines by using previously
84 // compiled shader ISA. The abstract shaders and creation struct are still required to create
85 // pipeline objects, the cache is optionally used by the driver to speed up compilation.
86 using CacheData = std::vector<u8>;
87 virtual CacheData GetCacheData() const { return {}; }
88 };