2017-09-08 03:42:56 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-09-08 03:42:56 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "VideoCommon/RenderState.h"
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
class AbstractShader;
|
|
|
|
class NativeVertexFormat;
|
|
|
|
|
|
|
|
// We use three pipeline usages:
|
|
|
|
// - GX
|
|
|
|
// - Per-stage UBO (VS/GS/PS, VS constants accessible from PS)
|
|
|
|
// - 8 combined image samplers (accessible from PS)
|
|
|
|
// - 1 SSBO, accessible from PS if bounding box is enabled
|
2022-06-18 19:03:28 -06:00
|
|
|
// - GX Uber
|
|
|
|
// - Same as GX, plus one VS SSBO for vertices if dynamic vertex loading is enabled
|
2017-09-08 03:42:56 -06:00
|
|
|
// - Utility
|
|
|
|
// - Single UBO, accessible from all stages [set=0, binding=1]
|
|
|
|
// - 8 combined image samplers (accessible from PS) [set=1, binding=0-7]
|
|
|
|
// - 1 texel buffer, accessible from PS [set=2, binding=0]
|
|
|
|
// - Compute
|
|
|
|
// - 1 uniform buffer [set=0, binding=1]
|
|
|
|
// - 8 combined image samplers [set=1, binding=0-7]
|
|
|
|
// - 1 texel buffer [set=2, binding=0]
|
|
|
|
// - 1 storage image [set=3, binding=0]
|
|
|
|
enum class AbstractPipelineUsage
|
|
|
|
{
|
|
|
|
GX,
|
2022-06-18 19:03:28 -06:00
|
|
|
GXUber,
|
2017-09-08 03:42:56 -06:00
|
|
|
Utility
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AbstractPipelineConfig
|
|
|
|
{
|
|
|
|
const NativeVertexFormat* vertex_format;
|
|
|
|
const AbstractShader* vertex_shader;
|
|
|
|
const AbstractShader* geometry_shader;
|
|
|
|
const AbstractShader* pixel_shader;
|
|
|
|
RasterizationState rasterization_state;
|
|
|
|
DepthState depth_state;
|
|
|
|
BlendingState blending_state;
|
2019-02-14 18:59:50 -07:00
|
|
|
FramebufferState framebuffer_state;
|
2017-09-08 03:42:56 -06:00
|
|
|
|
|
|
|
AbstractPipelineUsage usage;
|
|
|
|
|
|
|
|
bool operator==(const AbstractPipelineConfig& rhs) const
|
|
|
|
{
|
|
|
|
return std::tie(vertex_format, vertex_shader, geometry_shader, pixel_shader,
|
|
|
|
rasterization_state.hex, depth_state.hex, blending_state.hex,
|
|
|
|
framebuffer_state.hex, usage) ==
|
|
|
|
std::tie(rhs.vertex_format, rhs.vertex_shader, rhs.geometry_shader, rhs.pixel_shader,
|
|
|
|
rhs.rasterization_state.hex, rhs.depth_state.hex, rhs.blending_state.hex,
|
|
|
|
rhs.framebuffer_state.hex, rhs.usage);
|
|
|
|
}
|
|
|
|
bool operator!=(const AbstractPipelineConfig& rhs) const { return !operator==(rhs); }
|
|
|
|
bool operator<(const AbstractPipelineConfig& rhs) const
|
|
|
|
{
|
|
|
|
return std::tie(vertex_format, vertex_shader, geometry_shader, pixel_shader,
|
|
|
|
rasterization_state.hex, depth_state.hex, blending_state.hex,
|
|
|
|
framebuffer_state.hex, usage) <
|
|
|
|
std::tie(rhs.vertex_format, rhs.vertex_shader, rhs.geometry_shader, rhs.pixel_shader,
|
|
|
|
rhs.rasterization_state.hex, rhs.depth_state.hex, rhs.blending_state.hex,
|
|
|
|
rhs.framebuffer_state.hex, rhs.usage);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class AbstractPipeline
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AbstractPipeline() = default;
|
|
|
|
virtual ~AbstractPipeline() = default;
|
2019-04-15 05:55:26 -06:00
|
|
|
|
|
|
|
// "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.
|
|
|
|
using CacheData = std::vector<u8>;
|
|
|
|
virtual CacheData GetCacheData() const { return {}; }
|
2017-09-08 03:42:56 -06:00
|
|
|
};
|