refl bugfix
This commit is contained in:
parent
dc3bce761e
commit
78f2aa18bf
@ -1,5 +1,5 @@
|
||||
metadatas:
|
||||
- guid: 2b4239ff-796a-4b55-9d8f-272c80a16b17
|
||||
- guid: e41ec295-8385-41c7-8067-fd07059ec634
|
||||
name: ""
|
||||
t_hash: api::ShaderProgram
|
||||
meta:
|
||||
@ -7,4 +7,5 @@ metadatas:
|
||||
__data__:
|
||||
mOwner:
|
||||
guid: 3585c167-9cff-4327-88db-d07601382640
|
||||
mStage: 2
|
||||
includes: ~
|
||||
@ -1,5 +1,5 @@
|
||||
metadatas:
|
||||
- guid: 3890e4a2-7b6c-47d3-9bd2-578a50f8d684
|
||||
- guid: 536e5008-2349-4019-8de4-4790bb87ab2e
|
||||
name: ""
|
||||
t_hash: api::ShaderProgram
|
||||
meta:
|
||||
@ -7,4 +7,5 @@ metadatas:
|
||||
__data__:
|
||||
mOwner:
|
||||
guid: 3585c167-9cff-4327-88db-d07601382640
|
||||
mStage: 1
|
||||
includes: ~
|
||||
@ -32,6 +32,9 @@ namespace api {
|
||||
if (it_func) {
|
||||
return it_func(any.ptr);
|
||||
}
|
||||
if (any.IsEnum()) {
|
||||
return Serialize(any.Parent());
|
||||
}
|
||||
YAML::Node result;
|
||||
if (any.cls == meta_info<Any>()) {
|
||||
Any obj = any.CastTo<Any>();
|
||||
@ -83,6 +86,9 @@ namespace api {
|
||||
if (it_func) {
|
||||
return it_func(res, any.ptr);
|
||||
}
|
||||
if (any.IsEnum()) {
|
||||
return Deserialize(res, any.Parent());
|
||||
}
|
||||
if (any.cls == meta_info<Any>() && res) {
|
||||
auto __class = res["__class__"];
|
||||
if (!__class) {
|
||||
|
||||
@ -29,7 +29,7 @@ namespace zlog {
|
||||
}
|
||||
zloger::~zloger() noexcept
|
||||
{
|
||||
//m_logger->flush();
|
||||
m_logger->flush();
|
||||
//spdlog::drop_all();
|
||||
//spdlog::shutdown();
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
#include "module/module_manager.h"
|
||||
#include "os/file_manager.h"
|
||||
#include "archive/pch.h"
|
||||
namespace api {
|
||||
void CoreModule::OnLoad(int argc, char** argv)
|
||||
{
|
||||
|
||||
TextArchive::InitSerde();
|
||||
}
|
||||
void CoreModule::OnUnload()
|
||||
{
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
#include "pmr/name.h"
|
||||
#include "tinyimageformat/tinyimageformat_base.h"
|
||||
#include <cstdint>
|
||||
namespace api {
|
||||
using pmr::Name;
|
||||
enum class GraphicsAPI
|
||||
{
|
||||
OpenGL,
|
||||
@ -100,14 +102,14 @@ namespace api {
|
||||
void* pHeader;
|
||||
char* pFlag;
|
||||
struct Header {
|
||||
size_t hash;
|
||||
Name name;
|
||||
uint32_t size;
|
||||
void* pCpuData;
|
||||
void* pMappingData;
|
||||
};
|
||||
};
|
||||
struct ShaderDescriptorLayout {
|
||||
size_t hash;
|
||||
Name name;
|
||||
uint32_t set : 8;
|
||||
uint32_t binding : 8;
|
||||
uint32_t size : 16;
|
||||
|
||||
@ -83,7 +83,7 @@ namespace api
|
||||
layout.binding = compiler.get_decoration(res.id, spv::Decoration::DecorationBinding);
|
||||
layout.stageFlags = stage;
|
||||
if (auto result = FindFieldFn(fieldList, layout.set, layout.binding)) {
|
||||
layout.hash = result.field->name;
|
||||
layout.name = result.field->name;
|
||||
layout.isShared = result.info.isShared;
|
||||
}
|
||||
return layout;
|
||||
|
||||
@ -49,6 +49,7 @@ namespace refl {
|
||||
Any Parent()const;
|
||||
|
||||
bool HasParent()const;
|
||||
bool IsEnum()const;
|
||||
bool IsArray()const;
|
||||
bool IsObject()const;
|
||||
bool IsContainer()const;
|
||||
|
||||
@ -6,6 +6,10 @@ namespace refl{
|
||||
{
|
||||
return cls->flag & CLASS_PARENT_FLAG;
|
||||
}
|
||||
inline bool Any::IsEnum() const
|
||||
{
|
||||
return cls->flag & CLASS_ENUM_FLAG;
|
||||
}
|
||||
inline bool Any::IsArray() const
|
||||
{
|
||||
return cls->flag & CLASS_ARRAY_FLAG;
|
||||
@ -71,7 +75,7 @@ namespace refl{
|
||||
{
|
||||
void* data = pool->allocate(cls->size);
|
||||
Any any{ data, cls };
|
||||
Convert::Construct(any, this);
|
||||
Convert::Construct(any, *this);
|
||||
return any;
|
||||
}
|
||||
template<typename T>
|
||||
|
||||
@ -22,10 +22,9 @@ namespace refl {
|
||||
enum FieldFlag :uint32_t {
|
||||
FIELD_NONE_FLAG = 0,
|
||||
FIELD_MEMBER_FLAG = 1 << 0,
|
||||
FIELD_ATTRIBUTE_FLAG = 1 << 1,
|
||||
FIELD_METHOD_FLAG = 1 << 2,
|
||||
FIELD_METHOD_VALUE_FLAG = 1 << 3,
|
||||
FIELD_CTOR_FLAG = 1 << 4,
|
||||
FIELD_METHOD_FLAG = 1 << 1,
|
||||
FIELD_METHOD_VALUE_FLAG = 1 << 2,
|
||||
FIELD_CTOR_FLAG = 1 << 3,
|
||||
};
|
||||
struct FieldPtr {
|
||||
union Data
|
||||
@ -44,18 +43,18 @@ namespace refl {
|
||||
Data data{};
|
||||
uint32_t flag{};
|
||||
Offset GetOffset() const {
|
||||
if (flag & FIELD_ATTRIBUTE_FLAG) {
|
||||
if (flag & FIELD_MEMBER_FLAG) {
|
||||
return data.member.offset;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Any GetValue()const {
|
||||
if (flag & FIELD_ATTRIBUTE_FLAG)
|
||||
if (flag & FIELD_MEMBER_FLAG)
|
||||
return data.member.value;
|
||||
return {};
|
||||
}
|
||||
Any GetMeta()const {
|
||||
if (flag & FIELD_ATTRIBUTE_FLAG)
|
||||
if (flag & FIELD_MEMBER_FLAG)
|
||||
return data.member.meta;
|
||||
if (flag & FIELD_METHOD_FLAG)
|
||||
return data.method.meta;
|
||||
|
||||
@ -30,7 +30,7 @@ namespace refl {
|
||||
inline FieldPtr MetaHelp::CtorField(T(*ptr)(Args...), const MethodData& data)
|
||||
{
|
||||
const UClass* cls = meta_info<void(*)(const void*, real_type_t<Args>...)>();
|
||||
uint32_t flag = FIELD_MEMBER_FLAG | FIELD_CTOR_FLAG;
|
||||
uint32_t flag = FIELD_CTOR_FLAG;
|
||||
MethodData method;
|
||||
if (!data.value.empty()) {
|
||||
flag |= FIELD_METHOD_VALUE_FLAG;
|
||||
@ -46,7 +46,7 @@ namespace refl {
|
||||
inline FieldPtr MetaHelp::MemberField(T Obj::* ptr, std::string_view name, const MemberData& data)
|
||||
{
|
||||
const UClass* cls = meta_info<T>();
|
||||
uint32_t flag = FIELD_MEMBER_FLAG | FIELD_CTOR_FLAG;
|
||||
uint32_t flag = FIELD_MEMBER_FLAG;
|
||||
MemberData member;
|
||||
member.offset = reinterpret_cast<std::size_t>(&(reinterpret_cast<const Obj*>(0)->*ptr));
|
||||
if (data.value) {
|
||||
@ -76,7 +76,7 @@ namespace refl {
|
||||
template<typename T, typename R, typename ...Args>
|
||||
inline FieldPtr MetaHelp::MethodField(R(T::* ptr)(Args...), std::string_view name, const MethodData& data) {
|
||||
MethodData method;
|
||||
uint32_t flag = FIELD_MEMBER_FLAG | FIELD_METHOD_FLAG;
|
||||
uint32_t flag = FIELD_METHOD_FLAG;
|
||||
const UClass* cls = meta_info<real_type_t<R>(*)(const void*, real_type_t<Args>...)>();
|
||||
if (!data.value.empty()) {
|
||||
flag |= FIELD_METHOD_VALUE_FLAG;
|
||||
|
||||
@ -128,7 +128,7 @@ namespace refl {
|
||||
template<typename T>
|
||||
Name meta_name() noexcept
|
||||
{
|
||||
auto view = meta_tstr<T>().view();
|
||||
return Name(view);
|
||||
constexpr auto tstr = meta_tstr<T>();
|
||||
return Name(tstr.view());
|
||||
}
|
||||
}
|
||||
@ -87,21 +87,21 @@ namespace refl {
|
||||
//转化为指针类型
|
||||
template<typename T>
|
||||
struct args_type {
|
||||
using type = T;
|
||||
using type = std::remove_cv_t<T>;
|
||||
};
|
||||
template<typename T>
|
||||
struct args_type<T&> {
|
||||
using type = T;
|
||||
using type = std::remove_cv_t<T>;
|
||||
};
|
||||
template<typename T>
|
||||
struct args_type<T*> {
|
||||
using type = T;
|
||||
using type = std::remove_cv_t<T>;
|
||||
};
|
||||
}
|
||||
template<typename T>
|
||||
using real_type_t = detail::real_type<T>::type;
|
||||
template<typename T>
|
||||
using args_type_t = detail::args_type<std::remove_cv_t<T>>::type;
|
||||
using args_type_t = detail::args_type<T>::type;
|
||||
};
|
||||
namespace gen {
|
||||
template<typename T, size_t hash>
|
||||
|
||||
@ -12,6 +12,7 @@ namespace refl {
|
||||
CLASS_SEQUENCE_FLAG = 1 << 4,
|
||||
CLASS_MAP_FLAG = 1 << 5,
|
||||
CLASS_PARENT_FLAG = 1 << 6,
|
||||
CLASS_ENUM_FLAG = 1 << 7,
|
||||
};
|
||||
enum EFieldFind :uint32_t {
|
||||
FIND_ALL_FIELD = 0,
|
||||
@ -101,7 +102,7 @@ namespace refl {
|
||||
class UClass {
|
||||
public:
|
||||
Name name;
|
||||
uint32_t size;
|
||||
uint32_t size : 16;
|
||||
uint32_t flag : 16{0};
|
||||
const UClass* parent;
|
||||
vtable_uclass vtable;
|
||||
|
||||
@ -22,6 +22,10 @@ namespace refl {
|
||||
parent = meta_info<RT>();
|
||||
}
|
||||
else {
|
||||
if constexpr (std::is_enum_v<T>) {
|
||||
flag = CLASS_ENUM_FLAG;
|
||||
parent = meta_info<std::underlying_type_t<T>>();
|
||||
}
|
||||
vtable.AddConstruct(&UClass::Construct<T>);
|
||||
vtable.AddDestruct(&UClass::Destruct<T>);
|
||||
}
|
||||
|
||||
@ -115,6 +115,9 @@ namespace vkn {
|
||||
info.pFlag = (char*)pBuffer + meta_align_size(sizeof(Buffer) * count);
|
||||
char* pData = (char*)pHeader + header_size;
|
||||
for (auto& desc : descList) {
|
||||
new(pHeader)MaterialInfo::Header{};
|
||||
new(pBuffer)Buffer{};
|
||||
pHeader->name = desc.name;
|
||||
pHeader->size = desc.size;
|
||||
pHeader->pCpuData = pData;
|
||||
BufferCreator creatorInfo{};
|
||||
|
||||
@ -3,6 +3,6 @@ rule("engine.plugin")
|
||||
on_config(function (target)
|
||||
import("make_plugin")
|
||||
local file = target:extraconf("rules", "engine.plugin", "file")
|
||||
--make_plugin(target, file or "module.h")
|
||||
make_plugin(target, file or "module.h")
|
||||
end)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user