2023-06-29 07:56:06 +02:00
|
|
|
// Copyright 2023 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-09 23:24:05 +01:00
|
|
|
#include <array>
|
2023-06-29 07:56:06 +02:00
|
|
|
#include <map>
|
2024-01-23 08:07:42 +01:00
|
|
|
#include <span>
|
2023-06-29 07:56:06 +02:00
|
|
|
#include <string>
|
2024-01-23 08:07:42 +01:00
|
|
|
#include <string_view>
|
2023-12-09 23:24:05 +01:00
|
|
|
#include <variant>
|
2023-06-29 07:56:06 +02:00
|
|
|
|
|
|
|
#include <picojson.h>
|
|
|
|
|
|
|
|
#include "VideoCommon/Assets/CustomAsset.h"
|
|
|
|
|
|
|
|
namespace VideoCommon
|
|
|
|
{
|
|
|
|
struct ShaderProperty
|
|
|
|
{
|
2023-12-09 23:24:05 +01:00
|
|
|
struct RGB
|
2023-06-29 07:56:06 +02:00
|
|
|
{
|
2023-12-09 23:24:05 +01:00
|
|
|
std::array<float, 3> value;
|
2023-06-29 07:56:06 +02:00
|
|
|
};
|
2023-12-09 23:24:05 +01:00
|
|
|
|
|
|
|
struct RGBA
|
|
|
|
{
|
|
|
|
std::array<float, 4> value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sampler2D
|
|
|
|
{
|
|
|
|
CustomAssetLibrary::AssetID value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sampler2DArray
|
|
|
|
{
|
|
|
|
CustomAssetLibrary::AssetID value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SamplerCube
|
|
|
|
{
|
|
|
|
CustomAssetLibrary::AssetID value;
|
|
|
|
};
|
|
|
|
|
|
|
|
using Value = std::variant<s32, std::array<s32, 2>, std::array<s32, 3>, std::array<s32, 4>, float,
|
|
|
|
std::array<float, 2>, std::array<float, 3>, std::array<float, 4>, bool,
|
|
|
|
RGB, RGBA, Sampler2D, Sampler2DArray, SamplerCube>;
|
2024-01-23 08:07:42 +01:00
|
|
|
static std::span<const std::string_view> GetValueTypeNames();
|
|
|
|
static Value GetDefaultValueFromTypeName(std::string_view name);
|
2023-12-09 23:24:05 +01:00
|
|
|
|
|
|
|
Value m_default;
|
2023-06-29 07:56:06 +02:00
|
|
|
std::string m_description;
|
|
|
|
};
|
|
|
|
struct PixelShaderData
|
|
|
|
{
|
|
|
|
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
|
|
|
PixelShaderData* data);
|
2024-01-23 08:05:16 +01:00
|
|
|
static void ToJson(picojson::object& obj, const PixelShaderData& data);
|
2023-06-29 07:56:06 +02:00
|
|
|
|
|
|
|
// 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<std::string, ShaderProperty> m_properties;
|
|
|
|
std::string m_shader_source;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PixelShaderAsset final : public CustomLoadableAsset<PixelShaderData>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using CustomLoadableAsset::CustomLoadableAsset;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override;
|
|
|
|
};
|
|
|
|
} // namespace VideoCommon
|