depth-prepass #1
@@ -9,9 +9,6 @@ add_subdirectory(dependencies/libFGL)
|
||||
|
||||
PreSetup()
|
||||
|
||||
#file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/data)
|
||||
|
||||
#Enable cmake_modules
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
|
||||
|
||||
message("-- CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||
@@ -22,7 +19,6 @@ include(dependencies/glfw)
|
||||
include(dependencies/glm)
|
||||
include(cmake_modules/dependencies/tracy.cmake)
|
||||
include(dependencies/vulkan)
|
||||
include(dependencies/catch2)
|
||||
include(dependencies/slang)
|
||||
include(dependencies/json)
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/dependencies/catch2)
|
||||
@@ -3,7 +3,6 @@ add_subdirectory(vma)
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(objectloaders)
|
||||
add_subdirectory(editor)
|
||||
add_subdirectory(tests)
|
||||
|
||||
message("-- Creating SYMLINK ${CMAKE_BINARY_DIR}/shaders -> ${CMAKE_CURRENT_SOURCE_DIR}/shaders")
|
||||
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${CMAKE_BINARY_DIR}/bin/shaders SYMBOLIC)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace fgl::engine::components
|
||||
}
|
||||
}
|
||||
|
||||
TransformComponent::TransformComponent()
|
||||
TransformComponent::TransformComponent() : m_transform()
|
||||
{}
|
||||
|
||||
TransformComponent::TransformComponent( const WorldTransform& transform ) : m_transform( transform )
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_vulkan.h>
|
||||
|
||||
@@ -50,26 +51,28 @@ namespace fgl::editor
|
||||
|
||||
ImGui_ImplGlfw_InitForVulkan( window.window(), true );
|
||||
ImGui_ImplVulkan_InitInfo init_info {
|
||||
.ApiVersion = VK_API_VERSION_1_4,
|
||||
.Instance = device.instance(),
|
||||
.PhysicalDevice = *device.phyDevice().handle(),
|
||||
.Device = *device,
|
||||
.QueueFamily = device.phyDevice().queueInfo().getIndex( vk::QueueFlagBits::eGraphics ),
|
||||
.Queue = *device.graphicsQueue(),
|
||||
.DescriptorPool = *DescriptorPool::getInstance().getPool(),
|
||||
.RenderPass = VK_NULL_HANDLE,
|
||||
.DescriptorPoolSize = 0,
|
||||
.MinImageCount = 2,
|
||||
.ImageCount = 2,
|
||||
.MSAASamples = VK_SAMPLE_COUNT_1_BIT,
|
||||
|
||||
.PipelineCache = VK_NULL_HANDLE,
|
||||
.RenderPass = VK_NULL_HANDLE,
|
||||
.Subpass = 0,
|
||||
.MSAASamples = VK_SAMPLE_COUNT_1_BIT,
|
||||
|
||||
.UseDynamicRendering = VK_TRUE,
|
||||
.PipelineRenderingCreateInfo = pipeline_info,
|
||||
|
||||
.Allocator = VK_NULL_HANDLE,
|
||||
.CheckVkResultFn = VK_NULL_HANDLE,
|
||||
.MinAllocationSize = 1024 * 1024
|
||||
.MinAllocationSize = 1024 * 1024,
|
||||
|
||||
};
|
||||
|
||||
ImGui_ImplVulkan_Init( &init_info );
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#include <imgui_internal.h> // Included for DockBuilder since it's not exposed yet
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -15,7 +16,6 @@
|
||||
#include "FileBrowser.hpp"
|
||||
#include "engine/assets/model/Model.hpp"
|
||||
#include "engine/debug/DEBUG_NAMES.hpp"
|
||||
#include "engine/descriptors/DescriptorPool.hpp"
|
||||
#include "engine/rendering/Renderer.hpp"
|
||||
#include "gui_window_names.hpp"
|
||||
#include "safe_include.hpp"
|
||||
@@ -96,9 +96,9 @@ namespace fgl::engine::gui
|
||||
// ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
static std::weak_ptr< GameObject > selected_object {};
|
||||
static std::weak_ptr< GameObject > SELECTED_OBJECT {};
|
||||
|
||||
void itterateGameObjectNode( FrameInfo& info, OctTreeNode& node )
|
||||
void itterateGameObjectNode( [[maybe_unused]] FrameInfo& info, [[maybe_unused]] OctTreeNode& node )
|
||||
{
|
||||
/*
|
||||
if ( node.isLeaf() )
|
||||
@@ -161,7 +161,7 @@ namespace fgl::engine::gui
|
||||
|
||||
if ( ImGui::Selectable( object->getName().c_str() ) )
|
||||
{
|
||||
selected_object = object;
|
||||
SELECTED_OBJECT = object;
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
@@ -194,13 +194,13 @@ namespace fgl::engine::gui
|
||||
ZoneScoped;
|
||||
ImGui::Begin( ENTITY_INFO_NAME );
|
||||
|
||||
if ( selected_object.expired() )
|
||||
if ( SELECTED_OBJECT.expired() )
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto object { selected_object.lock() };
|
||||
const auto object { SELECTED_OBJECT.lock() };
|
||||
|
||||
drawObject( *object );
|
||||
drawComponentsList( *object );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
file(GLOB_RECURSE CPP_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/**.hpp"
|
||||
)
|
||||
|
||||
AddFGLLibrary(FGLEngine STATIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -13,34 +13,45 @@ target_link_libraries(FGLEngine PUBLIC stdc++exp)
|
||||
include(dependencies/spdlog)
|
||||
include(dependencies/imgui)
|
||||
|
||||
target_link_libraries(FGLEngine PUBLIC Vulkan::Vulkan glm ImGui FGLLoader spdlog slang)
|
||||
target_link_libraries(FGLEngine PUBLIC Vulkan::Vulkan ImGui FGLLoader spdlog slang glm)
|
||||
target_include_directories(FGLEngine SYSTEM PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
target_link_libraries(FGLEngine PUBLIC glfw Tracy::TracyClient VMA)
|
||||
target_include_directories(FGLEngine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
target_compile_features(FGLEngine PUBLIC cxx_std_23)
|
||||
|
||||
target_precompile_headers(FGLEngine PUBLIC
|
||||
<spdlog/spdlog.h>
|
||||
|
||||
<glm/vec4.hpp>
|
||||
<glm/vec3.hpp>
|
||||
<glm/vec2.hpp>
|
||||
|
||||
<imgui.h>
|
||||
)
|
||||
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_UPPER_BUILD_TYPE)
|
||||
|
||||
if (NOT DEFINED FGL_ENABLE_IMGUI AND CMAKE_UPPER_BUILD_TYPE STREQUAL "DEBUG")
|
||||
set(FGL_ENABLE_IMGUI 1)
|
||||
set(FGL_ENABLE_IMGUI 1)
|
||||
endif ()
|
||||
|
||||
message("-- FGL_ENABLE_IMGUI: ${FGL_ENABLE_IMGUI}")
|
||||
|
||||
|
||||
if (FGL_ENABLE_IMGUI)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI_DRAWERS=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI_DRAWERS=1)
|
||||
else ()
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI_DRAWERS=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_IMGUI_DRAWERS=0)
|
||||
endif ()
|
||||
|
||||
if (DEFINED FGL_ENABLE_TESTS AND FGL_ENABLE_TESTS)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_TESTS=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_ENABLE_TEST_ASSERT=1)
|
||||
target_link_libraries(FGLEngine PUBLIC Catch2::Catch2)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_TESTS=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_ENABLE_TEST_ASSERT=1)
|
||||
else ()
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_TESTS=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_ENABLE_TEST_ASSERT=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_TESTS=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC FGL_ENABLE_TEST_ASSERT=0)
|
||||
endif ()
|
||||
|
||||
# Enable tracking for buffers, I need to find some way to disable this when trying to link
|
||||
@@ -52,7 +63,7 @@ target_compile_definitions(FGLEngine PUBLIC TRACK_BUFFERS)
|
||||
target_compile_definitions(FGLEngine PUBLIC GLM_FORCE_RADIANS GLM_FORCE_DEPTH_ZERO_TO_ONE)
|
||||
|
||||
if (DEFINED FGL_ENABLE_CALIBRATED_PROFILING AND FGL_ENABLE_CALIBRATED_PROFILING)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_CALIBRATED_PROFILING=1)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_CALIBRATED_PROFILING=1)
|
||||
else ()
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_CALIBRATED_PROFILING=0)
|
||||
target_compile_definitions(FGLEngine PUBLIC ENABLE_CALIBRATED_PROFILING=0)
|
||||
endif ()
|
||||
|
||||
@@ -31,7 +31,8 @@ namespace fgl::engine
|
||||
EngineContext::EngineContext() :
|
||||
m_ubo_buffer_pool( 1_MiB, vk::BufferUsageFlagBits::eUniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||
m_delta_time( 0.0 ),
|
||||
m_camera_manager()
|
||||
m_camera_manager(),
|
||||
m_sun( nullptr )
|
||||
{
|
||||
ZoneScoped;
|
||||
using namespace fgl::literals::size_literals;
|
||||
@@ -44,8 +45,6 @@ namespace fgl::engine
|
||||
// memory::TransferManager::createInstance( device, 128_MiB );
|
||||
}
|
||||
|
||||
static Average< float, 60 * 15 > rolling_ms_average;
|
||||
|
||||
void EngineContext::processInput()
|
||||
{
|
||||
auto timer = debug::timing::push( "Process Inputs" );
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace fgl::engine
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||
|
||||
constexpr vk::AccessFlags getAccessFlags( const vk::ImageLayout layout )
|
||||
{
|
||||
switch ( layout )
|
||||
@@ -27,13 +30,8 @@ namespace fgl::engine
|
||||
FGL_UNREACHABLE();
|
||||
case vk::ImageLayout::eUndefined:
|
||||
return vk::AccessFlagBits::eNone;
|
||||
case vk::ImageLayout::eGeneral:
|
||||
break;
|
||||
case vk::ImageLayout::eColorAttachmentOptimal:
|
||||
return vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite;
|
||||
break;
|
||||
case vk::ImageLayout::eDepthStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eShaderReadOnlyOptimal:
|
||||
return vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eInputAttachmentRead;
|
||||
case vk::ImageLayout::eTransferSrcOptimal:
|
||||
@@ -42,50 +40,18 @@ namespace fgl::engine
|
||||
return vk::AccessFlagBits::eTransferWrite;
|
||||
case vk::ImageLayout::ePreinitialized:
|
||||
return vk::AccessFlagBits::eHostWrite;
|
||||
case vk::ImageLayout::eDepthReadOnlyStencilAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eStencilAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthStencilAttachmentOptimal:
|
||||
[[fallthrough]];
|
||||
case vk::ImageLayout::eDepthReadOnlyOptimal:
|
||||
[[fallthrough]];
|
||||
case vk::ImageLayout::eDepthAttachmentOptimal:
|
||||
return vk::AccessFlagBits::eDepthStencilAttachmentWrite;
|
||||
case vk::ImageLayout::eStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::ePresentSrcKHR:
|
||||
return vk::AccessFlags( 0 );
|
||||
case vk::ImageLayout::eVideoDecodeDstKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoDecodeSrcKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoDecodeDpbKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eSharedPresentKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eFragmentDensityMapOptimalEXT:
|
||||
break;
|
||||
case vk::ImageLayout::eFragmentShadingRateAttachmentOptimalKHR:
|
||||
return vk::AccessFlagBits::eFragmentShadingRateAttachmentReadKHR;
|
||||
case vk::ImageLayout::eRenderingLocalReadKHR:
|
||||
return vk::AccessFlagBits::eColorAttachmentWrite;
|
||||
case vk::ImageLayout::eVideoEncodeDstKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeSrcKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeDpbKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eAttachmentFeedbackLoopOptimalEXT:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeQuantizationMapKHR:
|
||||
break;
|
||||
}
|
||||
|
||||
FGL_UNREACHABLE();
|
||||
@@ -99,69 +65,23 @@ namespace fgl::engine
|
||||
FGL_UNREACHABLE();
|
||||
case vk::ImageLayout::eUndefined:
|
||||
return vk::PipelineStageFlagBits::eTopOfPipe;
|
||||
case vk::ImageLayout::eGeneral:
|
||||
break;
|
||||
case vk::ImageLayout::eColorAttachmentOptimal:
|
||||
return vk::PipelineStageFlagBits::eColorAttachmentOutput;
|
||||
case vk::ImageLayout::eDepthStencilAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eShaderReadOnlyOptimal:
|
||||
return vk::PipelineStageFlagBits::eVertexShader | vk::PipelineStageFlagBits::eFragmentShader;
|
||||
case vk::ImageLayout::eTransferSrcOptimal:
|
||||
[[fallthrough]];
|
||||
case vk::ImageLayout::eTransferDstOptimal:
|
||||
return vk::PipelineStageFlagBits::eTransfer;
|
||||
case vk::ImageLayout::ePreinitialized:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthReadOnlyStencilAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eDepthReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eStencilAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eStencilReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eReadOnlyOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::eAttachmentOptimal:
|
||||
break;
|
||||
case vk::ImageLayout::ePresentSrcKHR:
|
||||
return vk::PipelineStageFlagBits::eBottomOfPipe;
|
||||
case vk::ImageLayout::eVideoDecodeDstKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoDecodeSrcKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoDecodeDpbKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eSharedPresentKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eFragmentDensityMapOptimalEXT:
|
||||
break;
|
||||
case vk::ImageLayout::eFragmentShadingRateAttachmentOptimalKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eRenderingLocalReadKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeDstKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeSrcKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeDpbKHR:
|
||||
break;
|
||||
case vk::ImageLayout::eAttachmentFeedbackLoopOptimalEXT:
|
||||
break;
|
||||
case vk::ImageLayout::eVideoEncodeQuantizationMapKHR:
|
||||
break;
|
||||
}
|
||||
|
||||
FGL_UNREACHABLE();
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
vk::ImageMemoryBarrier Image::transitionTo(
|
||||
const vk::ImageLayout old_layout,
|
||||
const vk::ImageLayout new_layout,
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace fgl::engine
|
||||
return data;
|
||||
}
|
||||
|
||||
MaterialProperties::MaterialProperties()
|
||||
MaterialProperties::MaterialProperties() : m_pbr(), m_normal(), m_occlusion(), m_emissive()
|
||||
{
|
||||
Sampler sampler {};
|
||||
|
||||
|
||||
@@ -40,31 +40,31 @@ namespace fgl::engine
|
||||
{
|
||||
struct
|
||||
{
|
||||
std::shared_ptr< Texture > m_color_tex {};
|
||||
std::shared_ptr< Texture > m_color_tex { nullptr };
|
||||
glm::vec4 m_color_factors { 1.0f };
|
||||
|
||||
std::shared_ptr< Texture > m_metallic_roughness_tex;
|
||||
std::shared_ptr< Texture > m_metallic_roughness_tex { nullptr };
|
||||
float m_metallic_factor { 0.0f };
|
||||
float m_roughness_factor { 0.0f };
|
||||
} m_pbr;
|
||||
} m_pbr {};
|
||||
|
||||
struct
|
||||
{
|
||||
float m_scale { 1.0f };
|
||||
std::shared_ptr< Texture > m_texture;
|
||||
} m_normal;
|
||||
std::shared_ptr< Texture > m_texture { nullptr };
|
||||
} m_normal {};
|
||||
|
||||
struct
|
||||
{
|
||||
float m_strength { 1.0f };
|
||||
std::shared_ptr< Texture > m_texture;
|
||||
} m_occlusion;
|
||||
std::shared_ptr< Texture > m_texture { nullptr };
|
||||
} m_occlusion {};
|
||||
|
||||
struct
|
||||
{
|
||||
glm::vec3 m_factors { 1.0f };
|
||||
std::shared_ptr< Texture > m_texture;
|
||||
} m_emissive;
|
||||
std::shared_ptr< Texture > m_texture { nullptr };
|
||||
} m_emissive {};
|
||||
|
||||
void writeData( DeviceMaterialData& data ) const;
|
||||
DeviceMaterialData data() const;
|
||||
@@ -82,7 +82,7 @@ namespace fgl::engine
|
||||
{
|
||||
TextureID color_texture_id { constants::INVALID_TEXTURE_ID };
|
||||
alignas( 4 * 4 ) glm::vec4 color_factors { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
} color;
|
||||
} color {};
|
||||
|
||||
alignas( 16 ) struct Metallic
|
||||
{
|
||||
@@ -90,25 +90,25 @@ namespace fgl::engine
|
||||
alignas( 16 ) TextureID metallic_texture_id { constants::INVALID_TEXTURE_ID };
|
||||
float metallic_factor { 0.0f };
|
||||
float roughness_factor { 0.0f };
|
||||
} metallic;
|
||||
} metallic {};
|
||||
|
||||
alignas( 16 ) struct Normal
|
||||
{
|
||||
TextureID normal_texture_id { constants::INVALID_TEXTURE_ID };
|
||||
float normal_tex_scale { 0.0f };
|
||||
} normal;
|
||||
} normal {};
|
||||
|
||||
alignas( 16 ) struct Occlusion
|
||||
{
|
||||
TextureID occlusion_texture_id { constants::INVALID_TEXTURE_ID };
|
||||
float occlusion_tex_strength { 0.0f };
|
||||
} occlusion;
|
||||
} occlusion {};
|
||||
|
||||
alignas( 16 ) struct Emissive
|
||||
{
|
||||
TextureID emissive_texture_id { constants::INVALID_TEXTURE_ID };
|
||||
alignas( 4 * 4 ) glm::vec3 emissive_factors { 0.0f, 0.0f, 0.0f };
|
||||
} emissive;
|
||||
} emissive {};
|
||||
|
||||
DeviceMaterialData() = default;
|
||||
};
|
||||
@@ -134,16 +134,6 @@ namespace fgl::engine
|
||||
|
||||
static_assert( sizeof( DeviceMaterialData ) == 112 );
|
||||
|
||||
/*
|
||||
static_assert( sizeof( DeviceMaterialData ) == 76 );
|
||||
static_assert( offsetof( DeviceMaterialData, color_factors ) == 16 );
|
||||
static_assert( offsetof( DeviceMaterialData, metallic_texture_id ) == 32 );
|
||||
static_assert( offsetof( DeviceMaterialData, normal_texture_id ) == 44 );
|
||||
static_assert( offsetof( DeviceMaterialData, occlusion_texture_id ) == 52 );
|
||||
static_assert( offsetof( DeviceMaterialData, emissive_texture_id ) == 60 );
|
||||
static_assert( offsetof( DeviceMaterialData, emissive_factors ) == 64 );
|
||||
*/
|
||||
|
||||
class Material
|
||||
{
|
||||
MaterialID m_id;
|
||||
|
||||
@@ -40,17 +40,17 @@ namespace fgl::engine
|
||||
vk::MemoryPropertyFlagBits::eDeviceLocal ),
|
||||
m_primitive_info( m_long_buffer ),
|
||||
m_primitive_instances( m_short_buffer ),
|
||||
m_model_instances( m_short_buffer )
|
||||
m_model_instances( m_short_buffer ),
|
||||
m_primitives_desc( PRIMITIVE_SET.create() ),
|
||||
m_instances_desc( INSTANCES_SET.create() )
|
||||
{
|
||||
m_vertex_buffer->setDebugName( "Vertex buffer GPU" );
|
||||
m_index_buffer->setDebugName( "Index buffer" );
|
||||
|
||||
m_primitives_desc = PRIMITIVE_SET.create();
|
||||
m_primitives_desc->bindStorageBuffer( 0, m_primitive_info );
|
||||
m_primitives_desc->update();
|
||||
m_primitives_desc->setName( "Primitives" );
|
||||
|
||||
m_instances_desc = INSTANCES_SET.create();
|
||||
m_instances_desc->bindStorageBuffer( 0, m_primitive_instances );
|
||||
m_instances_desc->bindStorageBuffer( 1, m_model_instances );
|
||||
m_instances_desc->update();
|
||||
@@ -109,7 +109,7 @@ namespace fgl::engine
|
||||
PrimitiveInstanceInfo instance_info {};
|
||||
instance_info.m_primitive_info = render_info->idx();
|
||||
instance_info.m_model_info = model_instance.idx();
|
||||
instance_info.m_material = primitive.default_material->getID();
|
||||
instance_info.m_material = primitive.m_default_material->getID();
|
||||
|
||||
primitive_instances.emplace_back( buffers.m_primitive_instances.acquire( instance_info ) );
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
#include "ModelVertex.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wduplicated-branches"
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/hash.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "Model.hpp"
|
||||
#include "ModelInstance.hpp"
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace fgl::engine
|
||||
|
||||
bool Primitive::ready() const
|
||||
{
|
||||
return default_material->ready() && m_vertex_buffer.ready() && m_index_buffer.ready();
|
||||
return m_default_material->ready() && m_vertex_buffer.ready() && m_index_buffer.ready();
|
||||
}
|
||||
|
||||
std::shared_ptr< PrimitiveRenderInfoIndex > Primitive::buildRenderInfo()
|
||||
std::shared_ptr< PrimitiveRenderInfoIndex > Primitive::buildRenderInfo() const
|
||||
{
|
||||
auto& buffers { getModelBuffers() };
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace fgl::engine
|
||||
m_index_buffer( std::move( index_buffer ) ),
|
||||
m_bounding_box( bounding_box ),
|
||||
m_mode( mode ),
|
||||
default_material(),
|
||||
m_primitive_info( buildRenderInfo() )
|
||||
m_primitive_info( buildRenderInfo() ),
|
||||
m_default_material()
|
||||
{
|
||||
assert( m_bounding_box.getTransform().scale != glm::vec3( 0.0f ) );
|
||||
}
|
||||
@@ -75,8 +75,8 @@ namespace fgl::engine
|
||||
m_index_buffer( std::move( index_buffer ) ),
|
||||
m_bounding_box( bounding_box ),
|
||||
m_mode( mode ),
|
||||
default_material( material ),
|
||||
m_primitive_info( buildRenderInfo() )
|
||||
m_primitive_info( buildRenderInfo() ),
|
||||
m_default_material( material )
|
||||
{
|
||||
assert( m_bounding_box.getTransform().scale != glm::vec3( 0.0f ) );
|
||||
}
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "ModelInstanceInfo.hpp"
|
||||
#include "assets/material/Material.hpp"
|
||||
#include "engine/memory/buffers/vector/DeviceVector.hpp"
|
||||
#include "engine/primitives/boxes/OrientedBoundingBox.hpp"
|
||||
#include "memory/buffers/vector/IndexedVector.hpp"
|
||||
#include "objectloaders/tiny_gltf.h"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -22,6 +19,18 @@ namespace fgl::engine
|
||||
|
||||
using IndexBufferSuballocation = DeviceVector< std::uint32_t >;
|
||||
|
||||
enum class PrimitiveMode
|
||||
{
|
||||
POINTS,
|
||||
LINE,
|
||||
LINE_LOOP,
|
||||
LINE_STRIP,
|
||||
TRIANGLES,
|
||||
TRIANGLE_STRIP,
|
||||
TRIANGLE_FAN
|
||||
};
|
||||
|
||||
/*
|
||||
enum PrimitiveMode
|
||||
{
|
||||
POINTS = TINYGLTF_MODE_POINTS,
|
||||
@@ -32,6 +41,7 @@ namespace fgl::engine
|
||||
TRI_STRIP = TINYGLTF_MODE_TRIANGLE_STRIP,
|
||||
TRI_FAN = TINYGLTF_MODE_TRIANGLE_FAN
|
||||
};
|
||||
*/
|
||||
|
||||
struct PrimitiveTextures
|
||||
{
|
||||
@@ -67,7 +77,7 @@ namespace fgl::engine
|
||||
|
||||
struct Primitive
|
||||
{
|
||||
bool draw { true };
|
||||
bool m_draw { true };
|
||||
VertexBufferSuballocation m_vertex_buffer;
|
||||
IndexBufferSuballocation m_index_buffer;
|
||||
OrientedBoundingBox< CoordinateSpace::Model > m_bounding_box;
|
||||
@@ -75,14 +85,14 @@ namespace fgl::engine
|
||||
|
||||
std::shared_ptr< PrimitiveRenderInfoIndex > m_primitive_info;
|
||||
|
||||
std::shared_ptr< Material > default_material;
|
||||
std::shared_ptr< Material > m_default_material;
|
||||
|
||||
std::string m_name { "Unnamed Primitive" };
|
||||
|
||||
//! Returns true if the primitive is ready to be rendered (must have all textures, vertex buffer, and index buffer ready)
|
||||
bool ready() const;
|
||||
|
||||
std::shared_ptr< PrimitiveRenderInfoIndex > buildRenderInfo();
|
||||
std::shared_ptr< PrimitiveRenderInfoIndex > buildRenderInfo() const;
|
||||
|
||||
Primitive(
|
||||
VertexBufferSuballocation&& vertex_buffer,
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
SimpleVertex::SimpleVertex()
|
||||
{}
|
||||
|
||||
SimpleVertex::SimpleVertex( const glm::vec3 pos, const glm::vec3 color ) : m_position( pos ), m_color( color )
|
||||
{}
|
||||
|
||||
std::vector< vk::VertexInputBindingDescription > SimpleVertex::getBindingDescriptions()
|
||||
{
|
||||
// {buffer_idx, stride, rate}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace fgl::engine
|
||||
glm::vec3 m_position { 0.0f };
|
||||
glm::vec3 m_color { 1.0f };
|
||||
|
||||
SimpleVertex() = default;
|
||||
SimpleVertex();
|
||||
|
||||
SimpleVertex( const glm::vec3 pos, const glm::vec3 color ) : m_position( pos ), m_color( color ) {}
|
||||
SimpleVertex( glm::vec3 pos, glm::vec3 color );
|
||||
|
||||
static std::vector< vk::VertexInputBindingDescription > getBindingDescriptions();
|
||||
static std::vector< vk::VertexInputAttributeDescription > getAttributeDescriptions();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace fgl::engine
|
||||
std::move( vertex_suballoc ),
|
||||
std::move( index_suballoc ),
|
||||
generateBoundingFromVerts( verts ),
|
||||
PrimitiveMode::TRIS );
|
||||
PrimitiveMode::TRIANGLES );
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -4,6 +4,12 @@
|
||||
|
||||
#include "SceneBuilder.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <tiny_gltf.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "assets/model/ModelVertex.hpp"
|
||||
#include "engine/assets/model/Model.hpp"
|
||||
#include "engine/assets/stores.hpp"
|
||||
@@ -13,7 +19,6 @@
|
||||
#include "engine/gameobjects/GameObject.hpp"
|
||||
#include "gameobjects/components/TransformComponent.hpp"
|
||||
#include "mikktspace/mikktspace.hpp"
|
||||
#include "objectloaders/tiny_gltf.h"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -367,11 +372,11 @@ namespace fgl::engine
|
||||
context.m_pUserData = &interface;
|
||||
context.m_pInterface = &interface;
|
||||
|
||||
auto getNumFaces = [ & ]( [[maybe_unused]] const SMikkTSpaceContext* ctx ) -> int
|
||||
auto getNumFaces = [ & ]( [[maybe_unused]] const SMikkTSpaceContext* ctx ) noexcept -> int
|
||||
{ return static_cast< int >( indicies.size() ) / 3; };
|
||||
|
||||
auto getNumVerticesOfFace =
|
||||
[ & ]( [[maybe_unused]] const SMikkTSpaceContext* ctx, [[maybe_unused]] const int i_face ) -> int
|
||||
[ & ]( [[maybe_unused]] const SMikkTSpaceContext* ctx, [[maybe_unused]] const int i_face ) noexcept -> int
|
||||
{ return 3; };
|
||||
|
||||
auto getPosition = [ & ](
|
||||
@@ -456,22 +461,25 @@ namespace fgl::engine
|
||||
std::vector< ModelVertex > verts { extractVertexInfo( prim, root ) };
|
||||
std::vector< std::uint32_t > indicies { extractIndicies( prim, root ) };
|
||||
|
||||
switch ( static_cast< PrimitiveMode >( prim.mode ) )
|
||||
PrimitiveMode primitive_mode { PrimitiveMode::POINTS };
|
||||
|
||||
switch ( prim.mode )
|
||||
{
|
||||
case TRIS:
|
||||
case TINYGLTF_MODE_TRIANGLES:
|
||||
generateTrisTangents( verts, indicies );
|
||||
primitive_mode = PrimitiveMode::TRIANGLES;
|
||||
break;
|
||||
case POINTS:
|
||||
case TINYGLTF_MODE_POINTS:
|
||||
[[fallthrough]];
|
||||
case LINE:
|
||||
case TINYGLTF_MODE_LINE:
|
||||
[[fallthrough]];
|
||||
case LINE_LOOP:
|
||||
case TINYGLTF_MODE_LINE_LOOP:
|
||||
[[fallthrough]];
|
||||
case LINE_STRIP:
|
||||
case TINYGLTF_MODE_LINE_STRIP:
|
||||
[[fallthrough]];
|
||||
case TRI_STRIP:
|
||||
case TINYGLTF_MODE_TRIANGLE_STRIP:
|
||||
[[fallthrough]];
|
||||
case TRI_FAN:
|
||||
case TINYGLTF_MODE_TRIANGLE_FAN:
|
||||
[[fallthrough]];
|
||||
default:
|
||||
{
|
||||
@@ -480,18 +488,16 @@ namespace fgl::engine
|
||||
}
|
||||
}
|
||||
|
||||
Primitive primitive_mesh { Primitive::fromVerts(
|
||||
std::move( verts ),
|
||||
static_cast< PrimitiveMode >( prim.mode ),
|
||||
std::move( indicies ),
|
||||
m_vertex_buffer,
|
||||
m_index_buffer ) };
|
||||
auto primitive_mesh {
|
||||
Primitive::
|
||||
fromVerts( std::move( verts ), primitive_mode, std::move( indicies ), m_vertex_buffer, m_index_buffer )
|
||||
};
|
||||
|
||||
// If we have a texcoord then we have a UV map. Meaning we likely have textures to use
|
||||
if ( !has_texcoord ) return primitive_mesh;
|
||||
|
||||
//primitive_mesh.m_textures = loadTextures( prim, root );
|
||||
primitive_mesh.default_material = loadMaterial( prim, root );
|
||||
primitive_mesh.m_default_material = loadMaterial( prim, root );
|
||||
|
||||
return primitive_mesh;
|
||||
}
|
||||
@@ -648,15 +654,15 @@ namespace fgl::engine
|
||||
|
||||
material->properties.m_pbr.m_metallic_roughness_tex =
|
||||
loadTexture( metallic_roughness.metallicRoughnessTexture.index, root );
|
||||
material->properties.m_pbr.m_metallic_factor = metallic_roughness.metallicFactor;
|
||||
material->properties.m_pbr.m_roughness_factor = metallic_roughness.roughnessFactor;
|
||||
material->properties.m_pbr.m_metallic_factor = static_cast< float >( metallic_roughness.metallicFactor );
|
||||
material->properties.m_pbr.m_roughness_factor = static_cast< float >( metallic_roughness.roughnessFactor );
|
||||
}
|
||||
|
||||
material->properties.m_normal.m_texture = loadTexture( gltf_material.normalTexture.index, root );
|
||||
material->properties.m_normal.m_scale = gltf_material.normalTexture.scale;
|
||||
material->properties.m_normal.m_scale = static_cast< float >( gltf_material.normalTexture.scale );
|
||||
|
||||
material->properties.m_occlusion.m_texture = loadTexture( gltf_material.occlusionTexture.index, root );
|
||||
material->properties.m_occlusion.m_strength = gltf_material.occlusionTexture.strength;
|
||||
material->properties.m_occlusion.m_strength = static_cast< float >( gltf_material.occlusionTexture.strength );
|
||||
|
||||
material->properties.m_emissive.m_texture = loadTexture( gltf_material.emissiveTexture.index, root );
|
||||
material->properties.m_emissive.m_factors = convertToVec3( gltf_material.emissiveFactor );
|
||||
@@ -672,7 +678,7 @@ namespace fgl::engine
|
||||
const tinygltf::Node& node { root.nodes[ node_idx ] };
|
||||
|
||||
const int mesh_idx { node.mesh };
|
||||
const int skin_idx { node.skin };
|
||||
[[maybe_unused]] const int skin_idx { node.skin };
|
||||
|
||||
auto obj { GameObject::createGameObject() };
|
||||
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/hash.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
// Created by kj16609 on 5/18/24.
|
||||
//
|
||||
|
||||
#include <objectloaders/tiny_obj_loader.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#include <tiny_obj_loader.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "ModelBuilder.hpp"
|
||||
#include "engine/assets/model/ModelVertex.hpp"
|
||||
#include "engine/assets/model/Primitive.hpp"
|
||||
@@ -28,7 +31,7 @@ namespace fgl::engine
|
||||
const std::vector< tinyobj::shape_t >& shapes { reader.GetShapes() };
|
||||
[[maybe_unused]] const std::vector< tinyobj::material_t >& materials { reader.GetMaterials() };
|
||||
|
||||
if ( shapes.size() == 0 ) throw std::runtime_error( "Failed to get shapes from OBJ" );
|
||||
if ( shapes.empty() ) throw std::runtime_error( "Failed to get shapes from OBJ" );
|
||||
|
||||
const std::string& warn { reader.Warning() };
|
||||
const std::string& error { reader.Error() };
|
||||
@@ -47,33 +50,37 @@ namespace fgl::engine
|
||||
for ( const auto& index : shape.mesh.indices )
|
||||
{
|
||||
ModelVertex vert {};
|
||||
|
||||
if ( index.vertex_index >= 0 )
|
||||
{
|
||||
const auto vertex_index { 3ul * static_cast< std::uint64_t >( index.vertex_index ) };
|
||||
vert.m_position = {
|
||||
attrib.vertices[ static_cast< std::uint64_t >( 3 * index.vertex_index + 0 ) ],
|
||||
attrib.vertices[ static_cast< std::uint64_t >( 3 * index.vertex_index + 1 ) ],
|
||||
attrib.vertices[ static_cast< std::uint64_t >( 3 * index.vertex_index + 2 ) ],
|
||||
attrib.vertices[ vertex_index + 0ul ],
|
||||
attrib.vertices[ vertex_index + 1ul ],
|
||||
attrib.vertices[ vertex_index + 2ul ],
|
||||
};
|
||||
|
||||
vert.m_color = { attrib.colors[ static_cast< std::uint64_t >( 3 * index.vertex_index + 0 ) ],
|
||||
attrib.colors[ static_cast< std::uint64_t >( 3 * index.vertex_index + 1 ) ],
|
||||
attrib.colors[ static_cast< std::uint64_t >( 3 * index.vertex_index + 2 ) ] };
|
||||
vert.m_color = { attrib.colors[ vertex_index + 0ul ],
|
||||
attrib.colors[ vertex_index + 1ul ],
|
||||
attrib.colors[ vertex_index + 2ul ] };
|
||||
}
|
||||
|
||||
if ( index.normal_index >= 0 )
|
||||
{
|
||||
const auto normal_index { 3ul * static_cast< std::uint64_t >( index.normal_index ) };
|
||||
vert.m_normal = {
|
||||
attrib.normals[ static_cast< std::uint64_t >( 3 * index.normal_index + 0 ) ],
|
||||
attrib.normals[ static_cast< std::uint64_t >( 3 * index.normal_index + 1 ) ],
|
||||
attrib.normals[ static_cast< std::uint64_t >( 3 * index.normal_index + 2 ) ],
|
||||
attrib.normals[ normal_index + 0ul ],
|
||||
attrib.normals[ normal_index + 1ul ],
|
||||
attrib.normals[ normal_index + 2ul ],
|
||||
};
|
||||
}
|
||||
|
||||
if ( index.texcoord_index >= 0 )
|
||||
{
|
||||
const auto texcoord_index { 3ul * static_cast< std::uint64_t >( index.texcoord_index ) };
|
||||
vert.m_uv = {
|
||||
attrib.texcoords[ static_cast< std::uint64_t >( 3 * index.texcoord_index + 0 ) ],
|
||||
attrib.texcoords[ static_cast< std::uint64_t >( 3 * index.texcoord_index + 1 ) ],
|
||||
attrib.texcoords[ texcoord_index + 0ul ],
|
||||
attrib.texcoords[ texcoord_index + 1ul ],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,9 +109,9 @@ namespace fgl::engine
|
||||
const OrientedBoundingBox bounding_box { generateBoundingFromVerts( verts ) };
|
||||
|
||||
[[maybe_unused]] auto& itter = m_primitives.emplace_back(
|
||||
VertexBufferSuballocation( m_vertex_buffer, std::move( verts ) ),
|
||||
IndexBufferSuballocation( m_index_buffer, std::move( indicies ) ),
|
||||
VertexBufferSuballocation( m_vertex_buffer, verts ),
|
||||
IndexBufferSuballocation( m_index_buffer, indicies ),
|
||||
bounding_box,
|
||||
PrimitiveMode::TRIS );
|
||||
PrimitiveMode::TRIANGLES );
|
||||
}
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
#include "glm/geometric.hpp"
|
||||
#include "glm/vec3.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
|
||||
#define TFALSE false
|
||||
#define TTRUE true
|
||||
|
||||
@@ -853,10 +858,10 @@ int GenerateInitialVerticesIndexList(
|
||||
const SVec3 P1 = GetPosition( pContext, i1 );
|
||||
const SVec3 P2 = GetPosition( pContext, i2 );
|
||||
const SVec3 P3 = GetPosition( pContext, i3 );
|
||||
const float distSQ_02 = LengthSquared( vsub( P2, P0 ) );
|
||||
const float distSQ_13 = LengthSquared( vsub( P3, P1 ) );
|
||||
const float distSQ_02_2 = LengthSquared( vsub( P2, P0 ) );
|
||||
const float distSQ_13_2 = LengthSquared( vsub( P3, P1 ) );
|
||||
|
||||
bQuadDiagIs_02 = distSQ_13 >= distSQ_02;
|
||||
bQuadDiagIs_02 = distSQ_13_2 >= distSQ_02_2;
|
||||
}
|
||||
|
||||
if ( bQuadDiagIs_02 )
|
||||
@@ -1984,3 +1989,5 @@ void DegenEpilogue(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -4,6 +4,18 @@
|
||||
|
||||
#include "Texture.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#include <imgui/backends/imgui_impl_vulkan.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <stb_image.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "engine/FrameInfo.hpp"
|
||||
#include "engine/assets/image/Image.hpp"
|
||||
#include "engine/assets/image/ImageView.hpp"
|
||||
@@ -11,8 +23,6 @@
|
||||
#include "engine/descriptors/DescriptorSet.hpp"
|
||||
#include "engine/math/noise/perlin/generator.hpp"
|
||||
#include "engine/utility/IDPool.hpp"
|
||||
#include "imgui/backends/imgui_impl_vulkan.h"
|
||||
#include "objectloaders/stb_image.h"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -40,8 +50,8 @@ namespace fgl::engine
|
||||
|
||||
std::vector< std::byte > data {};
|
||||
|
||||
data.resize( x * y * 4 );
|
||||
std::memcpy( data.data(), data_c, x * y * 4 );
|
||||
data.resize( static_cast< std::size_t >( x ) * static_cast< std::size_t >( y ) * 4 );
|
||||
std::memcpy( data.data(), data_c, data.size() );
|
||||
|
||||
stbi_image_free( data_c );
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace fgl::engine
|
||||
|
||||
namespace memory
|
||||
{
|
||||
struct BufferSuballocationHandle;
|
||||
class BufferSuballocationHandle;
|
||||
class BufferHandle;
|
||||
} // namespace memory
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
#include "engine/memory/buffers/vector/HostVector.hpp"
|
||||
|
||||
#ifdef ENABLE_IMGUI
|
||||
#include "imgui.h"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace fgl::engine::memory
|
||||
@@ -94,7 +98,7 @@ namespace fgl::engine::memory
|
||||
command_buffer.endDebugUtilsLabelEXT();
|
||||
}
|
||||
|
||||
void TransferManager::resizeBuffer( const std::uint64_t size )
|
||||
void TransferManager::resizeBuffer( [[maybe_unused]] const std::uint64_t size )
|
||||
{
|
||||
// m_staging_buffer.resize( size );
|
||||
}
|
||||
@@ -367,7 +371,7 @@ namespace fgl::engine::memory
|
||||
"|- %s Unused",
|
||||
literals::size_literals::toString( m_staging_buffer->size() - m_staging_buffer->used() ).c_str() );
|
||||
|
||||
ImGui::Text( "|- %i transfer remaining", m_queue.size() );
|
||||
ImGui::Text( "|- %zu transfer remaining", m_queue.size() );
|
||||
ImGui::Text( "|- %zu objects being processed", m_processing.size() );
|
||||
ImGui::Text( "|- %zu total copy regions", m_copy_regions.size() );
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace fgl::engine
|
||||
{
|
||||
class BufferVector;
|
||||
|
||||
struct BufferSuballocationHandle;
|
||||
class BufferSuballocationHandle;
|
||||
|
||||
class BufferSuballocation;
|
||||
} // namespace memory
|
||||
|
||||
@@ -229,7 +229,8 @@ namespace fgl::engine
|
||||
|
||||
vk::Viewport CameraViewpoint::viewport() const
|
||||
{
|
||||
return { 0, 0, this->m_extent.width, this->m_extent.height, 0.0f, 1.0f };
|
||||
return { 0, 0, static_cast< float >( this->m_extent.width ), static_cast< float >( this->m_extent.height ),
|
||||
0.0f, 1.0f };
|
||||
}
|
||||
|
||||
descriptors::DescriptorSetLayout& CameraViewpoint::getDescriptorLayout()
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#include "CameraViewpoint.hpp"
|
||||
#include "CompositeSwapchain.hpp"
|
||||
#include "GBufferSwapchain.hpp"
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace fgl::engine
|
||||
{
|
||||
PerFrameArray< std::unique_ptr< descriptors::DescriptorSet > > data {};
|
||||
|
||||
for ( std::size_t i = 0; i < data.size(); ++i )
|
||||
for ( FrameIndex i = 0; i < data.size(); ++i )
|
||||
{
|
||||
auto set { shadowmap_descriptor_set.create() };
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace fgl::engine
|
||||
m_swapchain( createDepthSwapchain( extent ) ),
|
||||
m_direction( direction ),
|
||||
m_camera( CameraManager::createViewpoint( extent ) ),
|
||||
m_shadow_pipeline( nullptr ),
|
||||
m_culling_system(),
|
||||
m_extent( extent ),
|
||||
m_shadowmap_descriptor( createShadowmapDescriptors() )
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace fgl::engine
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
void drawShadowmaps( const FrameInfo& info );
|
||||
extern void drawShadowmaps( const FrameInfo& info );
|
||||
}
|
||||
|
||||
struct CameraInfo;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "assets/texture/Texture.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "rendering/devices/Device.hpp"
|
||||
#include "slang.h"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
|
||||
#include "glm.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wduplicated-branches"
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
std::format_context::iterator std::formatter< glm::qua< float > >::format( const glm::quat& quat, format_context& ctx )
|
||||
const
|
||||
|
||||
@@ -5,7 +5,12 @@
|
||||
#include "FlameGraph.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "engine/FGL_DEFINES.hpp"
|
||||
#include "engine/clock.hpp"
|
||||
|
||||
@@ -17,15 +17,75 @@
|
||||
namespace fgl::engine::descriptors
|
||||
{
|
||||
|
||||
void DescriptorSet::resetUpdate()
|
||||
{
|
||||
m_infos.clear();
|
||||
//Clear all writes
|
||||
m_descriptor_writes.clear();
|
||||
|
||||
m_infos.resize( m_binding_count );
|
||||
}
|
||||
|
||||
bool DescriptorSet::hasUpdates() const
|
||||
{
|
||||
return !m_descriptor_writes.empty();
|
||||
}
|
||||
|
||||
void DescriptorSet::update()
|
||||
{
|
||||
Device::getInstance().device().updateDescriptorSets( m_descriptor_writes, {} );
|
||||
m_initalized = true;
|
||||
resetUpdate();
|
||||
}
|
||||
|
||||
VkDescriptorSet DescriptorSet::operator*() const
|
||||
{
|
||||
return getVkDescriptorSet();
|
||||
}
|
||||
|
||||
VkDescriptorSet DescriptorSet::getVkDescriptorSet() const
|
||||
{
|
||||
FGL_ASSERT( !hasUpdates(), "Descriptor set has updates but binding was attempted" );
|
||||
FGL_ASSERT( m_initalized, "Descriptor set has not been initialized" );
|
||||
return *m_set;
|
||||
}
|
||||
|
||||
DescriptorSet::DescriptorSet(
|
||||
const vk::raii::DescriptorSetLayout& layout, const DescriptorIDX idx, const std::size_t binding_count ) :
|
||||
m_set_idx( idx ),
|
||||
m_infos(),
|
||||
m_descriptor_writes(),
|
||||
m_resources(),
|
||||
m_set( DescriptorPool::getInstance().allocateSet( layout ) ),
|
||||
m_binding_count( binding_count )
|
||||
{
|
||||
m_infos.resize( m_binding_count );
|
||||
}
|
||||
|
||||
DescriptorSet::~DescriptorSet()
|
||||
{}
|
||||
|
||||
void DescriptorSet::
|
||||
bindImage( const std::uint32_t binding_idx, const ImageView& view, const vk::ImageLayout layout )
|
||||
{
|
||||
assert( binding_idx < m_infos.size() && "Binding index out of range" );
|
||||
|
||||
//Store info
|
||||
m_infos[ binding_idx ] = view.descriptorInfo( layout );
|
||||
|
||||
vk::WriteDescriptorSet write {};
|
||||
write.dstSet = m_set;
|
||||
write.dstBinding = binding_idx;
|
||||
write.dstArrayElement = 0;
|
||||
write.descriptorCount = 1;
|
||||
write.descriptorType = vk::DescriptorType::eSampledImage;
|
||||
write.pBufferInfo = VK_NULL_HANDLE;
|
||||
write.pImageInfo = &( std::get< vk::DescriptorImageInfo >( m_infos[ binding_idx ] ) );
|
||||
write.pTexelBufferView = VK_NULL_HANDLE;
|
||||
|
||||
m_descriptor_writes.push_back( write );
|
||||
}
|
||||
|
||||
void DescriptorSet::bindUniformBuffer( const std::uint32_t binding_idx, const memory::BufferSuballocation& buffer )
|
||||
{
|
||||
assert( binding_idx < m_infos.size() && "Binding index out of range" );
|
||||
@@ -93,7 +153,7 @@ namespace fgl::engine::descriptors
|
||||
}
|
||||
|
||||
void DescriptorSet::
|
||||
bindImage( const std::uint32_t binding_idx, const ImageView& view, const vk::ImageLayout layout )
|
||||
bindAttachment( const std::uint32_t binding_idx, const ImageView& view, const vk::ImageLayout layout )
|
||||
{
|
||||
assert( binding_idx < m_infos.size() && "Binding index out of range" );
|
||||
|
||||
@@ -105,7 +165,7 @@ namespace fgl::engine::descriptors
|
||||
write.dstBinding = binding_idx;
|
||||
write.dstArrayElement = 0;
|
||||
write.descriptorCount = 1;
|
||||
write.descriptorType = vk::DescriptorType::eSampledImage;
|
||||
write.descriptorType = vk::DescriptorType::eInputAttachment;
|
||||
write.pBufferInfo = VK_NULL_HANDLE;
|
||||
write.pImageInfo = &( std::get< vk::DescriptorImageInfo >( m_infos[ binding_idx ] ) );
|
||||
write.pTexelBufferView = VK_NULL_HANDLE;
|
||||
@@ -139,63 +199,6 @@ namespace fgl::engine::descriptors
|
||||
m_descriptor_writes.push_back( write );
|
||||
}
|
||||
|
||||
void DescriptorSet::update()
|
||||
{
|
||||
Device::getInstance().device().updateDescriptorSets( m_descriptor_writes, {} );
|
||||
m_initalized = true;
|
||||
resetUpdate();
|
||||
}
|
||||
|
||||
VkDescriptorSet DescriptorSet::operator*() const
|
||||
{
|
||||
return getVkDescriptorSet();
|
||||
}
|
||||
|
||||
VkDescriptorSet DescriptorSet::getVkDescriptorSet() const
|
||||
{
|
||||
FGL_ASSERT( !hasUpdates(), "Descriptor set has updates but binding was attempted" );
|
||||
FGL_ASSERT( m_initalized, "Descriptor set has not been initialized" );
|
||||
return *m_set;
|
||||
}
|
||||
|
||||
DescriptorSet::~DescriptorSet()
|
||||
{}
|
||||
|
||||
void DescriptorSet::resetUpdate()
|
||||
{
|
||||
m_infos.clear();
|
||||
//Clear all writes
|
||||
m_descriptor_writes.clear();
|
||||
|
||||
m_infos.resize( m_binding_count );
|
||||
}
|
||||
|
||||
bool DescriptorSet::hasUpdates() const
|
||||
{
|
||||
return !m_descriptor_writes.empty();
|
||||
}
|
||||
|
||||
void DescriptorSet::
|
||||
bindAttachment( const std::uint32_t binding_idx, const ImageView& view, const vk::ImageLayout layout )
|
||||
{
|
||||
assert( binding_idx < m_infos.size() && "Binding index out of range" );
|
||||
|
||||
//Store info
|
||||
m_infos[ binding_idx ] = view.descriptorInfo( layout );
|
||||
|
||||
vk::WriteDescriptorSet write {};
|
||||
write.dstSet = m_set;
|
||||
write.dstBinding = binding_idx;
|
||||
write.dstArrayElement = 0;
|
||||
write.descriptorCount = 1;
|
||||
write.descriptorType = vk::DescriptorType::eInputAttachment;
|
||||
write.pBufferInfo = VK_NULL_HANDLE;
|
||||
write.pImageInfo = &( std::get< vk::DescriptorImageInfo >( m_infos[ binding_idx ] ) );
|
||||
write.pTexelBufferView = VK_NULL_HANDLE;
|
||||
|
||||
m_descriptor_writes.push_back( write );
|
||||
}
|
||||
|
||||
void DescriptorSet::setName( const std::string& str ) const
|
||||
{
|
||||
vk::DebugUtilsObjectNameInfoEXT info {};
|
||||
|
||||
@@ -60,18 +60,10 @@ namespace fgl::engine::descriptors
|
||||
|
||||
[[nodiscard]] DescriptorIDX setIDX() const { return m_set_idx; }
|
||||
|
||||
FGL_DELETE_DEFAULT_CTOR( DescriptorSet );
|
||||
FGL_DELETE_ALL_RO5( DescriptorSet );
|
||||
|
||||
DescriptorSet( const vk::raii::DescriptorSetLayout& layout, DescriptorIDX idx, std::size_t binding_count );
|
||||
|
||||
FGL_DELETE_COPY( DescriptorSet );
|
||||
|
||||
FGL_DELETE_MOVE( DescriptorSet );
|
||||
|
||||
//Move
|
||||
// DescriptorSet( DescriptorSet&& other ) noexcept;
|
||||
// DescriptorSet& operator=( DescriptorSet&& other ) noexcept;
|
||||
|
||||
~DescriptorSet();
|
||||
|
||||
void bindImage( std::uint32_t binding_idx, const ImageView& view, vk::ImageLayout layout );
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
inline static constexpr char* DRAG_TYPE_FILE_MODEL_INFO { "_MODEL_FILE_INFO" };
|
||||
inline static constexpr char* DRAG_TYPE_FILE_TEXTURE_INFO { "_TEXTURE_FILE_INFO" };
|
||||
inline static constexpr auto* DRAG_TYPE_FILE_MODEL_INFO { "_MODEL_FILE_INFO" };
|
||||
inline static constexpr auto* DRAG_TYPE_FILE_TEXTURE_INFO { "_TEXTURE_FILE_INFO" };
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace fgl::engine::components
|
||||
COMPONENT_CLASS( TransformComponent, TransformComponentID )
|
||||
{
|
||||
WorldTransform m_transform;
|
||||
std::shared_ptr< ModelInstanceInfoIndex > m_model_instance_info_index;
|
||||
std::shared_ptr< ModelInstanceInfoIndex > m_model_instance_info_index {};
|
||||
|
||||
using Updatable = std::variant< std::weak_ptr< ModelInstance > >;
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
#include "drawers.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <imgui.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "editor/src/gui/helpers.hpp"
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include "ComponentEditorInterface.hpp"
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
Sun::Sun() : m_shadowmap( createShadowmap( UniversalRotation::pointAt( constants::SUN_DIR ) ) )
|
||||
Sun::Sun() : m_shadowmap( createShadowmap( UniversalRotation::pointIn( constants::SUN_DIR ) ) )
|
||||
{}
|
||||
} // namespace fgl::engine
|
||||
@@ -3,7 +3,6 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "../../primitives/rotation/QuatRotation.hpp"
|
||||
#include "engine/primitives/boxes/OrientedBoundingBox.hpp"
|
||||
#include "engine/primitives/points/Coordinate.hpp"
|
||||
|
||||
|
||||
@@ -247,8 +247,8 @@ namespace fgl::engine::memory
|
||||
.emplace_back( selected_block_offset + desired_memory_size, selected_block_size - desired_memory_size );
|
||||
}
|
||||
|
||||
std::ranges::
|
||||
remove_if( m_active_suballocations, []( auto& suballocation ) -> bool { return suballocation.expired(); } );
|
||||
std::ranges::remove_if(
|
||||
m_active_suballocations, []( auto& suballocation ) noexcept -> bool { return suballocation.expired(); } );
|
||||
|
||||
auto suballocation_handle { std::make_shared< BufferSuballocationHandle >(
|
||||
Buffer( this->shared_from_this() ), selected_block_offset, desired_memory_size, t_alignment ) };
|
||||
@@ -416,7 +416,7 @@ namespace fgl::engine::memory
|
||||
} );
|
||||
}
|
||||
|
||||
Buffer Buffer::operator=( const std::shared_ptr< BufferHandle >& other )
|
||||
Buffer& Buffer::operator=( const std::shared_ptr< BufferHandle >& other )
|
||||
{
|
||||
std::shared_ptr< BufferHandle >::operator=( other );
|
||||
return *this;
|
||||
|
||||
@@ -14,10 +14,13 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "FGL_DEFINES.hpp"
|
||||
#include "engine/debug/Track.hpp"
|
||||
#include "math/literals/size.hpp"
|
||||
#include "vma/vma_impl.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wundef"
|
||||
#include <vma/vma_impl.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
@@ -166,8 +169,6 @@ namespace fgl::engine::memory
|
||||
|
||||
class Buffer final : public std::shared_ptr< BufferHandle >
|
||||
{
|
||||
Buffer operator=( const std::shared_ptr< BufferHandle >& other );
|
||||
|
||||
public:
|
||||
|
||||
[[nodiscard]] Buffer(
|
||||
@@ -179,6 +180,8 @@ namespace fgl::engine::memory
|
||||
|
||||
[[nodiscard]] vk::DeviceSize size() const;
|
||||
|
||||
Buffer& operator=( const std::shared_ptr< BufferHandle >& other );
|
||||
|
||||
~Buffer() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace fgl::engine::memory
|
||||
class BufferHandle;
|
||||
class SuballocationView;
|
||||
|
||||
struct BufferSuballocationHandle;
|
||||
class BufferSuballocationHandle;
|
||||
|
||||
class BufferSuballocation
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace fgl::engine::memory
|
||||
|
||||
void BufferSuballocationHandle::setReady( const bool value )
|
||||
{
|
||||
std::ranges::remove_if( m_dependents, []( const auto& handle ) { return handle.expired(); } );
|
||||
std::ranges::remove_if( m_dependents, []( const auto& handle ) noexcept -> bool { return handle.expired(); } );
|
||||
m_staged = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <queue>
|
||||
|
||||
#include "BufferHandle.hpp"
|
||||
#include "FGL_DEFINES.hpp"
|
||||
#include "engine/debug/Track.hpp"
|
||||
|
||||
namespace vk::raii
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace fgl::engine
|
||||
{
|
||||
namespace memory
|
||||
{
|
||||
struct Buffer;
|
||||
class Buffer;
|
||||
}
|
||||
|
||||
//! Single element allocation of T
|
||||
|
||||
@@ -10,19 +10,28 @@
|
||||
namespace fgl::engine::memory
|
||||
{
|
||||
|
||||
vk::Buffer SuballocationView::getVkBuffer()
|
||||
{
|
||||
return m_suballocation->getVkBuffer();
|
||||
}
|
||||
SuballocationView::SuballocationView(
|
||||
const std::shared_ptr< BufferSuballocationHandle >& handle,
|
||||
const vk::DeviceSize offset,
|
||||
const vk::DeviceSize size ) :
|
||||
m_suballocation( handle ),
|
||||
m_offset( offset ),
|
||||
m_size( size )
|
||||
{}
|
||||
|
||||
vk::DeviceSize SuballocationView::offset()
|
||||
{
|
||||
return m_offset + m_suballocation->offset();
|
||||
}
|
||||
|
||||
void SuballocationView::setOffset( vk::DeviceSize offset )
|
||||
void SuballocationView::setOffset( const vk::DeviceSize offset )
|
||||
{
|
||||
m_offset = offset;
|
||||
}
|
||||
|
||||
vk::Buffer SuballocationView::getVkBuffer() const
|
||||
{
|
||||
return m_suballocation->getVkBuffer();
|
||||
}
|
||||
|
||||
vk::DeviceSize SuballocationView::offset() const
|
||||
{
|
||||
return m_offset + m_suballocation->offset();
|
||||
}
|
||||
|
||||
} // namespace fgl::engine::memory
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace fgl::engine::memory
|
||||
{
|
||||
|
||||
struct BufferSuballocationHandle;
|
||||
class BufferSuballocationHandle;
|
||||
|
||||
class SuballocationView
|
||||
{
|
||||
@@ -21,20 +21,16 @@ namespace fgl::engine::memory
|
||||
|
||||
public:
|
||||
|
||||
SuballocationView(
|
||||
std::shared_ptr< BufferSuballocationHandle > handle, vk::DeviceSize offset, vk::DeviceSize size ) :
|
||||
m_suballocation( handle ),
|
||||
m_offset( offset ),
|
||||
m_size( size )
|
||||
{}
|
||||
[[nodiscard]] SuballocationView(
|
||||
const std::shared_ptr< BufferSuballocationHandle >& handle, vk::DeviceSize offset, vk::DeviceSize size );
|
||||
|
||||
void setOffset( vk::DeviceSize offset );
|
||||
|
||||
//! Returns the buffer
|
||||
vk::Buffer getVkBuffer();
|
||||
[[nodiscard]] vk::Buffer getVkBuffer() const;
|
||||
|
||||
//! Returns the offset of this view within the buffer
|
||||
vk::DeviceSize offset();
|
||||
[[nodiscard]] vk::DeviceSize offset() const;
|
||||
};
|
||||
|
||||
} // namespace fgl::engine::memory
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/matrix_decompose.hpp>
|
||||
|
||||
#include "MatrixEvolvedTypes.hpp"
|
||||
|
||||
|
||||
@@ -102,4 +102,19 @@ namespace fgl::engine
|
||||
*this = q * *this;
|
||||
}
|
||||
|
||||
glm::quat QuatRotation::internal_quat() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool QuatRotation::operator==( const QuatRotation& rot ) const
|
||||
{
|
||||
return static_cast< glm::quat >( *this ) == static_cast< glm::quat >( rot );
|
||||
}
|
||||
|
||||
bool operator==( const QuatRotation& rot, const glm::quat& quat )
|
||||
{
|
||||
return static_cast< glm::quat >( rot ) == quat;
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm/glm.hpp>
|
||||
#include <glm/glm/gtc/quaternion.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#pragma GCC diagnostic ignored "-Wduplicated-branches"
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/fwd.hpp>
|
||||
#include <glm/glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "engine/primitives/matricies/RotationMatrix.hpp"
|
||||
#include "engine/primitives/vectors/NormalVector.hpp"
|
||||
@@ -52,20 +53,14 @@ namespace fgl::engine
|
||||
void addZWorld( float );
|
||||
|
||||
// internal
|
||||
inline glm::quat internal_quat() const { return *this; }
|
||||
glm::quat internal_quat() const;
|
||||
|
||||
bool operator==( const QuatRotation& rot ) const
|
||||
{
|
||||
return static_cast< glm::quat >( *this ) == static_cast< glm::quat >( rot );
|
||||
}
|
||||
bool operator==( const QuatRotation& rot ) const;
|
||||
|
||||
friend bool operator==( const QuatRotation&, const glm::quat& );
|
||||
};
|
||||
|
||||
inline bool operator==( const QuatRotation& rot, const glm::quat& quat )
|
||||
{
|
||||
return static_cast< glm::quat >( rot ) == quat;
|
||||
}
|
||||
bool operator==( const QuatRotation& rot, const glm::quat& quat );
|
||||
|
||||
namespace constants
|
||||
{
|
||||
|
||||
@@ -6,7 +6,51 @@
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
UniversalRotation UniversalRotation::pointAt( const glm::vec3 vec )
|
||||
UniversalRotation::UniversalRotation() : e_rotation( constants::DEFAULT_ROTATION ), m_euler( true )
|
||||
{}
|
||||
|
||||
UniversalRotation::UniversalRotation( const EulerRotation e_rotation_in ) :
|
||||
e_rotation( e_rotation_in ),
|
||||
m_euler( true )
|
||||
{}
|
||||
|
||||
UniversalRotation::UniversalRotation( const QuatRotation q_rotation_in ) :
|
||||
q_rotation( q_rotation_in ),
|
||||
m_euler( false )
|
||||
{}
|
||||
|
||||
QuatRotation UniversalRotation::forcedQuat() const
|
||||
{
|
||||
if ( m_euler ) [[unlikely]]
|
||||
return e_rotation.toRotation();
|
||||
return q_rotation;
|
||||
}
|
||||
|
||||
EulerRotation& UniversalRotation::euler()
|
||||
{
|
||||
FGL_ASSERT( isEuler(), "Rotation is not euler" );
|
||||
return e_rotation;
|
||||
}
|
||||
|
||||
const EulerRotation& UniversalRotation::euler() const
|
||||
{
|
||||
FGL_ASSERT( isEuler(), "Rotation is not euler" );
|
||||
return e_rotation;
|
||||
}
|
||||
|
||||
QuatRotation& UniversalRotation::quat()
|
||||
{
|
||||
FGL_ASSERT( isQuat(), "Rotation is not quat" );
|
||||
return q_rotation;
|
||||
}
|
||||
|
||||
const QuatRotation& UniversalRotation::quat() const
|
||||
{
|
||||
FGL_ASSERT( isQuat(), "Rotation is not quat" );
|
||||
return q_rotation;
|
||||
}
|
||||
|
||||
UniversalRotation UniversalRotation::pointIn( const glm::vec3 vec )
|
||||
{
|
||||
return UniversalRotation( QuatRotation( glm::normalize( vec ) ) );
|
||||
}
|
||||
|
||||
@@ -13,69 +13,47 @@ namespace fgl::engine
|
||||
union
|
||||
{
|
||||
QuatRotation q_rotation;
|
||||
EulerRotation e_rotation { constants::DEFAULT_ROTATION };
|
||||
EulerRotation e_rotation;
|
||||
};
|
||||
|
||||
//! If true then the rotation is in a
|
||||
bool m_euler { true };
|
||||
//! If true then the rotation is a euler rotation
|
||||
bool m_euler;
|
||||
|
||||
public:
|
||||
|
||||
[[nodiscard]] UniversalRotation() : e_rotation( constants::DEFAULT_ROTATION ), m_euler( true ) {}
|
||||
[[nodiscard]] UniversalRotation();
|
||||
|
||||
[[nodiscard]] UniversalRotation( const EulerRotation& euler ) : e_rotation( euler ) {}
|
||||
[[nodiscard]] UniversalRotation( EulerRotation e_rotation_in );
|
||||
|
||||
[[nodiscard]] UniversalRotation( const QuatRotation& q_rotation ) : q_rotation( q_rotation ) {}
|
||||
[[nodiscard]] UniversalRotation( QuatRotation q_rotation_in );
|
||||
|
||||
FGL_DEFAULT_MOVE( UniversalRotation );
|
||||
FGL_DEFAULT_COPY( UniversalRotation );
|
||||
|
||||
NormalVector forward() const { return forcedQuat().forward(); }
|
||||
[[nodiscard]] NormalVector forward() const { return forcedQuat().forward(); }
|
||||
|
||||
NormalVector right() const { return forcedQuat().right(); }
|
||||
[[nodiscard]] NormalVector right() const { return forcedQuat().right(); }
|
||||
|
||||
NormalVector up() const { return forcedQuat().up(); }
|
||||
[[nodiscard]] NormalVector up() const { return forcedQuat().up(); }
|
||||
|
||||
inline bool isEuler() const { return m_euler; }
|
||||
[[nodiscard]] bool isEuler() const { return m_euler; }
|
||||
|
||||
inline bool isQuat() const { return !isEuler(); }
|
||||
[[nodiscard]] bool isQuat() const { return !isEuler(); }
|
||||
|
||||
//! Returns a quaternion rotation no matter the original rotation
|
||||
FGL_HOT [[nodiscard]] QuatRotation forcedQuat() const
|
||||
{
|
||||
if ( m_euler ) [[unlikely]]
|
||||
return e_rotation.toRotation();
|
||||
else [[likely]]
|
||||
return q_rotation;
|
||||
}
|
||||
[[nodiscard]] QuatRotation forcedQuat() const;
|
||||
|
||||
// Marked cold because it's only usd in the editor
|
||||
FGL_COLD EulerRotation& euler()
|
||||
{
|
||||
FGL_ASSERT( isEuler(), "Rotation is not euler" );
|
||||
return e_rotation;
|
||||
}
|
||||
[[nodiscard]] EulerRotation& euler();
|
||||
|
||||
// Marked cold because it's only usd in the editor
|
||||
FGL_COLD const EulerRotation& euler() const
|
||||
{
|
||||
FGL_ASSERT( isEuler(), "Rotation is not euler" );
|
||||
return e_rotation;
|
||||
}
|
||||
[[nodiscard]] const EulerRotation& euler() const;
|
||||
|
||||
FGL_HOT QuatRotation& quat()
|
||||
{
|
||||
FGL_ASSERT( isQuat(), "Rotation is not quat" );
|
||||
return q_rotation;
|
||||
}
|
||||
[[nodiscard]] QuatRotation& quat();
|
||||
|
||||
FGL_HOT const QuatRotation& quat() const
|
||||
{
|
||||
FGL_ASSERT( isQuat(), "Rotation is not quat" );
|
||||
return q_rotation;
|
||||
}
|
||||
[[nodiscard]] const QuatRotation& quat() const;
|
||||
|
||||
static UniversalRotation pointAt( const glm::vec3 vec );
|
||||
[[nodiscard]] static UniversalRotation pointIn( glm::vec3 vec );
|
||||
|
||||
// Universal modification
|
||||
void addX( float value );
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace fgl::engine
|
||||
|
||||
[[nodiscard]] PresentIndex imageCount() const
|
||||
{
|
||||
return static_cast< std::uint16_t >( m_swap_chain_images.size() );
|
||||
return static_cast< PresentIndex >( m_swap_chain_images.size() );
|
||||
}
|
||||
|
||||
[[nodiscard]] vk::Extent2D getSwapChainExtent() const { return m_swapchain_extent; }
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace fgl::engine
|
||||
throw std::runtime_error( "Failed to submit commmand buffer" );
|
||||
|
||||
is_frame_started = false;
|
||||
current_frame_idx = static_cast< std::uint16_t >( ( current_frame_idx + 1 ) % constants::MAX_FRAMES_IN_FLIGHT );
|
||||
current_frame_idx = static_cast< FrameIndex >( ( current_frame_idx + 1 ) % constants::MAX_FRAMES_IN_FLIGHT );
|
||||
}
|
||||
|
||||
void Renderer::setViewport( const CommandBuffer& buffer )
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
#include "engine/rendering/Surface.hpp"
|
||||
#include "extensions.hpp"
|
||||
#include "rendering/CommandBufferPool.hpp"
|
||||
#include "vma/vma_impl.hpp"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wundef"
|
||||
#include <vma/vma_impl.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
|
||||
@@ -6,9 +6,18 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <variant>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-tags"
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#include <slang-com-ptr.h>
|
||||
#include <slang.h>
|
||||
#include <variant>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "engine/FGL_DEFINES.hpp"
|
||||
#include "engine/constants.hpp"
|
||||
@@ -125,7 +134,7 @@ namespace fgl::engine
|
||||
|
||||
// Add the source directory to search paths
|
||||
const auto source_dir = path.parent_path().string();
|
||||
std::array< const char*, 2 > search_paths = { search_path_str.c_str(), source_dir.c_str() };
|
||||
std::array< const char*, 2 > search_paths = { { search_path_str.c_str(), source_dir.c_str() } };
|
||||
session_desc.searchPaths = search_paths.data();
|
||||
session_desc.searchPathCount = search_paths.size();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace fgl::engine
|
||||
|
||||
SetID max_set_idx { 0 };
|
||||
|
||||
for ( const auto& [ set_idx, _ ] : m_state->descriptor_set_layouts )
|
||||
for ( const auto& set_idx : m_state->descriptor_set_layouts | std::views::keys )
|
||||
{
|
||||
max_set_idx = std::max( max_set_idx, set_idx );
|
||||
}
|
||||
@@ -74,14 +74,14 @@ namespace fgl::engine
|
||||
m_state->m_dynamic_state.emplace_back( dynamic_state );
|
||||
}
|
||||
|
||||
void PipelineBuilder::setPushConstant( const vk::ShaderStageFlags flags, std::uint32_t size )
|
||||
void PipelineBuilder::setPushConstant( const vk::ShaderStageFlags flags, const std::uint32_t size )
|
||||
{
|
||||
m_state->push_constant.offset = 0;
|
||||
m_state->push_constant.size = size;
|
||||
m_state->push_constant.stageFlags = flags;
|
||||
}
|
||||
|
||||
void PipelineBuilder::setBindPoint( vk::PipelineBindPoint bind_point )
|
||||
void PipelineBuilder::setBindPoint( const vk::PipelineBindPoint bind_point )
|
||||
{
|
||||
m_state->bind_point = bind_point;
|
||||
}
|
||||
@@ -96,7 +96,9 @@ namespace fgl::engine
|
||||
return color_blend_attachment.back();
|
||||
}
|
||||
|
||||
PipelineBuilder::BuilderState::BuilderState( std::uint32_t subpass ) : m_subpass_stage( subpass )
|
||||
PipelineBuilder::BuilderState::BuilderState( const std::uint32_t subpass ) :
|
||||
m_subpass_stage( subpass ),
|
||||
bind_point( vk::PipelineBindPoint::eGraphics )
|
||||
{
|
||||
setDefault();
|
||||
}
|
||||
@@ -270,13 +272,15 @@ namespace fgl::engine
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
vk::raii::Pipeline PipelineBuilder::createDynamicPipeline( BuilderState& state, vk::raii::PipelineLayout& layout )
|
||||
vk::raii::Pipeline PipelineBuilder::
|
||||
createDynamicPipeline( BuilderState& state, const vk::raii::PipelineLayout& layout )
|
||||
{
|
||||
if ( state.shaders.compute ) return createComputePipeline( state, layout );
|
||||
return createGraphicsPipeline( state, layout );
|
||||
}
|
||||
|
||||
vk::raii::Pipeline PipelineBuilder::createComputePipeline( BuilderState& state, vk::raii::PipelineLayout& layout )
|
||||
vk::raii::Pipeline PipelineBuilder::
|
||||
createComputePipeline( BuilderState& state, const vk::raii::PipelineLayout& layout )
|
||||
{
|
||||
vk::StructureChain< vk::ComputePipelineCreateInfo > chain {};
|
||||
|
||||
@@ -295,7 +299,8 @@ namespace fgl::engine
|
||||
return Device::getInstance()->createComputePipeline( VK_NULL_HANDLE, info );
|
||||
}
|
||||
|
||||
vk::raii::Pipeline PipelineBuilder::createGraphicsPipeline( BuilderState& state, vk::raii::PipelineLayout& layout )
|
||||
vk::raii::Pipeline PipelineBuilder::
|
||||
createGraphicsPipeline( BuilderState& state, const vk::raii::PipelineLayout& layout )
|
||||
{
|
||||
vk::StructureChain< vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo > chain {};
|
||||
vk::GraphicsPipelineCreateInfo& info { chain.get< vk::GraphicsPipelineCreateInfo >() };
|
||||
@@ -357,12 +362,12 @@ namespace fgl::engine
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
vk::raii::Pipeline PipelineBuilder::createFromState( BuilderState& state, vk::raii::PipelineLayout& layout )
|
||||
vk::raii::Pipeline PipelineBuilder::createFromState( BuilderState& state, const vk::raii::PipelineLayout& layout )
|
||||
{
|
||||
return createDynamicPipeline( state, layout );
|
||||
}
|
||||
|
||||
vk::raii::Pipeline PipelineBuilder::rebuildFromState( BuilderState& state, vk::raii::PipelineLayout& layout )
|
||||
vk::raii::Pipeline PipelineBuilder::rebuildFromState( BuilderState& state, const vk::raii::PipelineLayout& layout )
|
||||
{
|
||||
auto& shaders { state.shaders };
|
||||
|
||||
|
||||
@@ -135,13 +135,13 @@ namespace fgl::engine
|
||||
static vk::raii::Pipeline
|
||||
createRenderPassPipeline( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
|
||||
static vk::raii::Pipeline createDynamicPipeline( BuilderState& state, vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline createDynamicPipeline( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
|
||||
static vk::raii::Pipeline createComputePipeline( BuilderState& state, vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline createGraphicsPipeline( BuilderState& state, vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline createComputePipeline( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline createGraphicsPipeline( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
|
||||
static vk::raii::Pipeline createFromState( BuilderState& state, vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline rebuildFromState( BuilderState& state, vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline createFromState( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
static vk::raii::Pipeline rebuildFromState( BuilderState& state, const vk::raii::PipelineLayout& layout );
|
||||
|
||||
std::unique_ptr< Pipeline > create();
|
||||
};
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
using PresentIndex = std::uint16_t;
|
||||
using FrameIndex = std::uint16_t;
|
||||
using PresentIndex = std::uint_fast8_t;
|
||||
using FrameIndex = std::uint_fast8_t;
|
||||
|
||||
using CameraIndex = std::uint16_t;
|
||||
using CameraIndex = std::uint_fast16_t;
|
||||
|
||||
using DeltaTime = float;
|
||||
} // namespace fgl::engine
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace fgl::engine
|
||||
class EntityRendererSystem
|
||||
{
|
||||
//! Standard pipeline for textureless models
|
||||
std::unique_ptr< Pipeline > m_standard_pipeline;
|
||||
std::unique_ptr< Pipeline > m_standard_pipeline {};
|
||||
|
||||
//! Pipeline for basic textured models (Single texture)
|
||||
std::unique_ptr< Pipeline > m_textured_pipeline;
|
||||
std::unique_ptr< Pipeline > m_textured_pipeline {};
|
||||
// std::unique_ptr< ComputePipeline > m_cull_pipeline {};
|
||||
|
||||
CommandBuffer& setupSystem( const FrameInfo& );
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace fgl::engine
|
||||
return command_buffer;
|
||||
}
|
||||
|
||||
void LineDrawer::pass( FrameInfo& info )
|
||||
void LineDrawer::pass( [[maybe_unused]] FrameInfo& info )
|
||||
{
|
||||
/*
|
||||
ZoneScopedN( "LineDrawer::pass" );
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 2/28/25.
|
||||
//
|
||||
#include "ShadowRenderer.hpp"
|
||||
|
||||
#include "FrameInfo.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
CommandBuffer& ShadowRenderer::setupSystem( const FrameInfo& info )
|
||||
{}
|
||||
|
||||
void ShadowRenderer::pass( FrameInfo& info )
|
||||
{
|
||||
// Render any shadowmaps attach to the camera
|
||||
auto& command_buffer { setupSystem( info ) };
|
||||
|
||||
//TODO: Implement object culling for shadowmaps
|
||||
// if ( draw_commands.empty() ) return;
|
||||
|
||||
m_pipeline->bind( command_buffer );
|
||||
}
|
||||
|
||||
ShadowRenderer::ShadowRenderer()
|
||||
{
|
||||
PipelineBuilder builder { 0 };
|
||||
|
||||
builder.setVertexShader( Shader::loadVertex( "shaders/shadowmap.slang" ) );
|
||||
|
||||
m_pipeline = builder.create();
|
||||
m_pipeline->setDebugName( "Shadow map pipeline" );
|
||||
}
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 2/28/25.
|
||||
//
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "memory/buffers/vector/HostVector.hpp"
|
||||
#include "rendering/pipelines/v2/Pipeline.hpp"
|
||||
|
||||
namespace fgl::engine
|
||||
{
|
||||
struct FrameInfo;
|
||||
struct ModelMatrixInfo;
|
||||
|
||||
class ShadowRenderer
|
||||
{
|
||||
std::unique_ptr< Pipeline > m_pipeline {};
|
||||
|
||||
using DrawParameterBuffer = HostVector< vk::DrawIndexedIndirectCommand >;
|
||||
using DrawIndexedIndirectCommand = HostVector< ModelMatrixInfo >;
|
||||
|
||||
public:
|
||||
|
||||
CommandBuffer& setupSystem( const FrameInfo& info );
|
||||
void pass( FrameInfo& info );
|
||||
|
||||
ShadowRenderer();
|
||||
};
|
||||
|
||||
} // namespace fgl::engine
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
AddFGLChildLibrary(FGLLoader STATIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
AddFGLChildLibrary(FGLLoader STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
#target_include_directories(FGLLoader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
// - base64: base64 decode/encode library.
|
||||
// - stb_image: Image loading library.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef TINY_GLTF_H_
|
||||
#define TINY_GLTF_H_
|
||||
|
||||
@@ -57,6 +57,7 @@ THE SOFTWARE.
|
||||
// #include "tiny_obj_loader.h"
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef TINY_OBJ_LOADER_H_
|
||||
#define TINY_OBJ_LOADER_H_
|
||||
|
||||
@@ -2366,9 +2367,8 @@ namespace tinyobj
|
||||
// flush previous material.
|
||||
if ( !material.name.empty() )
|
||||
{
|
||||
material_map->insert( std::pair<
|
||||
std::string,
|
||||
int >( material.name, static_cast< int >( materials->size() ) ) );
|
||||
material_map->insert(
|
||||
std::pair< std::string, int >( material.name, static_cast< int >( materials->size() ) ) );
|
||||
materials->push_back( material );
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#define TINYGLTF_USE_CPP14
|
||||
#include "tiny_gltf.h"
|
||||
#include "../include/tiny_gltf.h"
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -15267,7 +15267,7 @@ class binary_writer
|
||||
static CharType to_char_type(std::uint8_t x) noexcept
|
||||
{
|
||||
static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
|
||||
static_assert(std::is_trivial<CharType>::value, "CharType must be trivial");
|
||||
static_assert(std::is_trivially_constructible_v<CharType> && std::is_trivially_copyable_v<CharType>, "CharType must be trivial");
|
||||
CharType result;
|
||||
std::memcpy(&result, &x, sizeof(x));
|
||||
return result;
|
||||
@@ -9,5 +9,5 @@
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
#include "../include/tiny_obj_loader.h"
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -1,25 +0,0 @@
|
||||
if (NOT DEFINED FGL_ENABLE_TESTS)
|
||||
set(FGL_ENABLE_TESTS 0)
|
||||
endif ()
|
||||
|
||||
|
||||
if (FGL_ENABLE_TESTS)
|
||||
message("-- FGL_ENABLE_TESTS: Enabled")
|
||||
enable_testing()
|
||||
|
||||
file(GLOB_RECURSE FGL_TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/**.cpp")
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED 23)
|
||||
|
||||
add_executable(FGLTests ${FGL_TEST_SOURCES})
|
||||
target_link_libraries(FGLTests PUBLIC FGLEngine)
|
||||
target_link_libraries(FGLTests PRIVATE Catch2::Catch2WithMain)
|
||||
target_compile_definitions(FGLTests PUBLIC GLM_FORCE_RADIANS GLM_FORCE_DEPTH_ZERO_TO_ONE)
|
||||
target_compile_features(FGLTests PRIVATE cxx_std_23)
|
||||
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(FGLTests)
|
||||
else ()
|
||||
message("-- FGL_ENABLE_TESTS: Disabled")
|
||||
endif ()
|
||||
@@ -1,122 +0,0 @@
|
||||
//
|
||||
// Created by kj16609 on 2/15/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <catch2/catch_all.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#include "engine/primitives/Scale.hpp"
|
||||
#include "engine/primitives/matricies/Matrix.hpp"
|
||||
#include "engine/primitives/points/Coordinate.hpp"
|
||||
#include "engine/primitives/rotation/EulerRotation.hpp"
|
||||
#include "engine/primitives/rotation/QuatRotation.hpp"
|
||||
#include "engine/primitives/vectors/Vector.hpp"
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
template <>
|
||||
struct StringMaker< glm::vec3 >
|
||||
{
|
||||
static std::string convert( const glm::vec3& vec ) { return glm::to_string( vec ); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< fgl::engine::Vector >
|
||||
{
|
||||
static std::string convert( const fgl::engine::Vector& vec )
|
||||
{
|
||||
return StringMaker< glm::vec3 >::convert( static_cast< glm::vec3 >( vec.vec() ) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< glm::mat4 >
|
||||
{
|
||||
static std::string convert( const glm::mat4& mat )
|
||||
{
|
||||
return "\n\t" + glm::to_string( mat[ 0 ] ) + "\n\t" + glm::to_string( mat[ 1 ] ) + "\n\t"
|
||||
+ glm::to_string( mat[ 2 ] ) + "\n\t" + glm::to_string( mat[ 3 ] );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< glm::quat >
|
||||
{
|
||||
static std::string convert( const glm::quat& quat )
|
||||
{
|
||||
return std::format( "({},{},{},{})", quat.w, quat.x, quat.y, quat.z );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< fgl::engine::QuatRotation >
|
||||
{
|
||||
static std::string convert( const fgl::engine::QuatRotation& rot )
|
||||
{
|
||||
return StringMaker< glm::quat >::convert( rot.internal_quat() );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< fgl::engine::EulerRotation >
|
||||
{
|
||||
static std::string convert( const fgl::engine::EulerRotation& rot )
|
||||
{
|
||||
return StringMaker< glm::vec3 >::convert( glm::vec3( rot.x, rot.y, rot.z ) );
|
||||
}
|
||||
};
|
||||
|
||||
template < fgl::engine::MatrixType MType >
|
||||
struct StringMaker< fgl::engine::Matrix< MType > >
|
||||
{
|
||||
static std::string convert( const fgl::engine::Matrix< MType >& mat )
|
||||
{
|
||||
return StringMaker< glm::mat4 >::convert( static_cast< glm::mat4 >( mat ) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< ::fgl::engine::NormalVector >
|
||||
{
|
||||
static std::string convert( const fgl::engine::NormalVector vec )
|
||||
{
|
||||
return StringMaker< fgl::engine::Vector >::convert( static_cast< fgl::engine::Vector >( vec ) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< ::fgl::engine::Scale >
|
||||
{
|
||||
static std::string convert( const fgl::engine::Scale scale )
|
||||
{
|
||||
return StringMaker< glm::vec3 >::convert( static_cast< glm::vec3 >( scale ) );
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StringMaker< ::fgl::engine::ModelCoordinate >
|
||||
{
|
||||
static std::string convert( const fgl::engine::ModelCoordinate coord )
|
||||
{
|
||||
return StringMaker< glm::vec3 >::convert( coord.vec() );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#ifndef NDEBUG
|
||||
namespace glm
|
||||
{
|
||||
inline bool operator==( const glm::vec3& lhs, const glm::vec3& rhs )
|
||||
{
|
||||
return glm::all( ::glm::epsilonEqual( lhs, rhs, std::numeric_limits< float >::epsilon() ) );
|
||||
}
|
||||
|
||||
} // namespace glm
|
||||
#else
|
||||
#warning "Debug mode not enabled. Tests will fail when checking for floating point equality."
|
||||
#endif
|
||||
Reference in New Issue
Block a user