mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Move most backend functionality to VideoCommon
This commit is contained in:
@ -25,12 +25,16 @@
|
||||
#include "VideoCommon/GeometryShaderGen.h"
|
||||
#include "VideoCommon/PixelShaderGen.h"
|
||||
#include "VideoCommon/RenderState.h"
|
||||
#include "VideoCommon/TextureCacheBase.h"
|
||||
#include "VideoCommon/TextureConversionShader.h"
|
||||
#include "VideoCommon/TextureConverterShaderGen.h"
|
||||
#include "VideoCommon/UberShaderPixel.h"
|
||||
#include "VideoCommon/UberShaderVertex.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
|
||||
class NativeVertexFormat;
|
||||
enum class AbstractTextureFormat : u32;
|
||||
enum class TLUTFormat;
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
@ -44,8 +48,11 @@ public:
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
|
||||
// Changes the shader host config. Shaders will be reloaded if there are changes.
|
||||
void SetHostConfig(const ShaderHostConfig& host_config, u32 efb_multisamples);
|
||||
// Compiles/loads cached shaders.
|
||||
void InitializeShaderCache();
|
||||
|
||||
// Changes the shader host config. Shaders should be reloaded afterwards.
|
||||
void SetHostConfig(const ShaderHostConfig& host_config) { m_host_config = host_config; }
|
||||
|
||||
// Reloads/recreates all shaders and pipelines.
|
||||
void Reload();
|
||||
@ -53,9 +60,6 @@ public:
|
||||
// Retrieves all pending shaders/pipelines from the async compiler.
|
||||
void RetrieveAsyncShaders();
|
||||
|
||||
// Get utility shader header based on current config.
|
||||
std::string GetUtilityShaderHeader() const;
|
||||
|
||||
// Accesses ShaderGen shader caches
|
||||
const AbstractPipeline* GetPipelineForUid(const GXPipelineUid& uid);
|
||||
const AbstractPipeline* GetUberPipelineForUid(const GXUberPipelineUid& uid);
|
||||
@ -64,7 +68,48 @@ public:
|
||||
// The optional will be empty if this pipeline is now background compiling.
|
||||
std::optional<const AbstractPipeline*> GetPipelineForUidAsync(const GXPipelineUid& uid);
|
||||
|
||||
// Shared shaders
|
||||
const AbstractShader* GetScreenQuadVertexShader() const
|
||||
{
|
||||
return m_screen_quad_vertex_shader.get();
|
||||
}
|
||||
const AbstractShader* GetTextureCopyVertexShader() const
|
||||
{
|
||||
return m_texture_copy_vertex_shader.get();
|
||||
}
|
||||
const AbstractShader* GetEFBCopyVertexShader() const { return m_efb_copy_vertex_shader.get(); }
|
||||
const AbstractShader* GetTexcoordGeometryShader() const
|
||||
{
|
||||
return m_texcoord_geometry_shader.get();
|
||||
}
|
||||
const AbstractShader* GetTextureCopyPixelShader() const
|
||||
{
|
||||
return m_texture_copy_pixel_shader.get();
|
||||
}
|
||||
const AbstractShader* GetColorGeometryShader() const { return m_color_geometry_shader.get(); }
|
||||
const AbstractShader* GetColorPixelShader() const { return m_color_pixel_shader.get(); }
|
||||
|
||||
// EFB copy to RAM/VRAM pipelines
|
||||
const AbstractPipeline*
|
||||
GetEFBCopyToVRAMPipeline(const TextureConversionShaderGen::TCShaderUid& uid);
|
||||
const AbstractPipeline* GetEFBCopyToRAMPipeline(const EFBCopyParams& uid);
|
||||
|
||||
// RGBA8 framebuffer copy pipelines
|
||||
const AbstractPipeline* GetRGBA8CopyPipeline() const { return m_copy_rgba8_pipeline.get(); }
|
||||
const AbstractPipeline* GetRGBA8StereoCopyPipeline() const
|
||||
{
|
||||
return m_rgba8_stereo_copy_pipeline.get();
|
||||
}
|
||||
|
||||
// Palette texture conversion pipelines
|
||||
const AbstractPipeline* GetPaletteConversionPipeline(TLUTFormat format);
|
||||
|
||||
// Texture decoding compute shaders
|
||||
const AbstractShader* GetTextureDecodingShader(TextureFormat format, TLUTFormat palette_format);
|
||||
|
||||
private:
|
||||
static constexpr size_t NUM_PALETTE_CONVERSION_SHADERS = 3;
|
||||
|
||||
void WaitForAsyncCompiler();
|
||||
void LoadShaderCaches();
|
||||
void ClearShaderCaches();
|
||||
@ -74,6 +119,7 @@ private:
|
||||
void InvalidateCachedPipelines();
|
||||
void ClearPipelineCaches();
|
||||
void QueueUberShaderPipelines();
|
||||
bool CompileSharedPipelines();
|
||||
|
||||
// GX shader compiler methods
|
||||
std::unique_ptr<AbstractShader> CompileVertexShader(const VertexShaderUid& uid) const;
|
||||
@ -93,6 +139,9 @@ private:
|
||||
const AbstractShader* CreateGeometryShader(const GeometryShaderUid& uid);
|
||||
bool NeedsGeometryShader(const GeometryShaderUid& uid) const;
|
||||
|
||||
// Should we use geometry shaders for EFB copies?
|
||||
bool UseGeometryShaderForEFBCopies() const;
|
||||
|
||||
// GX pipeline compiler methods
|
||||
AbstractPipelineConfig
|
||||
GetGXPipelineConfig(const NativeVertexFormat* vertex_format, const AbstractShader* vertex_shader,
|
||||
@ -130,10 +179,17 @@ private:
|
||||
// Configuration bits.
|
||||
APIType m_api_type = APIType::Nothing;
|
||||
ShaderHostConfig m_host_config = {};
|
||||
AbstractTextureFormat m_efb_depth_format;
|
||||
u32 m_efb_multisamples = 1;
|
||||
std::unique_ptr<AsyncShaderCompiler> m_async_shader_compiler;
|
||||
|
||||
// Shared shaders
|
||||
std::unique_ptr<AbstractShader> m_screen_quad_vertex_shader;
|
||||
std::unique_ptr<AbstractShader> m_texture_copy_vertex_shader;
|
||||
std::unique_ptr<AbstractShader> m_efb_copy_vertex_shader;
|
||||
std::unique_ptr<AbstractShader> m_texcoord_geometry_shader;
|
||||
std::unique_ptr<AbstractShader> m_color_geometry_shader;
|
||||
std::unique_ptr<AbstractShader> m_texture_copy_pixel_shader;
|
||||
std::unique_ptr<AbstractShader> m_color_pixel_shader;
|
||||
|
||||
// GX Shader Caches
|
||||
template <typename Uid>
|
||||
struct ShaderModuleCache
|
||||
@ -157,6 +213,22 @@ private:
|
||||
std::map<GXUberPipelineUid, std::pair<std::unique_ptr<AbstractPipeline>, bool>>
|
||||
m_gx_uber_pipeline_cache;
|
||||
File::IOFile m_gx_pipeline_uid_cache_file;
|
||||
|
||||
// EFB copy to VRAM/RAM pipelines
|
||||
std::map<TextureConversionShaderGen::TCShaderUid, std::unique_ptr<AbstractPipeline>>
|
||||
m_efb_copy_to_vram_pipelines;
|
||||
std::map<EFBCopyParams, std::unique_ptr<AbstractPipeline>> m_efb_copy_to_ram_pipelines;
|
||||
|
||||
// Copy pipeline for RGBA8 textures
|
||||
std::unique_ptr<AbstractPipeline> m_copy_rgba8_pipeline;
|
||||
std::unique_ptr<AbstractPipeline> m_rgba8_stereo_copy_pipeline;
|
||||
|
||||
// Palette conversion pipelines
|
||||
std::array<std::unique_ptr<AbstractPipeline>, NUM_PALETTE_CONVERSION_SHADERS>
|
||||
m_palette_conversion_pipelines;
|
||||
|
||||
// Texture decoding shaders
|
||||
std::map<std::pair<u32, u32>, std::unique_ptr<AbstractShader>> m_texture_decoding_shaders;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
Reference in New Issue
Block a user