Compare commits
9 commits
61473c2758
...
487f907ffb
| Author | SHA1 | Date | |
|---|---|---|---|
| 487f907ffb | |||
| 20ef8c04d8 | |||
| 77c04d38c9 | |||
| 81811351b8 | |||
| e1360cabce | |||
| 054af3fd8f | |||
| 5fbd9282d1 | |||
| 7132bd3324 | |||
| 3a06d51ee4 |
17 changed files with 69 additions and 65 deletions
|
|
@ -6,6 +6,7 @@ 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::beg,
|
std::ios::binary,
|
||||||
};
|
};
|
||||||
expect_true(stream.is_open());
|
expect_true(stream.is_open());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,11 @@ 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)
|
target_link_libraries(input PUBLIC surface math logger tbb)
|
||||||
|
|
||||||
add_test_module(input system.test.cpp)
|
add_test_module(input system.test.cpp)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#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
|
||||||
|
|
@ -48,9 +49,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_registry->add<surface::SurfaceComponent>(
|
m_surface_system.create_surface_component(
|
||||||
entity,
|
entity,
|
||||||
surface::SurfaceComponent::CreateInfo {}
|
{ .title = "", .resolution = { 20u, 20u } }
|
||||||
);
|
);
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
|
|
@ -58,6 +59,8 @@ 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::MessengerCallbackData data,
|
renderer::MessageData 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_component(
|
m_surface_system->create_surface_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,
|
||||||
});
|
});
|
||||||
|
|
||||||
m_renderer_system->create_messenger_component(
|
std::ignore = 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,7 +10,6 @@
|
||||||
#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,7 +1,6 @@
|
||||||
#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 {
|
||||||
|
|
||||||
|
|
@ -9,11 +8,9 @@ inline void vkc(VkResult result)
|
||||||
{
|
{
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
throw std::runtime_error { std::format(
|
throw std::runtime_error {
|
||||||
"Vulkan call failed with result: {}({})",
|
std::format("Vulkan call failed with result: {}", std::to_underlying(result))
|
||||||
string_VkResult(result),
|
};
|
||||||
std::to_underlying(result)
|
|
||||||
) };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
#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 {
|
||||||
|
|
||||||
|
|
@ -15,10 +14,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 = IRenderer::frames_in_flight_upper_limit;
|
static constexpr auto frames_in_flight_upper_limit = 5u;
|
||||||
|
|
||||||
/** 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 = IRenderer::frames_in_flight_lower_limit;
|
static constexpr auto frames_in_flight_lower_limit = 1u;
|
||||||
|
|
||||||
struct Configuration
|
struct Configuration
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ target_link_libraries(surface PUBLIC
|
||||||
app
|
app
|
||||||
math
|
math
|
||||||
memory
|
memory
|
||||||
|
tbb
|
||||||
PRIVATE
|
PRIVATE
|
||||||
logger
|
logger
|
||||||
lt_debug
|
lt_debug
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,7 @@ void System::on_unregister()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
auto System::create_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
|
void System::create_surface_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);
|
||||||
|
|
@ -183,8 +182,6 @@ try
|
||||||
{
|
{
|
||||||
XUnmapWindow(display, main_window);
|
XUnmapWindow(display, main_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &component;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &exp)
|
catch (const std::exception &exp)
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +189,6 @@ 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)
|
||||||
|
|
@ -394,7 +390,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;
|
||||||
|
|
@ -428,6 +424,7 @@ 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,6 +16,7 @@ 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
|
||||||
|
|
@ -48,35 +49,39 @@ public:
|
||||||
return m_registry;
|
return m_registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto add_surface_component(
|
auto create_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,
|
||||||
}
|
}
|
||||||
) -> SurfaceComponent &
|
) -> std::optional<SurfaceComponent *>
|
||||||
{
|
{
|
||||||
auto entity = m_registry->create_entity();
|
auto entity = m_registry->create_entity();
|
||||||
return m_registry->add<SurfaceComponent>(entity, info);
|
m_system.create_surface_component(entity, info);
|
||||||
|
|
||||||
|
return &m_registry->get<SurfaceComponent>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_values(const SurfaceComponent &component)
|
void check_values(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 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -96,10 +101,6 @@ 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" } = [] {
|
||||||
|
|
@ -112,7 +113,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.add_surface_component();
|
fixture.create_component();
|
||||||
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
expect_eq(fixture.registry()->view<SurfaceComponent>().get_size(), 1);
|
||||||
|
|
||||||
system.reset();
|
system.reset();
|
||||||
|
|
@ -142,29 +143,28 @@ 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.add_surface_component();
|
const auto &component = fixture.create_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.add_surface_component({ .resolution = { width, 0 } }); });
|
expect_throw([&] { fixture.create_component({ .resolution = { width, 0 } }); });
|
||||||
|
|
||||||
expect_throw([&] { fixture.add_surface_component({ .resolution = { 0, height } }); });
|
expect_throw([&] { fixture.create_component({ .resolution = { 0, height } }); });
|
||||||
|
|
||||||
expect_throw([&] {
|
expect_throw([&] {
|
||||||
fixture.add_surface_component(
|
fixture.create_component(
|
||||||
{ .title = "", .resolution = { SurfaceComponent::max_dimension + 1, height } }
|
{ .title = "", .resolution = { SurfaceComponent::max_dimension + 1, height } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect_throw([&] {
|
expect_throw([&] {
|
||||||
fixture.add_surface_component(
|
fixture.create_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.add_surface_component({ .title = big_str, .resolution = { width, height } });
|
fixture.create_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.add_surface_component({ .resolution = { width, 0 } }); });
|
expect_throw([&] { fixture.create_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.add_surface_component();
|
const auto &component = fixture.create_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.add_surface_component();
|
fixture.create_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.add_surface_component();
|
auto &surface = **fixture.create_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.add_surface_component();
|
auto &surface = **fixture.create_component();
|
||||||
|
|
||||||
constexpr auto title = "ABC";
|
constexpr auto title = "ABC";
|
||||||
constexpr auto position = math::ivec2 { 50, 50 };
|
constexpr auto position = math::ivec2 { 50, 50 };
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ public:
|
||||||
|
|
||||||
void on_unregister() override;
|
void on_unregister() override;
|
||||||
|
|
||||||
auto create_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
|
void create_surface_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info);
|
||||||
-> std::optional<SurfaceComponent *>;
|
|
||||||
|
|
||||||
void tick(app::TickInfo tick) override;
|
void tick(app::TickInfo tick) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
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,7 +321,6 @@ 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,3 +1,4 @@
|
||||||
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