migrated (most of) ./ext/ into the core engine (because in reality I don't think it'd be easy to make them optional)

This commit is contained in:
ecker 2025-08-10 18:58:27 -05:00
parent acfadd5c2d
commit 87ed97408f
42 changed files with 127 additions and 107 deletions

View File

@ -319,13 +319,13 @@ cdi:
cd ./bin/dreamcast/; ./elf2cdi.sh $(TARGET_NAME) cd ./bin/dreamcast/; ./elf2cdi.sh $(TARGET_NAME)
else else
$(PREFIX): $(EX_DLL) $(TARGET) $(TARGET_SHADERS) $(PREFIX): $(EX_DLL) $(EXT_EX_DLL) $(TARGET) $(TARGET_SHADERS)
%.$(PREFIX).o: %.cpp %.$(PREFIX).o: %.cpp
$(CXX) $(FLAGS) $(INCS) -c $< -o $@ $(CXX) $(FLAGS) $(INCS) -c $< -o $@
$(EX_DLL): FLAGS += -DUF_EXPORTS -DEXT_EXPORTS #$(EX_DLL): FLAGS += -DUF_EXPORTS -DEXT_EXPORTS
#$(EX_DLL): FLAGS += -DUF_EXPORTS $(EX_DLL): FLAGS += -DUF_EXPORTS
$(EX_DLL): $(OBJS_DLL) $(EX_DLL): $(OBJS_DLL)
$(CXX) $(FLAGS) -shared -o $(EX_DLL) -Wl,--out-implib=$(IM_DLL) $(OBJS_DLL) $(LIBS) $(INCS) $(LINKS) $(CXX) $(FLAGS) -shared -o $(EX_DLL) -Wl,--out-implib=$(IM_DLL) $(OBJS_DLL) $(LIBS) $(INCS) $(LINKS)
cp $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_DLL).a cp $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_DLL).a
@ -341,7 +341,7 @@ $(EXT_EX_DLL): $(OBJS_EXT_DLL)
cp $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_EXT_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_EXT_DLL).a cp $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_EXT_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_EXT_DLL).a
$(TARGET): $(OBJS) $(TARGET): $(OBJS)
$(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -o $(TARGET) $(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -l$(EXT_LIB_NAME) -o $(TARGET)
endif endif
%.spv: %.glsl %.spv: %.glsl

View File

@ -19,9 +19,9 @@ uf::Serializer client::config;
void client::initialize() { void client::initialize() {
uf::renderer::device.window = &client::window; uf::renderer::device.window = &client::window;
ext::load(); uf::load();
client::config = ext::config; client::config = uf::config;
/* Initialize window */ { /* Initialize window */ {
// Window size // Window size
@ -46,7 +46,7 @@ void client::initialize() {
client::window.create( size, title ); client::window.create( size, title );
#if !UF_ENV_DREAMCAST #if !UF_ENV_DREAMCAST
// Set refresh rate // Set refresh rate
ext::config["window"]["refresh rate"] = client::window.getRefreshRate(); uf::config["window"]["refresh rate"] = client::window.getRefreshRate();
// Miscellaneous // Miscellaneous
client::window.setVisible(client::config["window"]["visible"].as<bool>()); client::window.setVisible(client::config["window"]["visible"].as<bool>());
client::window.setCursorVisible(client::config["window"]["mouse"]["visible"].as<bool>()); client::window.setCursorVisible(client::config["window"]["mouse"]["visible"].as<bool>());

View File

@ -29,10 +29,15 @@ namespace {
if ( client::terminated ) return; if ( client::terminated ) return;
UF_MSG_INFO("Termination via std::atexit()!"); UF_MSG_INFO("Termination via std::atexit()!");
ext::ready = false;
client::ready = false; client::ready = false;
//ext::ready = false;
uf::ready = false;
client::terminated = true; client::terminated = true;
ext::terminate();
//ext::terminate();
uf::terminate();
client::terminate(); client::terminate();
} }
@ -72,7 +77,7 @@ int main(int argc, char** argv){
for ( size_t i = 0; i < argc; ++i ) { for ( size_t i = 0; i < argc; ++i ) {
char* c_str = argv[i]; char* c_str = argv[i];
std::string string(argv[i]); std::string string(argv[i]);
ext::arguments.emplace_back(string); uf::arguments.emplace_back(string);
} }
std::atexit(::handlers::exit); std::atexit(::handlers::exit);
@ -80,10 +85,11 @@ int main(int argc, char** argv){
signal(SIGSEGV, ::handlers::segv); signal(SIGSEGV, ::handlers::segv);
client::initialize(); client::initialize();
ext::initialize(); //ext::initialize();
uf::initialize();
// For Multithreaded initialization // For Multithreaded initialization
while ( !client::ready || !ext::ready ) { while ( !client::ready || !uf::ready ) {
static uf::Timer<long long> timer(false); static uf::Timer<long long> timer(false);
static double next = 1; static double next = 1;
if ( !timer.running() ) timer.start(); if ( !timer.running() ) timer.start();
@ -95,7 +101,7 @@ int main(int argc, char** argv){
} }
} }
while ( client::ready && ext::ready ) { while ( client::ready && uf::ready ) {
#if UF_EXCEPTIONS #if UF_EXCEPTIONS
try { try {
#endif #endif
@ -103,19 +109,23 @@ int main(int argc, char** argv){
// auto& thread = uf::thread::fetchWorker(); // auto& thread = uf::thread::fetchWorker();
auto& thread = uf::thread::get("Render"); auto& thread = uf::thread::get("Render");
uf::thread::queue(thread, [&]{ uf::thread::queue(thread, [&]{
ext::render(); //ext::render();
uf::render();
client::render(); client::render();
}); });
client::tick(); client::tick();
ext::tick(); //ext::tick();
uf::tick();
uf::thread::wait( thread ); uf::thread::wait( thread );
} else { } else {
client::tick(); client::tick();
ext::tick(); uf::tick();
//ext::tick();
ext::render(); //ext::render();
uf::render();
client::render(); client::render();
} }
#if UF_EXCEPTIONS #if UF_EXCEPTIONS
@ -139,7 +149,8 @@ int main(int argc, char** argv){
if ( !client::terminated ) { if ( !client::terminated ) {
client::terminated = true; client::terminated = true;
UF_MSG_INFO("Natural termination!"); UF_MSG_INFO("Natural termination!");
ext::terminate(); //ext::terminate();
uf::terminate();
client::terminate(); client::terminate();
} }
return 0; return 0;

View File

@ -1,4 +1,6 @@
#pragma once #pragma once
#include <uf/engine/ext.h>
#include <uf/ext/ext.h> #include <uf/ext/ext.h>
#include <uf/utils/window/window.h> #include <uf/utils/window/window.h>

View File

@ -0,0 +1,18 @@
#include <uf/config.h>
#include <uf/utils/memory/vector.h>
#include <uf/utils/memory/string.h>
#include <uf/utils/serialize/serializer.h>
namespace uf {
extern bool UF_API ready;
extern uf::stl::vector<uf::stl::string> UF_API arguments;
extern uf::Serializer UF_API config;
extern void UF_API load();
extern void UF_API load( ext::json::Value& );
extern void UF_API initialize();
extern bool UF_API running();
extern void UF_API tick();
extern void UF_API render();
extern void UF_API terminate();
}

View File

@ -36,17 +36,8 @@
#define EXT_API EXT_API_IMPORT #define EXT_API EXT_API_IMPORT
#endif #endif
#include <uf/utils/memory/string.h>
#include <uf/utils/serialize/serializer.h>
namespace ext { namespace ext {
extern bool EXT_API ready;
extern uf::stl::vector<uf::stl::string> EXT_API arguments;
extern uf::Serializer EXT_API config;
extern void EXT_API load();
extern void EXT_API load( ext::json::Value& );
extern void EXT_API initialize(); extern void EXT_API initialize();
extern bool EXT_API running();
extern void EXT_API tick(); extern void EXT_API tick();
extern void EXT_API render(); extern void EXT_API render();
extern void EXT_API terminate(); extern void EXT_API terminate();

View File

@ -1,9 +1,10 @@
#include "main.h" #include <uf/engine/ext.h>
#include "ext.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <cstdlib>
#include <sys/stat.h> #include <sys/stat.h>
#include <uf/utils/time/time.h> #include <uf/utils/time/time.h>
@ -45,9 +46,9 @@
#include <uf/ext/imgui/imgui.h> #include <uf/ext/imgui/imgui.h>
#include <uf/ext/vall_e/vall_e.h> #include <uf/ext/vall_e/vall_e.h>
bool ext::ready = false; bool uf::ready = false;
uf::stl::vector<uf::stl::string> ext::arguments; uf::stl::vector<uf::stl::string> uf::arguments;
uf::Serializer ext::config; uf::Serializer uf::config;
namespace { namespace {
struct { struct {
@ -69,7 +70,7 @@ namespace {
} total; } total;
} times; } times;
auto& json = ext::config; auto& json = uf::config;
struct { struct {
struct { struct {
@ -107,10 +108,10 @@ namespace {
} sceneTransition; } sceneTransition;
} }
void EXT_API ext::load() { void UF_API uf::load() {
ext::config.readFromFile(uf::io::root+"config.json"); uf::config.readFromFile(uf::io::root+"config.json");
} }
void EXT_API ext::load( ext::json::Value& json ) { void UF_API uf::load( ext::json::Value& json ) {
::config.engine.gc.enabled = json["engine"]["debug"]["garbage collection"]["enabled"].as(::config.engine.gc.enabled); ::config.engine.gc.enabled = json["engine"]["debug"]["garbage collection"]["enabled"].as(::config.engine.gc.enabled);
::config.engine.gc.every = json["engine"]["debug"]["garbage collection"]["every"].as(::config.engine.gc.every); ::config.engine.gc.every = json["engine"]["debug"]["garbage collection"]["every"].as(::config.engine.gc.every);
::config.engine.gc.mode = json["engine"]["debug"]["garbage collection"]["mode"].as(::config.engine.gc.mode); ::config.engine.gc.mode = json["engine"]["debug"]["garbage collection"]["mode"].as(::config.engine.gc.mode);
@ -306,7 +307,7 @@ void EXT_API ext::load( ext::json::Value& json ) {
} }
} }
void EXT_API ext::initialize() { void UF_API uf::initialize() {
/* Setup deferred Main thread */ { /* Setup deferred Main thread */ {
uf::thread::get(uf::thread::mainThreadName); uf::thread::get(uf::thread::mainThreadName);
} }
@ -323,7 +324,7 @@ void EXT_API ext::initialize() {
/* Arguments */ { /* Arguments */ {
bool modified = false; bool modified = false;
auto& arguments = ::json["arguments"]; auto& arguments = ::json["arguments"];
for ( auto& arg : ext::arguments ) { for ( auto& arg : uf::arguments ) {
// store raw argument // store raw argument
int i = arguments.size(); int i = arguments.size();
arguments[i] = arg; arguments[i] = arg;
@ -354,10 +355,10 @@ void EXT_API ext::initialize() {
if ( modified ) UF_MSG_DEBUG("New config: {}", ::json.serialize()); if ( modified ) UF_MSG_DEBUG("New config: {}", ::json.serialize());
} }
/* Seed */ { /* Seed */ {
srand(time(NULL)); std::srand(std::time(NULL));
} }
/* Open output file */ { /* Open output file */ {
io.output.open(io.filenames.output); ::io.output.open(::io.filenames.output);
} }
/* Initialize timers */ { /* Initialize timers */ {
times.sys.start(); times.sys.start();
@ -428,7 +429,7 @@ void EXT_API ext::initialize() {
// metadata["system"]["config"] = ::json; // metadata["system"]["config"] = ::json;
} }
ext::load( ::json ); uf::load( ::json );
// renderer settings // renderer settings
{ {
@ -724,7 +725,7 @@ void EXT_API ext::initialize() {
if ( json["message"].is<uf::stl::string>() ) { if ( json["message"].is<uf::stl::string>() ) {
UF_MSG_DEBUG( "{}", json["message"].as<uf::stl::string>() ); UF_MSG_DEBUG( "{}", json["message"].as<uf::stl::string>() );
} }
ext::ready = false; uf::ready = false;
}); });
} }
@ -743,11 +744,11 @@ void EXT_API ext::initialize() {
}); });
*/ */
ext::ready = true; uf::ready = true;
UF_MSG_INFO("EXT took {} seconds to initialize", times.sys.elapsed().asDouble()); UF_MSG_INFO("EXT took {} seconds to initialize", times.sys.elapsed().asDouble());
} }
void EXT_API ext::tick() { void UF_API uf::tick() {
#if 1 #if 1
if ( ::sceneTransition.phase >= 0 ) { if ( ::sceneTransition.phase >= 0 ) {
auto target = ::sceneTransition.payload["scene"].as<uf::stl::string>(); auto target = ::sceneTransition.payload["scene"].as<uf::stl::string>();
@ -925,7 +926,7 @@ void EXT_API ext::tick() {
#endif #endif
#endif #endif
} }
void EXT_API ext::render() { void UF_API uf::render() {
if ( uf::scene::scenes.empty() ) return; if ( uf::scene::scenes.empty() ) return;
if ( ::sceneTransition.phase >= 0 ) { if ( ::sceneTransition.phase >= 0 ) {
@ -953,7 +954,7 @@ void EXT_API ext::render() {
} }
#endif #endif
} }
void EXT_API ext::terminate() { void UF_API uf::terminate() {
/* Kill threads */ { /* Kill threads */ {
uf::thread::terminate(); uf::thread::terminate();
} }
@ -1025,9 +1026,9 @@ void EXT_API ext::terminate() {
} }
/* Flush input buffer */ { /* Flush input buffer */ {
io.output << io.input << "\n"; ::io.output << ::io.input << "\n";
for ( const auto& str : uf::iostream.getHistory() ) io.output << str << "\n"; for ( const auto& str : uf::iostream.getHistory() ) ::io.output << str << "\n";
io.output << "\nTerminated after " << times.sys.elapsed().asDouble() << " seconds" << "\n"; ::io.output << "\nTerminated after " << times.sys.elapsed().asDouble() << " seconds" << "\n";
io.output.close(); ::io.output.close();
} }
} }

View File

@ -32,7 +32,7 @@ void ext::GuiManagerBehavior::initialize( uf::Object& self ) {
auto& metadata = this->getComponent<ext::GuiManagerBehavior::Metadata>(); auto& metadata = this->getComponent<ext::GuiManagerBehavior::Metadata>();
auto& metadataJson = this->getComponent<uf::Serializer>(); auto& metadataJson = this->getComponent<uf::Serializer>();
metadata.size = uf::vector::decode( ext::config["window"]["size"], pod::Vector2f{} ); metadata.size = uf::vector::decode( uf::config["window"]["size"], pod::Vector2f{} );
this->addHook( "window:Resized", [&](pod::payloads::windowResized& payload){ this->addHook( "window:Resized", [&](pod::payloads::windowResized& payload){
metadata.size = payload.window.size; metadata.size = payload.window.size;
} ); } );

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <uf/config.h> #include <uf/config.h>
#include <uf/ext/ext.h> #include <uf/engine/ext.h>
#include <uf/engine/entity/entity.h> #include <uf/engine/entity/entity.h>
#include <uf/engine/scene/scene.h> #include <uf/engine/scene/scene.h>

View File

@ -64,7 +64,7 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) {
float raidou = (float) size.x / (float) size.y; float raidou = (float) size.x / (float) size.y;
if ( size.x == 0 || size.y == 0 ) { if ( size.x == 0 || size.y == 0 ) {
size = uf::vector::decode( ext::config["window"]["size"], pod::Vector2ui{} ); size = uf::vector::decode( uf::config["window"]["size"], pod::Vector2ui{} );
raidou = (float) size.x / (float) size.y; raidou = (float) size.x / (float) size.y;
#if 0 #if 0
this->addHook( "window:Resized", [&, fov, range](pod::payloads::windowResized& payload){ this->addHook( "window:Resized", [&, fov, range](pod::payloads::windowResized& payload){
@ -80,8 +80,8 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) {
} }
// sloppy // sloppy
metadata.mouse.sensitivity = uf::vector::decode( ext::config["window"]["mouse"]["sensitivity"], metadata.mouse.sensitivity ); metadata.mouse.sensitivity = uf::vector::decode( uf::config["window"]["mouse"]["sensitivity"], metadata.mouse.sensitivity );
metadata.mouse.smoothing = uf::vector::decode( ext::config["window"]["mouse"]["smoothing"], metadata.mouse.smoothing ); metadata.mouse.smoothing = uf::vector::decode( uf::config["window"]["mouse"]["smoothing"], metadata.mouse.smoothing );
this->addHook( "window:Mouse.CursorVisibility", [&](pod::payloads::windowMouseCursorVisibility& payload){ this->addHook( "window:Mouse.CursorVisibility", [&](pod::payloads::windowMouseCursorVisibility& payload){
metadata.system.control = !payload.mouse.visible; metadata.system.control = !payload.mouse.visible;

View File

@ -190,11 +190,11 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) {
// //
auto& scene = uf::scene::getCurrentScene(); auto& scene = uf::scene::getCurrentScene();
auto& sceneMetadataJson = scene.getComponent<uf::Serializer>(); auto& sceneMetadataJson = scene.getComponent<uf::Serializer>();
size_t maxLights = ext::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512); size_t maxLights = uf::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512);
size_t maxTextures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512); size_t maxTextures2D = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
size_t maxTexturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128); size_t maxTexturesCube = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128);
size_t maxTextures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1); size_t maxTextures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1);
size_t maxCascades = ext::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16); size_t maxCascades = uf::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16);
shader.buffers.emplace_back( storage.buffers.instance.alias() ); shader.buffers.emplace_back( storage.buffers.instance.alias() );
shader.buffers.emplace_back( storage.buffers.instanceAddresses.alias() ); shader.buffers.emplace_back( storage.buffers.instanceAddresses.alias() );
@ -332,7 +332,7 @@ void ext::RayTraceSceneBehavior::Metadata::serialize( uf::Object& self, uf::Seri
void ext::RayTraceSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) { void ext::RayTraceSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) {
// merge vxgi settings with global settings // merge vxgi settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["rt"]; const auto& globalSettings = uf::config["engine"]["scenes"]["rt"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["rt"][key] ) ) return; if ( !ext::json::isNull( serializer["rt"][key] ) ) return;
serializer["rt"][key] = value; serializer["rt"][key] = value;
@ -350,8 +350,8 @@ void ext::RayTraceSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Se
/*this->*/renderer.scale = serializer["rt"]["size"].as(/*this->*/renderer.scale); /*this->*/renderer.scale = serializer["rt"]["size"].as(/*this->*/renderer.scale);
} else if ( ext::json::isArray( serializer["rt"]["size"] ) ) { } else if ( ext::json::isArray( serializer["rt"]["size"] ) ) {
/*this->*/renderer.size = uf::vector::decode( serializer["rt"]["size"], /*this->*/renderer.size ); /*this->*/renderer.size = uf::vector::decode( serializer["rt"]["size"], /*this->*/renderer.size );
} else if ( ext::config["engine"]["ext"]["vulkan"]["framebuffer"]["size"].is<float>() ) { } else if ( uf::config["engine"]["ext"]["vulkan"]["framebuffer"]["size"].is<float>() ) {
/*this->*/renderer.scale = ext::config["engine"]["ext"]["vulkan"]["framebuffer"]["size"].as(/*this->*/renderer.scale); /*this->*/renderer.scale = uf::config["engine"]["ext"]["vulkan"]["framebuffer"]["size"].as(/*this->*/renderer.scale);
} }
/*this->*/renderer.full = serializer["rt"]["full"].as(/*this->*/renderer.full); /*this->*/renderer.full = serializer["rt"]["full"].as(/*this->*/renderer.full);

View File

@ -32,7 +32,10 @@
#include "../light/behavior.h" #include "../light/behavior.h"
#include "../voxelizer/behavior.h" #include "../voxelizer/behavior.h"
#include "../raytrace/behavior.h" #include "../raytrace/behavior.h"
#include "../../ext.h"
#include <uf/engine/ext.h>
//#include "../../ext.h"
// #include "../../gui/gui.h" // #include "../../gui/gui.h"
UF_BEHAVIOR_REGISTER_CPP(ext::ExtSceneBehavior) UF_BEHAVIOR_REGISTER_CPP(ext::ExtSceneBehavior)
@ -50,7 +53,7 @@ void ext::ExtSceneBehavior::initialize( uf::Object& self ) {
this->addHook( "system:Quit.%UID%", [&](ext::json::Value& payload){ this->addHook( "system:Quit.%UID%", [&](ext::json::Value& payload){
uf::renderer::settings::experimental::dedicatedThread = false; uf::renderer::settings::experimental::dedicatedThread = false;
ext::ready = false; uf::ready = false;
}); });
this->addHook( "menu:Open", [&](ext::json::Value& payload){ this->addHook( "menu:Open", [&](ext::json::Value& payload){
@ -790,7 +793,7 @@ void ext::ExtSceneBehavior::Metadata::serialize( uf::Object& self, uf::Serialize
void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) { void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) {
// merge light settings with global settings // merge light settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["lights"]; const auto& globalSettings = uf::config["engine"]["scenes"]["lights"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["light"][key] ) ) return; if ( !ext::json::isNull( serializer["light"][key] ) ) return;
serializer["light"][key] = value; serializer["light"][key] = value;
@ -798,7 +801,7 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali
} }
// merge bloom settings with global settings // merge bloom settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["lights"]["bloom"]; const auto& globalSettings = uf::config["engine"]["scenes"]["lights"]["bloom"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["light"]["bloom"][key] ) ) return; if ( !ext::json::isNull( serializer["light"]["bloom"][key] ) ) return;
serializer["light"]["bloom"][key] = value; serializer["light"]["bloom"][key] = value;
@ -806,7 +809,7 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali
} }
// merge shadows settings with global settings // merge shadows settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["lights"]["shadows"]; const auto& globalSettings = uf::config["engine"]["scenes"]["lights"]["shadows"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["light"]["shadows"][key] ) ) return; if ( !ext::json::isNull( serializer["light"]["shadows"][key] ) ) return;
serializer["light"]["shadows"][key] = value; serializer["light"]["shadows"][key] = value;
@ -814,16 +817,16 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali
} }
// merge fog settings with global settings // merge fog settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["lights"]["fog"]; const auto& globalSettings = uf::config["engine"]["scenes"]["lights"]["fog"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["light"]["fog"][key] ) ) return; if ( !ext::json::isNull( serializer["light"]["fog"][key] ) ) return;
serializer["light"]["fog"][key] = value; serializer["light"]["fog"][key] = value;
} ); } );
} }
/*this->*/max.textures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as(/*this->*/max.textures2D); /*this->*/max.textures2D = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as(/*this->*/max.textures2D);
/*this->*/max.texturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as(/*this->*/max.texturesCube); /*this->*/max.texturesCube = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as(/*this->*/max.texturesCube);
/*this->*/max.textures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as(/*this->*/max.textures3D); /*this->*/max.textures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as(/*this->*/max.textures3D);
/*this->*/shadow.enabled = serializer["light"]["shadows"]["enabled"].as(/*this->*/shadow.enabled); /*this->*/shadow.enabled = serializer["light"]["shadows"]["enabled"].as(/*this->*/shadow.enabled);
/*this->*/shadow.samples = serializer["light"]["shadows"]["samples"].as(/*this->*/shadow.samples); /*this->*/shadow.samples = serializer["light"]["shadows"]["samples"].as(/*this->*/shadow.samples);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <uf/config.h> #include <uf/config.h>
#include <uf/ext/ext.h> #include <uf/engine/ext.h>
#include <uf/engine/entity/entity.h> #include <uf/engine/entity/entity.h>
#include <uf/engine/scene/scene.h> #include <uf/engine/scene/scene.h>
#include <uf/utils/math/vector.h> #include <uf/utils/math/vector.h>

View File

@ -16,7 +16,7 @@
#include "../light/behavior.h" #include "../light/behavior.h"
#include "../scene/behavior.h" #include "../scene/behavior.h"
#include <uf/ext/ext.h> #include <uf/engine/ext.h>
UF_BEHAVIOR_REGISTER_CPP(ext::VoxelizerSceneBehavior) UF_BEHAVIOR_REGISTER_CPP(ext::VoxelizerSceneBehavior)
@ -112,9 +112,9 @@ void ext::VoxelizerSceneBehavior::initialize( uf::Object& self ) {
renderMode.blitter.descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE; renderMode.blitter.descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
renderMode.blitter.process = true; renderMode.blitter.process = true;
size_t maxTextures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512); size_t maxTextures2D = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
size_t maxTexturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128); size_t maxTexturesCube = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128);
size_t maxTextures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1); size_t maxTextures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1);
for ( size_t i = 0; i < maxTextures2D; ++i ) renderMode.blitter.material.textures.emplace_back().aliasTexture(uf::renderer::Texture2D::empty); for ( size_t i = 0; i < maxTextures2D; ++i ) renderMode.blitter.material.textures.emplace_back().aliasTexture(uf::renderer::Texture2D::empty);
for ( size_t i = 0; i < maxTexturesCube; ++i ) renderMode.blitter.material.textures.emplace_back().aliasTexture(uf::renderer::TextureCube::empty); for ( size_t i = 0; i < maxTexturesCube; ++i ) renderMode.blitter.material.textures.emplace_back().aliasTexture(uf::renderer::TextureCube::empty);
@ -318,7 +318,7 @@ void ext::VoxelizerSceneBehavior::Metadata::serialize( uf::Object& self, uf::Ser
void ext::VoxelizerSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) { void ext::VoxelizerSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) {
// merge vxgi settings with global settings // merge vxgi settings with global settings
{ {
const auto& globalSettings = ext::config["engine"]["scenes"]["vxgi"]; const auto& globalSettings = uf::config["engine"]["scenes"]["vxgi"];
ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){ ext::json::forEach( globalSettings, [&]( const uf::stl::string& key, const ext::json::Value& value ){
if ( !ext::json::isNull( serializer["vxgi"][key] ) ) return; if ( !ext::json::isNull( serializer["vxgi"][key] ) ) return;
serializer["vxgi"][key] = value; serializer["vxgi"][key] = value;

View File

@ -10,7 +10,8 @@
#include <uf/utils/memory/map.h> #include <uf/utils/memory/map.h>
#include <uf/ext/xatlas/xatlas.h> #include <uf/ext/xatlas/xatlas.h>
#include <uf/ext/ffx/fsr.h> #include <uf/ext/ffx/fsr.h>
#include <uf/ext/ext.h>
#include <uf/engine/ext.h>
#if UF_ENV_DREAMCAST #if UF_ENV_DREAMCAST
#define UF_DEBUG_TIMER_MULTITRACE_START(...) UF_TIMER_MULTITRACE_START(__VA_ARGS__) #define UF_DEBUG_TIMER_MULTITRACE_START(...) UF_TIMER_MULTITRACE_START(__VA_ARGS__)
@ -440,9 +441,9 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M
} }
{ {
size_t maxTextures = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512); size_t maxTextures = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
size_t maxCubemaps = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128); size_t maxCubemaps = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128);
size_t maxTextures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(128); size_t maxTextures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(128);
auto& shader = graphic.material.getShader("fragment", "baking"); auto& shader = graphic.material.getShader("fragment", "baking");
shader.setSpecializationConstants({ shader.setSpecializationConstants({

View File

@ -13,7 +13,7 @@
#include <uf/ext/vulkan/graphic.h> #include <uf/ext/vulkan/graphic.h>
#include <uf/engine/graph/graph.h> #include <uf/engine/graph/graph.h>
#include <uf/ext/ext.h> #include <uf/engine/ext.h>
#define BARYCENTRIC 1 #define BARYCENTRIC 1
#if BARYCENTRIC #if BARYCENTRIC
@ -270,11 +270,11 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
auto& shader = blitter.material.getShader(DEFERRED_MODE, "deferred"); auto& shader = blitter.material.getShader(DEFERRED_MODE, "deferred");
size_t maxLights = ext::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512); size_t maxLights = uf::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512);
size_t maxTextures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512); size_t maxTextures2D = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
size_t maxTexturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128); size_t maxTexturesCube = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128);
size_t maxTextures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(128); size_t maxTextures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(128);
size_t maxCascades = ext::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16); size_t maxCascades = uf::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16);
shader.setSpecializationConstants({ shader.setSpecializationConstants({
{ "TEXTURES", maxTextures2D }, { "TEXTURES", maxTextures2D },
@ -687,7 +687,7 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
} }
} }
} }
bool shouldRecord = true; // ( settings::pipelines::rt && !ext::config["engine"]["scenes"]["rt"]["full"].as<bool>() ) || !settings::pipelines::rt; bool shouldRecord = true; // ( settings::pipelines::rt && !uf::config["engine"]["scenes"]["rt"]["full"].as<bool>() ) || !settings::pipelines::rt;
for (size_t i = 0; i < commands.size(); ++i) { for (size_t i = 0; i < commands.size(); ++i) {
auto commandBuffer = commands[i]; auto commandBuffer = commands[i];
VK_CHECK_RESULT( vkBeginCommandBuffer(commandBuffer, &cmdBufInfo) ); VK_CHECK_RESULT( vkBeginCommandBuffer(commandBuffer, &cmdBufInfo) );

View File

@ -9,7 +9,7 @@
#include <uf/ext/vulkan/graphic.h> #include <uf/ext/vulkan/graphic.h>
#include <uf/engine/graph/graph.h> #include <uf/engine/graph/graph.h>
#include <uf/utils/camera/camera.h> #include <uf/utils/camera/camera.h>
#include <uf/ext/ext.h> #include <uf/engine/ext.h>
const uf::stl::string ext::vulkan::RenderTargetRenderMode::getType() const { const uf::stl::string ext::vulkan::RenderTargetRenderMode::getType() const {
return "RenderTarget"; return "RenderTarget";
@ -322,11 +322,11 @@ void ext::vulkan::RenderTargetRenderMode::initialize( Device& device ) {
auto& shader = blitter.material.getShader("compute"); auto& shader = blitter.material.getShader("compute");
size_t maxLights = ext::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512); size_t maxLights = uf::config["engine"]["scenes"]["lights"]["max"].as<size_t>(512);
size_t maxTextures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512); size_t maxTextures2D = uf::config["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
size_t maxTexturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128); size_t maxTexturesCube = uf::config["engine"]["scenes"]["textures"]["max"]["cube"].as<size_t>(128);
size_t maxTextures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1); size_t maxTextures3D = uf::config["engine"]["scenes"]["textures"]["max"]["3D"].as<size_t>(1);
size_t maxCascades = ext::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16); size_t maxCascades = uf::config["engine"]["scenes"]["vxgi"]["cascades"].as<size_t>(16);
shader.setSpecializationConstants({ shader.setSpecializationConstants({
{ "TEXTURES", maxTextures2D }, { "TEXTURES", maxTextures2D },

View File

@ -1,7 +1,8 @@
#include <uf/utils/io/fmt.h> #include <uf/utils/io/fmt.h>
#include <uf/utils/io/console.h> #include <uf/utils/io/console.h>
#include <uf/utils/hook/hook.h> #include <uf/utils/hook/hook.h>
#include <uf/ext/ext.h>
#include <uf/engine/ext.h>
#include <uf/engine/entity/entity.h> #include <uf/engine/entity/entity.h>
#include <uf/engine/scene/scene.h> #include <uf/engine/scene/scene.h>
@ -68,7 +69,7 @@ void uf::console::initialize() {
uf::console::registerCommand("json", "Modifies the gamestate by setting a JSON value", [&]( const uf::stl::string& arguments )->uf::stl::string{ uf::console::registerCommand("json", "Modifies the gamestate by setting a JSON value", [&]( const uf::stl::string& arguments )->uf::stl::string{
auto match = uf::string::match( arguments, "/^(.+?) *= *(.+?)$/" ); auto match = uf::string::match( arguments, "/^(.+?) *= *(.+?)$/" );
if ( match.empty() ) { if ( match.empty() ) {
uf::Serializer target = ext::config; uf::Serializer target = uf::config;
return ext::json::encode( arguments == "" ? target : target.path( arguments ), { return ext::json::encode( arguments == "" ? target : target.path( arguments ), {
.pretty = true .pretty = true
} ); } );
@ -80,8 +81,8 @@ void uf::console::initialize() {
uf::Serializer value; uf::Serializer value;
value.deserialize(valueString); value.deserialize(valueString);
ext::config.path(keyString) = value; uf::config.path(keyString) = value;
ext::load( ext::config ); uf::load( uf::config );
return "Value `" + keyString + "` set to `" + ext::json::encode( value ) + "`"; return "Value `" + keyString + "` set to `" + ext::json::encode( value ) + "`";
}); });

View File

@ -1 +0,0 @@
#pragma once

View File

@ -1,7 +0,0 @@
#pragma once
#include <uf/ext/ext.h>
namespace ext {
}