Debian Codegraph @

Source/Core/VideoCommon/Resources/ShaderResource.h

raw symbols SCIP
1 // Copyright 2025 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <atomic>
7 #include <optional>
8
9 #include "VideoCommon/Resources/Resource.h"
10
11 #include "VideoCommon/Assets/ShaderAsset.h"
12 #include "VideoCommon/GXPipelineTypes.h"
13 #include "VideoCommon/ShaderGenCommon.h"
14
15 namespace VideoCommon
16 {
17 class ShaderResource final : public Resource
18 {
19 public:
20 ShaderResource(Resource::ResourceContext resource_context,
21 std::optional<GXPipelineUid> pipeline_uid, std::string preprocessor_setting,
22 const ShaderHostConfig& shader_host_config);
23
24 class Data
25 {
26 public:
27 AbstractShader* GetVertexShader() const;
28 AbstractShader* GetPixelShader() const;
29 AbstractShader* GetGeometryShader() const;
30
31 bool IsCompiled() const;
32 AbstractTextureType GetTextureType(std::size_t index);
33
34 private:
35 friend class ShaderResource;
36 std::unique_ptr<AbstractShader> m_vertex_shader;
37 std::unique_ptr<AbstractShader> m_pixel_shader;
38 std::unique_ptr<AbstractShader> m_geometry_shader;
39 std::shared_ptr<RasterSurfaceShaderData> m_shader_data;
40 bool m_needs_geometry_shader = false;
41 std::atomic_bool m_processing_finished;
42 };
43
44 // Changes the shader host config. Shaders should be reloaded afterwards.
45 void SetHostConfig(const ShaderHostConfig& host_config);
46 const std::shared_ptr<Data>& GetData() const { return m_current_data; }
47
48 void MarkAsActive() override;
49 void MarkAsPending() override;
50
51 private:
52 void ResetData() override;
53 Resource::TaskComplete CollectPrimaryData() override;
54 TaskComplete ProcessData() override;
55
56 // Note: asset cache owns the asset, we access as a reference
57 RasterSurfaceShaderAsset* m_shader_asset = nullptr;
58
59 std::shared_ptr<Data> m_current_data;
60 std::shared_ptr<Data> m_load_data;
61
62 bool m_processing_load_data = false;
63
64 ShaderHostConfig m_shader_host_config;
65
66 // If provided, denotes this shader will be used as a custom draw shader.
67 // If not provided, denotes this will be used as an efb post processing shader.
68 std::optional<GXPipelineUid> m_uid;
69 std::string m_preprocessor_settings;
70 };
71 } // namespace VideoCommon