// Copyright 2023 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include #include #include #include #include #include "VideoCommon/Assets/CustomAsset.h" #include "VideoCommon/TextureConfig.h" class ShaderCode; namespace VideoCommon { struct ShaderProperty { struct RGB { std::array value; }; struct RGBA { std::array value; }; using Value = std::variant, std::array, std::array, float, std::array, std::array, std::array, bool, RGB, RGBA>; static std::span GetValueTypeNames(); static Value GetDefaultValueFromTypeName(std::string_view name); static void WriteAsShaderCode(ShaderCode& shader_source, std::string_view name, const ShaderProperty& property); Value default_value; std::string description; }; struct RasterSurfaceShaderData { static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json, RasterSurfaceShaderData* data); static void ToJson(picojson::object& obj, const RasterSurfaceShaderData& data); // These shader properties describe the input that the // shader expects to expose. The key is text // expected to be in the shader code and the propery // describes various details about the input std::map uniform_properties; std::string vertex_source; std::string pixel_source; struct SamplerData { AbstractTextureType type; std::string name; bool operator==(const SamplerData&) const = default; }; std::vector samplers; }; class RasterSurfaceShaderAsset final : public CustomLoadableAsset { public: using CustomLoadableAsset::CustomLoadableAsset; private: CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override; }; } // namespace VideoCommon