Skip to content

Commit

Permalink
Dev (#22)
Browse files Browse the repository at this point in the history
Improving vulkan backend and working with new record API for vulkan.
  • Loading branch information
SpinnerX authored Sep 9, 2024
1 parent 2663004 commit 95e0c22
Show file tree
Hide file tree
Showing 54 changed files with 2,597 additions and 549 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: ✅ CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 12 * * 0"

jobs:
secrets: inherit
14 changes: 6 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Breaking change was removing the bit timing sections from hal::can::settings,
# now it is just baud_rate.
name: 🚀 Deploy Version

on:
workflow_dispatch:

jobs:
deploy:
if: startsWith(github.ref, 'refs/tags/')
uses: engine3d-dev/ci/.github/workflows/[email protected]
engine3d:
uses: engine3d-dev/ci/.github/workflows/deploy.yml@main
with:
compiler: gcc
version: ${{ github.ref_name }}
# version: ${{ github.ref_name }}
arch: x86_64
compiler_version: 12.3
compiler_package: ""
os: Linux
secrets: inherit
secrets: inherit
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "engine3d/Core/backend/third_party/JolyPhysics"]
path = engine3d/Core/backend/third_party/JolyPhysics
url = https://github.com/engine3d-dev/JoltPhysics
[submodule "engine3d/Core/backend/third_party/imgui"]
path = engine3d/Core/backend/third_party/imgui
url = https://github.com/SpinnerX/imgui
[submodule "engine3d/Core/backend/third_party/ImGuizmo"]
path = engine3d/Core/backend/third_party/ImGuizmo
url = https://github.com/SpinnerX/ImGuizmo
67 changes: 25 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,24 @@ project(engine3d C CXX)

set(CMAKE_CXX_STANDARD 23)

# Setting the makefile location in chocolatey
# set(CMAKE_MAKE_PROGRAM "${env:ChocolateyInstall}")
# set(CMAKE_GENERATOR "Unix Makefiles")
# message("generator is set to ${CMAKE_GENERATOR}/make.exe")
# set(CMAKE_MAKE_PROGRAM $ENV{ChocolateyInstall}/make.exe)
# message("Testing message from engine3d/CMakeLists.txt!!!")
# message("Choco make directory ===============>>> ${CMAKE_MAKE_PROGRAM}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # works (in creating the compile_commands.json file)

find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(Vulkan REQUIRED)
find_package(VulkanHeaders REQUIRED)
find_package(glm REQUIRED)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(imguidocking REQUIRED)
find_package(box2d REQUIRED)
# find_package(SPIRV-Tools REQUIRED)
# add_subdirectory(engine3d/Core/backend/third_party/JoltPhysics)

include(FetchContent)

# Include Jolt (3D Physics framework)
FetchContent_Declare(
JoltPhysics
GIT_REPOSITORY "https://github.com/engine3d-dev/JoltPhysics"
SOURCE_SUBDIR "build"
)

FetchContent_MakeAvailable(JoltPhysics)

# find_package(shaderc REQUIRED)
# find_package(joltphysics REQUIRED)
# For some reason draco is having some errors with ftell in one of it's files
# Draco is a dependency for using assimp
find_package(joltphysics REQUIRED)
# find_package(assimp REQUIRED)
# find_package(shaderc REQUIRED)

add_subdirectory(src)
add_subdirectory(Editor)
add_subdirectory(Testbed)

# This will run the build doing -j which is building at full capacity.
# TODO - Should probably have this be disabled by default and have this be a flag set through conan.
# add_custom_target(my_parallel_build
# COMMAND ${CMAKE_COMMAND} --build -j
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# COMMENT "My parallel build with 5 cores")
# add_subdirectory(Editor)

