update asset
This commit is contained in:
parent
1bf3f23303
commit
71bb63a487
13
engine/3rdparty/glm/test/01bezier.cpp
vendored
13
engine/3rdparty/glm/test/01bezier.cpp
vendored
@ -1,13 +0,0 @@
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/fwd.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
int main() {
|
||||
glm::vec3 v0(1,1,0),n1(0,0,1);
|
||||
glm::vec3 p0(1, 2, 3), p1(3, 4, 5), p2 = p0;
|
||||
p2.z += 10;
|
||||
glm::vec3 up = glm::cross(v0, p1 - p0);
|
||||
//glm::quat rt{};
|
||||
cout << sizeof(v0)<< " " << sizeof(glm::mat3x3) << " ";
|
||||
}
|
||||
6
engine/3rdparty/glm/xmake.lua
vendored
6
engine/3rdparty/glm/xmake.lua
vendored
@ -1,6 +0,0 @@
|
||||
|
||||
add_requires("glm")
|
||||
target("glm_test01_bezier")
|
||||
set_kind("binary")
|
||||
add_packages("glm")
|
||||
add_files("test/01bezier.cpp")
|
||||
14
engine/3rdparty/zasset/include/zasset/asset.h
vendored
14
engine/3rdparty/zasset/include/zasset/asset.h
vendored
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
namespace engineapi
|
||||
@ -5,18 +6,17 @@ namespace engineapi
|
||||
class Asset {
|
||||
public:
|
||||
enum {
|
||||
ASSET_NONE,
|
||||
ASSET_SHARED_TYPE,
|
||||
ASSET_COPY_TYPE,
|
||||
ASSET_ASYNC_TYPE,
|
||||
ASSET_LOADED_TYPE,
|
||||
ASSET_NUM,
|
||||
ASSET_NONE = 0,
|
||||
ASSET_SHARED_TYPE = 1 << 0,
|
||||
ASSET_COPY_TYPE = 1 << 1,
|
||||
ASSET_ASYNC_TYPE = 1 << 2,
|
||||
ASSET_LOADED_TYPE = 1 << 3,
|
||||
};
|
||||
protected:
|
||||
uint32_t mFlags;
|
||||
std::string mName;
|
||||
public:
|
||||
Asset(std::string& name, uint32_t flags):mName(name),mFlags(flags) {};
|
||||
Asset(std::string name, uint32_t flags):mName(name),mFlags(flags) {};
|
||||
virtual void onLoadFinished() { mFlags |= ASSET_LOADED_TYPE; };
|
||||
virtual void SyncLoad() {};
|
||||
virtual void AsyncLoad() {};
|
||||
|
||||
@ -12,33 +12,34 @@ namespace engineapi
|
||||
{
|
||||
public:
|
||||
struct AssetWrap {
|
||||
Asset& asset;
|
||||
Asset* asset;
|
||||
uint32_t count;
|
||||
AssetWrap(Asset& asset): asset(asset),count(0) {
|
||||
AssetWrap(Asset* asset): asset(asset),count(0) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::map<const std::string, AssetWrap> mAssetMap;
|
||||
public:
|
||||
template<typename TAsset>
|
||||
TAsset* LoadAsset(const std::string& asset_url,uint32_t flags)
|
||||
TAsset* LoadAsset(const std::string& asset_url, uint32_t types, uint32_t flags)
|
||||
{
|
||||
std::filesystem::path asset_path = getFullPath(asset_url);
|
||||
std::filesystem::path asset_path = getFullPath(asset_url, types);
|
||||
auto it = mAssetMap.find(asset_path.string());
|
||||
if (it != mAssetMap.end()) {
|
||||
if (it->second.asset.IsShared()) {
|
||||
return &(it->second.asset);
|
||||
if (it->second.asset->IsShared()) {
|
||||
return (TAsset*)(it->second.asset);
|
||||
}
|
||||
if (it->second.asset.IsCopyed()) {
|
||||
if (it->second.asset->IsCopyed()) {
|
||||
TAsset* asset = new TAsset(asset_path.string(), flags);
|
||||
*asset = it->second.asset;
|
||||
*asset = *(TAsset*)(it->second.asset);
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
TAsset* asset = new TAsset(asset_path.string(), flags);
|
||||
if (asset->IsShared() || asset->IsCopyed()) {
|
||||
mAssetMap.emplace(asset_path.string(), *asset);
|
||||
mAssetMap.emplace(asset_path.string(), asset);
|
||||
}
|
||||
if (asset->IsAsync()) {
|
||||
asset->AsyncLoad();
|
||||
@ -48,6 +49,8 @@ namespace engineapi
|
||||
}
|
||||
return asset;
|
||||
}
|
||||
std::filesystem::path getFullPath(const std::string& relative_path) const;
|
||||
std::filesystem::path getFullPath(const std::string& relative_path, uint32_t types) const;
|
||||
public:
|
||||
static AssetManager* Instance;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#include "zasset/asset_manager.h"
|
||||
|
||||
std::filesystem::path engineapi::AssetManager::getFullPath(const std::string& relative_path) const
|
||||
{
|
||||
return std::filesystem::path(relative_path);
|
||||
namespace engineapi {
|
||||
AssetManager* AssetManager::Instance = nullptr;
|
||||
std::filesystem::path AssetManager::getFullPath(const std::string& relative_path, uint32_t types) const
|
||||
{
|
||||
return std::filesystem::path(relative_path);
|
||||
}
|
||||
}
|
||||
|
||||
24
engine/src/engine/object/mesh/actor.cpp
Normal file
24
engine/src/engine/object/mesh/actor.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "actor.h"
|
||||
#include "zasset/asset_manager.h"
|
||||
#include "../property/actor_property.h"
|
||||
namespace engineapi {
|
||||
ActorMesh::ActorMesh(Mesh& mesh, ActorProperty& property)
|
||||
:DynamicMesh(mesh)
|
||||
,mProperty(property)
|
||||
{
|
||||
|
||||
}
|
||||
ActorMesh* ActorMesh::New(ActorProperty& property)
|
||||
{
|
||||
Mesh* mesh = AssetManager::Instance->LoadAsset<Mesh>(property.path, property.types, property.flags);
|
||||
return new ActorMesh(*mesh, property);
|
||||
}
|
||||
ActorMesh* ActorMesh::New(uint32_t id)
|
||||
{
|
||||
ActorProperty* property = Property::GetProperty<ActorProperty>(id);
|
||||
if (property) {
|
||||
return New(*property);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
14
engine/src/engine/object/mesh/actor.h
Normal file
14
engine/src/engine/object/mesh/actor.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "dynamic.h"
|
||||
namespace engineapi {
|
||||
class ActorProperty;
|
||||
class ActorMesh : public DynamicMesh {
|
||||
protected:
|
||||
ActorProperty& mProperty;
|
||||
public:
|
||||
ActorMesh(Mesh& mesh, ActorProperty& property);
|
||||
public:
|
||||
static ActorMesh* New(ActorProperty& property);
|
||||
static ActorMesh* New(uint32_t id);
|
||||
};
|
||||
}
|
||||
9
engine/src/engine/object/mesh/dynamic.cpp
Normal file
9
engine/src/engine/object/mesh/dynamic.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "dynamic.h"
|
||||
|
||||
namespace engineapi {
|
||||
DynamicMesh::DynamicMesh(Mesh& mesh)
|
||||
:StaticMesh(mesh)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
engine/src/engine/object/mesh/dynamic.h
Normal file
11
engine/src/engine/object/mesh/dynamic.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "static.h"
|
||||
namespace engineapi {
|
||||
class Mesh;
|
||||
class DynamicMesh : public StaticMesh{
|
||||
protected:
|
||||
|
||||
public:
|
||||
DynamicMesh(Mesh& mesh);
|
||||
};
|
||||
}
|
||||
13
engine/src/engine/object/mesh/static.cpp
Normal file
13
engine/src/engine/object/mesh/static.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "static.h"
|
||||
#include "engine/render/asset/mesh.h"
|
||||
|
||||
namespace engineapi {
|
||||
StaticMesh::StaticMesh(Mesh& mesh)
|
||||
:mPtr(mesh)
|
||||
{
|
||||
}
|
||||
void StaticMesh::LoadMesh()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
18
engine/src/engine/object/mesh/static.h
Normal file
18
engine/src/engine/object/mesh/static.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "glm/vec3.hpp"
|
||||
#include "engine/render/asset/mesh.h"
|
||||
namespace engineapi {
|
||||
class StaticMesh {
|
||||
protected:
|
||||
Mesh& mPtr;
|
||||
glm::vec3 mCenter;
|
||||
float mRadius;
|
||||
|
||||
public:
|
||||
StaticMesh(Mesh& mesh);
|
||||
|
||||
void LoadMesh();
|
||||
};
|
||||
}
|
||||
8
engine/src/engine/object/property/actor_property.h
Normal file
8
engine/src/engine/object/property/actor_property.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include "property.h"
|
||||
namespace engineapi {
|
||||
class ActorProperty :public Property{
|
||||
public:
|
||||
static const uint32_t Type = Property::ActorPropertyType;
|
||||
};
|
||||
}
|
||||
5
engine/src/engine/object/property/property.cpp
Normal file
5
engine/src/engine/object/property/property.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "property.h"
|
||||
|
||||
namespace engineapi {
|
||||
std::map<uint32_t, Property> Property::PropertyMap;
|
||||
}
|
||||
27
engine/src/engine/object/property/property.h
Normal file
27
engine/src/engine/object/property/property.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
namespace engineapi {
|
||||
class Property {
|
||||
public:
|
||||
enum {
|
||||
ActorPropertyType = 1,
|
||||
};
|
||||
public:
|
||||
uint32_t id = 0;
|
||||
uint32_t types = 0;
|
||||
uint32_t flags = 0;
|
||||
std::string path = "";
|
||||
public:
|
||||
static std::map<uint32_t, Property> PropertyMap;
|
||||
|
||||
template<typename TProperty>
|
||||
static TProperty* GetProperty(uint32_t id) {
|
||||
auto it = PropertyMap.find(id);
|
||||
if (it != PropertyMap.end() && it->second.types && TProperty::Type) {
|
||||
return (TProperty*)(&it->second);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
}
|
||||
0
engine/src/engine/render/asset/asset.cpp
Normal file
0
engine/src/engine/render/asset/asset.cpp
Normal file
9
engine/src/engine/render/asset/asset.h
Normal file
9
engine/src/engine/render/asset/asset.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "zasset/asset.h"
|
||||
|
||||
namespace engineapi {
|
||||
class AssetRender : public Asset {
|
||||
public:
|
||||
using Asset::Asset;
|
||||
};
|
||||
};
|
||||
0
engine/src/engine/render/asset/material.cpp
Normal file
0
engine/src/engine/render/asset/material.cpp
Normal file
7
engine/src/engine/render/asset/material.h
Normal file
7
engine/src/engine/render/asset/material.h
Normal file
@ -0,0 +1,7 @@
|
||||
#include "asset.h"
|
||||
|
||||
namespace engineapi {
|
||||
class Material : public AssetRender {
|
||||
|
||||
};
|
||||
};
|
||||
70
engine/src/engine/render/asset/mesh.cpp
Normal file
70
engine/src/engine/render/asset/mesh.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "mesh.h"
|
||||
#include "assimp/Importer.hpp"
|
||||
#include "assimp/scene.h"
|
||||
#include "assimp/postprocess.h"
|
||||
#include "zlog.h"
|
||||
namespace engineapi {
|
||||
void Mesh::SyncLoad()
|
||||
{
|
||||
std::vector<glm::vec3> vertexPositions = std::vector<glm::vec3>();
|
||||
Assimp::Importer importer;
|
||||
const aiScene* scene = importer.ReadFile(mName, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
|
||||
// process ASSIMP's root node recursively
|
||||
aiMesh* mesh = scene->mMeshes[scene->mRootNode->mMeshes[0]];
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
||||
{
|
||||
VertexData vertexData;
|
||||
glm::vec3 vector;
|
||||
// positions
|
||||
vector.x = mesh->mVertices[i].x;
|
||||
vector.y = mesh->mVertices[i].y;
|
||||
vector.z = mesh->mVertices[i].z;
|
||||
vertexData.position = vector;
|
||||
// normals
|
||||
if (mesh->HasNormals())
|
||||
{
|
||||
vector.x = mesh->mNormals[i].x;
|
||||
vector.y = mesh->mNormals[i].y;
|
||||
vector.z = mesh->mNormals[i].z;
|
||||
vertexData.normal = vector;
|
||||
}
|
||||
// texture coordinates
|
||||
if (mesh->mTextureCoords[0]) // does the mesh contain texture coordinates?
|
||||
{
|
||||
glm::vec2 vec;
|
||||
// a vertex can contain up to 8 different texture coordinates. We thus make the assumption that we won't
|
||||
// use models where a vertex can have multiple texture coordinates so we always take the first set (0).
|
||||
vec.x = mesh->mTextureCoords[0][i].x;
|
||||
vec.y = mesh->mTextureCoords[0][i].y;
|
||||
vertexData.texCoords = vec;
|
||||
// tangent
|
||||
vector.x = mesh->mTangents[i].x;
|
||||
vector.y = mesh->mTangents[i].y;
|
||||
vector.z = mesh->mTangents[i].z;
|
||||
vertexData.tangent = vector;
|
||||
// bitangent
|
||||
vector.x = mesh->mBitangents[i].x;
|
||||
vector.y = mesh->mBitangents[i].y;
|
||||
vector.z = mesh->mBitangents[i].z;
|
||||
vertexData.bitangent = vector;
|
||||
}
|
||||
else
|
||||
{
|
||||
zlog::info("Mesh do not contains uv.");
|
||||
}
|
||||
|
||||
mVertices.push_back(vertexData);
|
||||
vertexPositions.emplace_back(vertexData.position);
|
||||
}
|
||||
// now wak through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.
|
||||
for (unsigned int i = 0; i < mesh->mNumFaces; i++)
|
||||
{
|
||||
aiFace face = mesh->mFaces[i];
|
||||
// retrieve all indices of the face and store them in the indices vector
|
||||
for (unsigned int j = 0; j < face.mNumIndices; j++)
|
||||
mIndices.push_back(face.mIndices[j]);
|
||||
}
|
||||
importer.FreeScene();
|
||||
|
||||
}
|
||||
}
|
||||
31
engine/src/engine/render/asset/mesh.h
Normal file
31
engine/src/engine/render/asset/mesh.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "asset.h"
|
||||
#include "glm/vec2.hpp"
|
||||
#include "glm/vec3.hpp"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
namespace engineapi {
|
||||
class Texture;
|
||||
class Material;
|
||||
class Mesh : public AssetRender {
|
||||
public:
|
||||
struct VertexData
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec2 texCoords;
|
||||
glm::vec3 normal;
|
||||
glm::vec3 tangent;
|
||||
glm::vec3 bitangent;
|
||||
};
|
||||
protected:
|
||||
Material* mMaterial;
|
||||
std::map<const std::string*, Texture*> mTextureMap;
|
||||
|
||||
std::vector<VertexData> mVertices;
|
||||
std::vector<uint32_t> mIndices;
|
||||
|
||||
public:
|
||||
using AssetRender::AssetRender;
|
||||
void SyncLoad()override;
|
||||
};
|
||||
};
|
||||
0
engine/src/engine/render/asset/texture.cpp
Normal file
0
engine/src/engine/render/asset/texture.cpp
Normal file
7
engine/src/engine/render/asset/texture.h
Normal file
7
engine/src/engine/render/asset/texture.h
Normal file
@ -0,0 +1,7 @@
|
||||
#include "asset.h"
|
||||
|
||||
namespace engineapi {
|
||||
class Texture : public AssetRender {
|
||||
|
||||
};
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
#include "window.h"
|
||||
namespace renderapi {
|
||||
namespace engineapi {
|
||||
Window::WindowClass Window::WindowClass::wndClass;
|
||||
|
||||
Window::WindowClass::WindowClass() noexcept
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
namespace renderapi {
|
||||
namespace engineapi {
|
||||
class Window {
|
||||
protected:
|
||||
int mWidth;
|
||||
@ -68,10 +68,6 @@ namespace vulkanapi {
|
||||
}
|
||||
importer.FreeScene();
|
||||
|
||||
Backend::TransferWorker->InvokeBuffer([&](CommandBuffer* cmd) {
|
||||
cmd->CopyBuffer(&stageVertexBuffer, _vertexBuffer);
|
||||
cmd->CopyBuffer(&stageIndexBuffer, _indexBuffer);
|
||||
});
|
||||
}
|
||||
void Mesh::AsyncLoad()
|
||||
{
|
||||
@ -79,6 +75,7 @@ namespace vulkanapi {
|
||||
}
|
||||
void Mesh::BindCommand(CommandBuffer& cmd)
|
||||
{
|
||||
|
||||
//cmd->CopyBuffer(&stageVertexBuffer, _vertexBuffer);
|
||||
// cmd->CopyBuffer(&stageIndexBuffer, _indexBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,9 @@ namespace vulkanapi {
|
||||
|
||||
auto deviceCreator = DeviceCreator(*mInstance);
|
||||
deviceCreator.AddWindowExtension();
|
||||
deviceCreator.desiredPhysicalDeviceFeatures.geometryShader = VK_TRUE;
|
||||
deviceCreator.desiredPhysicalDeviceFeatures.independentBlend = true;
|
||||
deviceCreator.desiredPhysicalDeviceFeatures.depthClamp = true;
|
||||
//deviceCreator.desiredPhysicalDeviceFeatures.geometryShader = VK_TRUE;
|
||||
deviceCreator.AddQueue(Queue::TransferQueue, VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT, 1.0);
|
||||
deviceCreator.AddQueue(Queue::RenderQueue, VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT, 1.0);
|
||||
deviceCreator.AddQueue(Queue::ComputeQueue, VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT, 1.0);
|
||||
@ -40,12 +42,12 @@ namespace vulkanapi {
|
||||
auto queue = mDevice->GetQueue(name);
|
||||
if (queue) {
|
||||
auto worker = new CommandWorker(name, *mDevice, *queue, flag);
|
||||
mWorkerMap.emplace(name, worker);
|
||||
mWorkerMap.emplace(&name, worker);
|
||||
}
|
||||
}
|
||||
CommandWorker* Backend::GetWorker(const std::string& name)
|
||||
{
|
||||
auto it = mWorkerMap.find(name);
|
||||
auto it = mWorkerMap.find(&name);
|
||||
if (it != mWorkerMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ namespace vulkanapi {
|
||||
protected:
|
||||
Instance* mInstance;
|
||||
Device* mDevice;
|
||||
std::map<const std::string&, CommandWorker*> mWorkerMap;
|
||||
std::map<const std::string*, CommandWorker*> mWorkerMap;
|
||||
public:
|
||||
static CommandWorker* TransferWorker;
|
||||
public:
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#include "record.h"
|
||||
#include <iostream>
|
||||
#include <engine/vulkanapi/device/device.h>
|
||||
namespace vulkanapi {
|
||||
CommandRecord::CommandRecord()
|
||||
{
|
||||
mParts.reserve(64);
|
||||
}
|
||||
void CommandRecord::Apply(CommandBuffer* buf)
|
||||
{
|
||||
for (auto cmd : mParts) {
|
||||
cmd(buf);
|
||||
}
|
||||
}
|
||||
void CommandRecord::Record(CommandFn cmd)
|
||||
{
|
||||
mParts.push_back(cmd);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "engine/vulkanapi/vulkan.h"
|
||||
namespace vulkanapi {
|
||||
class CommandBuffer;
|
||||
typedef void (*CommandFn)(CommandBuffer* buf);
|
||||
class CommandRecord {
|
||||
protected:
|
||||
std::vector<CommandFn> mParts;
|
||||
public:
|
||||
CommandRecord();
|
||||
void Apply(CommandBuffer* buf);
|
||||
void Record(CommandFn cmd);
|
||||
};
|
||||
};
|
||||
@ -7,7 +7,7 @@
|
||||
#include <vulkan/vulkan_win32.h>
|
||||
namespace vulkanapi {
|
||||
Window::Window(Backend& backend, int frames, uint32_t width, uint32_t height, const char* title)
|
||||
:renderapi::Window(width, height , title)
|
||||
:engineapi::Window(width, height , title)
|
||||
, mSurfaceKHR(nullptr)
|
||||
, mSwapchain(nullptr)
|
||||
{
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "engine/renderapi/window.h"
|
||||
#include "engine/render/window.h"
|
||||
#include "vulkan.h"
|
||||
namespace vulkanapi {
|
||||
class Backend;
|
||||
class Swapchain;
|
||||
class Window : public renderapi::Window {
|
||||
class Window : public engineapi::Window {
|
||||
protected:
|
||||
VkSurfaceKHR mSurfaceKHR{NULL};
|
||||
Swapchain* mSwapchain;
|
||||
|
||||
@ -29,14 +29,15 @@ namespace vulkanapi {
|
||||
device_create_info.enabledLayerCount = layers.size();
|
||||
device_create_info.ppEnabledLayerNames = layers.data();
|
||||
#endif // _USE_GRAPHIC_DEBUG
|
||||
system("cls");
|
||||
VkResult result = vkCreateDevice(mPhysical, &device_create_info, nullptr, &mPtr);
|
||||
if ((result != VK_SUCCESS) || (mPtr == VK_NULL_HANDLE)) {
|
||||
zlog::error("Could not create logical device.");
|
||||
zlog::error("Could not create logical device. VkResult {}", result);
|
||||
}
|
||||
for (auto& queue : Creator.desiredQueues) {
|
||||
Queue* gq = new Queue(queue.name, queue.queueFamilyIndex, VK_NULL_HANDLE);
|
||||
vkGetDeviceQueue(mPtr, queue.queueFamilyIndex, 0, &(gq->Ptr()));
|
||||
mQueueMap.emplace(queue.name, gq);
|
||||
mQueueMap.emplace(&queue.name, gq);
|
||||
}
|
||||
}
|
||||
Device::~Device() {
|
||||
@ -47,7 +48,7 @@ namespace vulkanapi {
|
||||
}
|
||||
Queue* Device::GetQueue(const std::string& name)
|
||||
{
|
||||
auto it = mQueueMap.find(name);
|
||||
auto it = mQueueMap.find(&name);
|
||||
if (it != mQueueMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ namespace vulkanapi {
|
||||
protected:
|
||||
VkDevice mPtr{ NULL };
|
||||
VkPhysicalDevice mPhysical{NULL};
|
||||
std::map<const std::string&, Queue*> mQueueMap;
|
||||
std::map<const std::string*, Queue*> mQueueMap;
|
||||
public:
|
||||
VkDevice& Ptr() {
|
||||
return mPtr;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "device.h"
|
||||
#include "device_creator.h"
|
||||
#include "instance.h"
|
||||
#include "queue.h"
|
||||
#include "zlog.h"
|
||||
namespace vulkanapi {
|
||||
DeviceCreator::DeviceCreator(Instance& instance)
|
||||
@ -18,10 +18,10 @@ namespace vulkanapi {
|
||||
void DeviceCreator::AddWindowExtension()
|
||||
{
|
||||
AddExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
AddQueue("PresentQueue", VK_QUEUE_FLAG_BITS_MAX_ENUM, 1.0f);
|
||||
//AddQueue(Queue::PresentQueue, VK_QUEUE_FLAG_BITS_MAX_ENUM, 1.0f);
|
||||
#ifdef _USE_GRAPHIC_DEBUG
|
||||
AddLayer("VK_LAYER_KHRONOS_validation");
|
||||
AddLayer("VK_LAYER_RENDERDOC_Capture");
|
||||
//AddLayer("VK_LAYER_KHRONOS_validation");
|
||||
//AddLayer("VK_LAYER_RENDERDOC_Capture");
|
||||
#endif
|
||||
}
|
||||
bool DeviceCreator::CheckProperty(const VkPhysicalDevice device)
|
||||
@ -101,7 +101,7 @@ namespace vulkanapi {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index != -1 && queue_create_infos[index].queueCount < queue_families[index].queueCount) {
|
||||
if (index != -1 && queue_create_infos[index].queueCount < 1) {
|
||||
queue.queueFamilyIndex = index;
|
||||
queue_create_infos[index].queueCount++;
|
||||
queue_prioritie[index].push_back(queue.prioritie);
|
||||
|
||||
@ -22,7 +22,7 @@ namespace vulkanapi {
|
||||
public:
|
||||
VkPhysicalDeviceFeatures desiredPhysicalDeviceFeatures;
|
||||
VkPhysicalDeviceType desiredPhysicalDeviceType;
|
||||
std::vector<const std::string> desiredExtensions;
|
||||
std::vector<std::string> desiredExtensions;
|
||||
std::vector<DesiredQueue> desiredQueues;
|
||||
public:
|
||||
Instance& instance;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
#include "instance_creator.h"
|
||||
#include "zlog.h"
|
||||
@ -36,6 +35,7 @@ namespace vulkanapi {
|
||||
{
|
||||
AddLayer("VK_LAYER_KHRONOS_validation");
|
||||
AddLayer("VK_LAYER_RENDERDOC_Capture");
|
||||
AddLayer("VK_LAYER_LUNARG_api_dump");
|
||||
AddExtension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
AddExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ namespace vulkanapi {
|
||||
const std::string Queue::ComputeQueue("ComputeQueue");
|
||||
const std::string Queue::PresentQueue("PresentQueue");
|
||||
Queue::Queue(const std::string& name, uint32_t queueFamilyIndex, VkQueue queue)
|
||||
: mName(name), mQueueFamilyIndex(queueFamilyIndex), mPtr(queue), mMtx()
|
||||
: mName(name), mQueueFamilyIndex(queueFamilyIndex), mPtr(queue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -4,8 +4,10 @@
|
||||
#include "engine/vulkanapi/window.h"
|
||||
#include "engine/vulkanapi/pass/gbuffer.h"
|
||||
#include "engine/vulkanapi/pass/forwardpass.h"
|
||||
#include "engine/object/mesh/actor.h"
|
||||
#include "engine/object/property/actor_property.h"
|
||||
#include "zlog.h"
|
||||
|
||||
using namespace engineapi;
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const char* name = "zengine";
|
||||
@ -14,8 +16,13 @@ int main(int argc, char** argv)
|
||||
auto wnd = vulkanapi::Window(vulkan, 3, 640, 720, name);
|
||||
auto gbuffer = vulkanapi::GeometryBuffer(vulkan.GetDevice(), 3, 640, 720);
|
||||
auto forwardpass = vulkanapi::ForwardPass(vulkan.GetDevice(), gbuffer);
|
||||
ActorProperty property;
|
||||
property.id = 1;
|
||||
property.path = "assets/models/cube.obj";
|
||||
auto actor = ActorMesh::New(property);
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
delete actor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ target("zengine")
|
||||
set_kind("binary")
|
||||
set_rundir(".")
|
||||
add_deps("zcoro","zlog","zasset")
|
||||
add_packages("vulkansdk","tinyobjloader","glm","assimp")
|
||||
add_packages("vulkansdk","tinyobjloader","assimp")
|
||||
add_includedirs("src")
|
||||
add_syslinks("user32")
|
||||
add_files("src/*.cpp", "src/**.cpp")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user