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