# Copy to source directory
# Copy to compile_commands.json for .clangd
add_custom_target(
copy-compile-commands ALL
DEPENDS
Expand Down Expand Up @@ -90,26 +56,43 @@ add_custom_command(
# Usage - used to suppress that lld-link error and use the defaulted linked .library
if(MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "/Z1" "/NOD")
# else()
# target_compile_options(${PROJECT_NAME} PUBLIC "-fsanitize=address")
endif(MSVC)

# target_include_directory is setting some private settings for differentiating what internal includes are privates and what should be includes should be exposed to the application-dev
target_include_directories(${PROJECT_NAME} PRIVATE engine3d/ engine3d/Core)
message("PROJECT SOURCE DIR ====>>> ${CMAKE_SOURCE_DIR}")
<<<<<<< HEAD
=======
# message("PROJECT SOURCE DIR ====>>> ${CMAKE_SOURCE_DIR}")
>>>>>>> fa59aaf07c9cbf80f5d25918c4d43b3cca25238f
target_include_directories(${PROJECT_NAME} PUBLIC ${JoltPhysics_SOURCE_DIR} ${GLM_INCLUDE_DIR} ./engine3d)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
PRIVATE
glfw
${OPENGL_LIBRARIES}
Vulkan::Vulkan
vulkan-headers::vulkan-headers
<<<<<<< HEAD
=======
# vulkan-headers::vulkan-headers
>>>>>>> fa59aaf07c9cbf80f5d25918c4d43b3cca25238f
glm::glm
fmt::fmt
spdlog::spdlog
yaml-cpp::yaml-cpp
<<<<<<< HEAD
imguidocking::imguidocking
box2d::box2d
Jolt
Jolt::Jolt
=======
# box2d::box2d
# Jolt
imguidocking::imguidocking
Jolt::Jolt
# shaderc::shaderc
>>>>>>> fa59aaf07c9cbf80f5d25918c4d43b3cca25238f
)

install(TARGETS ${PROJECT_NAME})
26 changes: 13 additions & 13 deletions Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
cmake_minimum_required(VERSION 3.15)
project(Editor CXX)

include_directories(
../
)

set(
all_src
Editor/Editor.h
Editor/Editor.cpp
Editor/EngineLayer.cpp
Editor/UILayer.cpp
platforms/main.cpp
platforms/win32.cpp
)

find_package(spdlog REQUIRED)
find_package(glm REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(Vulkan REQUIRED)
find_package(imguidocking REQUIRED)
find_package(engine3d REQUIRED)

add_executable(${PROJECT_NAME} ${all_src})

# target_link_libraries(${PROJECT_NAME} engine3d)
target_include_directories(${PROJECT_NAME} PRIVATE ../)

target_link_libraries(
${PROJECT_NAME}
engine3d
glfw
glm::glm
fmt::fmt
spdlog::spdlog
glm::glm
yaml-cpp::yaml-cpp
box2d::box2d
# joltphysics::joltphysics
Vulkan::Vulkan
imguidocking::imguidocking
engine3d::engine3d
)
116 changes: 50 additions & 66 deletions Editor/Editor/Editor.cpp
Original file line number Diff line number Diff line change
@@ -1,87 +1,71 @@
#include "Editor.h"
#include "EngineLayer.h"
#include "UILayer.h"
#include <engine3d/Core/Event/InputPoll.h>
#include "engine3d/Core/EngineLogger.h"
#include "engine3d/Core/Renderer/Renderer.h"
#include <engine3d/Core/Timestep.h>
#include <GLFW/glfw3.h>
#include <imgui/imgui.h>

namespace engine3d{

EditorApplication::EditorApplication(){
InitiateEditor();
EditorApplication::EditorApplication(const std::string& p_DebugName) : ApplicationInstance(p_DebugName) {
<<<<<<< HEAD
Renderer::Initialize();
Renderer::SetBackgroundColor({1.0f, 0.0f, 0.0f, 0.0f});
}

EditorApplication::~EditorApplication(){
ShutdownEditor();
}
EditorApplication::~EditorApplication() {}

void EditorApplication::InitiateEditor(){
//! @note Initially we will have our actual rendering and everything engine-related in EngineLayer
//! @note UILayer is where all of the UI-related stuff are done.
//! @note UILayer for right now is used for initiating any imgui related configurations.
m_Layers[0] = new EngineLayer();
m_Layers[0]->OnAttach();
m_Layers[1] = new UILayer();
m_Layers[1]->OnAttach();
void EditorApplication::UpdateThisApplicationInstance(){

Renderer::Initialize();

//! @note Setting our color to being light blue
Renderer::SetBackgroundColor({0.0f, 0.5f, 0.5f, 0.f});
// Renderer::SetBackgroundColor({1.0f, 0.0f, 0.0f, 1.0f});

// m_CmdBuffer = vk::VulkanCommandBuffer(vk::VulkanSwapchain::GetImagesSize());
// m_CmdBuffer.RecordCommandBuffers();

//! @param index, zero - indicates getting first data in queue at index 0 (zero)
//! @note TODO -- for cmd buffers/queues, shader modules, and render passes. Figuring out what parameters are important that users should specify when creating this instance
//! @note This is because as it stands the API requires for instancing the object before initializing it, but should just utilize the constructor to cleanup the API for initiating our object's lifetimes.
// m_CmdQueue = vk::VulkanCommandQueue(0);
// m_RenderPass.InitializeRenderPass();
// m_RenderPass.InitializeFramebuffers();
// m_TriangleShaderVertModule = vk::VulkanShaderModule("Resources/shaders/TriangleShader/triangle.vert.spirv");
// m_TriangleShaderFragModule = vk::VulkanShaderModule("Resources/shaders/TriangleShader/triangle.frag.spirv");
// engine3d::UILayer::InitializeUI(m_CmdQueue.GetVkQueueInstance());

// m_ShaderPipeline = vk::VulkanShaderCompiler(m_TriangleShaderVertModule.GetVkShaderModuleInstance(), m_TriangleShaderFragModule.GetVkShaderModuleInstance(), m_RenderPass.GetRenderPassInstnace());

//! @note Just testing to see if application still closes cleanly.
// if(InputPoll::IsKeyPressed(ENGINE_KEY_ESCAPE)){
// exit(0);
// }

//! @note This function will render our primitives
//! @note TODO -- Flush should only happens when our scene is given everything that lives within this scene (ref to lifetimes)
/* Renderer::FlushScene(); */

Renderer::Presentation();
// ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
// ImGui::End();
}

void EditorApplication::ShutdownEditor(){
// m_Pipeline.CleanupPipeline();
// m_VulkDevice.CleanupDevice();
ApplicationInstance* InitializeApplication(){
return new EditorApplication();
}

void EditorApplication::RunEditor(){
=======
/* Renderer::Initialize(); */
/* Renderer::SetBackgroundColor({0.0f, 0.5f, 0.5f, 0.f}); */
Renderer::SetBackgroundColor({1.0f, 0.0f, 0.0f, 0.0f});

while(!glfwWindowShouldClose(vk::VulkanPipeline::GetCurrentWindow())){
m_LastFrameTime = (float)glfwGetTime();
Timerstep ts = m_LastFrameTime;
ConsoleLogInfo("Initializing Current Application Name === {}!!!", ApplicationInstance::CurrentApplicationName());
}

for(const auto& layer : m_Layers){
layer->OnUpdate(ts);
}
EditorApplication::~EditorApplication() {}

// Clearing screen
// uint32_t idx = m_CmdQueue.AcquireNextImage();
// m_CmdQueue.WaitIdleFence();
// m_CmdQueue.SubmitAsync(m_CmdBuffer[idx]);
// // m_CmdQueue.WaitIdle();
// m_CmdQueue.WaitIdleFence();
// m_CmdQueue.Presentation(idx);
Renderer::FlushScene();
void EditorApplication::UpdateThisApplicationInstance(){

//! @note Just testing to see if application still closes cleanly.
// if(InputPoll::IsKeyPressed(ENGINE_KEY_ESCAPE)){
// exit(0);
// }

//! @note This function will render our primitives
//! @note TODO -- Flush should only happens when our scene is given everything that lives within this scene (ref to lifetimes)
/* Renderer::FlushScene(); */

Renderer::Presentation();
// ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
// ImGui::End();
}

// m_RenderPass.BeginPass(idx, m_CmdBuffer[idx], VK_SUBPASS_CONTENTS_INLINE, m_ShaderPipeline.GetShaderPipeline());
// vkCmdBindPipeline(m_CmdBuffer[idx], VK_PIPELINE_BIND_POINT_GRAPHICS, m_ShaderPipeline.GetShaderPipeline());
// vkCmdDraw(m_CmdBuffer[idx], 3, 1, 0, 0);
// m_RenderPass.EndPass(m_CmdBuffer[idx]);
ApplicationInstance* InitializeApplication(){
return new EditorApplication();
}

for(const auto& layer : m_Layers){
layer->OnUIRender();
}
>>>>>>> fa59aaf07c9cbf80f5d25918c4d43b3cca25238f

glfwPollEvents();
}
}

};
};
27 changes: 10 additions & 17 deletions Editor/Editor/Editor.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
#pragma once
#include <engine3d/Core/EngineLogger.h>
#include <engine3d/Core/BaseApplication.h>
#include <engine3d/Core/backend/Vulkan/Vulkan.h>
#include <engine3d/Core/backend/Vulkan/VulkanDevice.h>
#include <engine3d/Core/backend/Vulkan/VulkanSwapchain.h>
#include <engine3d/Core/backend/Vulkan/VulkanCommandBuffer.h>
#include <engine3d/Core/backend/Vulkan/VulkanCommandQueue.h>
#include <engine3d/Core/Layer.h>
#include <array>
#include <engine3d/Core/ApplicationInstance.h>

namespace engine3d{

//! @note Our actual editor application
class EditorApplication{
//! @note TODO -- Having a cenrtal application that will be used across both editor and the game(being developed)
//! @note So when they're packaged, they can be shipped under one application excluding editor stuff and only things relevant to the game.
class EditorApplication : public ApplicationInstance{
public:
EditorApplication();
~EditorApplication();

void RunEditor();
EditorApplication(const std::string& debugName = "Engine3D Editor");
virtual ~EditorApplication();
private:
void InitiateEditor();
void ShutdownEditor();
//! @note TODO -- Probably have a cleanup handler for this
//! @note Such as WorldCleanup() or some API to make sure we can cleanly deallocate and delete things...
// void ShutdownEditor();
void UpdateThisApplicationInstance() override;

private:
//! @note Editor application, Engine, UI Layer.
std::array<Layer *, 1> m_Layers;
float m_LastFrameTime = 0.0f;
};
};
Loading

0 comments on commit 95e0c22

Please sign in to comment.