update engine parray
This commit is contained in:
parent
7ee697a1e2
commit
9aa69217e1
@ -1,13 +1,6 @@
|
|||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "render/renderapi.h"
|
#include "render/renderapi.h"
|
||||||
namespace engineapi {
|
namespace engineapi {
|
||||||
Mesh::Mesh(string name, uint32_t flags, parray<Vertex>& vertices, vector<uint32_t>& indices)
|
|
||||||
:Asset(name, flags)
|
|
||||||
,mVertices(vertices)
|
|
||||||
,mIndices(indices)
|
|
||||||
{
|
|
||||||
BeginLoad();
|
|
||||||
}
|
|
||||||
void Mesh::BeginLoad()
|
void Mesh::BeginLoad()
|
||||||
{
|
{
|
||||||
Asset::BeginLoad();
|
Asset::BeginLoad();
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "zstd/parray.h"
|
#include "refl/std/parray.h"
|
||||||
#include "asset_render.h"
|
#include "asset_render.h"
|
||||||
#include "../meta/vertex.h"
|
#include "../meta/vertex.h"
|
||||||
namespace engineapi {
|
namespace engineapi {
|
||||||
using zstd::parray;
|
using refl::parray;
|
||||||
|
using refl::ToParray;
|
||||||
class Texture;
|
class Texture;
|
||||||
class Material;
|
class Material;
|
||||||
class Mesh : public Asset {
|
class Mesh : public Asset {
|
||||||
@ -12,7 +13,15 @@ namespace engineapi {
|
|||||||
parray<Vertex> mVertices;
|
parray<Vertex> mVertices;
|
||||||
vector<uint32_t> mIndices;
|
vector<uint32_t> mIndices;
|
||||||
public:
|
public:
|
||||||
Mesh(string name, uint32_t flags, parray<Vertex>& vertices, vector<uint32_t>& indices);
|
template<typename T>
|
||||||
|
requires std::is_base_of_v<Vertex, T>
|
||||||
|
Mesh(string name, uint32_t flags,vector<T>& vertices, vector<uint32_t>& indices)
|
||||||
|
:Asset(name, flags)
|
||||||
|
, mVertices(vertices)
|
||||||
|
, mIndices(indices)
|
||||||
|
{
|
||||||
|
BeginLoad();
|
||||||
|
}
|
||||||
void BeginLoad()override;
|
void BeginLoad()override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -45,10 +45,7 @@ namespace engineapi {
|
|||||||
}
|
}
|
||||||
Mesh* Model::ProcessMesh(const aiMesh* mesh) {
|
Mesh* Model::ProcessMesh(const aiMesh* mesh) {
|
||||||
// data to fill
|
// data to fill
|
||||||
parray<Vertex> vertices(mesh->mNumVertices, sizeof(BoneVertex));
|
vector<BoneVertex> vertices;
|
||||||
parray<Vertex> vertices2(mesh->mNumVertices, sizeof(BoneVertex));
|
|
||||||
BoneVertex vertex2;
|
|
||||||
vertices2.push_back(vertex2);
|
|
||||||
vector<uint32_t> indices;
|
vector<uint32_t> indices;
|
||||||
// Walk through each of the mesh's vertices
|
// Walk through each of the mesh's vertices
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
||||||
|
|||||||
0
engine/src/engine/render/meta/meta.cpp
Normal file
0
engine/src/engine/render/meta/meta.cpp
Normal file
11
engine/src/engine/render/meta/meta.h
Normal file
11
engine/src/engine/render/meta/meta.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "refl/refl.h"
|
||||||
|
namespace engineapi {
|
||||||
|
enum class EVkFormat : uint32_t {
|
||||||
|
None = 0,
|
||||||
|
R32G32B32 = 106,
|
||||||
|
};
|
||||||
|
struct VertexMeta {
|
||||||
|
EVkFormat vkFormat;
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "math/vector3.h"
|
#include "math/vector3.h"
|
||||||
#include "math/vector2.h"
|
#include "math/vector2.h"
|
||||||
#include "refl/refl.h"
|
#include "meta.h"
|
||||||
// 顶点最多关联4个骨骼
|
// 顶点最多关联4个骨骼
|
||||||
#define MAX_NUM_BONES_PER_VERTEX 4
|
#define MAX_NUM_BONES_PER_VERTEX 4
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ namespace engineapi {
|
|||||||
struct PosVertex_Meta;
|
struct PosVertex_Meta;
|
||||||
struct PosVertex : public Vertex{
|
struct PosVertex : public Vertex{
|
||||||
using MyMeta = PosVertex_Meta;
|
using MyMeta = PosVertex_Meta;
|
||||||
__cppast(Meta = {})
|
__cppast(VkMeta = { {} ,VertexMeta{.vkFormat=EVkFormat::R32G32B32} })
|
||||||
Vector3 Position = {};
|
Vector3 Position = {};
|
||||||
};
|
};
|
||||||
struct TexVertex_Meta;
|
struct TexVertex_Meta;
|
||||||
@ -46,4 +46,5 @@ namespace engineapi {
|
|||||||
void AddBoneData(uint32_t boneID, float weight);
|
void AddBoneData(uint32_t boneID, float weight);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#include "meta_vertex_gen.inl"
|
#include "meta_vertex_gen.inl"
|
||||||
|
#include "vkmeta_vertex_gen.inl"
|
||||||
@ -67,7 +67,7 @@ namespace vulkanapi {
|
|||||||
meshBuffer->vertexCount = Vertices.size();
|
meshBuffer->vertexCount = Vertices.size();
|
||||||
|
|
||||||
// ----------------------------------------------- Vertex Buffer -----------------------------------------------
|
// ----------------------------------------------- Vertex Buffer -----------------------------------------------
|
||||||
VkDeviceSize vertexBufferSize = Vertices.data_size();
|
VkDeviceSize vertexBufferSize = Vertices.capicty();
|
||||||
VmaAllocationCreateInfo vertexVmaStagingInfo = {};
|
VmaAllocationCreateInfo vertexVmaStagingInfo = {};
|
||||||
VmaAllocation vertexVmaStagingAlloc;
|
VmaAllocation vertexVmaStagingAlloc;
|
||||||
VkBuffer vertexStagingBuffer = Buffer::CreateStageBuffer(vertexVmaStagingInfo, vertexVmaStagingAlloc, vertexBufferSize);
|
VkBuffer vertexStagingBuffer = Buffer::CreateStageBuffer(vertexVmaStagingInfo, vertexVmaStagingAlloc, vertexBufferSize);
|
||||||
|
|||||||
@ -45,6 +45,7 @@ namespace vulkanapi {
|
|||||||
for (int i = 0; i < Creator.frames;i++) {
|
for (int i = 0; i < Creator.frames;i++) {
|
||||||
mSurfaces.push_back(new Image(Creator.device,"swapchain" + to_string(i), swapchain_images[i], args));
|
mSurfaces.push_back(new Image(Creator.device,"swapchain" + to_string(i), swapchain_images[i], args));
|
||||||
}
|
}
|
||||||
|
mFrames = Creator.frames;
|
||||||
mSurfaceSemaphore = Creator.device.CreateSemaphore();
|
mSurfaceSemaphore = Creator.device.CreateSemaphore();
|
||||||
mRenderSemaphore = Creator.device.CreateSemaphore();
|
mRenderSemaphore = Creator.device.CreateSemaphore();
|
||||||
}
|
}
|
||||||
@ -52,6 +53,9 @@ namespace vulkanapi {
|
|||||||
{
|
{
|
||||||
ctx.surfaceSemaphore = mSurfaceSemaphore;
|
ctx.surfaceSemaphore = mSurfaceSemaphore;
|
||||||
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, ctx.surfaceSemaphore, VK_NULL_HANDLE, &ctx.frame);
|
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, ctx.surfaceSemaphore, VK_NULL_HANDLE, &ctx.frame);
|
||||||
|
if (ctx.frame >= mFrames) {
|
||||||
|
ctx.frame = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Swapchain::Present(VulkanContext& ctx)
|
void Swapchain::Present(VulkanContext& ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,6 +11,7 @@ namespace vulkanapi {
|
|||||||
protected:
|
protected:
|
||||||
VkSwapchainKHR mPtr;
|
VkSwapchainKHR mPtr;
|
||||||
Device& mDevice;
|
Device& mDevice;
|
||||||
|
int mFrames;
|
||||||
vector<Image*> mSurfaces;
|
vector<Image*> mSurfaces;
|
||||||
VkSemaphore mSurfaceSemaphore;
|
VkSemaphore mSurfaceSemaphore;
|
||||||
VkSemaphore mRenderSemaphore;
|
VkSemaphore mRenderSemaphore;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
includes("3rdparty/xmake.lua")
|
includes("3rdparty/xmake.lua")
|
||||||
includes("xmake/xmake.lua")
|
includes("xmake/xmake.lua")
|
||||||
--includes("test/**xmake.lua")
|
--includes("test/**xmake.lua")
|
||||||
|
set_languages("cxx20")
|
||||||
target("zengine")
|
target("zengine")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
set_rundir(".")
|
set_rundir(".")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user