- Add ResetFast to Pool using c++20 concept - Add Put function to Pool - Use Pool Index instead of pointers in Command - Add accessor to Li Pools to prevent wrong command usage - Add Command Formatter - Use ResetFast for all Pools - Add Reset func to Li::Vertex (for ResetFast) - Add Pool Expandor and Put funcs to Lithium pools - Add getters for GfxDriverBase to PD::Li Pools
123 lines
3.9 KiB
C++
123 lines
3.9 KiB
C++
#pragma once
|
|
|
|
#include <pd/lithium/atlas.hpp>
|
|
#include <pd/lithium/command.hpp>
|
|
#include <pd/lithium/rect.hpp>
|
|
#include <pd/lithium/texture.hpp>
|
|
#include <pd/lithium/vertex.hpp>
|
|
|
|
template <>
|
|
struct std::formatter<PD::TextureFilter> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::TextureFilter& value, FormatContext& ctx) const {
|
|
std::string_view ret = "Unknown";
|
|
switch (value) {
|
|
case PD::TextureFilter::Linear:
|
|
ret = "Linear";
|
|
break;
|
|
case PD::TextureFilter::Nearest:
|
|
ret = "Nearest";
|
|
break;
|
|
}
|
|
return std::format_to(ctx.out(), "{}", ret);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::TextureFormat> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::TextureFormat& value, FormatContext& ctx) const {
|
|
std::string_view ret = "Unknown";
|
|
switch (value) {
|
|
case PD::TextureFormat::RGBA32:
|
|
ret = "RGBA32";
|
|
break;
|
|
case PD::TextureFormat::RGB24:
|
|
ret = "RGB24";
|
|
break;
|
|
case PD::TextureFormat::A8:
|
|
ret = "A8";
|
|
break;
|
|
}
|
|
return std::format_to(ctx.out(), "{}", ret);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::Li::Rect> : std::formatter<std::string> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::Li::Rect& value, FormatContext& ctx) const {
|
|
// {l, t, r, t, l, b, r, b}
|
|
return std::format_to(ctx.out(), "{}, {}, {}, {}, {}, {}, {}, {}",
|
|
value.Top.x, value.Top.y, value.Top.z, value.Top.w,
|
|
value.Bot.x, value.Bot.y, value.Bot.z, value.Bot.w);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::Li::Texture> : std::formatter<std::string> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::Li::Texture& value, FormatContext& ctx) const {
|
|
// {ID, [w, h], [l, t, r, t, l, b, r, b]}
|
|
return std::format_to(ctx.out(), "{}, [{}], [{}]", value.GetID(),
|
|
value.GetSize(), value.GetUV());
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::Li::Vertex> : std::formatter<std::string> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::Li::Vertex& value, FormatContext& ctx) const {
|
|
// { [x, y], [u, v], colorhex }
|
|
return std::format_to(ctx.out(), "[{}], [{}], #{:08X}", value.pos, value.uv,
|
|
value.color);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::Li::AtlasState> : std::formatter<std::string> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::Li::AtlasState& value, FormatContext& ctx) const {
|
|
std::string_view ret = "Unknown";
|
|
switch (value) {
|
|
case PD::Li::AtlasState::Invalid:
|
|
ret = "Invalid";
|
|
break;
|
|
case PD::Li::AtlasState::ReqCreate:
|
|
ret = "RequestCreate";
|
|
break;
|
|
case PD::Li::AtlasState::ReqUpdate:
|
|
ret = "RequestUpdate";
|
|
break;
|
|
case PD::Li::AtlasState::ReqDestroy:
|
|
ret = "RequestDestroy";
|
|
break;
|
|
}
|
|
return std::format_to(ctx.out(), "{}", ret);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct std::formatter<PD::Li::Command> : std::formatter<std::string> {
|
|
constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
|
auto format(const PD::Li::Command& value, FormatContext& ctx) const {
|
|
return std::format_to(ctx.out(), "[0x{:X}, 0x{:X}] [{}, {}] 0x{:X}",
|
|
(PD::ptr)value.FirstVertex, (PD::ptr)value.FirstIndex,
|
|
value.VertexCount, value.IndexCount, value.Tex);
|
|
}
|
|
};
|