Compare commits
No commits in common. "487f907ffbeb1fcc4f4bb65766845c913b1c5fd2" and "61473c275820b5f226a6f79a6e07b12608638862" have entirely different histories.
487f907ffb
...
61473c2758
17 changed files with 65 additions and 69 deletions
|
|
@ -6,7 +6,6 @@ PUBLIC
|
||||||
assets
|
assets
|
||||||
logger
|
logger
|
||||||
lt_debug
|
lt_debug
|
||||||
tbb
|
|
||||||
)
|
)
|
||||||
add_test_module(libasset_baker
|
add_test_module(libasset_baker
|
||||||
bakers.test.cpp
|
bakers.test.cpp
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ Suite packing = "shader_pack"_suite = [] {
|
||||||
|
|
||||||
auto stream = std::ifstream {
|
auto stream = std::ifstream {
|
||||||
out_path,
|
out_path,
|
||||||
std::ios::binary,
|
std::ios::binary | std::ios::beg,
|
||||||
};
|
};
|
||||||
expect_true(stream.is_open());
|
expect_true(stream.is_open());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,6 @@ public:
|
||||||
return m_registry;
|
return m_registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto id() const -> EntityId
|
|
||||||
{
|
|
||||||
return m_identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
memory::Ref<Registry> m_registry;
|
memory::Ref<Registry> m_registry;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
add_library_module(input system.cpp)
|
add_library_module(input system.cpp)
|
||||||
target_link_libraries(input PUBLIC surface math logger tbb)
|
target_link_libraries(input PUBLIC surface math logger)
|
||||||
|
|
||||||
add_test_module(input system.test.cpp)
|
add_test_module(input system.test.cpp)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include <memory/reference.hpp>
|
#include <memory/reference.hpp>
|
||||||
#include <memory/scope.hpp>
|
#include <memory/scope.hpp>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <surface/system.hpp>
|
|
||||||
#include <test/test.hpp>
|
#include <test/test.hpp>
|
||||||
|
|
||||||
// NOLINTBEGIN
|
// NOLINTBEGIN
|
||||||
|
|
@ -49,9 +48,9 @@ public:
|
||||||
auto add_surface_component() -> ecs::EntityId
|
auto add_surface_component() -> ecs::EntityId
|
||||||
{
|
{
|
||||||
auto entity = m_registry->create_entity();
|
auto entity = m_registry->create_entity();
|
||||||
m_surface_system.create_surface_component(
|
m_registry->add<surface::SurfaceComponent>(
|
||||||
entity,
|
entity,
|
||||||
{ .title = "", .resolution = { 20u, 20u } }
|
surface::SurfaceComponent::CreateInfo {}
|
||||||
);
|
);
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
|
|
@ -59,8 +58,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
memory::Ref<ecs::Registry> m_registry = memory::create_ref<ecs::Registry>();
|
memory::Ref<ecs::Registry> m_registry = memory::create_ref<ecs::Registry>();
|
||||||
|
|
||||||
surface::System m_surface_system = surface::System { m_registry };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Suite raii = "raii"_suite = "raii"_suite = [] {
|
Suite raii = "raii"_suite = "raii"_suite = [] {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ namespace lt {
|
||||||
void renderer_callback(
|
void renderer_callback(
|
||||||
renderer::MessageSeverity message_severity,
|
renderer::MessageSeverity message_severity,
|
||||||
renderer::MessageType message_type,
|
renderer::MessageType message_type,
|
||||||
renderer::MessageData data,
|
renderer::MessengerCallbackData data,
|
||||||
std::any &user_data
|
std::any user_data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
log_dbg("RENDERER CALLBACK: {}", data.message);
|
log_dbg("RENDERER CALLBACK: {}", data.message);
|
||||||
|
|
@ -149,7 +149,7 @@ public:
|
||||||
m_surface_system = memory::create_ref<lt::surface::System>(m_editor_registry);
|
m_surface_system = memory::create_ref<lt::surface::System>(m_editor_registry);
|
||||||
|
|
||||||
m_window = m_editor_registry->create_entity();
|
m_window = m_editor_registry->create_entity();
|
||||||
m_surface_system->create_surface_component(
|
m_surface_system->create_component(
|
||||||
m_window,
|
m_window,
|
||||||
SurfaceComponent::CreateInfo {
|
SurfaceComponent::CreateInfo {
|
||||||
.title = "Editor Window",
|
.title = "Editor Window",
|
||||||
|
|
@ -207,12 +207,12 @@ public:
|
||||||
memory::Ref<app::SystemStats> system_stats = nullptr;
|
memory::Ref<app::SystemStats> system_stats = nullptr;
|
||||||
|
|
||||||
m_renderer_system = std::make_shared<renderer::System>(renderer::System::CreateInfo {
|
m_renderer_system = std::make_shared<renderer::System>(renderer::System::CreateInfo {
|
||||||
.config = { .target_api = renderer::Api::vulkan, .max_frames_in_flight = 3u },
|
.config = { .target_api = renderer::API::Vulkan, .max_frames_in_flight = 3u },
|
||||||
.registry = m_editor_registry,
|
.registry = m_editor_registry,
|
||||||
.surface_entity = entity,
|
.surface_entity = entity,
|
||||||
});
|
});
|
||||||
|
|
||||||
std::ignore = m_renderer_system->create_messenger_component(
|
m_renderer_system->create_messenger_component(
|
||||||
m_window,
|
m_window,
|
||||||
renderer::MessengerComponent::CreateInfo {
|
renderer::MessengerComponent::CreateInfo {
|
||||||
.severities = renderer::MessageSeverity::all,
|
.severities = renderer::MessageSeverity::all,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <memory/reference.hpp>
|
#include <memory/reference.hpp>
|
||||||
#include <mirror/layers/editor_layer.hpp>
|
#include <mirror/layers/editor_layer.hpp>
|
||||||
#include <renderer/framebuffer.hpp>
|
#include <renderer/framebuffer.hpp>
|
||||||
|
#include <renderer/graphics_context.hpp>
|
||||||
#include <renderer/texture.hpp>
|
#include <renderer/texture.hpp>
|
||||||
#include <ui/ui.hpp>
|
#include <ui/ui.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,49 +140,49 @@ void Instance::initialize_instance()
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto settings = std::array<VkLayerSettingEXT, 7>({
|
const auto settings = std::array<VkLayerSettingEXT, 7>({
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "validate_core",
|
.pSettingName = "validate_core",
|
||||||
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
||||||
.valueCount = 1,
|
.valueCount = 1,
|
||||||
.pValues = &setting_validate_core,
|
.pValues = &setting_validate_core,
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "validate_sync",
|
.pSettingName = "validate_sync",
|
||||||
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
||||||
.valueCount = 1,
|
.valueCount = 1,
|
||||||
.pValues = &setting_validate_sync,
|
.pValues = &setting_validate_sync,
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "thread_safety",
|
.pSettingName = "thread_safety",
|
||||||
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
||||||
.valueCount = 1,
|
.valueCount = 1,
|
||||||
.pValues = &setting_thread_safety,
|
.pValues = &setting_thread_safety,
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "debug_action",
|
.pSettingName = "debug_action",
|
||||||
.type = VK_LAYER_SETTING_TYPE_STRING_EXT,
|
.type = VK_LAYER_SETTING_TYPE_STRING_EXT,
|
||||||
.valueCount = 1,
|
.valueCount = 1,
|
||||||
.pValues = static_cast<const void *>(&setting_debug_action),
|
.pValues = static_cast<const void *>(&setting_debug_action),
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "report_flags",
|
.pSettingName = "report_flags",
|
||||||
.type = VK_LAYER_SETTING_TYPE_STRING_EXT,
|
.type = VK_LAYER_SETTING_TYPE_STRING_EXT,
|
||||||
.valueCount = setting_report_flags.size(),
|
.valueCount = setting_report_flags.size(),
|
||||||
.pValues = static_cast<const void *>(setting_report_flags.data()),
|
.pValues = static_cast<const void *>(setting_report_flags.data()),
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "enable_message_limit",
|
.pSettingName = "enable_message_limit",
|
||||||
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
.type = VK_LAYER_SETTING_TYPE_BOOL32_EXT,
|
||||||
.valueCount = 1,
|
.valueCount = 1,
|
||||||
.pValues = &setting_enable_message_limit,
|
.pValues = &setting_enable_message_limit,
|
||||||
},
|
},
|
||||||
VkLayerSettingEXT {
|
{
|
||||||
.pLayerName = layer_name,
|
.pLayerName = layer_name,
|
||||||
.pSettingName = "duplicate_message_limit",
|
.pSettingName = "duplicate_message_limit",
|
||||||
.type = VK_LAYER_SETTING_TYPE_UINT32_EXT,
|
.type = VK_LAYER_SETTING_TYPE_UINT32_EXT,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <renderer/backend/vk/vulkan.hpp>
|
#include <renderer/backend/vk/vulkan.hpp>
|
||||||
|
#include <vulkan/vk_enum_string_helper.h>
|
||||||
|
|
||||||
namespace lt::renderer::vk {
|
namespace lt::renderer::vk {
|
||||||
|
|
||||||
|
|
@ -8,9 +9,11 @@ inline void vkc(VkResult result)
|
||||||
{
|
{
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
throw std::runtime_error {
|
throw std::runtime_error { std::format(
|
||||||
std::format("Vulkan call failed with result: {}", std::to_underlying(result))
|
"Vulkan call failed with result: {}({})",
|
||||||
};
|
string_VkResult(result),
|
||||||
|
std::to_underlying(result)
|
||||||
|
) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <memory/scope.hpp>
|
#include <memory/scope.hpp>
|
||||||
#include <renderer/api.hpp>
|
#include <renderer/api.hpp>
|
||||||
#include <renderer/components/messenger.hpp>
|
#include <renderer/components/messenger.hpp>
|
||||||
|
#include <renderer/frontend/renderer/renderer.hpp>
|
||||||
|
|
||||||
namespace lt::renderer {
|
namespace lt::renderer {
|
||||||
|
|
||||||
|
|
@ -14,10 +15,10 @@ class System: public app::ISystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** config.max_frames_in_flight should not be higher than this value. */
|
/** config.max_frames_in_flight should not be higher than this value. */
|
||||||
static constexpr auto frames_in_flight_upper_limit = 5u;
|
static constexpr auto frames_in_flight_upper_limit = IRenderer::frames_in_flight_upper_limit;
|
||||||
|
|
||||||
/** config.max_frames_in_flight should not be lower than this value. */
|
/** config.max_frames_in_flight should not be lower than this value. */
|
||||||
static constexpr auto frames_in_flight_lower_limit = 1u;
|
static constexpr auto frames_in_flight_lower_limit = IRenderer::frames_in_flight_lower_limit;
|
||||||
|
|
||||||
struct Configuration
|
struct Configuration
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ target_link_libraries(surface PUBLIC
|
||||||
app
|
app
|
||||||
math
|
math
|
||||||
memory
|
memory
|
||||||
tbb
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
logger
|
logger
|
||||||
lt_debug
|
lt_debug
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ void System::on_unregister()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::create_surface_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
|
auto System::create_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
|
||||||
|
-> std::optional<SurfaceComponent *>
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto &component = m_registry->add<SurfaceComponent>(entity, info);
|
auto &component = m_registry->add<SurfaceComponent>(entity, info);
|
||||||
|
|
@ -182,6 +183,8 @@ try
|
||||||
{
|
{
|
||||||
XUnmapWindow(display, main_window);
|
XUnmapWindow(display, main_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &component;
|
||||||
}
|
}
|
||||||
catch (const std::exception &exp)
|
catch (const std::exception &exp)
|
||||||
{
|
{
|
||||||
|
|
@ -189,6 +192,7 @@ catch (const std::exception &exp)
|
||||||
log_err("\tentity: {}", entity);
|
log_err("\tentity: {}", entity);
|
||||||
log_err("\twhat: {}", exp.what());
|
log_err("\twhat: {}", exp.what());
|
||||||
m_registry->remove<SurfaceComponent>(entity);
|
m_registry->remove<SurfaceComponent>(entity);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::on_surface_destruct(ecs::Registry ®istry, ecs::EntityId entity)
|
void System::on_surface_destruct(ecs::Registry ®istry, ecs::EntityId entity)
|
||||||
|
|
@ -390,7 +394,7 @@ void System::modify_resolution(SurfaceComponent &surface, const ModifyResolution
|
||||||
|
|
||||||
void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequest &request)
|
void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequest &request)
|
||||||
{
|
{
|
||||||
// surface.m_position = request.position;
|
surface.m_position = request.position;
|
||||||
|
|
||||||
auto &[display, window, _] = surface.m_native_data;
|
auto &[display, window, _] = surface.m_native_data;
|
||||||
const auto &[x, y] = request.position;
|
const auto &[x, y] = request.position;
|
||||||
|
|
@ -424,7 +428,6 @@ void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequ
|
||||||
// So we just put the event back into the queue and move on.
|
// So we just put the event back into the queue and move on.
|
||||||
XPutBackEvent(display, &event);
|
XPutBackEvent(display, &event);
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
XFlush(display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::modify_visiblity(SurfaceComponent &surface, const ModifyVisibilityRequest &request)
|
void System::modify_visiblity(SurfaceComponent &surface, const ModifyVisibilityRequest &request)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ using test::expect_eq;
|
||||||
using test::expect_ne;
|
using test::expect_ne;
|
||||||
using test::expect_not_nullptr;
|
using test::expect_not_nullptr;
|
||||||
using test::expect_throw;
|
using test::expect_throw;
|
||||||
using test::expect_true;
|
|
||||||
using test::Suite;
|
using test::Suite;
|
||||||
|
|
||||||
[[nodiscard]] auto tick_info() -> app::TickInfo
|
[[nodiscard]] auto tick_info() -> app::TickInfo
|
||||||
|
|
@ -49,39 +48,35 @@ public:
|
||||||
return m_registry;
|
return m_registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto create_component(
|
auto add_surface_component(
|
||||||
SurfaceComponent::CreateInfo info = SurfaceComponent::CreateInfo {
|
SurfaceComponent::CreateInfo info = SurfaceComponent::CreateInfo {
|
||||||
.title = title,
|
.title = title,
|
||||||
.resolution = { width, height },
|
.resolution = { width, height },
|
||||||
.vsync = vsync,
|
.vsync = vsync,
|
||||||
.visible = visible,
|
.visible = visible,
|
||||||
}
|
}
|
||||||
) -> std::optional<SurfaceComponent *>
|
) -> SurfaceComponent &
|
||||||
{
|
{
|
||||||
auto entity = m_registry->create_entity();
|
auto entity = m_registry->create_entity();
|
||||||
m_system.create_surface_component(entity, info);
|
return m_registry->add<SurfaceComponent>(entity, info);
|
||||||
|
|
||||||
return &m_registry->get<SurfaceComponent>(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_values(SurfaceComponent *component)
|
void check_values(const SurfaceComponent &component)
|
||||||
{
|
{
|
||||||
#ifdef LIGHT_PLATFORM_LINUX
|
#ifdef LIGHT_PLATFORM_LINUX
|
||||||
expect_not_nullptr(component->get_native_data().display);
|
expect_not_nullptr(component.get_native_data().display);
|
||||||
expect_ne(component->get_native_data().window, 0);
|
expect_ne(component.get_native_data().window, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
expect_eq(component->get_resolution().x, width);
|
expect_eq(component.get_resolution().x, width);
|
||||||
expect_eq(component->get_resolution().y, height);
|
expect_eq(component.get_resolution().y, height);
|
||||||
expect_eq(component->get_title(), title);
|
expect_eq(component.get_title(), title);
|
||||||
expect_eq(component->is_vsync(), vsync);
|
expect_eq(component.is_vsync(), vsync);
|
||||||
expect_eq(component->is_visible(), visible);
|
expect_eq(component.is_visible(), visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
memory::Ref<ecs::Registry> m_registry = memory::create_ref<ecs::Registry>();
|
memory::Ref<ecs::Registry> m_registry = memory::create_ref<ecs::Registry>();
|
||||||
|
|
||||||
System m_system { m_registry };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -101,6 +96,10 @@ Suite raii = "raii"_suite = [] {
|
||||||
|
|
||||||
Case { "unhappy path throws" } = [] {
|
Case { "unhappy path throws" } = [] {
|
||||||
expect_throw([] { ignore = System { {} }; });
|
expect_throw([] { ignore = System { {} }; });
|
||||||
|
|
||||||
|
auto fixture = Fixture {};
|
||||||
|
fixture.add_surface_component();
|
||||||
|
expect_throw([&] { ignore = System { fixture.registry() }; });
|
||||||
};
|
};
|
||||||
|
|
||||||
Case { "post construct has correct state" } = [] {
|
Case { "post construct has correct state" } = [] {
|
||||||
|
|
@ -113,7 +112,7 @@ Suite raii = "raii"_suite = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = memory::create_scope<System>(fixture.registry());
|
auto system = memory::create_scope<System>(fixture.registry());
|
||||||
|
|
||||||
fixture.create_component();
|
fixture.add_surface_component();
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
||||||
|
|
||||||
system.reset();
|
system.reset();
|
||||||
|
|
@ -143,28 +142,29 @@ Suite system_events = "system_events"_suite = [] {
|
||||||
Suite registry_events = "registry_events"_suite = [] {
|
Suite registry_events = "registry_events"_suite = [] {
|
||||||
Case { "on_construct<SurfaceComponent> initializes component" } = [] {
|
Case { "on_construct<SurfaceComponent> initializes component" } = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
|
auto system = System { fixture.registry() };
|
||||||
|
|
||||||
const auto &component = fixture.create_component();
|
const auto &component = fixture.add_surface_component();
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
||||||
fixture.check_values(*component);
|
fixture.check_values(component);
|
||||||
};
|
};
|
||||||
|
|
||||||
Case { "unhappy on_construct<SurfaceComponent> throws" } = [] {
|
Case { "unhappy on_construct<SurfaceComponent> throws" } = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = System { fixture.registry() };
|
auto system = System { fixture.registry() };
|
||||||
|
|
||||||
expect_throw([&] { fixture.create_component({ .resolution = { width, 0 } }); });
|
expect_throw([&] { fixture.add_surface_component({ .resolution = { width, 0 } }); });
|
||||||
|
|
||||||
expect_throw([&] { fixture.create_component({ .resolution = { 0, height } }); });
|
expect_throw([&] { fixture.add_surface_component({ .resolution = { 0, height } }); });
|
||||||
|
|
||||||
expect_throw([&] {
|
expect_throw([&] {
|
||||||
fixture.create_component(
|
fixture.add_surface_component(
|
||||||
{ .title = "", .resolution = { SurfaceComponent::max_dimension + 1, height } }
|
{ .title = "", .resolution = { SurfaceComponent::max_dimension + 1, height } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect_throw([&] {
|
expect_throw([&] {
|
||||||
fixture.create_component(
|
fixture.add_surface_component(
|
||||||
{ .title = "", .resolution = { width, SurfaceComponent::max_dimension + 1 } }
|
{ .title = "", .resolution = { width, SurfaceComponent::max_dimension + 1 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -172,7 +172,7 @@ Suite registry_events = "registry_events"_suite = [] {
|
||||||
auto big_str = std::string {};
|
auto big_str = std::string {};
|
||||||
big_str.resize(SurfaceComponent::max_title_length + 1);
|
big_str.resize(SurfaceComponent::max_title_length + 1);
|
||||||
expect_throw([&] {
|
expect_throw([&] {
|
||||||
fixture.create_component({ .title = big_str, .resolution = { width, height } });
|
fixture.add_surface_component({ .title = big_str, .resolution = { width, height } });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ Suite registry_events = "registry_events"_suite = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = System { fixture.registry() };
|
auto system = System { fixture.registry() };
|
||||||
|
|
||||||
expect_throw([&] { fixture.create_component({ .resolution = { width, 0 } }); });
|
expect_throw([&] { fixture.add_surface_component({ .resolution = { width, 0 } }); });
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 0);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -188,9 +188,9 @@ Suite registry_events = "registry_events"_suite = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = memory::create_scope<System>(fixture.registry());
|
auto system = memory::create_scope<System>(fixture.registry());
|
||||||
|
|
||||||
const auto &component = fixture.create_component();
|
const auto &component = fixture.add_surface_component();
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
||||||
fixture.check_values(*component);
|
fixture.check_values(component);
|
||||||
|
|
||||||
system.reset();
|
system.reset();
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 0);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 0);
|
||||||
|
|
@ -207,7 +207,7 @@ Suite tick = "tick"_suite = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = System { fixture.registry() };
|
auto system = System { fixture.registry() };
|
||||||
|
|
||||||
fixture.create_component();
|
fixture.add_surface_component();
|
||||||
system.tick(tick_info());
|
system.tick(tick_info());
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -216,7 +216,7 @@ Suite tick_handles_events = "tick_handles_events"_suite = [] {
|
||||||
Case { "ticking clears previous tick's events" } = [] {
|
Case { "ticking clears previous tick's events" } = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = System { fixture.registry() };
|
auto system = System { fixture.registry() };
|
||||||
auto &surface = **fixture.create_component();
|
auto &surface = fixture.add_surface_component();
|
||||||
|
|
||||||
// flush window-creation events
|
// flush window-creation events
|
||||||
system.tick(tick_info());
|
system.tick(tick_info());
|
||||||
|
|
@ -237,7 +237,7 @@ Suite tick_handles_requests = "tick_handles_requests"_suite = [] {
|
||||||
Case { "ticking clears requests" } = [] {
|
Case { "ticking clears requests" } = [] {
|
||||||
auto fixture = Fixture {};
|
auto fixture = Fixture {};
|
||||||
auto system = System { fixture.registry() };
|
auto system = System { fixture.registry() };
|
||||||
auto &surface = **fixture.create_component();
|
auto &surface = fixture.add_surface_component();
|
||||||
|
|
||||||
constexpr auto title = "ABC";
|
constexpr auto title = "ABC";
|
||||||
constexpr auto position = math::ivec2 { 50, 50 };
|
constexpr auto position = math::ivec2 { 50, 50 };
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ public:
|
||||||
|
|
||||||
void on_unregister() override;
|
void on_unregister() override;
|
||||||
|
|
||||||
void create_surface_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info);
|
auto create_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
|
||||||
|
-> std::optional<SurfaceComponent *>;
|
||||||
|
|
||||||
void tick(app::TickInfo tick) override;
|
void tick(app::TickInfo tick) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
add_library_module(test test.cpp entrypoint.cpp)
|
add_library_module(test test.cpp entrypoint.cpp)
|
||||||
add_library_module(fuzz_test test.cpp fuzz.cpp)
|
add_library_module(fuzz_test test.cpp fuzz.cpp)
|
||||||
|
|
||||||
target_link_libraries(test PUBLIC tbb)
|
|
||||||
target_link_libraries(fuzz_test PUBLIC tbb)
|
|
||||||
|
|
||||||
add_test_module(test test.test.cpp)
|
add_test_module(test test.test.cpp)
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,7 @@ struct TestSuite
|
||||||
template<typename TSuite>
|
template<typename TSuite>
|
||||||
TestSuite(TSuite body)
|
TestSuite(TSuite body)
|
||||||
{
|
{
|
||||||
|
std::println("CONSTRUCTOR");
|
||||||
#ifndef LIGHT_SKIP_TESTS
|
#ifndef LIGHT_SKIP_TESTS
|
||||||
details::Registry::register_suite(+body);
|
details::Registry::register_suite(+body);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
add_library_module(time timer.cpp)
|
add_library_module(time timer.cpp)
|
||||||
target_link_libraries(time PUBLIC tbb)
|
|
||||||
add_test_module(time timer.test.cpp)
|
add_test_module(time timer.test.cpp)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue