diff --git a/bin/data/config.json b/bin/data/config.json index e7245a01..70043326 100644 --- a/bin/data/config.json +++ b/bin/data/config.json @@ -6,11 +6,11 @@ "meshes": { "interleaved": false }, "lights": { "enabled": true, "useLightmaps": true, - "max": 16, + "max": 32, "shadows": { "enabled": true, "update": 2, - "max": 4, + "max": 12, "samples": 1 }, "bloom": { @@ -29,20 +29,20 @@ } }, "vxgi": { - "limiter": 0.5, - // "limiter": 0.125, - "size": 128, + // "limiter": 0.5, + "limiter": 0.125, + "size": 256, "dispatch": 8, "cascades": 3, - "cascadePower": 3, - "granularity": 12, + "cascadePower": 1.5, + "granularity": 4, "voxelizeScale": 1, "occlusionFalloff": 2, "traceStartOffsetFactor": 1, "shadows": 0, "extents": { - "min": [ -16, -4, -16 ], - "max": [ 16, 4, 16 ] + "min": [ -8, -4, -8 ], + "max": [ 8, 4, 8 ] } }, "rt": { @@ -61,8 +61,10 @@ }, "ext": { "vulkan": { - "validation": { "enabled": false, + "validation": { "enabled": true, "filters": [ + "0x1feed437", // VUID-VkImageMemoryBarrier-synchronization2-03857 (screams because of FSR2 retardation) + // "0x141cb623", // UNASSIGNED-Threading-MultipleThreads (screams at me, a part of transient command buffer recording/submitting) "0x35d7ea98", // VUID-vkUpdateDescriptorSets-None-03047 () "0x4dae5635", // UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (false positive for cubemaps) @@ -92,29 +94,30 @@ }, "framebuffer": { "msaa": 1, - "size": 1 // 0.5 + "size": 1 + // "size": 0.8 // "size": [ 640, 480, "NEAREST" ] // "size": [ 1280, 720 ] // "size": [ 960, 540 ] // "size": [ 640, 480 ] }, - "gpu": 1, "experimental": { - "rebuild on tick begin": false, "batch queue submissions": true, - "dedicated thread": true + "dedicated thread": false + }, + "invariant": { + "multithreaded recording": true }, - "invariant": {}, "pipelines": { "deferred": true, - "vsync": true, - "hdr": true, - "vxgi": true, + "vsync": false, + "hdr": false, + "vxgi": false, "culling": false, - "bloom": true, - "rt": true, - "postProcess": true, - "fsr": true + "bloom": false, + "rt": false, + "fsr": false, + "postProcess": false }, "formats": { "depth": "D32_SFLOAT", @@ -321,7 +324,7 @@ "visible" : true, "center" : false, "sensitivity": [ 0.75, 0.75 ], - "smoothing": [ 4, 4 ] + "smoothing": [ 2, 2 ] }, "mode" : "windowed", // fullscreen, borderless, windowed "icon" : "./data/textures/icon.png", diff --git a/bin/data/entities/scripts/player.lua b/bin/data/entities/scripts/player.lua index 180c0714..62f78e5e 100644 --- a/bin/data/entities/scripts/player.lua +++ b/bin/data/entities/scripts/player.lua @@ -77,7 +77,7 @@ ent:bind( "tick", function(self) -- toggle flashlight if light.enabled then local center = flattenedTransform.position - local direction = flattenedTransform.forward * 4 + local direction = flattenedTransform.forward * 8 local offset = 0.25 local _, depth = physicsState:rayCast( center, direction ) diff --git a/bin/data/scenes/sourceengine/scene.json b/bin/data/scenes/sourceengine/scene.json index 67186921..e6fc27da 100644 --- a/bin/data/scenes/sourceengine/scene.json +++ b/bin/data/scenes/sourceengine/scene.json @@ -6,8 +6,8 @@ ], "metadata": { "light": { - "ambient": [ 0, 0, 0 ], - // "ambient": [ 0.05, 0.05, 0.05 ], + // "ambient": [ 0, 0, 0 ], + "ambient": [ 0.05, 0.05, 0.05 ], // "ambient": [ 0.15, 0.15, 0.15 ], // "ambient": [ 0.5, 0.5, 0.5 ], // "ambient": [ 0.8, 0.8, 0.8 ], diff --git a/bin/data/scenes/sourceengine/sh2_mcdonalds.json b/bin/data/scenes/sourceengine/sh2_mcdonalds.json index 5024a7ba..6a2fb293 100644 --- a/bin/data/scenes/sourceengine/sh2_mcdonalds.json +++ b/bin/data/scenes/sourceengine/sh2_mcdonalds.json @@ -7,7 +7,7 @@ "metadata": { "graph": { "lights": { -// "lightmap": false + "scale": 4.0 }, "assets": [ "./audio/soundscape/sh2_ambience.ogg" @@ -31,12 +31,12 @@ "light_environment": { "transform": { "orientation": [0,0,0,1] }, "light": { "color": [0.05, 0.05, 0.05], - "power": 100000, + "power": 10, "global": true, "bias": { "constant": 1.25, "slope": 1.75, - "shader": 0.0000025 + "shader": 0.000005 }, "radius": [0.95, 0], "resolution": 1536 @@ -44,9 +44,10 @@ // regex matches // "/^prop_physics_[^o]/": { "action": "load", "payload": { "import": "/prop.json" } }, - "/^prop_physics_override/": { "action": "load", "payload": {} }, - "/^prop_physics_/": { "action": "load", "payload": {} }, - "/^func_physbox/": { "action": "load", "payload": {} }, + // "/^prop_physics_override/": { "action": "load", "payload": {} }, + // "/^prop_physics_/": { "action": "load", "payload": {} }, + // "/^func_physbox/": { "action": "load", "payload": {} }, + "/^.+?_phys.+?[^o]/": { "action": "load", "payload": { "import": "/prop.json" } }, "materials/models/props_wasteland/prison_lamp001a": { "material": { "emissive": [0, 0, 0, 0] } }, "/^tools\\/toolsnodraw/": { "material": { diff --git a/bin/data/scenes/sourceengine/sourceengine.json b/bin/data/scenes/sourceengine/sourceengine.json index 2f1ce5e4..beb54dda 100644 --- a/bin/data/scenes/sourceengine/sourceengine.json +++ b/bin/data/scenes/sourceengine/sourceengine.json @@ -1,6 +1,6 @@ { // "import": "./rp_downtown_v2.json" -// "import": "./ss2_medsci1.json" - "import": "./sh2_mcdonalds.json" + "import": "./ss2_medsci1.json" +// "import": "./sh2_mcdonalds.json" // "import": "./gm_construct.json" } \ No newline at end of file diff --git a/bin/data/shaders/common/macros.h b/bin/data/shaders/common/macros.h index 8a28546f..94256583 100644 --- a/bin/data/shaders/common/macros.h +++ b/bin/data/shaders/common/macros.h @@ -70,7 +70,7 @@ #endif #if BARYCENTRIC #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #endif diff --git a/bin/data/shaders/common/shadows.h b/bin/data/shaders/common/shadows.h index f6d42ca3..20100334 100644 --- a/bin/data/shaders/common/shadows.h +++ b/bin/data/shaders/common/shadows.h @@ -109,7 +109,7 @@ float shadowFactorRT( const Light light, float def ) { ray.direction = light.position - ray.origin; float tMin = ubo.settings.rt.defaultRayBounds.x; - float tMax = length(ray.direction) - 0.0001; + float tMax = length(ray.direction) - ubo.settings.rt.defaultRayBounds.x; ray.direction = normalize(ray.direction); @@ -119,8 +119,7 @@ float shadowFactorRT( const Light light, float def ) { rayQueryEXT rayQuery; rayQueryInitializeEXT(rayQuery, tlas, rayFlags, cullMask, ray.origin, tMin, ray.direction, tMax); - while(rayQueryProceedEXT(rayQuery)) { - } + while(rayQueryProceedEXT(rayQuery)); return rayQueryGetIntersectionTypeEXT(rayQuery, true) == gl_RayQueryCommittedIntersectionNoneEXT ? 1.0 : 0.0; } diff --git a/bin/data/shaders/common/vxgi.h b/bin/data/shaders/common/vxgi.h index a67042ee..83621d1b 100644 --- a/bin/data/shaders/common/vxgi.h +++ b/bin/data/shaders/common/vxgi.h @@ -132,10 +132,10 @@ void indirectLighting() { #endif const float DIFFUSE_CONE_APERTURE = 2.0 * 0.57735f; - const float DIFFUSE_INDIRECT_FACTOR = 1.0f / float(CONES_COUNT); + const float DIFFUSE_INDIRECT_FACTOR = 0; // 1.0f / float(CONES_COUNT) * 0.125f; const float SPECULAR_CONE_APERTURE = clamp(tan(PI * 0.5f * surface.material.roughness), 0.0174533f, PI); // tan( R * PI * 0.5f * 0.1f ); - const float SPECULAR_INDIRECT_FACTOR = (1.0 - surface.material.metallic) * 0.25; // 1.0f; + const float SPECULAR_INDIRECT_FACTOR = (1.0 - surface.material.metallic); // * 0.25; // 1.0f; vec4 indirectDiffuse = vec4(0); vec4 indirectSpecular = vec4(0); diff --git a/bin/data/shaders/display/deferred/comp/comp.h b/bin/data/shaders/display/deferred/comp/comp.h index 6522aca1..0edbb190 100644 --- a/bin/data/shaders/display/deferred/comp/comp.h +++ b/bin/data/shaders/display/deferred/comp/comp.h @@ -129,13 +129,17 @@ layout(buffer_reference, scalar) buffer VID { uint v[]; }; #define IMAGE_STORE(X, Y) imageStore( X, ivec2(gl_GlobalInvocationID.xy), Y ) void postProcess() { - float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722)); - vec4 outFragBright = brightness > ubo.settings.bloom.threshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1); - vec2 outFragMotion = surface.motion; #if FOG fog( surface.ray, surface.fragment.rgb, surface.fragment.a ); #endif + float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722)); + bool bloom = brightness > ubo.settings.bloom.threshold; + if ( bloom ) { + toneMap( surface.fragment.rgb, brightness ); + } vec4 outFragColor = vec4(surface.fragment.rgb, 1.0); + vec4 outFragBright = bloom ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1); + vec2 outFragMotion = surface.motion; IMAGE_STORE( imageColor, outFragColor ); IMAGE_STORE( imageBright, outFragBright ); diff --git a/client/main.cpp b/client/main.cpp index c727fc2f..8ead90cb 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -72,14 +72,16 @@ int main(int argc, char** argv){ } } + auto& renderer = uf::thread::fetchWorker(); +// auto& renderer = uf::thread::get("Render"); + while ( client::ready && ext::ready ) { #if UF_EXCEPTIONS try { #endif - if ( uf::renderer::settings::experimental::dedicatedThread /*&& !uf::renderer::states::rebuild*/ ) { - // auto& thread = uf::thread::fetchWorker(); - auto& thread = uf::thread::get("Render"); - uf::thread::queue(thread, [&]{ + #if 1 + if ( uf::renderer::settings::experimental::dedicatedThread ) { + uf::thread::queue(renderer, [&]{ ext::render(); client::render(); }); @@ -87,8 +89,10 @@ int main(int argc, char** argv){ client::tick(); ext::tick(); - uf::thread::wait( thread ); - } else { + uf::thread::wait(renderer); + } else + #endif + { client::tick(); ext::tick(); diff --git a/engine/inc/uf/ext/vulkan/buffer.h b/engine/inc/uf/ext/vulkan/buffer.h index de906adf..68a9e0f4 100644 --- a/engine/inc/uf/ext/vulkan/buffer.h +++ b/engine/inc/uf/ext/vulkan/buffer.h @@ -29,15 +29,15 @@ namespace ext { void* map( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ); void unmap(); - void* map( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ) const; - void unmap() const; + // void* map( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ) const; + // void unmap() const; + // VkResult bind( VkDeviceSize offset = 0 ); + // void copyTo( void* data, VkDeviceSize size ); + // VkResult flush( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ) const; + // VkResult invalidate( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ); - VkResult bind( VkDeviceSize offset = 0 ); - void setupDescriptor( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ); - void copyTo( void* data, VkDeviceSize size ); - VkResult flush( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ) const; - VkResult invalidate( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ); + void updateDescriptor( VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0 ); void allocate( VkBufferCreateInfo ); uint64_t getAddress(); diff --git a/engine/inc/uf/ext/vulkan/device.h b/engine/inc/uf/ext/vulkan/device.h index eeb18bcf..92b66e1b 100644 --- a/engine/inc/uf/ext/vulkan/device.h +++ b/engine/inc/uf/ext/vulkan/device.h @@ -97,6 +97,12 @@ namespace ext { CommandBuffer fetchCommandBuffer( QueueEnum queue, bool waits = VK_DEFAULT_COMMAND_BUFFER_WAIT ); void flushCommandBuffer( CommandBuffer commandBuffer ); + ext::vulkan::Buffer createBuffer( + const void* data, + VkDeviceSize size, + VkBufferUsageFlags usage, + VkMemoryPropertyFlags memoryProperties + ); VkResult createBuffer( const void* data, VkDeviceSize size, @@ -111,10 +117,10 @@ namespace ext { VkMemoryPropertyFlags memoryProperties ); - VkQueue& getQueue( QueueEnum ); - VkCommandPool& getCommandPool( QueueEnum ); - VkQueue& getQueue( QueueEnum, std::thread::id ); - VkCommandPool& getCommandPool( QueueEnum, std::thread::id ); + VkQueue getQueue( QueueEnum ); + VkCommandPool getCommandPool( QueueEnum ); + VkQueue getQueue( QueueEnum, std::thread::id ); + VkCommandPool getCommandPool( QueueEnum, std::thread::id ); // RAII void initialize(); diff --git a/engine/inc/uf/ext/vulkan/rendermode.h b/engine/inc/uf/ext/vulkan/rendermode.h index a52291b4..f9a864ca 100644 --- a/engine/inc/uf/ext/vulkan/rendermode.h +++ b/engine/inc/uf/ext/vulkan/rendermode.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace ext { namespace vulkan { @@ -20,6 +21,8 @@ namespace ext { uint32_t height = 0; float scale = 0; + ext::vulkan::Graphic blitter; + struct { uf::Serializer json; @@ -28,8 +31,10 @@ namespace ext { uf::stl::string target = ""; uf::stl::string pipeline = ""; uf::stl::vector pipelines; - uf::stl::vector outputs; + // uf::stl::vector outputs; + uf::stl::unordered_map attachments; + uf::stl::unordered_map buffers; struct { float frequency = 0.0f; @@ -75,23 +80,25 @@ namespace ext { void cleanupAllCommands(); void cleanupCommands( std::thread::id = std::this_thread::get_id() ); + + ext::vulkan::Graphic& getBlitter(); + RenderTarget& getRenderTarget(); + + bool hasAttachment( const uf::stl::string& ) const; + const RenderTarget::Attachment& getAttachment( const uf::stl::string& ) const; + size_t getAttachmentIndex( const uf::stl::string& ) const; + + bool hasBuffer( const uf::stl::string& ) const; + const Buffer& getBuffer( const uf::stl::string& ) const; + size_t getBufferIndex( const uf::stl::string& ) const; + + const uf::stl::string getTarget() const; + void setTarget( const uf::stl::string& ); virtual ~RenderMode(); // RAII virtual const uf::stl::string getName() const; virtual const uf::stl::string getType() const; - virtual RenderTarget& getRenderTarget(size_t = 0); - virtual const RenderTarget& getRenderTarget(size_t = 0) const; - - virtual bool hasAttachment( const uf::stl::string& ) const; - virtual const RenderTarget::Attachment& getAttachment( const uf::stl::string& ) const; - virtual size_t getAttachmentIndex( const uf::stl::string& ) const; - - virtual const size_t blitters() const; - virtual ext::vulkan::Graphic* getBlitter(size_t = 0); - virtual uf::stl::vector getBlitters(); - - virtual GraphicDescriptor bindGraphicDescriptor( const GraphicDescriptor&, size_t = 0 ); virtual void initialize( Device& device ); diff --git a/engine/inc/uf/ext/vulkan/rendermodes/base.h b/engine/inc/uf/ext/vulkan/rendermodes/base.h index 108d6408..f5ef6c27 100644 --- a/engine/inc/uf/ext/vulkan/rendermodes/base.h +++ b/engine/inc/uf/ext/vulkan/rendermodes/base.h @@ -4,10 +4,7 @@ namespace ext { namespace vulkan { - struct UF_API BaseRenderMode : RenderMode { - // virtual ~RenderMode(); - - // + struct UF_API BaseRenderMode : public RenderMode { virtual const uf::stl::string getType() const; virtual void initialize( Device& device ); diff --git a/engine/inc/uf/ext/vulkan/rendermodes/deferred.h b/engine/inc/uf/ext/vulkan/rendermodes/deferred.h index bd7e3d55..0226eac0 100644 --- a/engine/inc/uf/ext/vulkan/rendermodes/deferred.h +++ b/engine/inc/uf/ext/vulkan/rendermodes/deferred.h @@ -1,17 +1,11 @@ #pragma once #include -#include namespace ext { namespace vulkan { - struct UF_API DeferredRenderMode : public ext::vulkan::RenderMode { - ext::vulkan::Graphic blitter; - + struct UF_API DeferredRenderMode : public ext::vulkan::RenderMode { virtual const uf::stl::string getType() const; - virtual const size_t blitters() const; - virtual ext::vulkan::Graphic* getBlitter(size_t = 0); - virtual uf::stl::vector getBlitters(); virtual GraphicDescriptor bindGraphicDescriptor( const GraphicDescriptor&, size_t = 0 ); diff --git a/engine/inc/uf/ext/vulkan/rendermodes/rendertarget.h b/engine/inc/uf/ext/vulkan/rendermodes/rendertarget.h index 8a832d3e..68457282 100644 --- a/engine/inc/uf/ext/vulkan/rendermodes/rendertarget.h +++ b/engine/inc/uf/ext/vulkan/rendermodes/rendertarget.h @@ -1,22 +1,11 @@ #pragma once #include -#include namespace ext { namespace vulkan { struct UF_API RenderTargetRenderMode : public ext::vulkan::RenderMode { - ext::vulkan::Graphic blitter; - - // - const uf::stl::string getTarget() const; - void setTarget( const uf::stl::string& ); - - // virtual const uf::stl::string getType() const; - virtual const size_t blitters() const; - virtual ext::vulkan::Graphic* getBlitter(size_t = 0); - virtual uf::stl::vector getBlitters(); virtual GraphicDescriptor bindGraphicDescriptor( const GraphicDescriptor&, size_t = 0 ); diff --git a/engine/inc/uf/ext/vulkan/shader.h b/engine/inc/uf/ext/vulkan/shader.h index cca12b17..62b1f09a 100644 --- a/engine/inc/uf/ext/vulkan/shader.h +++ b/engine/inc/uf/ext/vulkan/shader.h @@ -5,7 +5,6 @@ #include #include #include -#include #define UF_GRAPHIC_POINTERED_USERDATA 1 @@ -20,6 +19,8 @@ namespace ext { ext::json::Value definitionToJson(/*const*/ ext::json::Value& definition ); ext::vulkan::userdata_t jsonToUserdata( const ext::json::Value& payload, const ext::json::Value& definition ); + struct RenderMode; + struct UF_API Shader : public Buffers { bool aliased = false; @@ -113,7 +114,16 @@ namespace ext { VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED; VkFilter filter = VK_FILTER_NEAREST; }; - uf::stl::vector attachments; + struct BufferDescriptor { + uf::stl::string name{}; + ext::vulkan::Buffer fallback; + const ext::vulkan::RenderMode* renderMode{}; + VkBufferUsageFlags flags{}; + }; + struct { + uf::stl::vector attachments; + uf::stl::vector buffers; + } aliases; } metadata; ext::vulkan::userdata_t specializationConstants; @@ -128,10 +138,13 @@ namespace ext { void destroy(); bool validate(); + bool hasAttachment( const uf::stl::string& name ); void aliasAttachment( const Metadata::AttachmentDescriptor& descriptor ); void aliasAttachment( const uf::stl::string& name, const ext::vulkan::RenderMode* renderMode = NULL, VkImageLayout = VK_IMAGE_LAYOUT_UNDEFINED, VkFilter filter = VK_FILTER_NEAREST ); - bool hasAttachment( const uf::stl::string& name ); + bool hasBuffer( const uf::stl::string& name ); + void aliasBuffer( const Metadata::BufferDescriptor& descriptor ); + void aliasBuffer( const uf::stl::string& name, const ext::vulkan::Buffer& = {}, const ext::vulkan::RenderMode* renderMode = NULL, VkBufferUsageFlags = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT ); bool hasUniform( const uf::stl::string& name ) const; diff --git a/engine/inc/uf/utils/camera/camera.h b/engine/inc/uf/utils/camera/camera.h index 4c3bbae7..58cc3539 100644 --- a/engine/inc/uf/utils/camera/camera.h +++ b/engine/inc/uf/utils/camera/camera.h @@ -15,8 +15,9 @@ namespace uf { namespace pod { struct UF_API Camera { - bool modified = false; + // bool modified = false; bool stereoscopic = false; + size_t ttl{}; pod::Transform<> transform; struct Viewports { diff --git a/engine/inc/uf/utils/image/image.h b/engine/inc/uf/utils/image/image.h index 21f68393..527d3572 100644 --- a/engine/inc/uf/utils/image/image.h +++ b/engine/inc/uf/utils/image/image.h @@ -10,7 +10,7 @@ namespace uf { class UF_API Image { public: typedef pod::Vector2ui vec2_t; - typedef pod::PixelRgba8 pixel_t; + typedef pod::Vector pixel_t; typedef uf::stl::vector container_t; protected: uf::stl::string m_filename; @@ -21,21 +21,12 @@ namespace uf { std::size_t m_format; public: // C-tor - /* - Image(); // Default - Image( const Image::vec2_t& size ); // Just Size - Image( Image&& move ); // Move pixels - Image( const Image& copy ); // Copy pixels - Image( Image::container_t&& move, const Image::vec2_t& size ); // Move from vector of pixels - Image( const Image::container_t& copy, const Image::vec2_t& size ); // Copy from vector of pixels - */ bool open( const uf::stl::string& filename, bool = true ); // from file void open( const std::istream& stream ); // from stream void move( Image::container_t&& move, const Image::vec2_t& size ); // move from vector of pixels void copy( const Image::container_t& copy, const Image::vec2_t& size ); // copy from vector of pixels void copy( const uf::Image& ); // copy from image object // D-tor - ~Image(); void clear(); // empties pixel container // Getters void loadFromBuffer( const Image::pixel_t::type_t* pointer, const pod::Vector2ui& size, std::size_t bpp, std::size_t channels, bool flip = false ); diff --git a/engine/inc/uf/utils/image/pixel.h b/engine/inc/uf/utils/image/pixel.h index 990ee6f2..194edf73 100644 --- a/engine/inc/uf/utils/image/pixel.h +++ b/engine/inc/uf/utils/image/pixel.h @@ -1,5 +1,5 @@ #pragma once - +#if 0 #include namespace pod { @@ -120,4 +120,5 @@ namespace uf { template T& /*UF_API*/ negate( T& pixel ); // Flip sign of all components } } -#include "pixel.inl" \ No newline at end of file +#include "pixel.inl" +#endif \ No newline at end of file diff --git a/engine/inc/uf/utils/time/time.h b/engine/inc/uf/utils/time/time.h index 3deadd96..e3d59def 100644 --- a/engine/inc/uf/utils/time/time.h +++ b/engine/inc/uf/utils/time/time.h @@ -83,6 +83,8 @@ namespace uf { }; namespace time { + extern UF_API size_t frame; + extern UF_API uf::Timer<> timer; extern UF_API double current; extern UF_API double previous; diff --git a/engine/src/engine/asset/asset.cpp b/engine/src/engine/asset/asset.cpp index 3530f0a0..e32c57d1 100644 --- a/engine/src/engine/asset/asset.cpp +++ b/engine/src/engine/asset/asset.cpp @@ -76,7 +76,10 @@ void uf::Asset::processQueue() { if ( callback != "" && filename != "" ) uf::hooks.call(callback, payload); }); +// bool bitch = !tasks.container.empty(); +// if ( bitch ) UF_MSG_DEBUG("Batching Jobs: {}", tasks.container.size()); uf::thread::execute( tasks ); +// if ( bitch ) UF_MSG_DEBUG("Finished Jobs: {}", tasks.container.size()); } void uf::Asset::cache( const uf::stl::string& callback, const uf::Asset::Payload& payload ) { mutex.lock(); diff --git a/engine/src/engine/graph/convert.cpp b/engine/src/engine/graph/convert.cpp index 97220229..2a19bdcb 100644 --- a/engine/src/engine/graph/convert.cpp +++ b/engine/src/engine/graph/convert.cpp @@ -103,7 +103,7 @@ namespace { } } -pod::Graph& UF_API uf::graph::convert( uf::Object& object, bool process ) { +pod::Graph& uf::graph::convert( uf::Object& object, bool process ) { auto& graph = object.getComponent(); graph.name = object.getName(); diff --git a/engine/src/engine/graph/decode.cpp b/engine/src/engine/graph/decode.cpp index 266bc6f3..157fd439 100644 --- a/engine/src/engine/graph/decode.cpp +++ b/engine/src/engine/graph/decode.cpp @@ -350,9 +350,9 @@ pod::Graph uf::graph::load( const uf::stl::string& filename, const uf::Serialize if ( !ext::json::isArray(graph.metadata["decode"]["attributes"]) ) { #if UF_USE_OPENGL - graph.metadata["decode"]["attributes"] = uf::stl::vector({ "position", "uv", "st" }); + graph.metadata["decode"]["attributes"] = uf::stl::vector({ "position", "uv", "st" }); #else - graph.metadata["decode"]["attributes"] = uf::stl::vector({ "position", "color", "uv", "st", "tangent", "joints", "weights", "normal", "id" }); + graph.metadata["decode"]["attributes"] = uf::stl::vector({ "position", "color", "uv", "st", "tangent", "joints", "weights", "normal", "id" }); #endif } diff --git a/engine/src/engine/graph/graph.cpp b/engine/src/engine/graph/graph.cpp index a76aa0e6..1eaccf18 100644 --- a/engine/src/engine/graph/graph.cpp +++ b/engine/src/engine/graph/graph.cpp @@ -183,10 +183,19 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M uf::renderer::Buffer* indirect = NULL; for ( auto& buffer : graphic.buffers ) if ( !indirect && buffer.usage & uf::renderer::enums::Buffer::INDIRECT ) indirect = &buffer; +/* + { + auto& renderMode = uf::renderer::getRenderMode("", true); + if ( !renderMode.hasBuffer("camera") ) { + renderMode.metadata.buffers["camera"] = renderMode.initializeBuffer( (const void*) nullptr, sizeof(pod::Camera::Viewports), uf::renderer::enums::Buffer::UNIFORM ); + } + } +*/ { auto& shader = graphic.material.getShader("vertex"); - shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); + // shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); + shader.aliasBuffer( "camera", uf::graph::storage.buffers.camera ); // // shader.buffers.emplace_back( uf::graph::storage.buffers.drawCommands.alias() ); #if UF_USE_VULKAN shader.buffers.emplace_back( indirect->alias() ); @@ -240,7 +249,8 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M auto& shader = graphic.material.getShader("compute", uf::renderer::settings::pipelines::names::culling); - shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); + // shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); + shader.aliasBuffer( "camera", uf::graph::storage.buffers.camera ); shader.buffers.emplace_back( indirect->alias() ); shader.buffers.emplace_back( uf::graph::storage.buffers.instance.alias() ); @@ -350,8 +360,6 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M { "PASSES", maxPasses }, }); - // shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); - // shader.buffers.emplace_back( uf::graph::storage.buffers.drawCommands.alias() ); #if UF_USE_VULKAN shader.buffers.emplace_back( indirect->alias() ); #endif @@ -1025,11 +1033,12 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) #else metadata.system.ignoreGraph = graph.metadata["debug"]["static"].as(); #endif + float powerScale = graph.metadata["lights"]["scale"].as(1); uf::Serializer metadataLight; metadataLight["radius"][0] = 0.001; metadataLight["radius"][1] = l.range; // l.range <= 0.001f ? graph.metadata["lights"]["range cap"].as() : l.range; - metadataLight["power"] = l.intensity; // * graph.metadata["lights"]["power scale"].as(); + metadataLight["power"] = l.intensity * powerScale; // * graph.metadata["lights"]["power scale"].as(); metadataLight["color"][0] = l.color.x; metadataLight["color"][1] = l.color.y; metadataLight["color"][2] = l.color.z; @@ -1429,12 +1438,15 @@ void uf::graph::render() { auto& controller = scene.getController(); auto& camera = controller.getComponent(); + camera.update(); auto viewport = camera.data().viewport; #if UF_USE_FFX_FSR - auto jitter = ext::fsr::getJitterMatrix(); - for ( auto i = 0; i < uf::camera::maxViews; ++i ) { - viewport.matrices[i].projection = jitter * viewport.matrices[i].projection; + if ( ext::fsr::initialized ) { + auto jitter = ext::fsr::getJitterMatrix(); + for ( auto i = 0; i < uf::camera::maxViews; ++i ) { + viewport.matrices[i].projection = jitter * viewport.matrices[i].projection; + } } #endif @@ -1443,16 +1455,10 @@ void uf::graph::render() { #if UF_USE_VULKAN auto* renderMode = uf::renderer::getCurrentRenderMode(); if ( !renderMode ) return; + if ( !renderMode->hasBuffer("camera") ) return; + auto& buffer = renderMode->getBuffer("camera"); + buffer.update( (const void*) &viewport, sizeof(pod::Camera::Viewports) ); /* - TIMER(1, renderMode->getType() == "Deferred") { - UF_MSG_DEBUG("{}: {}", renderMode->getName(), renderMode->getType()); - UF_MSG_DEBUG("{}: {}", controller.getName(), controller.getUid()); - UF_MSG_DEBUG("\tTransform[0]: {}", uf::transform::toString( controller.getComponent>() )); - UF_MSG_DEBUG("\tTransform[1]: {}", uf::transform::toString( camera.getTransform() )); - UF_MSG_DEBUG("\tMatrix: {}", uf::matrix::toString( viewport.matrices[0].view )); - } -*/ - for ( auto& buffer : renderMode->buffers ) { if ( !(buffer.usage & uf::renderer::enums::Buffer::UNIFORM) ) continue; if ( buffer.allocationInfo.size != sizeof(pod::Camera::Viewports) ) continue; @@ -1460,6 +1466,7 @@ void uf::graph::render() { buffer.update( (const void*) &viewport, sizeof(pod::Camera::Viewports) ); return; } +*/ #endif } void uf::graph::destroy() { diff --git a/engine/src/engine/object/behavior.cpp b/engine/src/engine/object/behavior.cpp index c91c15df..99f617cc 100644 --- a/engine/src/engine/object/behavior.cpp +++ b/engine/src/engine/object/behavior.cpp @@ -64,8 +64,10 @@ void uf::ObjectBehavior::initialize( uf::Object& self ) { this->addHook( "asset:QueueLoad.%UID%", [&](pod::payloads::assetLoad& payload){ uf::stl::string callback = this->formatHookName("asset:FinishedLoad.%UID%"); if ( payload.monoThreaded ) { + // UF_MSG_DEBUG("Queued: {}", payload.filename); if ( assetLoader.load( payload ) != "" ) this->queueHook( callback, payload ); } else { + // UF_MSG_DEBUG("Immediate: {}", payload.filename); assetLoader.load( callback, payload ); } }); @@ -97,8 +99,6 @@ void uf::ObjectBehavior::initialize( uf::Object& self ) { } }); - UF_BEHAVIOR_METADATA_BIND_SERIALIZER_HOOKS(metadata, metadataJson); - if ( ext::json::isObject(metadataJson["physics"]) ) { auto& collider = this->getComponent(); collider.stats.flags = metadataJson["physics"]["flags"].as(collider.stats.flags); @@ -122,6 +122,8 @@ void uf::ObjectBehavior::initialize( uf::Object& self ) { uf::physics::impl::create( *this, radius, height ); } } + + UF_BEHAVIOR_METADATA_BIND_SERIALIZER_HOOKS(metadata, metadataJson); } void uf::ObjectBehavior::destroy( uf::Object& self ) { auto& metadata = this->getComponent(); @@ -217,27 +219,25 @@ void uf::ObjectBehavior::tick( uf::Object& self ) { } auto& queue = metadata.hooks.queue; +// if ( !queue.empty() ) + { + decltype(metadata.hooks.queue) unprocessed; + unprocessed.reserve( metadata.hooks.queue.size() ); -// if ( !uf::Object::timer.running() ) uf::Object::timer.start(); -// double curTime = uf::Object::timer.elapsed().asDouble(); - auto curTime = uf::time::current; + decltype(metadata.hooks.queue) executeQueue; + executeQueue.reserve( metadata.hooks.queue.size() ); - decltype(metadata.hooks.queue) unprocessed; - unprocessed.reserve( metadata.hooks.queue.size() ); - - decltype(metadata.hooks.queue) executeQueue; - executeQueue.reserve( metadata.hooks.queue.size() ); - - for ( auto& q : queue ) { - if ( q.timeout < curTime ) executeQueue.emplace_back(q); - else unprocessed.emplace_back(q); + for ( auto& q : queue ) { + if ( q.timeout < uf::time::current ) executeQueue.emplace_back(q); + else unprocessed.emplace_back(q); + } + for ( auto& q : executeQueue ) { + if ( q.type == 1 ) this->callHook( q.name, q.userdata ); + else if ( q.type == -1 ) this->callHook( q.name, q.json ); + else this->callHook( q.name ); + } + queue = std::move(unprocessed); } - for ( auto& q : executeQueue ) { - if ( q.type == 1 ) this->callHook( q.name, q.userdata ); - else if ( q.type == -1 ) this->callHook( q.name, q.json ); - else this->callHook( q.name ); - } - queue = std::move(unprocessed); #if UF_ENTITY_METADATA_USE_JSON metadata.serialize(self, metadataJson); diff --git a/engine/src/engine/object/object.cpp b/engine/src/engine/object/object.cpp index 56635fcd..bd6a0e49 100644 --- a/engine/src/engine/object/object.cpp +++ b/engine/src/engine/object/object.cpp @@ -26,7 +26,7 @@ UF_OBJECT_REGISTER_BEGIN(uf::Object) UF_OBJECT_REGISTER_END() uf::Object::Object() UF_BEHAVIOR_ENTITY_CPP_ATTACH(uf::Object) -void UF_API uf::Object::queueDeletion() { +void uf::Object::queueDeletion() { for ( uf::Entity* kv : this->getChildren() ) ((uf::Object*) kv)->queueDeletion(); if ( this->hasParent() )this->getParent().removeChild(*this); @@ -307,73 +307,17 @@ bool uf::Object::load( const uf::Serializer& _json ) { } } // Set movement - { - if ( ext::json::isObject( json["physics"] ) && !this->hasComponent() ) { - auto& physics = this->getComponent(); - physics.linear.velocity = uf::vector::decode( json["physics"]["linear"]["velocity"], physics.linear.velocity ); - physics.linear.acceleration = uf::vector::decode( json["physics"]["linear"]["acceleration"], physics.linear.acceleration ); - physics.rotational.velocity = uf::vector::decode( json["physics"]["rotational"]["velocity"], physics.rotational.velocity ); - physics.rotational.acceleration = uf::vector::decode( json["physics"]["rotational"]["acceleration"], physics.rotational.acceleration ); - } + if ( ext::json::isObject( json["physics"] ) && !this->hasComponent() ) { + auto& physics = this->getComponent(); + physics.linear.velocity = uf::vector::decode( json["physics"]["linear"]["velocity"], physics.linear.velocity ); + physics.linear.acceleration = uf::vector::decode( json["physics"]["linear"]["acceleration"], physics.linear.acceleration ); + physics.rotational.velocity = uf::vector::decode( json["physics"]["rotational"]["velocity"], physics.rotational.velocity ); + physics.rotational.acceleration = uf::vector::decode( json["physics"]["rotational"]["acceleration"], physics.rotational.acceleration ); } // Load assets -#if 1 - { - this->loadAssets( json ); - } -#else - auto& scene = uf::scene::getCurrentScene(); - auto& assetLoader = scene.getComponent(); + this->loadAssets( json ); - #define ASSET_ENTRY(type) { uf::string::lowercase(#type), uf::Asset::Type::type } - const uf::stl::unordered_map assets = { - ASSET_ENTRY(AUDIO), - ASSET_ENTRY(IMAGE), - ASSET_ENTRY(GRAPH), - ASSET_ENTRY(LUA), - }; - - for ( auto& pair : assets ) { - auto& assetType = pair.second; - auto& assetTypeString = pair.first; - - uf::Serializer target; - bool override = false; - if ( ext::json::isObject( metadataJson["system"]["assets"] ) ) { - target = metadataJson["system"]["assets"]; - } else if ( ext::json::isArray( json["assets"] ) ) { - target = json["assets"]; - } else if ( ext::json::isObject( json["assets"] ) && !ext::json::isNull( json["assets"][assetTypeString] ) ) { - target = json["assets"][assetTypeString]; - } - - for ( size_t i = 0; i < target.size(); ++i ) { - bool isObject = ext::json::isObject( target[i] ); - uf::stl::string f = isObject ? target[i]["filename"].as() : target[i].as(); - uf::stl::string filename = uf::io::resolveURI( f, metadata.system.root ); - uf::stl::string mime = isObject ? target[i]["mime"].as("") : ""; - uf::Asset::Payload payload = uf::Asset::resolveToPayload( filename, mime ); - if ( !uf::Asset::isExpected( payload, assetType ) ) continue; - payload.hash = isObject ? target[i]["hash"].as("") : ""; - payload.monoThreaded = isObject ? !target[i]["multithreaded"].as(true) : !true; - this->queueHook( "asset:QueueLoad.%UID%", payload, isObject ? target[i]["delay"].as() : 0 ); - bool bind = isObject ? target[i]["bind"].as(true) : true; - - switch ( assetType ) { - case uf::Asset::Type::LUA: { - if ( bind ) uf::instantiator::bind("LuaBehavior", *this); - } break; - case uf::Asset::Type::GRAPH: { - auto& aMetadata = assetLoader.getComponent(); - aMetadata[filename] = json["metadata"]["graph"]; - aMetadata[filename]["root"] = json["root"]; - if ( bind ) uf::instantiator::bind("GraphBehavior", *this); - } break; - } - } - } -#endif // Bind behaviors { if ( json["type"].is() ) uf::instantiator::bind( json["type"].as(), *this ); diff --git a/engine/src/ext/discord/discord.cpp b/engine/src/ext/discord/discord.cpp index cf4889cf..078a831c 100644 --- a/engine/src/ext/discord/discord.cpp +++ b/engine/src/ext/discord/discord.cpp @@ -55,7 +55,7 @@ namespace { DiscordState state{}; } -void UF_API ext::discord::initialize(){ +void ext::discord::initialize(){ ::discord::Core* core{}; auto result = ::discord::Core::Create(600081027943366656, DiscordCreateFlags_Default, &core); @@ -297,7 +297,7 @@ void UF_API ext::discord::initialize(){ */ } -void UF_API ext::discord::tick() { +void ext::discord::tick() { state.core->RunCallbacks(); } @@ -391,7 +391,7 @@ namespace { struct Application app; } -void UF_API ext::::discord::initialize() { +void ext::::discord::initialize() { memset(&app, 0, sizeof(app)); struct IDiscordUserEvents users_events; @@ -432,13 +432,13 @@ void UF_API ext::::discord::initialize() { app.relationships = app.core->get_relationship_manager(app.core); } -void UF_API ext::::discord::tick() { +void ext::::discord::tick() { DISCORD_REQUIRE(app.core->run_callbacks(app.core)); } */ #else -void UF_API ext::discord::initialize(){ +void ext::discord::initialize(){ } -void UF_API ext::discord::tick(){ +void ext::discord::tick(){ } #endif \ No newline at end of file diff --git a/engine/src/ext/ffx/fsr.cpp b/engine/src/ext/ffx/fsr.cpp index c0339d8d..6676f453 100644 --- a/engine/src/ext/ffx/fsr.cpp +++ b/engine/src/ext/ffx/fsr.cpp @@ -193,7 +193,7 @@ float ext::fsr::sharpness = 1.0f; float ext::fsr::jitterScale = 2.0f; bool ext::fsr::initialized = false; -void UF_API ext::fsr::initialize() { +void ext::fsr::initialize() { ffxFsr2SetInstanceFunctions( uf::renderer::device.instance, vkGetInstanceProcAddr ); scratchBuffer.resize(ffxFsr2GetScratchMemorySizeVK(uf::renderer::device.physicalDevice, uf::renderer::device.extensionProperties.device.size())); @@ -226,13 +226,13 @@ void UF_API ext::fsr::initialize() { ); auto& renderMode = uf::renderer::getRenderMode("", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); auto& shader = blitter.material.getShader("fragment"); shader.textures.clear(); shader.textures.emplace_back().aliasTexture( fsrTarget ); } } -void UF_API ext::fsr::tick() { +void ext::fsr::tick() { if ( !ext::fsr::initialized ) return; pod::Vector2ui renderSize = {}; pod::Vector2ui displaySize = {}; @@ -252,7 +252,7 @@ void UF_API ext::fsr::tick() { ); auto& renderMode = uf::renderer::getRenderMode("", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); auto& shader = blitter.material.getShader("fragment"); shader.textures.clear(); shader.textures.emplace_back().aliasTexture( fsrTarget ); @@ -293,18 +293,18 @@ void UF_API ext::fsr::tick() { // UF_MSG_DEBUG("{}, {} x {} ({} {})", ext::fsr::jitterScale, jitter.x, jitter.y, index, jitterPhaseCount); ::jitterMatrix = uf::matrix::translate( uf::matrix::identity(), pod::Vector3f{ jitter.x, jitter.y, 0 } ); } -void UF_API ext::fsr::render() { +void ext::fsr::render() { if ( !ext::fsr::initialized ) return; auto commandBuffer = uf::renderer::device.fetchCommandBuffer(uf::renderer::QueueEnum::GRAPHICS, true); draw(commandBuffer, uf::renderer::states::currentBuffer); uf::renderer::device.flushCommandBuffer(commandBuffer); } -void UF_API ext::fsr::terminate() { +void ext::fsr::terminate() { if ( !ext::fsr::initialized ) return; FFX_ERROR_CHECK(ffxFsr2ContextDestroy( &::context )); } -pod::Matrix4f UF_API ext::fsr::getJitterMatrix() { +pod::Matrix4f ext::fsr::getJitterMatrix() { return ::jitterMatrix; } diff --git a/engine/src/ext/freetype/freetype.cpp b/engine/src/ext/freetype/freetype.cpp index 9c37bd4c..c93615ed 100644 --- a/engine/src/ext/freetype/freetype.cpp +++ b/engine/src/ext/freetype/freetype.cpp @@ -4,7 +4,7 @@ ext::freetype::Library ext::freetype::library; -UF_API ext::freetype::Library::Library() : loaded(false) { +ext::freetype::Library::Library() : loaded(false) { ext::freetype::initialize(); } ext::freetype::Library::~Library() { @@ -15,7 +15,7 @@ ext::freetype::Glyph::~Glyph() { ext::freetype::destroy(*this); } -UF_API bool ext::freetype::initialize() { +bool ext::freetype::initialize() { int error = 0; if ( (error = FT_Init_FreeType( &ext::freetype::library.library ) )) { std::cout << "Error #" << ext::freetype::getError(error) << ": FreeType failed to initialize" << std::endl; @@ -24,16 +24,16 @@ UF_API bool ext::freetype::initialize() { ext::freetype::library.loaded = true; return true; } -UF_API bool ext::freetype::initialized() { +bool ext::freetype::initialized() { return ext::freetype::library.loaded; } -UF_API void ext::freetype::terminate() { +void ext::freetype::terminate() { if ( !ext::freetype::library.loaded ) return; FT_Done_FreeType(ext::freetype::library.library); ext::freetype::library.loaded = false; } -UF_API ext::freetype::Glyph ext::freetype::initialize( const uf::stl::string& font ) { +ext::freetype::Glyph ext::freetype::initialize( const uf::stl::string& font ) { if ( !ext::freetype::initialized() ) ext::freetype::initialize(); ext::freetype::Glyph glyph; int error = 0; @@ -45,7 +45,7 @@ UF_API ext::freetype::Glyph ext::freetype::initialize( const uf::stl::string& fo } return glyph; } -UF_API bool ext::freetype::initialize( ext::freetype::Glyph& glyph, const uf::stl::string& font ) { +bool ext::freetype::initialize( ext::freetype::Glyph& glyph, const uf::stl::string& font ) { if ( !ext::freetype::initialized() ) ext::freetype::initialize(); int error = 0; if ( (error = FT_New_Face( ext::freetype::library.library, font.c_str(), 0, &glyph.face )) ) { @@ -58,18 +58,18 @@ UF_API bool ext::freetype::initialize( ext::freetype::Glyph& glyph, const uf::st } return true; } -UF_API void ext::freetype::destroy( ext::freetype::Glyph& glyph ) { +void ext::freetype::destroy( ext::freetype::Glyph& glyph ) { FT_Done_Face( glyph.face ); } -UF_API void ext::freetype::setPixelSizes( ext::freetype::Glyph& glyph, int height ) { +void ext::freetype::setPixelSizes( ext::freetype::Glyph& glyph, int height ) { FT_Set_Pixel_Sizes( glyph.face, 0, height ); } -UF_API void ext::freetype::setPixelSizes( ext::freetype::Glyph& glyph, int width, int height ) { +void ext::freetype::setPixelSizes( ext::freetype::Glyph& glyph, int width, int height ) { FT_Set_Pixel_Sizes( glyph.face, width, height ); } -UF_API bool ext::freetype::load( ext::freetype::Glyph& glyph, unsigned long c ) { +bool ext::freetype::load( ext::freetype::Glyph& glyph, unsigned long c ) { int error = 0; if ( (error = FT_Load_Char(glyph.face, c, FT_LOAD_RENDER) )) { std::cout << "Error #" << ext::freetype::getError(error) << ": FreeType failed to load glyph `" << c << "`" << std::endl; @@ -77,7 +77,7 @@ UF_API bool ext::freetype::load( ext::freetype::Glyph& glyph, unsigned long c ) } return true; } -UF_API bool ext::freetype::load( ext::freetype::Glyph& glyph, const uf::String& string ) { +bool ext::freetype::load( ext::freetype::Glyph& glyph, const uf::String& string ) { unsigned long c = string.translate().at(0); int error = 0; if ( (error = FT_Load_Char(glyph.face, FT_Get_Char_Index(glyph.face, c), FT_LOAD_RENDER) )) { @@ -87,7 +87,7 @@ UF_API bool ext::freetype::load( ext::freetype::Glyph& glyph, const uf::String& return true; } -UF_API uf::stl::string ext::freetype::getError( int error ) { +uf::stl::string ext::freetype::getError( int error ) { #undef FTERRORS_H_ #define FT_ERRORDEF( e, v, s ) { e, s }, #define FT_ERROR_START_LIST { diff --git a/engine/src/ext/opengl/opengl.cpp b/engine/src/ext/opengl/opengl.cpp index e9d2ccf8..4488c6cb 100644 --- a/engine/src/ext/opengl/opengl.cpp +++ b/engine/src/ext/opengl/opengl.cpp @@ -97,10 +97,10 @@ uf::stl::vector ext::opengl::renderModes = { new ext::opengl::BaseRenderMode, }; -uf::stl::string UF_API ext::opengl::errorString() { +uf::stl::string ext::opengl::errorString() { return ext::opengl::errorString(glGetError()); } -uf::stl::string UF_API ext::opengl::errorString( GLenum error ) { +uf::stl::string ext::opengl::errorString( GLenum error ) { uf::stl::string str = ""; if (error == GL_NO_ERROR) return str; #if UF_ENV_DREAMCAST @@ -173,27 +173,27 @@ uf::stl::vector ext::opengl::getRenderModes( const uf: } return targets; } -void UF_API ext::opengl::removeRenderMode( ext::opengl::RenderMode* mode, bool free ) { +void ext::opengl::removeRenderMode( ext::opengl::RenderMode* mode, bool free ) { if ( !mode ) return; renderModes.erase( std::remove( renderModes.begin(), renderModes.end(), mode ), renderModes.end() ); mode->destroy(); if ( free ) delete mode; ext::opengl::states::rebuild = true; } -ext::opengl::RenderMode* UF_API ext::opengl::getCurrentRenderMode() { +ext::opengl::RenderMode* ext::opengl::getCurrentRenderMode() { return getCurrentRenderMode( std::this_thread::get_id() ); } -ext::opengl::RenderMode* UF_API ext::opengl::getCurrentRenderMode( std::thread::id id ) { +ext::opengl::RenderMode* ext::opengl::getCurrentRenderMode( std::thread::id id ) { return ext::opengl::currentRenderMode.get(id); } -void UF_API ext::opengl::setCurrentRenderMode( ext::opengl::RenderMode* renderMode ) { +void ext::opengl::setCurrentRenderMode( ext::opengl::RenderMode* renderMode ) { return setCurrentRenderMode( renderMode, std::this_thread::get_id() ); } -void UF_API ext::opengl::setCurrentRenderMode( ext::opengl::RenderMode* renderMode, std::thread::id id ) { +void ext::opengl::setCurrentRenderMode( ext::opengl::RenderMode* renderMode, std::thread::id id ) { ext::opengl::currentRenderMode.get(id) = renderMode; } -void UF_API ext::opengl::initialize() { +void ext::opengl::initialize() { device.initialize(); // swapchain.initialize( device ); if ( uf::io::exists(uf::io::root + "/textures/missing.png") ) { @@ -376,7 +376,7 @@ void UF_API ext::opengl::initialize() { } #endif } -void UF_API ext::opengl::tick(){ +void ext::opengl::tick(){ ext::opengl::mutex.lock(); if ( ext::opengl::states::resized || ext::opengl::settings::experimental::rebuildOnTickBegin ) { ext::opengl::states::rebuild = true; @@ -413,7 +413,7 @@ void UF_API ext::opengl::tick(){ ext::opengl::states::resized = false; ext::opengl::mutex.unlock(); } -void UF_API ext::opengl::render(){ +void ext::opengl::render(){ ext::opengl::mutex.lock(); #if !UF_ENV_DREAMCAST ext::opengl::device.activateContext(); @@ -480,7 +480,7 @@ void UF_API ext::opengl::render(){ #endif ext::opengl::mutex.unlock(); } -void UF_API ext::opengl::destroy() { +void ext::opengl::destroy() { ext::opengl::mutex.lock(); synchronize(); @@ -503,7 +503,7 @@ void UF_API ext::opengl::destroy() { device.destroy(); ext::opengl::mutex.unlock(); } -void UF_API ext::opengl::synchronize( uint8_t flag ) { +void ext::opengl::synchronize( uint8_t flag ) { if ( flag & 0b01 ) { for ( auto& renderMode : renderModes ) { if ( !renderMode ) continue; @@ -515,7 +515,7 @@ void UF_API ext::opengl::synchronize( uint8_t flag ) { // vkDeviceWaitIdle( device ); } } -uf::stl::string UF_API ext::opengl::allocatorStats(){ +uf::stl::string ext::opengl::allocatorStats(){ return ""; } ext::opengl::enums::Format::type_t ext::opengl::formatFromString( const uf::stl::string& string ) { diff --git a/engine/src/ext/toml/toml.cpp b/engine/src/ext/toml/toml.cpp index a40679b7..7398ea36 100644 --- a/engine/src/ext/toml/toml.cpp +++ b/engine/src/ext/toml/toml.cpp @@ -75,7 +75,7 @@ TOML_NAMESPACE_START } TOML_NAMESPACE_END; -uf::stl::string UF_API ext::toml::fromJson( const uf::stl::string& source ) { +uf::stl::string ext::toml::fromJson( const uf::stl::string& source ) { ext::json::Value j; ext::json::decode( j, source ); @@ -88,13 +88,13 @@ uf::stl::string UF_API ext::toml::fromJson( const uf::stl::string& source ) { std::stringstream ss; ss << tbl; return ss.str(); #if UF_EXCEPTIONS - } catch ( const ::toml::parse_error& err ) { + } catch ( const ::toml::parse_error& e ) { UF_MSG_ERROR("TOML error: {}", e.what()); } return ""; #endif } -uf::stl::vector UF_API ext::toml::fromJson( const uf::stl::vector& source ) { +uf::stl::vector ext::toml::fromJson( const uf::stl::vector& source ) { ext::json::Value j; ext::json::decode( j, source ); @@ -108,13 +108,13 @@ uf::stl::vector UF_API ext::toml::fromJson( const uf::stl::vector{ str.begin(), str.end() }; #if UF_EXCEPTIONS - } catch ( const ::toml::parse_error& err ) { + } catch ( const ::toml::parse_error& e ) { UF_MSG_ERROR("TOML error: {}", e.what()); } return {}; #endif } -uf::stl::string UF_API ext::toml::toJson( const uf::stl::string& source ) { +uf::stl::string ext::toml::toJson( const uf::stl::string& source ) { #if UF_EXCEPTIONS try { #endif @@ -127,13 +127,13 @@ uf::stl::string UF_API ext::toml::toJson( const uf::stl::string& source ) { std::stringstream ss; ss << ::toml::json_formatter{ result }; return ss.str(); #if UF_EXCEPTIONS - } catch ( const ::toml::parse_error& err ) { + } catch ( const ::toml::parse_error& e ) { UF_MSG_ERROR("TOML error: {}", e.what()); } return ""; #endif } -uf::stl::vector UF_API ext::toml::toJson( const uf::stl::vector& source ) { +uf::stl::vector ext::toml::toJson( const uf::stl::vector& source ) { #if UF_EXCEPTIONS try { #endif @@ -148,7 +148,7 @@ uf::stl::vector UF_API ext::toml::toJson( const uf::stl::vector{ str.begin(), str.end() }; #if UF_EXCEPTIONS - } catch ( const ::toml::parse_error& err ) { + } catch ( const ::toml::parse_error& e ) { UF_MSG_ERROR("TOML error: {}", e.what()); } return {}; diff --git a/engine/src/ext/vulkan/buffer.cpp b/engine/src/ext/vulkan/buffer.cpp index 728e23ed..8bb83f4e 100644 --- a/engine/src/ext/vulkan/buffer.cpp +++ b/engine/src/ext/vulkan/buffer.cpp @@ -50,6 +50,7 @@ void ext::vulkan::Buffer::unmap() { vmaUnmapMemory( allocator, allocation ); mapped = nullptr; } +/* void* ext::vulkan::Buffer::map( VkDeviceSize size, VkDeviceSize offset ) const { void* mapped{}; VK_CHECK_RESULT(vmaMapMemory( allocator, allocation, &mapped )); @@ -58,22 +59,9 @@ void* ext::vulkan::Buffer::map( VkDeviceSize size, VkDeviceSize offset ) const { void ext::vulkan::Buffer::unmap() const { vmaUnmapMemory( allocator, allocation ); } - VkResult ext::vulkan::Buffer::bind( VkDeviceSize offset ) { return VK_SUCCESS; } - -void ext::vulkan::Buffer::setupDescriptor( VkDeviceSize size, VkDeviceSize offset ) { - descriptor.offset = offset; - descriptor.buffer = buffer; - descriptor.range = size; -} - -void ext::vulkan::Buffer::copyTo( void* data, VkDeviceSize size ) { - assert(mapped); - memcpy(mapped, data, size); -} - VkResult ext::vulkan::Buffer::flush( VkDeviceSize size, VkDeviceSize offset ) const { return VK_SUCCESS; } @@ -81,6 +69,17 @@ VkResult ext::vulkan::Buffer::flush( VkDeviceSize size, VkDeviceSize offset ) co VkResult ext::vulkan::Buffer::invalidate( VkDeviceSize size, VkDeviceSize offset ) { return VK_SUCCESS; } +void ext::vulkan::Buffer::copyTo( void* data, VkDeviceSize size ) { + assert(mapped); + memcpy(mapped, data, size); +} +*/ + +void ext::vulkan::Buffer::updateDescriptor( VkDeviceSize size, VkDeviceSize offset ) { + descriptor.offset = offset; + descriptor.buffer = buffer; + descriptor.range = size; +} void ext::vulkan::Buffer::allocate( VkBufferCreateInfo bufferCreateInfo ) { VmaAllocationCreateInfo allocCreateInfo = {}; @@ -117,7 +116,9 @@ void ext::vulkan::Buffer::initialize( ext::vulkan::Device& device, size_t alignm void ext::vulkan::Buffer::destroy(bool defer) { if ( !device || aliased ) return; if ( defer ) { + ext::vulkan::mutex.lock(); device->transient.buffers.emplace_back(*this); + ext::vulkan::mutex.unlock(); } else if ( buffer ) { vmaDestroyBuffer( allocator, buffer, allocation ); } @@ -159,15 +160,16 @@ bool ext::vulkan::Buffer::update( const void* data, VkDeviceSize length, bool st } if ( !data ) return false; if ( !stage ) { - void* map = this->map(); + auto* self = const_cast(this); + void* map = self->map(); memcpy(map, data, length); - if ((this->memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0) this->flush(); - this->unmap(); + self->unmap(); return false; } ext::vulkan::Device* device = this->device ? this->device : &ext::vulkan::device; Buffer staging = device->fetchTransientBuffer( +// Buffer staging = device->createBuffer( data, length, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, diff --git a/engine/src/ext/vulkan/device.cpp b/engine/src/ext/vulkan/device.cpp index cb79a9e1..618e4a71 100644 --- a/engine/src/ext/vulkan/device.cpp +++ b/engine/src/ext/vulkan/device.cpp @@ -570,18 +570,34 @@ void ext::vulkan::Device::flushCommandBuffer( VkCommandBuffer commandBuffer, Que VK_CHECK_RESULT( vkEndCommandBuffer( commandBuffer ) ); +#if 0 + if ( immediate ) { + VkSubmitInfo submitInfo = ext::vulkan::initializers::submitInfo(); + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &commandBuffer; + + auto queue = getQueue( queueType ); + VK_CHECK_RESULT(vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE)); + VK_CHECK_RESULT(vkQueueWaitIdle( queue )); + vkFreeCommandBuffers(logicalDevice, getCommandPool( queueType ), 1, &commandBuffer); + } +#else VkSubmitInfo submitInfo = ext::vulkan::initializers::submitInfo(); submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &commandBuffer; - auto& queue = getQueue( queueType ); + auto queue = getQueue( queueType ); VK_CHECK_RESULT(vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE)); if ( immediate ) { VK_CHECK_RESULT(vkQueueWaitIdle( queue )); vkFreeCommandBuffers(logicalDevice, getCommandPool( queueType ), 1, &commandBuffer); - } else { + } +#endif + else { + ext::vulkan::mutex.lock(); this->transient.commandBuffers[queueType].emplace_back(commandBuffer); + ext::vulkan::mutex.unlock(); } } /* @@ -623,6 +639,16 @@ ext::vulkan::CommandBuffer ext::vulkan::Device::fetchCommandBuffer( ext::vulkan: void ext::vulkan::Device::flushCommandBuffer( ext::vulkan::CommandBuffer commandBuffer ) { return this->flushCommandBuffer( commandBuffer.handle, commandBuffer.queueType, commandBuffer.immediate ); } +ext::vulkan::Buffer ext::vulkan::Device::createBuffer( + const void* data, + VkDeviceSize size, + VkBufferUsageFlags usage, + VkMemoryPropertyFlags memoryProperties +) { + ext::vulkan::Buffer buffer; + VK_CHECK_RESULT(createBuffer(data, size, usage, memoryProperties, buffer)); + return buffer; +} VkResult ext::vulkan::Device::createBuffer( const void* data, VkDeviceSize size, @@ -641,15 +667,15 @@ VkResult ext::vulkan::Device::createBuffer( if ( data != nullptr ) { void* map = buffer.map(); memcpy(map, data, size); - if ((memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0) buffer.flush(); buffer.unmap(); + // if ((memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0) buffer.flush(); } // Initialize a default descriptor that covers the whole buffer size - buffer.setupDescriptor(); + buffer.updateDescriptor(); // Attach the memory to the buffer object - return buffer.bind(); + return VK_SUCCESS; } ext::vulkan::Buffer ext::vulkan::Device::fetchTransientBuffer( const void* data, @@ -657,92 +683,81 @@ ext::vulkan::Buffer ext::vulkan::Device::fetchTransientBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryProperties ) { + + ext::vulkan::mutex.lock(); auto& buffer = this->transient.buffers.emplace_back(); VK_CHECK_RESULT(this->createBuffer(data, size, usage, memoryProperties, buffer)); + ext::vulkan::mutex.unlock(); return buffer.alias(); } -VkCommandPool& ext::vulkan::Device::getCommandPool( ext::vulkan::QueueEnum queueEnum) { +VkCommandPool ext::vulkan::Device::getCommandPool( ext::vulkan::QueueEnum queueEnum) { return this->getCommandPool( queueEnum, std::this_thread::get_id() ); } -VkQueue& ext::vulkan::Device::getQueue( ext::vulkan::QueueEnum queueEnum ) { +VkQueue ext::vulkan::Device::getQueue( ext::vulkan::QueueEnum queueEnum ) { return this->getQueue( queueEnum, std::this_thread::get_id() ); } -VkCommandPool& ext::vulkan::Device::getCommandPool( ext::vulkan::QueueEnum queueEnum, std::thread::id id ) { - uint32_t index = 0; - VkCommandPool* pool = NULL; - bool exists = false; +VkCommandPool ext::vulkan::Device::getCommandPool( ext::vulkan::QueueEnum queueEnum, std::thread::id id ) { + uint32_t index{0}; + uf::ThreadUnique* commandPool{NULL}; + switch ( queueEnum ) { case QueueEnum::GRAPHICS: index = device.queueFamilyIndices.graphics; - // if ( commandPool.graphics.count(id) > 0 ) exists = true; - // pool = &commandPool.graphics[id]; - exists = commandPool.graphics.has(id); - pool = &commandPool.graphics.get(id); + commandPool = &this->commandPool.graphics; break; case QueueEnum::COMPUTE: index = device.queueFamilyIndices.compute; - // if ( commandPool.compute.count(id) > 0 ) exists = true; - // pool = &commandPool.compute[id]; - exists = commandPool.compute.has(id); - pool = &commandPool.compute.get(id); + commandPool = &this->commandPool.compute; break; case QueueEnum::TRANSFER: index = device.queueFamilyIndices.transfer; - // if ( commandPool.transfer.count(id) > 0 ) exists = true; - // pool = &commandPool.transfer[id]; - exists = commandPool.transfer.has(id); - pool = &commandPool.transfer.get(id); + commandPool = &this->commandPool.transfer; break; } + UF_ASSERT( commandPool ); + auto guard = commandPool->guardMutex(); + bool exists = commandPool->has(id); + VkCommandPool& pool = commandPool->get(id); if ( !exists ) { VkCommandPoolCreateFlags createFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VkCommandPoolCreateInfo cmdPoolInfo = {}; cmdPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; cmdPoolInfo.queueFamilyIndex = index; cmdPoolInfo.flags = createFlags; - if ( vkCreateCommandPool( this->logicalDevice, &cmdPoolInfo, nullptr, pool ) != VK_SUCCESS ) + if ( vkCreateCommandPool( this->logicalDevice, &cmdPoolInfo, nullptr, &pool ) != VK_SUCCESS ) UF_EXCEPTION("Vulkan error: failed to create command pool for graphics!"); } - return *pool; + return pool; } -VkQueue& ext::vulkan::Device::getQueue( ext::vulkan::QueueEnum queueEnum, std::thread::id id ) { +VkQueue ext::vulkan::Device::getQueue( ext::vulkan::QueueEnum queueEnum, std::thread::id id ) { uint32_t index = 0; - VkQueue* queue = NULL; - bool exists = false; + uf::ThreadUnique* commandPool{NULL}; switch ( queueEnum ) { case QueueEnum::GRAPHICS: index = device.queueFamilyIndices.graphics; - exists = queues.graphics.has(id); - queue = &queues.graphics.get(id); - // if ( queues.graphics.count(id) > 0 ) exists = true; - // queue = &queues.graphics[id]; + commandPool = &queues.graphics; break; case QueueEnum::PRESENT: index = device.queueFamilyIndices.present; - exists = queues.present.has(id); - queue = &queues.present.get(id); - // if ( queues.present.count(id) > 0 ) exists = true; - // queue = &queues.present[id]; + commandPool = &queues.present; break; case QueueEnum::COMPUTE: index = device.queueFamilyIndices.compute; - exists = queues.compute.has(id); - queue = &queues.compute.get(id); - // if ( queues.compute.count(id) > 0 ) exists = true; - // queue = &queues.compute[id]; + commandPool = &queues.compute; break; case QueueEnum::TRANSFER: index = device.queueFamilyIndices.transfer; - exists = queues.transfer.has(id); - queue = &queues.transfer.get(id); - // if ( queues.transfer.count(id) > 0 ) exists = true; - // queue = &queues.transfer[id]; + commandPool = &queues.transfer; break; } + UF_ASSERT( commandPool ); + auto guard = commandPool->guardMutex(); + bool exists = commandPool->has(id); + VkQueue& queue = commandPool->get(id); if ( !exists ) { - vkGetDeviceQueue( device, index, 0, queue ); + vkGetDeviceQueue( device, index, 0, &queue ); } - return *queue; + return queue; } void ext::vulkan::Device::initialize() { diff --git a/engine/src/ext/vulkan/graphic.cpp b/engine/src/ext/vulkan/graphic.cpp index c889eb06..3d6a3580 100644 --- a/engine/src/ext/vulkan/graphic.cpp +++ b/engine/src/ext/vulkan/graphic.cpp @@ -218,7 +218,7 @@ void ext::vulkan::Pipeline::initialize( const Graphic& graphic, const GraphicDes // Graphic { RenderMode& renderMode = ext::vulkan::getRenderMode( descriptor.renderMode, true ); - auto& renderTarget = renderMode.getRenderTarget( descriptor.renderTarget ); + auto& renderTarget = renderMode.getRenderTarget(/*descriptor.renderTarget*/); VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = ext::vulkan::initializers::pipelineInputAssemblyStateCreateInfo( descriptor.topology, @@ -481,8 +481,7 @@ void ext::vulkan::Pipeline::update( const Graphic& graphic, const GraphicDescrip this->descriptor = descriptor; RenderMode& renderMode = ext::vulkan::getRenderMode(descriptor.renderMode, true); - auto& renderTarget = renderMode.getRenderTarget(descriptor.renderTarget ); - + auto& renderTarget = renderMode.getRenderTarget(/*descriptor.renderTarget*/); auto shaders = getShaders( graphic.material.shaders ); uf::stl::vector writeDescriptorSets; @@ -510,12 +509,31 @@ void ext::vulkan::Pipeline::update( const Graphic& graphic, const GraphicDescrip auto& infos = INFOS.emplace_back(); uf::stl::vector types; + for ( auto& descriptor : shader->metadata.aliases.buffers ) { + auto matches = uf::string::match(descriptor.name, R"(/^(.+?)\[(\d+)\]$/)"); + auto name = matches.size() == 2 ? matches[0] : descriptor.name; + auto view = matches.size() == 2 ? stoi(matches[1]) : -1; + const ext::vulkan::Buffer* buffer = &descriptor.fallback; + if ( descriptor.renderMode ) { + if ( descriptor.renderMode->hasBuffer(name) ) + buffer = &descriptor.renderMode->getBuffer(name); + } else if ( renderMode.hasBuffer(name) ) { + buffer = &renderMode.getBuffer(name); + } + + if ( !buffer ) continue; + + if ( buffer->usage & uf::renderer::enums::Buffer::UNIFORM ) infos.uniform.emplace_back(buffer->descriptor); + if ( buffer->usage & uf::renderer::enums::Buffer::STORAGE ) infos.storage.emplace_back(buffer->descriptor); + } + #if 0 // add per-rendermode buffers for ( auto& buffer : renderMode.buffers ) { if ( buffer.usage & uf::renderer::enums::Buffer::UNIFORM ) infos.uniform.emplace_back(buffer.descriptor); if ( buffer.usage & uf::renderer::enums::Buffer::STORAGE ) infos.storage.emplace_back(buffer.descriptor); // if ( buffer.usage & uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE ) infos.accelerationStructure.emplace_back(buffer.descriptor); } + #endif // add per-shader buffers for ( auto& buffer : shader->buffers ) { if ( buffer.usage & uf::renderer::enums::Buffer::UNIFORM ) infos.uniform.emplace_back(buffer.descriptor); @@ -556,7 +574,7 @@ void ext::vulkan::Pipeline::update( const Graphic& graphic, const GraphicDescrip }\ } - for ( auto& descriptor : shader->metadata.attachments ) { + for ( auto& descriptor : shader->metadata.aliases.attachments ) { auto texture = Texture2D::empty.alias(); texture.sampler.descriptor.filter.min = descriptor.filter; texture.sampler.descriptor.filter.mag = descriptor.filter; @@ -659,7 +677,7 @@ void ext::vulkan::Pipeline::update( const Graphic& graphic, const GraphicDescrip if ( infos.accelerationStructure.empty() ) { uf::stl::string renderModeName = uf::renderer::hasRenderMode("Compute:RT", true) ? "Compute:RT" : ""; - auto& blitter = *(uf::renderer::getRenderMode(renderModeName, true).getBlitter()); + auto& blitter = uf::renderer::getRenderMode(renderModeName, true).getBlitter(); if ( !blitter.accelerationStructures.tops.empty() ) { tlases.emplace_back(blitter.accelerationStructures.tops.front()); } @@ -1486,6 +1504,7 @@ void ext::vulkan::Graphic::generateBottomAccelerationStructures() { } ext::vulkan::Buffer oldBuffer; + oldBuffer.alignment = acclerationStructureProperties.minAccelerationStructureScratchOffsetAlignment; oldBuffer.initialize( NULL, totalBlasBufferSize, uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE | uf::renderer::enums::Buffer::ADDRESS ); this->buffers[blasBufferIndex].swap(oldBuffer); diff --git a/engine/src/ext/vulkan/rendermode.cpp b/engine/src/ext/vulkan/rendermode.cpp index bc08ec2f..5914a20e 100644 --- a/engine/src/ext/vulkan/rendermode.cpp +++ b/engine/src/ext/vulkan/rendermode.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -24,26 +25,27 @@ const uf::stl::string ext::vulkan::RenderMode::getName() const { // return metadata["name"].as(); return metadata.name; } -ext::vulkan::RenderTarget& ext::vulkan::RenderMode::getRenderTarget( size_t i ) { +ext::vulkan::Graphic& ext::vulkan::RenderMode::getBlitter() { + return blitter; +} +ext::vulkan::RenderTarget& ext::vulkan::RenderMode::getRenderTarget() { return renderTarget; } -const ext::vulkan::RenderTarget& ext::vulkan::RenderMode::getRenderTarget( size_t i ) const { - return renderTarget; +const uf::stl::string ext::vulkan::RenderMode::getTarget() const { +// auto& metadata = *const_cast(&this->metadata); +// return metadata["target"].as(); + return metadata.target; +} +void ext::vulkan::RenderMode::setTarget( const uf::stl::string& target ) { +// this->metadata["target"] = target; + metadata.target = target; } void ext::vulkan::RenderMode::bindCallback( int32_t subpass, const ext::vulkan::RenderMode::callback_t& callback ) { commandBufferCallbacks[subpass] = callback; } -const size_t ext::vulkan::RenderMode::blitters() const { - return 0; -} -ext::vulkan::Graphic* ext::vulkan::RenderMode::getBlitter( size_t i ) { - return NULL; -} -uf::stl::vector ext::vulkan::RenderMode::getBlitters() { - return {}; -} + bool ext::vulkan::RenderMode::hasAttachment( const uf::stl::string& name ) const { return metadata.attachments.count(name) > 0; } @@ -54,6 +56,16 @@ const ext::vulkan::RenderTarget::Attachment& ext::vulkan::RenderMode::getAttachm size_t ext::vulkan::RenderMode::getAttachmentIndex( const uf::stl::string& name ) const { return hasAttachment( name ) ? metadata.attachments.at(name) : SIZE_MAX; } +bool ext::vulkan::RenderMode::hasBuffer( const uf::stl::string& name ) const { + return metadata.buffers.count(name) > 0; +} +const ext::vulkan::Buffer& ext::vulkan::RenderMode::getBuffer( const uf::stl::string& name ) const { + UF_ASSERT_MSG( hasBuffer( name ), "attachment in `{}`: {} not found: {}", this->getName(), this->getType(), name ); + return this->buffers[metadata.buffers.at(name)]; +} +size_t ext::vulkan::RenderMode::getBufferIndex( const uf::stl::string& name ) const { + return hasAttachment( name ) ? metadata.buffers.at(name) : SIZE_MAX; +} uf::Image ext::vulkan::RenderMode::screenshot( size_t attachmentID, size_t layerID ) { uf::Image image; @@ -377,6 +389,9 @@ void ext::vulkan::RenderMode::initialize( Device& device ) { metadata.pipelines.emplace_back(metadata.pipeline); } + if ( !this->hasBuffer("camera") ) { + this->metadata.buffers["camera"] = this->initializeBuffer( (const void*) nullptr, sizeof(pod::Camera::Viewports), uf::renderer::enums::Buffer::UNIFORM ); + } } void ext::vulkan::RenderMode::tick() { diff --git a/engine/src/ext/vulkan/rendermodes/base.cpp b/engine/src/ext/vulkan/rendermodes/base.cpp index 7ada0194..af88990b 100644 --- a/engine/src/ext/vulkan/rendermodes/base.cpp +++ b/engine/src/ext/vulkan/rendermodes/base.cpp @@ -12,11 +12,6 @@ namespace { uf::stl::vector images; } -/* -ext::vulkan::BaseRenderMode::~BaseRenderMode() { - this->destroy(); -} -*/ const uf::stl::string ext::vulkan::BaseRenderMode::getType() const { return "Swapchain"; } diff --git a/engine/src/ext/vulkan/rendermodes/deferred.cpp b/engine/src/ext/vulkan/rendermodes/deferred.cpp index bba82d90..4107c871 100644 --- a/engine/src/ext/vulkan/rendermodes/deferred.cpp +++ b/engine/src/ext/vulkan/rendermodes/deferred.cpp @@ -17,7 +17,7 @@ #define BARYCENTRIC 1 #if BARYCENTRIC #ifndef BARYCENTRIC_CALCULATE - #define BARYCENTRIC_CALCULATE 1 + #define BARYCENTRIC_CALCULATE 0 #endif #endif @@ -32,15 +32,6 @@ namespace { const uf::stl::string ext::vulkan::DeferredRenderMode::getType() const { return "Deferred"; } -const size_t ext::vulkan::DeferredRenderMode::blitters() const { - return 1; -} -ext::vulkan::Graphic* ext::vulkan::DeferredRenderMode::getBlitter( size_t i ) { - return &this->blitter; -} -uf::stl::vector ext::vulkan::DeferredRenderMode::getBlitters() { - return { &this->blitter }; -} void ext::vulkan::DeferredRenderMode::initialize( Device& device ) { ext::vulkan::RenderMode::initialize( device ); diff --git a/engine/src/ext/vulkan/rendermodes/rendertarget.cpp b/engine/src/ext/vulkan/rendermodes/rendertarget.cpp index 3ff829db..34438b5e 100644 --- a/engine/src/ext/vulkan/rendermodes/rendertarget.cpp +++ b/engine/src/ext/vulkan/rendermodes/rendertarget.cpp @@ -10,28 +10,9 @@ #include #include -const uf::stl::string ext::vulkan::RenderTargetRenderMode::getTarget() const { -// auto& metadata = *const_cast(&this->metadata); -// return metadata["target"].as(); - return metadata.target; -} -void ext::vulkan::RenderTargetRenderMode::setTarget( const uf::stl::string& target ) { -// this->metadata["target"] = target; - metadata.target = target; -} - const uf::stl::string ext::vulkan::RenderTargetRenderMode::getType() const { return "RenderTarget"; } -const size_t ext::vulkan::RenderTargetRenderMode::blitters() const { - return 1; -} -ext::vulkan::Graphic* ext::vulkan::RenderTargetRenderMode::getBlitter( size_t i ) { - return &this->blitter; -} -uf::stl::vector ext::vulkan::RenderTargetRenderMode::getBlitters() { - return { &this->blitter }; -} ext::vulkan::GraphicDescriptor ext::vulkan::RenderTargetRenderMode::bindGraphicDescriptor( const ext::vulkan::GraphicDescriptor& reference, size_t pass ) { ext::vulkan::GraphicDescriptor descriptor = ext::vulkan::RenderMode::bindGraphicDescriptor(reference, pass); diff --git a/engine/src/ext/vulkan/rendermodes/transition.inl b/engine/src/ext/vulkan/rendermodes/transition.inl index a2ebbc14..3cc15643 100644 --- a/engine/src/ext/vulkan/rendermodes/transition.inl +++ b/engine/src/ext/vulkan/rendermodes/transition.inl @@ -13,7 +13,7 @@ namespace { subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; subresourceRange.layerCount = self->metadata.eyes; - for ( auto& descriptor : shader.metadata.attachments ) { + for ( auto& descriptor : shader.metadata.aliases.attachments ) { if ( descriptor.layout == VK_IMAGE_LAYOUT_UNDEFINED ) continue; VkImage image = VK_NULL_HANDLE; if ( descriptor.renderMode ) { @@ -43,7 +43,7 @@ namespace { subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; subresourceRange.layerCount = self->metadata.eyes; - for ( auto& descriptor : shader.metadata.attachments ) { + for ( auto& descriptor : shader.metadata.aliases.attachments ) { if ( descriptor.layout == VK_IMAGE_LAYOUT_UNDEFINED ) continue; VkImage image = VK_NULL_HANDLE; if ( descriptor.renderMode ) { diff --git a/engine/src/ext/vulkan/shader.cpp b/engine/src/ext/vulkan/shader.cpp index cae59f45..4664a9ca 100644 --- a/engine/src/ext/vulkan/shader.cpp +++ b/engine/src/ext/vulkan/shader.cpp @@ -856,18 +856,31 @@ bool ext::vulkan::Shader::validate() { return valid; } +bool ext::vulkan::Shader::hasAttachment( const uf::stl::string& name ) { + for ( auto& attachment : metadata.aliases.attachments ) { + if ( attachment.name == name ) return true; + } + return false; +} void ext::vulkan::Shader::aliasAttachment( const ext::vulkan::Shader::Metadata::AttachmentDescriptor& descriptor ) { - metadata.attachments.emplace_back(descriptor); + metadata.aliases.attachments.emplace_back(descriptor); } void ext::vulkan::Shader::aliasAttachment( const uf::stl::string& name, const ext::vulkan::RenderMode* renderMode, VkImageLayout layout, VkFilter filter ) { return aliasAttachment({ name, renderMode, layout, filter }); } -bool ext::vulkan::Shader::hasAttachment( const uf::stl::string& name ) { - for ( auto& attachment : metadata.attachments ) { + +bool ext::vulkan::Shader::hasBuffer( const uf::stl::string& name ) { + for ( auto& attachment : metadata.aliases.buffers ) { if ( attachment.name == name ) return true; } return false; } +void ext::vulkan::Shader::aliasBuffer( const ext::vulkan::Shader::Metadata::BufferDescriptor& descriptor ) { + metadata.aliases.buffers.emplace_back(descriptor); +} +void ext::vulkan::Shader::aliasBuffer( const uf::stl::string& name, const ext::vulkan::Buffer& fallback, const ext::vulkan::RenderMode* renderMode, VkBufferUsageFlags flags ) { + return aliasBuffer({ name, fallback.alias(), renderMode, flags }); +} bool ext::vulkan::Shader::hasUniform( const uf::stl::string& name ) const { return metadata.definitions.uniforms.count(name) > 0; diff --git a/engine/src/ext/vulkan/vulkan.cpp b/engine/src/ext/vulkan/vulkan.cpp index 21988e21..bbcd4ef6 100644 --- a/engine/src/ext/vulkan/vulkan.cpp +++ b/engine/src/ext/vulkan/vulkan.cpp @@ -43,9 +43,10 @@ uf::stl::vector ext::vulkan::settings::requestedInstanceExtensi VkFilter ext::vulkan::settings::swapchainUpscaleFilter = VK_FILTER_LINEAR; // these go hand in hand for the above -bool ext::vulkan::settings::experimental::dedicatedThread = false; +bool ext::vulkan::settings::experimental::dedicatedThread = true; +bool ext::vulkan::settings::experimental::batchQueueSubmissions = true; + bool ext::vulkan::settings::experimental::rebuildOnTickBegin = false; -bool ext::vulkan::settings::experimental::batchQueueSubmissions = false; bool ext::vulkan::settings::experimental::enableMultiGPU = false; // not so experimental @@ -258,24 +259,24 @@ void ext::vulkan::removeRenderMode( ext::vulkan::RenderMode* mode, bool free ) { if ( free ) delete mode; ext::vulkan::states::rebuild = true; } -ext::vulkan::RenderMode* UF_API ext::vulkan::getCurrentRenderMode() { +ext::vulkan::RenderMode* ext::vulkan::getCurrentRenderMode() { return getCurrentRenderMode( std::this_thread::get_id() ); } -ext::vulkan::RenderMode* UF_API ext::vulkan::getCurrentRenderMode( std::thread::id id ) { +ext::vulkan::RenderMode* ext::vulkan::getCurrentRenderMode( std::thread::id id ) { // bool exists = ext::vulkan::currentRenderMode.has(id); // auto& currentRenderMode = ext::vulkan::currentRenderMode.get(id); // return currentRenderMode; return ext::vulkan::currentRenderMode.get(id); } -void UF_API ext::vulkan::setCurrentRenderMode( ext::vulkan::RenderMode* renderMode ) { +void ext::vulkan::setCurrentRenderMode( ext::vulkan::RenderMode* renderMode ) { return setCurrentRenderMode( renderMode, std::this_thread::get_id() ); } -void UF_API ext::vulkan::setCurrentRenderMode( ext::vulkan::RenderMode* renderMode, std::thread::id id ) { +void ext::vulkan::setCurrentRenderMode( ext::vulkan::RenderMode* renderMode, std::thread::id id ) { ext::vulkan::currentRenderMode.get(id) = renderMode; } void ext::vulkan::initialize() { - ext::vulkan::mutex.lock(); +// ext::vulkan::mutex.lock(); device.initialize(); swapchain.initialize( device ); @@ -370,104 +371,73 @@ void ext::vulkan::initialize() { } #endif - ext::vulkan::mutex.unlock(); +// ext::vulkan::mutex.unlock(); } void ext::vulkan::tick() { - ext::vulkan::mutex.lock(); +// ext::vulkan::mutex.lock(); if ( ext::vulkan::states::resized || ext::vulkan::settings::experimental::rebuildOnTickBegin ) { ext::vulkan::states::rebuild = true; } - #if 0 - { - auto& scene = uf::scene::getCurrentScene(); - auto/*&*/ graph = scene.getGraph(); - auto tasks = uf::thread::schedule(settings::experimental::dedicatedThread); - for ( auto entity : graph ) { - if ( !entity->hasComponent() ) continue; - ext::vulkan::Graphic& graphic = entity->getComponent(); - if ( graphic.initialized || !graphic.process || graphic.initialized ) continue; - tasks.queue([&]{ - graphic.initializePipeline(); - ext::vulkan::states::rebuild = true; - }); - } - uf::thread::execute( tasks ); + auto& scene = uf::scene::getCurrentScene(); + auto/*&*/ graph = scene.getGraph(); + for ( auto entity : graph ) { + if ( !entity->hasComponent() ) continue; + ext::vulkan::Graphic& graphic = entity->getComponent(); + if ( graphic.initialized || !graphic.process || graphic.initialized ) continue; + graphic.initializePipeline(); + ext::vulkan::states::rebuild = true; } - #else - { - auto& scene = uf::scene::getCurrentScene(); - auto/*&*/ graph = scene.getGraph(); - for ( auto entity : graph ) { - if ( !entity->hasComponent() ) continue; - ext::vulkan::Graphic& graphic = entity->getComponent(); - if ( graphic.initialized || !graphic.process || graphic.initialized ) continue; - graphic.initializePipeline(); + + for ( auto& renderMode : renderModes ) { + if ( !renderMode ) continue; + if ( !renderMode->device ) { + renderMode->initialize(ext::vulkan::device); ext::vulkan::states::rebuild = true; } + renderMode->tick(); } - #endif - #if 0 - { - auto tasks = uf::thread::schedule(settings::experimental::dedicatedThread); - for ( auto& renderMode : renderModes ) { - if ( !renderMode ) continue; - if ( !renderMode->device ) { - tasks.queue([&]{ - renderMode->initialize(ext::vulkan::device); - ext::vulkan::states::rebuild = true; - renderMode->tick(); - }); - } else { - tasks.queue([&]{ - renderMode->tick(); - }); - } - } - uf::thread::execute( tasks ); - } - #else - { - for ( auto& renderMode : renderModes ) { - if ( !renderMode ) continue; - if ( !renderMode->device ) { - renderMode->initialize(ext::vulkan::device); - ext::vulkan::states::rebuild = true; - } - renderMode->tick(); - } - } - #endif - { - auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording ); - for ( auto& renderMode : renderModes ) { if ( !renderMode ) continue; - if ( ext::vulkan::states::rebuild || renderMode->rebuild ) tasks.queue([&]{ - if ( settings::invariant::individualPipelines ) renderMode->bindPipelines(); - renderMode->createCommandBuffers(); - }); - } - uf::thread::execute( tasks ); + + auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording ); + for ( auto& renderMode : renderModes ) { if ( !renderMode ) continue; + if ( ext::vulkan::states::rebuild || renderMode->rebuild ) tasks.queue([&]{ + if ( settings::invariant::individualPipelines ) renderMode->bindPipelines(); + renderMode->createCommandBuffers(); + }); } + + uf::thread::execute( tasks ); ext::vulkan::states::rebuild = false; ext::vulkan::states::resized = false; - ext::vulkan::mutex.unlock(); +// ext::vulkan::mutex.unlock(); } void ext::vulkan::render() { if ( ext::vulkan::states::frameSkip ) { ext::vulkan::states::frameSkip = false; return; } - ext::vulkan::mutex.lock(); +// ext::vulkan::mutex.lock(); // cleanup in-flight commands + ext::vulkan::mutex.lock(); auto transient = std::move(device.transient); + ext::vulkan::mutex.unlock(); + for ( auto& pair : /*device.*/transient.commandBuffers ) { auto queueType = pair.first; auto& commandBuffers = pair.second; - auto& queue = device.getQueue( queueType ); - auto& commandPool = device.getCommandPool( queueType ); + #if 0 + VkSubmitInfo submitInfo = ext::vulkan::initializers::submitInfo(); + submitInfo.commandBufferCount = commandBuffers.size(); + submitInfo.pCommandBuffers = commandBuffers.data(); + auto queue = device.getQueue( queueType ); + VK_CHECK_RESULT(vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE)); + #else + auto queue = device.getQueue( queueType ); + #endif + auto commandPool = device.getCommandPool( queueType ); VK_CHECK_RESULT(vkQueueWaitIdle( queue )); vkFreeCommandBuffers(device, commandPool, commandBuffers.size(), commandBuffers.data()); @@ -481,8 +451,8 @@ void ext::vulkan::render() { auto& cb = pair.second; auto& commandBuffer = cb.commandBuffer; - auto& queue = device.getQueue( queueType ); - auto& commandPool = device.getCommandPool( queueType ); + auto queue = device.getQueue( queueType ); + auto commandPool = device.getCommandPool( queueType ); VK_CHECK_RESULT(vkQueueWaitIdle( queue )); vkResetCommandBuffer(device, commandPool, 1, &commandBuffer); @@ -508,7 +478,7 @@ void ext::vulkan::render() { uf::stl::vector submitsCompute; submitsCompute.reserve( auxRenderModes.size() ); // stuff we can batch - // auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording ); +// auto tasks = uf::thread::schedule( settings::invariant::multithreadedRecording ); for ( auto renderMode : auxRenderModes ) { auto submitInfo = renderMode->queue(); if ( submitInfo.sType != VK_STRUCTURE_TYPE_SUBMIT_INFO ) continue; @@ -516,14 +486,14 @@ void ext::vulkan::render() { else submitsGraphics.emplace_back(submitInfo); renderMode->executed = true; - // tasks.queue([&]{ +// tasks.queue([&]{ ext::vulkan::setCurrentRenderMode(renderMode); uf::graph::render(); uf::scene::render(); ext::vulkan::setCurrentRenderMode(NULL); - // }); +// }); } - // uf::thread::execute( tasks ); +// uf::thread::execute( tasks ); VK_CHECK_RESULT(vkWaitForFences(device, fences.size(), fences.data(), VK_TRUE, VK_DEFAULT_FENCE_TIMEOUT)); VK_CHECK_RESULT(vkResetFences(device, fences.size(), fences.data())); @@ -531,20 +501,22 @@ void ext::vulkan::render() { VK_CHECK_RESULT(vkQueueSubmit(device.getQueue( QueueEnum::COMPUTE ), submitsCompute.size(), submitsCompute.data(), ::auxFences.compute[states::currentBuffer])); VK_CHECK_RESULT(vkQueueSubmit(device.getQueue( QueueEnum::GRAPHICS ), submitsGraphics.size(), submitsGraphics.data(), ::auxFences.graphics[states::currentBuffer])); + // stuff we can't batch for ( auto renderMode : specialRenderModes ) { ext::vulkan::setCurrentRenderMode(renderMode); uf::graph::render(); uf::scene::render(); + #if UF_USE_FFX_FSR + if ( renderMode->getName() == "Swapchain" && settings::pipelines::fsr && ext::fsr::initialized ) { + ext::fsr::tick(); + ext::fsr::render(); + } + #endif renderMode->render(); ext::vulkan::setCurrentRenderMode(NULL); } - #if UF_USE_FFX_FSR - if ( settings::pipelines::fsr ) { - ext::fsr::render(); - } - #endif for ( auto renderMode : renderModes ) { if ( renderMode->commandBufferCallbacks.count(RenderMode::EXECUTE_END) > 0 ) renderMode->commandBufferCallbacks[RenderMode::EXECUTE_END]( VkCommandBuffer{}, 0 ); @@ -572,10 +544,10 @@ void ext::vulkan::render() { for ( auto& buffer : transient.buffers ) buffer.destroy(false); transient.buffers.clear(); - ext::vulkan::mutex.unlock(); +// ext::vulkan::mutex.unlock(); } void ext::vulkan::destroy() { - ext::vulkan::mutex.lock(); +// ext::vulkan::mutex.lock(); synchronize(); #if UF_USE_FFX_FSR @@ -603,7 +575,7 @@ void ext::vulkan::destroy() { swapchain.destroy(); device.destroy(); - ext::vulkan::mutex.unlock(); +// ext::vulkan::mutex.unlock(); } void ext::vulkan::synchronize( uint8_t flag ) { if ( flag & 0b01 ) { diff --git a/engine/src/ext/xatlas/xatlas.cpp b/engine/src/ext/xatlas/xatlas.cpp index 3347374e..7f7501eb 100644 --- a/engine/src/ext/xatlas/xatlas.cpp +++ b/engine/src/ext/xatlas/xatlas.cpp @@ -5,10 +5,10 @@ #define UF_XATLAS_UNWRAP_MULTITHREAD 1 #define UF_XATLAS_UNWRAP_SERIAL 1 // really big scenes will gorge on memory -size_t UF_API ext::xatlas::unwrap( pod::Graph& graph ) { +size_t ext::xatlas::unwrap( pod::Graph& graph ) { return graph.metadata["exporter"]["unwrap lazy"].as(false) ? unwrapLazy( graph ) : unwrapExperimental( graph ); } -size_t UF_API ext::xatlas::unwrapExperimental( pod::Graph& graph ) { +size_t ext::xatlas::unwrapExperimental( pod::Graph& graph ) { struct Entry { size_t index = 0; size_t commandID = 0; @@ -382,7 +382,7 @@ size_t UF_API ext::xatlas::unwrapExperimental( pod::Graph& graph ) { return atlasCount; } -size_t UF_API ext::xatlas::unwrapLazy( pod::Graph& graph ) { +size_t ext::xatlas::unwrapLazy( pod::Graph& graph ) { struct Entry { size_t index = 0; size_t commandID = 0; diff --git a/engine/src/ext/zlib/zlib.cpp b/engine/src/ext/zlib/zlib.cpp index 2ad6d666..6f6b7aa4 100644 --- a/engine/src/ext/zlib/zlib.cpp +++ b/engine/src/ext/zlib/zlib.cpp @@ -10,7 +10,7 @@ size_t ext::zlib::bufferSize = 2048; /* -uf::stl::vector UF_API ext::zlib::compress( const void* data, size_t size ) { +uf::stl::vector ext::zlib::compress( const void* data, size_t size ) { uf::stl::vector buffer; // zlib struct @@ -31,13 +31,13 @@ uf::stl::vector UF_API ext::zlib::compress( const void* data, size_t si return buffer; } -uf::stl::vector UF_API ext::zlib::decompress( const void* data, size_t size ) { +uf::stl::vector ext::zlib::decompress( const void* data, size_t size ) { uf::stl::vector buffer; return buffer; } */ -uf::stl::vector UF_API ext::zlib::decompressFromFile( const uf::stl::string& filename ) { +uf::stl::vector ext::zlib::decompressFromFile( const uf::stl::string& filename ) { uf::stl::vector buffer; gzFile in = gzopen( filename.c_str(), "rb" ); @@ -58,7 +58,7 @@ uf::stl::vector UF_API ext::zlib::decompressFromFile( const uf::stl::st gzclose( in ); return buffer; } -size_t UF_API ext::zlib::compressToFile( const uf::stl::string& filename, const void* data, size_t size ) { +size_t ext::zlib::compressToFile( const uf::stl::string& filename, const void* data, size_t size ) { gzFile out = gzopen( filename.c_str(), "wb" ); if ( !out ) { UF_MSG_ERROR("Zlib: failed to open file for write: {}", filename); diff --git a/engine/src/spec/context/universal.cpp b/engine/src/spec/context/universal.cpp index a684f729..4cdc2abf 100644 --- a/engine/src/spec/context/universal.cpp +++ b/engine/src/spec/context/universal.cpp @@ -39,7 +39,7 @@ namespace { } } // -bool UF_API_CALL spec::uni::Context::setActive(bool active) { +bool spec::uni::Context::setActive(bool active) { if (active) { if (this != currentContext) { // Activate the context @@ -61,11 +61,11 @@ bool UF_API_CALL spec::uni::Context::setActive(bool active) { return true; // This context is not the active one on this thread, don't do anything } // -void UF_API_CALL spec::uni::Context::initialize() { +void spec::uni::Context::initialize() { // Activate the context this->setActive(true); } -void UF_API_CALL spec::uni::Context::globalInit() { +void spec::uni::Context::globalInit() { // Create the shared context sharedContext = new spec::Context(NULL); sharedContext->initialize(); @@ -75,7 +75,7 @@ void UF_API_CALL spec::uni::Context::globalInit() { // - another valid context is activated in the current thread sharedContext->setActive(false); } -void UF_API_CALL spec::uni::Context::globalCleanup() { +void spec::uni::Context::globalCleanup() { // Destroy the shared context delete sharedContext; sharedContext = NULL; @@ -85,17 +85,17 @@ void UF_API_CALL spec::uni::Context::globalCleanup() { for (std::set::iterator it = internalContexts.begin(); it != internalContexts.end(); ++it) delete *it; internalContexts.clear(); } -void UF_API_CALL spec::uni::Context::ensureContext() { +void spec::uni::Context::ensureContext() { // If there's no active context on the current thread, activate an internal one if (!currentContext) getInternalContext()->setActive(true); } -spec::uni::Context* UF_API_CALL spec::uni::Context::create() { +spec::uni::Context* spec::uni::Context::create() { spec::uni::Context* context = new spec::Context(sharedContext); context->initialize(); return context; } -spec::uni::Context* UF_API_CALL spec::uni::Context::create(const spec::uni::Context::Settings& settings, const Context::window_t& owner) { +spec::uni::Context* spec::uni::Context::create(const spec::uni::Context::Settings& settings, const Context::window_t& owner) { // Make sure that there's an active context (context creation may need extensions, and thus a valid context) Context::ensureContext(); // Create the context @@ -103,7 +103,7 @@ spec::uni::Context* UF_API_CALL spec::uni::Context::create(const spec::uni::Cont context->initialize(); return context; } -spec::uni::Context* UF_API_CALL spec::uni::Context::create(const spec::uni::Context::Settings& settings, unsigned int width, unsigned int height) { +spec::uni::Context* spec::uni::Context::create(const spec::uni::Context::Settings& settings, unsigned int width, unsigned int height) { // Make sure that there's an active context (context creation may need extensions, and thus a valid context) Context::ensureContext(); // Create the context @@ -113,14 +113,12 @@ spec::uni::Context* UF_API_CALL spec::uni::Context::create(const spec::uni::Cont } // -// -UF_API_CALL spec::uni::Context::Context() : +spec::uni::Context::Context() : m_window (NULL), m_ownsWindow (false) { -} -UF_API_CALL spec::uni::Context::Context( Context::window_t::handle_t window, bool ownsWindow, const spec::uni::Context::Settings& settings ) : +} spec::uni::Context::Context( Context::window_t::handle_t window, bool ownsWindow, const spec::uni::Context::Settings& settings ) : m_window (window), m_ownsWindow (ownsWindow), m_settings (settings) @@ -132,7 +130,7 @@ spec::uni::Context::~Context() { // this->terminate(); } -int UF_API_CALL spec::uni::Context::evaluateFormat( const spec::uni::Context::Settings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing ) { +int spec::uni::Context::evaluateFormat( const spec::uni::Context::Settings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing ) { return std::abs(int(settings.bitsPerPixel - colorBits)) + std::abs(int(settings.depthBits - depthBits)) + std::abs(int(settings.stencilBits - stencilBits)) + diff --git a/engine/src/spec/context/windows.cpp b/engine/src/spec/context/windows.cpp index b085b973..fbbc0b1e 100644 --- a/engine/src/spec/context/windows.cpp +++ b/engine/src/spec/context/windows.cpp @@ -3,7 +3,7 @@ #include #if UF_ENV_WINDOWS && UF_USE_OPENGL && !UF_USE_OPENGL_GLDC -UF_API_CALL spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings ) : +spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings ) : uni::Context( NULL, true, settings ), m_deviceContext (NULL), m_context (NULL) @@ -18,7 +18,7 @@ UF_API_CALL spec::win32::Context::Context( uni::Context* shared, const Context:: if ( this->m_deviceContext ) this->create(shared); } -UF_API_CALL spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings, const Context::window_t& window ) : +spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings, const Context::window_t& window ) : uni::Context( NULL, false, settings ), m_deviceContext (NULL), m_context (NULL) @@ -31,14 +31,14 @@ UF_API_CALL spec::win32::Context::Context( uni::Context* shared, const Context:: if ( this->m_deviceContext ) this->create(shared); } -UF_API_CALL spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings, unsigned int width, unsigned int height ) : Context( shared, settings ) { +spec::win32::Context::Context( uni::Context* shared, const Context::Settings& settings, unsigned int width, unsigned int height ) : Context( shared, settings ) { } spec::win32::Context::~Context() { this->terminate(); } -void UF_API_CALL spec::win32::Context::create( uni::Context* shared ) { +void spec::win32::Context::create( uni::Context* shared ) { // this->m_settings = settings; Context::Settings glSettings{24, 4, 8, 0, 3, 3}; @@ -188,7 +188,7 @@ void UF_API_CALL spec::win32::Context::create( uni::Context* shared ) { } } } -void UF_API_CALL spec::win32::Context::terminate() { +void spec::win32::Context::terminate() { // Destroy the OpenGL context if ( this->m_context ) { if ( wglGetCurrentContext() == this->m_context) wglMakeCurrent(NULL, NULL); diff --git a/engine/src/spec/terminal/dreamcast.cpp b/engine/src/spec/terminal/dreamcast.cpp index 321a444a..19784c97 100644 --- a/engine/src/spec/terminal/dreamcast.cpp +++ b/engine/src/spec/terminal/dreamcast.cpp @@ -2,16 +2,16 @@ #ifdef UF_ENV_DREAMCAST -void UF_API_CALL spec::Terminal::clear() { +void spec::Terminal::clear() { spec::uni::Terminal::clear(); } -void UF_API_CALL spec::Terminal::setLocale() { +void spec::Terminal::setLocale() { spec::uni::Terminal::setLocale(); } -void UF_API_CALL spec::Terminal::hide() { +void spec::Terminal::hide() { } -void UF_API_CALL spec::Terminal::show() { +void spec::Terminal::show() { } #endif \ No newline at end of file diff --git a/engine/src/spec/terminal/universal.cpp b/engine/src/spec/terminal/universal.cpp index 02d65d3c..3ebfb310 100644 --- a/engine/src/spec/terminal/universal.cpp +++ b/engine/src/spec/terminal/universal.cpp @@ -7,17 +7,17 @@ spec::Terminal spec::terminal; -spec::uni::Terminal& UF_API_CALL spec::Terminal::getUniversal() { +spec::uni::Terminal& spec::Terminal::getUniversal() { return (spec::uni::Terminal&) *this; } -void UF_API_CALL spec::uni::Terminal::clear() { +void spec::uni::Terminal::clear() { } -void UF_API_CALL spec::uni::Terminal::hide() { +void spec::uni::Terminal::hide() { } -void UF_API_CALL spec::uni::Terminal::show() { +void spec::uni::Terminal::show() { } -void UF_API_CALL spec::uni::Terminal::setLocale() { +void spec::uni::Terminal::setLocale() { #if UF_ENV_DREAMCAST #else const char* locales[4] = { diff --git a/engine/src/spec/terminal/unknown.cpp b/engine/src/spec/terminal/unknown.cpp index 3586ab11..6da183d3 100644 --- a/engine/src/spec/terminal/unknown.cpp +++ b/engine/src/spec/terminal/unknown.cpp @@ -2,10 +2,10 @@ #if UF_ENV_UNKNOWN -void UF_API_CALL spec::Terminal::clear() { +void spec::Terminal::clear() { spec::uni::Terminal::clear(); } -void UF_API_CALL spec::Terminal::setLocale() { +void spec::Terminal::setLocale() { spec::uni::Terminal::setLocale(); } diff --git a/engine/src/spec/terminal/windows.cpp b/engine/src/spec/terminal/windows.cpp index f6103613..12e92a79 100644 --- a/engine/src/spec/terminal/windows.cpp +++ b/engine/src/spec/terminal/windows.cpp @@ -2,7 +2,7 @@ #ifdef UF_ENV_WINDOWS -void UF_API_CALL spec::Terminal::clear() { +void spec::Terminal::clear() { spec::uni::Terminal::clear(); COORD topLeft = { 0, 0 }; @@ -20,16 +20,16 @@ void UF_API_CALL spec::Terminal::clear() { ); SetConsoleCursorPosition(console, topLeft); } -void UF_API_CALL spec::Terminal::setLocale() { +void spec::Terminal::setLocale() { spec::uni::Terminal::setLocale(); SetConsoleOutputCP(CP_UTF8); } -void UF_API_CALL spec::Terminal::hide() { +void spec::Terminal::hide() { ShowWindow( GetConsoleWindow(), SW_HIDE); } -void UF_API_CALL spec::Terminal::show() { +void spec::Terminal::show() { ShowWindow( GetConsoleWindow(), SW_RESTORE); } diff --git a/engine/src/spec/time/dreamcast.cpp b/engine/src/spec/time/dreamcast.cpp index 593bc5d8..287a4d47 100644 --- a/engine/src/spec/time/dreamcast.cpp +++ b/engine/src/spec/time/dreamcast.cpp @@ -2,10 +2,10 @@ #ifdef UF_ENV_DREAMCAST #include -spec::uni::Time::time_t UF_API_CALL spec::dreamcast::Time::getTime() { +spec::uni::Time::time_t spec::dreamcast::Time::getTime() { return timer_us_gettime64(); } -spec::uni::Time& UF_API_CALL spec::dreamcast::Time::getUniversal() { +spec::uni::Time& spec::dreamcast::Time::getUniversal() { return (spec::uni::Time&) *this; } diff --git a/engine/src/spec/time/universal.cpp b/engine/src/spec/time/universal.cpp index 887f0b81..000a76d7 100644 --- a/engine/src/spec/time/universal.cpp +++ b/engine/src/spec/time/universal.cpp @@ -12,7 +12,7 @@ namespace { chrono_time_t start = getTimePoint(); } -spec::uni::Time::time_t UF_API_CALL spec::uni::Time::getTime() { +spec::uni::Time::time_t spec::uni::Time::getTime() { std::chrono::duration elapsed = getTimePoint() - start; return elapsed.count() * 1000000; } \ No newline at end of file diff --git a/engine/src/spec/time/unknown.cpp b/engine/src/spec/time/unknown.cpp index d624a451..ca33fa9f 100644 --- a/engine/src/spec/time/unknown.cpp +++ b/engine/src/spec/time/unknown.cpp @@ -2,7 +2,7 @@ #ifdef UF_ENV_UNKNOWN /* -spec::uni::Time::time_t UF_API_CALL spec::Time::getTime() { +spec::uni::Time::time_t spec::Time::getTime() { return spec::uni::Time::getTime(); } */ diff --git a/engine/src/spec/time/windows.cpp b/engine/src/spec/time/windows.cpp index 54d48ae1..e0a680a4 100644 --- a/engine/src/spec/time/windows.cpp +++ b/engine/src/spec/time/windows.cpp @@ -11,7 +11,7 @@ namespace { } -spec::uni::Time::time_t UF_API_CALL spec::win32::Time::getTime() { +spec::uni::Time::time_t spec::win32::Time::getTime() { HANDLE curThread = GetCurrentThread(); DWORD_PTR prevMask = SetThreadAffinityMask(curThread, 1); static LARGE_INTEGER freq = getFrequency(); @@ -21,7 +21,7 @@ spec::uni::Time::time_t UF_API_CALL spec::win32::Time::getTime() { return 1000000 * time.QuadPart / freq.QuadPart; } -spec::uni::Time& UF_API_CALL spec::win32::Time::getUniversal() { +spec::uni::Time& spec::win32::Time::getUniversal() { return (spec::uni::Time&) *this; } diff --git a/engine/src/spec/window/dreamcast.cpp b/engine/src/spec/window/dreamcast.cpp index 4feef8f2..20b16f53 100644 --- a/engine/src/spec/window/dreamcast.cpp +++ b/engine/src/spec/window/dreamcast.cpp @@ -317,8 +317,8 @@ uf::stl::string spec::dreamcast::pvr_malloc_stats( bool verbose ) { return str.str(); } -UF_API_CALL spec::dreamcast::Window::Window() : m_context(NULL) {} -void UF_API_CALL spec::dreamcast::Window::create( const spec::dreamcast::Window::vector_t& _size, const spec::dreamcast::Window::title_t& title ) { +spec::dreamcast::Window::Window() : m_context(NULL) {} +void spec::dreamcast::Window::create( const spec::dreamcast::Window::vector_t& _size, const spec::dreamcast::Window::title_t& title ) { ::keyboard.device = maple_enum_type(1, MAPLE_FUNC_KEYBOARD); this->setSize(_size); @@ -338,32 +338,32 @@ spec::dreamcast::Window::~Window() { } #endif } -void UF_API_CALL spec::dreamcast::Window::terminate() { +void spec::dreamcast::Window::terminate() { } -spec::dreamcast::Window::handle_t UF_API_CALL spec::dreamcast::Window::getHandle() const { +spec::dreamcast::Window::handle_t spec::dreamcast::Window::getHandle() const { return NULL; // this->m_handle; } -spec::dreamcast::Window::vector_t UF_API_CALL spec::dreamcast::Window::getPosition() const { +spec::dreamcast::Window::vector_t spec::dreamcast::Window::getPosition() const { return { 0, 0 }; } -spec::dreamcast::Window::vector_t UF_API_CALL spec::dreamcast::Window::getSize() const { +spec::dreamcast::Window::vector_t spec::dreamcast::Window::getSize() const { return ::resolution; } -size_t UF_API_CALL spec::dreamcast::Window::getRefreshRate() const { +size_t spec::dreamcast::Window::getRefreshRate() const { return 60; } -void UF_API_CALL spec::dreamcast::Window::centerWindow() { +void spec::dreamcast::Window::centerWindow() { } -void UF_API_CALL spec::dreamcast::Window::setPosition( const spec::dreamcast::Window::vector_t& position ) { +void spec::dreamcast::Window::setPosition( const spec::dreamcast::Window::vector_t& position ) { } -void UF_API_CALL spec::dreamcast::Window::setMousePosition( const spec::dreamcast::Window::vector_t& position ) { +void spec::dreamcast::Window::setMousePosition( const spec::dreamcast::Window::vector_t& position ) { } -spec::dreamcast::Window::vector_t UF_API_CALL spec::dreamcast::Window::getMousePosition( ) { +spec::dreamcast::Window::vector_t spec::dreamcast::Window::getMousePosition( ) { return { ::resolution.x / 2, ::resolution.y / 2 }; } -void UF_API_CALL spec::dreamcast::Window::setSize( const spec::dreamcast::Window::vector_t& size ) { +void spec::dreamcast::Window::setSize( const spec::dreamcast::Window::vector_t& size ) { int e = 0; int p = PM_RGB565; @@ -384,28 +384,28 @@ void UF_API_CALL spec::dreamcast::Window::setSize( const spec::dreamcast::Window UF_MSG_DEBUG("Changing resolution to {}", uf::vector::toString( size )); } -void UF_API_CALL spec::dreamcast::Window::setTitle( const spec::dreamcast::Window::title_t& title ) { +void spec::dreamcast::Window::setTitle( const spec::dreamcast::Window::title_t& title ) { } -void UF_API_CALL spec::dreamcast::Window::setIcon( const spec::dreamcast::Window::vector_t& size, uint8_t* pixels ) { +void spec::dreamcast::Window::setIcon( const spec::dreamcast::Window::vector_t& size, uint8_t* pixels ) { } -void UF_API_CALL spec::dreamcast::Window::setVisible( bool visibility ) { +void spec::dreamcast::Window::setVisible( bool visibility ) { } -void UF_API_CALL spec::dreamcast::Window::setCursorVisible( bool visibility ) { +void spec::dreamcast::Window::setCursorVisible( bool visibility ) { } -void UF_API_CALL spec::dreamcast::Window::setKeyRepeatEnabled( bool state ) { +void spec::dreamcast::Window::setKeyRepeatEnabled( bool state ) { // this->m_keyRepeatEnabled = state; } -void UF_API_CALL spec::dreamcast::Window::requestFocus() { +void spec::dreamcast::Window::requestFocus() { } -bool UF_API_CALL spec::dreamcast::Window::hasFocus() const { +bool spec::dreamcast::Window::hasFocus() const { // return (uf::Window::focused = true); return uf::Window::focused; } #include -void UF_API_CALL spec::dreamcast::Window::bufferInputs() { +void spec::dreamcast::Window::bufferInputs() { uf::Window::focused = true; uf::inputs::kbm::states::LShift = GetModifier(KBD_MOD_LSHIFT); @@ -522,7 +522,7 @@ void UF_API_CALL spec::dreamcast::Window::bufferInputs() { uf::inputs::kbm::states::Num9 = GetKeyState(KBD_KEY_9); uf::inputs::kbm::states::Num0 = GetKeyState(KBD_KEY_0); } -void UF_API_CALL spec::dreamcast::Window::processEvents() { +void spec::dreamcast::Window::processEvents() { if ( !::keyboard.device ) ::keyboard.device = maple_enum_type(0, MAPLE_FUNC_KEYBOARD); if ( ::keyboard.device ) ::keyboard.state = (kbd_state_t*) maple_dev_status(::keyboard.device); @@ -579,7 +579,7 @@ void UF_API_CALL spec::dreamcast::Window::processEvents() { } } } -bool UF_API_CALL spec::dreamcast::Window::pollEvents( bool block ) { +bool spec::dreamcast::Window::pollEvents( bool block ) { if ( this->m_events.empty() ) { do { this->processEvents(); @@ -609,34 +609,34 @@ bool UF_API_CALL spec::dreamcast::Window::pollEvents( bool block ) { return true; } -void UF_API_CALL spec::dreamcast::Window::registerWindowClass() { +void spec::dreamcast::Window::registerWindowClass() { } -void UF_API_CALL spec::dreamcast::Window::processEvent(/*UINT message, WPARAM wParam, LPARAM lParam*/) { +void spec::dreamcast::Window::processEvent(/*UINT message, WPARAM wParam, LPARAM lParam*/) { } -void UF_API_CALL spec::dreamcast::Window::setTracking(bool state) { +void spec::dreamcast::Window::setTracking(bool state) { } -void UF_API_CALL spec::dreamcast::Window::setMouseGrabbed(bool state) { +void spec::dreamcast::Window::setMouseGrabbed(bool state) { // this->m_mouseGrabbed = state; this->grabMouse(state); } -void UF_API_CALL spec::dreamcast::Window::grabMouse(bool state) { +void spec::dreamcast::Window::grabMouse(bool state) { } -pod::Vector2ui UF_API_CALL spec::dreamcast::Window::getResolution() { +pod::Vector2ui spec::dreamcast::Window::getResolution() { return ::resolution; } -void UF_API_CALL spec::dreamcast::Window::toggleFullscreen( bool borderless ) { +void spec::dreamcast::Window::toggleFullscreen( bool borderless ) { } -bool UF_API_CALL spec::dreamcast::Window::isKeyPressed(const uf::stl::string& key) { +bool spec::dreamcast::Window::isKeyPressed(const uf::stl::string& key) { auto code = GetKeyCode(key); auto keys = GetKeys(); for ( auto key : keys ) if ( key == code ) return true; return false;// } -void UF_API_CALL spec::dreamcast::Window::display() { +void spec::dreamcast::Window::display() { #if UF_USE_OPENGL && UF_OPENGL_CONTEXT_IN_WINDOW if ( this->m_context ){ spec::Context* context = (spec::Context*) this->m_context; diff --git a/engine/src/spec/window/universal.cpp b/engine/src/spec/window/universal.cpp index 4523d643..959b74a6 100644 --- a/engine/src/spec/window/universal.cpp +++ b/engine/src/spec/window/universal.cpp @@ -7,12 +7,12 @@ bool spec::uni::Window::focused = false; /* -void UF_API_CALL spec::uni::Window::pushEvent( const uf::ReadableHook::name_t& name, const uf::ReadableHook::argument_t& argument ) { +void spec::uni::Window::pushEvent( const uf::ReadableHook::name_t& name, const uf::ReadableHook::argument_t& argument ) { if ( !uf::hooks.prefersReadable() ) return; if ( !uf::hooks.exists(name) ) return; this->m_events.readable.push({name, argument}); } -void UF_API_CALL spec::uni::Window::pushEvent( const uf::OptimalHook::name_t& name, const uf::OptimalHook::argument_t& argument ) { +void spec::uni::Window::pushEvent( const uf::OptimalHook::name_t& name, const uf::OptimalHook::argument_t& argument ) { if ( uf::hooks.prefersReadable() ) { uf::userdata::destroy(argument); return; @@ -24,13 +24,13 @@ void UF_API_CALL spec::uni::Window::pushEvent( const uf::OptimalHook::name_t& na this->m_events.optimal.push({name}); this->m_events.optimal.back().argument = argument; } -void UF_API_CALL spec::uni::Window::pushEvent( const uf::ReadableHook::argument_t& serialized ) { +void spec::uni::Window::pushEvent( const uf::ReadableHook::argument_t& serialized ) { if ( !uf::hooks.prefersReadable() ) return; uf::Serializer json = serialized; if ( !uf::hooks.exists(json["type"].as()) ) return; this->m_events.readable.push({json["type"].as(), serialized}); } -void UF_API_CALL spec::uni::Window::pushEvent( const uf::OptimalHook::argument_t& userdata ) { +void spec::uni::Window::pushEvent( const uf::OptimalHook::argument_t& userdata ) { if ( uf::hooks.prefersReadable() ) return; // Header userdata struct Header { @@ -47,29 +47,29 @@ void UF_API_CALL spec::uni::Window::pushEvent( const uf::OptimalHook::argument_t } */ /* -void UF_API_CALL spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const uf::stl::string& payload ) { +void spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const uf::stl::string& payload ) { auto& event = this->m_events.emplace(); event.name = name; event.payload.create( uf::Serializer(payload) ); } -void UF_API_CALL spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const ext::json::Value& payload ) { +void spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const ext::json::Value& payload ) { auto& event = this->m_events.emplace(); event.name = name; event.payload.create( uf::Serializer(payload) ); } -void UF_API_CALL spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const uf::Serializer& payload ) { +void spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const uf::Serializer& payload ) { auto& event = this->m_events.emplace(); event.name = name; event.payload.create( uf::Serializer(payload) ); } */ -void UF_API_CALL spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const pod::Hook::userdata_t& payload ) { +void spec::uni::Window::pushEvent( const uf::Hooks::name_t& name, const pod::Hook::userdata_t& payload ) { auto& event = this->m_events.emplace(); event.name = name; event.payload = payload; } /* -void UF_API_CALL spec::uni::Window::pushEvent( const pod::Hook::userdata_t& payload ) { +void spec::uni::Window::pushEvent( const pod::Hook::userdata_t& payload ) { struct Header { uf::stl::string type; }; @@ -79,12 +79,12 @@ void UF_API_CALL spec::uni::Window::pushEvent( const pod::Hook::userdata_t& payl } */ #if 0 -void UF_API_CALL spec::uni::Window::processEvents() { +void spec::uni::Window::processEvents() { } -bool UF_API_CALL spec::uni::Window::isKeyPressed(const uf::stl::string& key) { +bool spec::uni::Window::isKeyPressed(const uf::stl::string& key) { return false; } -bool UF_API_CALL spec::uni::Window::pollEvents( bool block ) { +bool spec::uni::Window::pollEvents( bool block ) { if ( this->m_events.empty() ) { do { this->processEvents(); diff --git a/engine/src/spec/window/windows.cpp b/engine/src/spec/window/windows.cpp index ccda3a68..2217c4f5 100644 --- a/engine/src/spec/window/windows.cpp +++ b/engine/src/spec/window/windows.cpp @@ -440,7 +440,7 @@ namespace { float lastMouseWheel; } -UF_API_CALL spec::win32::Window::Window() : +spec::win32::Window::Window() : m_handle (NULL), m_context (NULL), m_callback (0), @@ -455,7 +455,7 @@ UF_API_CALL spec::win32::Window::Window() : m_asyncParse (false) { } -UF_API_CALL spec::win32::Window::Window( spec::win32::Window::handle_t handle ) : +spec::win32::Window::Window( spec::win32::Window::handle_t handle ) : m_handle (handle), m_callback (0), m_cursor (NULL), @@ -473,7 +473,7 @@ UF_API_CALL spec::win32::Window::Window( spec::win32::Window::handle_t handle ) m_callback = SetWindowLongPtrW(this->m_handle, GWLP_WNDPROC, reinterpret_cast(&::globalOnEvent)); } } -UF_API_CALL spec::win32::Window::Window( const spec::win32::Window::vector_t& size, const spec::win32::Window::title_t& title ) : +spec::win32::Window::Window( const spec::win32::Window::vector_t& size, const spec::win32::Window::title_t& title ) : m_handle (NULL), m_context (NULL), m_callback (0), @@ -488,7 +488,7 @@ UF_API_CALL spec::win32::Window::Window( const spec::win32::Window::vector_t& si { this->create(size, title); } -void UF_API_CALL spec::win32::Window::create( const spec::win32::Window::vector_t& _size, const spec::win32::Window::title_t& title ) { +void spec::win32::Window::create( const spec::win32::Window::vector_t& _size, const spec::win32::Window::title_t& title ) { setProcessDpiAware(); if ( windowCount == 0 ) this->registerWindowClass(); @@ -553,7 +553,7 @@ spec::win32::Window::~Window() { } #endif } -void UF_API_CALL spec::win32::Window::terminate() { +void spec::win32::Window::terminate() { if ( this == (spec::win32::Window*) fullscreenWindow ) { ChangeDisplaySettingsW(NULL, 0); fullscreenWindow = NULL; @@ -563,10 +563,10 @@ void UF_API_CALL spec::win32::Window::terminate() { ReleaseCapture(); } -spec::win32::Window::handle_t UF_API_CALL spec::win32::Window::getHandle() const { +spec::win32::Window::handle_t spec::win32::Window::getHandle() const { return this->m_handle; } -spec::win32::Window::vector_t UF_API_CALL spec::win32::Window::getPosition() const { +spec::win32::Window::vector_t spec::win32::Window::getPosition() const { RECT rectangle; GetWindowRect( this->m_handle, &rectangle ); spec::win32::Window::vector_t vec; @@ -574,7 +574,7 @@ spec::win32::Window::vector_t UF_API_CALL spec::win32::Window::getPosition() con vec.y = rectangle.top; return vec; } -spec::win32::Window::vector_t UF_API_CALL spec::win32::Window::getSize() const { +spec::win32::Window::vector_t spec::win32::Window::getSize() const { RECT rectangle; GetClientRect( this->m_handle, &rectangle ); spec::win32::Window::vector_t vec; @@ -582,14 +582,14 @@ spec::win32::Window::vector_t UF_API_CALL spec::win32::Window::getSize() const { vec.y = rectangle.bottom - rectangle.top; return vec; } -size_t UF_API_CALL spec::win32::Window::getRefreshRate() const { +size_t spec::win32::Window::getRefreshRate() const { HDC screenDC = GetDC(NULL); int refreshRate = GetDeviceCaps( screenDC, VREFRESH ); ReleaseDC(NULL, screenDC); return refreshRate; } -void UF_API_CALL spec::win32::Window::centerWindow() { +void spec::win32::Window::centerWindow() { if ( fullscreenWindow == (void*) this ) return; RECT rect; GetWindowRect ( this->m_handle, &rect ) ; @@ -601,24 +601,24 @@ void UF_API_CALL spec::win32::Window::centerWindow() { offset /= 2; SetWindowPos( this->m_handle, 0, offset.x, offset.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); } -void UF_API_CALL spec::win32::Window::setPosition( const spec::win32::Window::vector_t& position ) { +void spec::win32::Window::setPosition( const spec::win32::Window::vector_t& position ) { if ( fullscreenWindow == (void*) this ) return; SetWindowPos(this->m_handle, NULL, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } -void UF_API_CALL spec::win32::Window::setMousePosition( const spec::win32::Window::vector_t& position ) { +void spec::win32::Window::setMousePosition( const spec::win32::Window::vector_t& position ) { POINT pt = { position.x, position.y }; ClientToScreen(this->m_handle, &pt); ReleaseCapture(); SetCursorPos(pt.x,pt.y); SetCapture(this->m_handle); } -spec::win32::Window::vector_t UF_API_CALL spec::win32::Window::getMousePosition( ) { +spec::win32::Window::vector_t spec::win32::Window::getMousePosition( ) { POINT pt; GetCursorPos( &pt ); ScreenToClient( this->m_handle, &pt ); return { pt.x, pt.y }; } -void UF_API_CALL spec::win32::Window::setSize( const spec::win32::Window::vector_t& size ) { +void spec::win32::Window::setSize( const spec::win32::Window::vector_t& size ) { if ( fullscreenWindow == (void*) this ) return; RECT rectangle = { 0, 0, size.x, size.y }; if ( rectangle.right <= 0 && rectangle.bottom <= 0 ) { @@ -629,11 +629,11 @@ void UF_API_CALL spec::win32::Window::setSize( const spec::win32::Window::vector SetWindowPos(this->m_handle, NULL, 0, 0, rectangle.right - rectangle.left, rectangle.bottom - rectangle.top, SWP_NOMOVE | SWP_NOZORDER); } -void UF_API_CALL spec::win32::Window::setTitle( const spec::win32::Window::title_t& title ) { +void spec::win32::Window::setTitle( const spec::win32::Window::title_t& title ) { SetWindowTextW(this->m_handle, std::wstring(title).c_str()); // SetWindowTextW(this->m_handle, (wchar_t*) std::wstring(title).c_str()); } -void UF_API_CALL spec::win32::Window::setIcon( const spec::win32::Window::vector_t& size, uint8_t* pixels ) { +void spec::win32::Window::setIcon( const spec::win32::Window::vector_t& size, uint8_t* pixels ) { // First destroy the previous one uf::stl::vector iconPixels(size.x * size.y * 4); @@ -666,18 +666,18 @@ void UF_API_CALL spec::win32::Window::setIcon( const spec::win32::Window::vector } */ } -void UF_API_CALL spec::win32::Window::setVisible( bool visibility ) { +void spec::win32::Window::setVisible( bool visibility ) { ShowWindow(this->m_handle, visibility ? SW_SHOW : SW_HIDE); } -void UF_API_CALL spec::win32::Window::setCursorVisible( bool visibility ) { +void spec::win32::Window::setCursorVisible( bool visibility ) { this->m_cursor = ( visibility ? LoadCursor(NULL, IDC_ARROW) : NULL ); SetCursor(this->m_cursor); } -void UF_API_CALL spec::win32::Window::setKeyRepeatEnabled( bool state ) { +void spec::win32::Window::setKeyRepeatEnabled( bool state ) { this->m_keyRepeatEnabled = state; } -void UF_API_CALL spec::win32::Window::requestFocus() { +void spec::win32::Window::requestFocus() { DWORD thisPid = GetWindowThreadProcessId(this->m_handle, NULL); DWORD forePid = GetWindowThreadProcessId(GetForegroundWindow(), NULL); @@ -694,11 +694,11 @@ void UF_API_CALL spec::win32::Window::requestFocus() { FlashWindowEx(&info); } } -bool UF_API_CALL spec::win32::Window::hasFocus() const { +bool spec::win32::Window::hasFocus() const { return this->m_handle == GetForegroundWindow(); } -void UF_API_CALL spec::win32::Window::bufferInputs() { +void spec::win32::Window::bufferInputs() { uf::Window::focused = this->hasFocus(); uf::inputs::kbm::states::LShift = GetAsyncKeyState(VK_LSHIFT) & 0x8000; @@ -822,7 +822,7 @@ void UF_API_CALL spec::win32::Window::bufferInputs() { uf::inputs::kbm::states::MouseWheel = ::lastMouseWheel; ::lastMouseWheel = 0; } -void UF_API_CALL spec::win32::Window::processEvents() { +void spec::win32::Window::processEvents() { if ( !this->m_callback ) { MSG message; while ( PeekMessageW( &message, NULL, 0, 0, PM_REMOVE ) ) { @@ -882,7 +882,7 @@ void UF_API_CALL spec::win32::Window::processEvents() { } } } -bool UF_API_CALL spec::win32::Window::pollEvents( bool block ) { +bool spec::win32::Window::pollEvents( bool block ) { if ( this->m_events.empty() ) { do { this->processEvents(); @@ -960,7 +960,7 @@ bool UF_API_CALL spec::win32::Window::pollEvents( bool block ) { #endif } -void UF_API_CALL spec::win32::Window::registerWindowClass() { +void spec::win32::Window::registerWindowClass() { WNDCLASSW windowClass; windowClass.style = 0; windowClass.lpfnWndProc = &(::globalOnEvent); @@ -974,7 +974,7 @@ void UF_API_CALL spec::win32::Window::registerWindowClass() { windowClass.lpszClassName = className.c_str(); RegisterClassW(&windowClass); } -void UF_API_CALL spec::win32::Window::processEvent(UINT message, WPARAM wParam, LPARAM lParam) { +void spec::win32::Window::processEvent(UINT message, WPARAM wParam, LPARAM lParam) { if (!this->m_handle) return; uf::stl::string hook = "window:Unknown"; @@ -1434,7 +1434,7 @@ void UF_API_CALL spec::win32::Window::processEvent(UINT message, WPARAM wParam, } } -void UF_API_CALL spec::win32::Window::setTracking(bool state) { +void spec::win32::Window::setTracking(bool state) { TRACKMOUSEEVENT mouseEvent; mouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); mouseEvent.hwndTrack = this->m_handle; @@ -1442,11 +1442,11 @@ void UF_API_CALL spec::win32::Window::setTracking(bool state) { mouseEvent.dwHoverTime = HOVER_DEFAULT; TrackMouseEvent(&mouseEvent); } -void UF_API_CALL spec::win32::Window::setMouseGrabbed(bool state) { +void spec::win32::Window::setMouseGrabbed(bool state) { this->m_mouseGrabbed = state; this->grabMouse(state); } -void UF_API_CALL spec::win32::Window::grabMouse(bool state) { +void spec::win32::Window::grabMouse(bool state) { if (state) { RECT rect; GetClientRect(m_handle, &rect); @@ -1456,10 +1456,10 @@ void UF_API_CALL spec::win32::Window::grabMouse(bool state) { ClipCursor(NULL); } } -pod::Vector2ui UF_API_CALL spec::win32::Window::getResolution() { +pod::Vector2ui spec::win32::Window::getResolution() { return { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) }; } -void UF_API_CALL spec::win32::Window::toggleFullscreen( bool borderless ) { +void spec::win32::Window::toggleFullscreen( bool borderless ) { static pod::Vector2ui lastSize = this->getSize(); static LONG lastStyle; static LONG lastExStyle; @@ -1494,19 +1494,19 @@ void UF_API_CALL spec::win32::Window::toggleFullscreen( bool borderless ) { fullscreenWindow = (void*) this; } -bool UF_API_CALL spec::win32::Window::isKeyPressed(const uf::stl::string& key) { +bool spec::win32::Window::isKeyPressed(const uf::stl::string& key) { return uf::Window::focused && (GetAsyncKeyState( GetKeyCode( key ) ) & 0x8000); } -uf::stl::string UF_API_CALL spec::win32::Window::getKey(WPARAM key, LPARAM flags) { +uf::stl::string spec::win32::Window::getKey(WPARAM key, LPARAM flags) { return GetKeyName( key, flags ); } #if defined(UF_USE_VULKAN) && UF_USE_VULKAN == 1 -uf::stl::vector UF_API_CALL spec::win32::Window::getExtensions( bool validationEnabled ) { +uf::stl::vector spec::win32::Window::getExtensions( bool validationEnabled ) { uf::stl::vector instanceExtensions = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME }; if ( validationEnabled ) instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); return instanceExtensions; } -void UF_API_CALL spec::win32::Window::createSurface( VkInstance instance, VkSurfaceKHR& surface ) { +void spec::win32::Window::createSurface( VkInstance instance, VkSurfaceKHR& surface ) { VkWin32SurfaceCreateInfoKHR surfaceCreateInfo = {}; surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; surfaceCreateInfo.hinstance = (HINSTANCE) GetModuleHandleW(NULL); @@ -1515,7 +1515,7 @@ void UF_API_CALL spec::win32::Window::createSurface( VkInstance instance, VkSurf } #endif -void UF_API_CALL spec::win32::Window::display() { +void spec::win32::Window::display() { #if UF_USE_OPENGL && UF_OPENGL_CONTEXT_IN_WINDOW if ( this->m_context ){ spec::Context* context = (spec::Context*) this->m_context; diff --git a/engine/src/utils/audio/emitter.cpp b/engine/src/utils/audio/emitter.cpp index 02570f95..c6d1365e 100644 --- a/engine/src/utils/audio/emitter.cpp +++ b/engine/src/utils/audio/emitter.cpp @@ -13,47 +13,47 @@ bool uf::SoundEmitter::has( const uf::stl::string& filename ) const { for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return true; return false; } -uf::Audio& UF_API uf::SoundEmitter::add() { +uf::Audio& uf::SoundEmitter::add() { return this->m_container.emplace_back(); } -uf::Audio& UF_API uf::SoundEmitter::add( const uf::stl::string& filename ) { +uf::Audio& uf::SoundEmitter::add( const uf::stl::string& filename ) { // if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->add(); sound.open(filename); return sound; } -uf::Audio& UF_API uf::SoundEmitter::load( const uf::stl::string& filename ) { +uf::Audio& uf::SoundEmitter::load( const uf::stl::string& filename ) { // if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->add(); sound.load(filename); return sound; } -uf::Audio& UF_API uf::SoundEmitter::stream( const uf::stl::string& filename ) { +uf::Audio& uf::SoundEmitter::stream( const uf::stl::string& filename ) { // if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->add(); sound.stream(filename); return sound; } -uf::Audio& UF_API uf::SoundEmitter::get( const uf::stl::string& filename ) { +uf::Audio& uf::SoundEmitter::get( const uf::stl::string& filename ) { if ( !this->has(filename) ) return this->add(filename); for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return audio; return this->add(); } -const uf::Audio& UF_API uf::SoundEmitter::get( const uf::stl::string& filename ) const { +const uf::Audio& uf::SoundEmitter::get( const uf::stl::string& filename ) const { for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return audio; return uf::audio::null; } -uf::SoundEmitter::container_t& UF_API uf::SoundEmitter::get() { +uf::SoundEmitter::container_t& uf::SoundEmitter::get() { return this->m_container; } -const uf::SoundEmitter::container_t& UF_API uf::SoundEmitter::get() const { +const uf::SoundEmitter::container_t& uf::SoundEmitter::get() const { return this->m_container; } -void UF_API uf::SoundEmitter::update() { +void uf::SoundEmitter::update() { for ( auto& audio : this->m_container ) if ( audio.playing() ) audio.update(); } -void UF_API uf::SoundEmitter::cleanup( bool purge ) { +void uf::SoundEmitter::cleanup( bool purge ) { for ( size_t i = 0; i < this->m_container.size(); ++i ) { if ( !purge && this->m_container[i].playing() ) continue; this->m_container[i].destroy(); @@ -68,7 +68,7 @@ uf::MappedSoundEmitter::~MappedSoundEmitter() { bool uf::MappedSoundEmitter::has( const uf::stl::string& filename ) const { return this->m_container.count(filename) > 0; } -uf::Audio& UF_API uf::MappedSoundEmitter::add( const uf::stl::string& filename ) { +uf::Audio& uf::MappedSoundEmitter::add( const uf::stl::string& filename ) { if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->m_container[filename]; @@ -76,14 +76,14 @@ uf::Audio& UF_API uf::MappedSoundEmitter::add( const uf::stl::string& filename ) return sound; } -uf::Audio& UF_API uf::MappedSoundEmitter::load( const uf::stl::string& filename ) { +uf::Audio& uf::MappedSoundEmitter::load( const uf::stl::string& filename ) { if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->m_container[filename]; sound.load(filename); return sound; } -uf::Audio& UF_API uf::MappedSoundEmitter::stream( const uf::stl::string& filename ) { +uf::Audio& uf::MappedSoundEmitter::stream( const uf::stl::string& filename ) { if ( this->has(filename) ) return this->get(filename); uf::Audio& sound = this->m_container[filename]; @@ -91,25 +91,25 @@ uf::Audio& UF_API uf::MappedSoundEmitter::stream( const uf::stl::string& filenam return sound; } -uf::Audio& UF_API uf::MappedSoundEmitter::get( const uf::stl::string& filename ) { +uf::Audio& uf::MappedSoundEmitter::get( const uf::stl::string& filename ) { if ( !this->has(filename) ) return this->add(filename); return this->m_container[filename]; } -const uf::Audio& UF_API uf::MappedSoundEmitter::get( const uf::stl::string& filename ) const { +const uf::Audio& uf::MappedSoundEmitter::get( const uf::stl::string& filename ) const { return this->m_container.at(filename); } -uf::MappedSoundEmitter::container_t& UF_API uf::MappedSoundEmitter::get() { +uf::MappedSoundEmitter::container_t& uf::MappedSoundEmitter::get() { return this->m_container; } -const uf::MappedSoundEmitter::container_t& UF_API uf::MappedSoundEmitter::get() const { +const uf::MappedSoundEmitter::container_t& uf::MappedSoundEmitter::get() const { return this->m_container; } -void UF_API uf::MappedSoundEmitter::update() { +void uf::MappedSoundEmitter::update() { for ( auto& pair : this->m_container ) { pair.second.update(); } } -void UF_API uf::MappedSoundEmitter::cleanup( bool purge ) { +void uf::MappedSoundEmitter::cleanup( bool purge ) { for ( auto& pair : this->m_container ) { if ( purge || !pair.second.playing() ) { pair.second.stop(); diff --git a/engine/src/utils/camera/camera.cpp b/engine/src/utils/camera/camera.cpp index b3f54d9f..47a6b784 100644 --- a/engine/src/utils/camera/camera.cpp +++ b/engine/src/utils/camera/camera.cpp @@ -20,6 +20,7 @@ pod::Vector3f uf::camera::eye( const pod::Camera& camera, uint_fast8_t i ) { return position; } void uf::camera::view( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) { + camera.ttl = uf::time::frame + 1; if ( i >= uf::camera::maxViews ) { for ( i = 0; i < uf::camera::maxViews; ++i ) { camera.previous[i] = camera.viewport.matrices[i].projection * camera.viewport.matrices[i].view; @@ -31,6 +32,7 @@ void uf::camera::view( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8 camera.viewport.matrices[i].view = mat; } void uf::camera::projection( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) { + camera.ttl = uf::time::frame + 1; if ( i >= uf::camera::maxViews ) { for ( i = 0; i < uf::camera::maxViews; ++i ) camera.viewport.matrices[i].projection = mat; return; @@ -38,7 +40,7 @@ void uf::camera::projection( pod::Camera& camera, const pod::Matrix4f& mat, uint camera.viewport.matrices[i].projection = mat; } void uf::camera::update( pod::Camera& camera, bool override ) { - if ( !override && !camera.modified ) return; + if ( !override && uf::time::frame <= camera.ttl ) return; // skip updating the view matrices if it was already updated #if UF_USE_OPENVR if ( this->m_pod.stereoscopic && ext::openvr::context ) { camera.transform.orientation = uf::quaternion::identity(); @@ -47,19 +49,17 @@ void uf::camera::update( pod::Camera& camera, bool override ) { uf::camera::view( camera, ext::openvr::hmdViewMatrix(vr::Eye_Left, view ), 0 ); uf::camera::view( camera, ext::openvr::hmdViewMatrix(vr::Eye_Right, view ), 1 ); - } else { -#else - { + } else #endif + { pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( camera.transform, false, 1 ) ); uf::camera::view( camera, view ); } - camera.modified = false; } // uf::Camera::Camera() { - this->m_pod.modified = true; + this->m_pod.ttl = {}; this->m_pod.stereoscopic = true; this->m_pod.transform = uf::transform::initialize(this->m_pod.transform); @@ -86,7 +86,7 @@ const pod::Matrix4& uf::Camera::getProjection( uint_fast8_t i ) const { return t pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) { return this->m_pod.previous[MIN(i, uf::camera::maxViews)]; } const pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) const { return this->m_pod.previous[MIN(i, uf::camera::maxViews)]; } -bool uf::Camera::modified() const { return this->m_pod.modified; } +bool uf::Camera::modified() const { return uf::time::frame <= this->m_pod.ttl; } void uf::Camera::setStereoscopic( bool b ) { this->m_pod.stereoscopic = b; } pod::Vector3f uf::Camera::getEye( uint_fast8_t i ) const { return uf::camera::eye( this->m_pod, i ); @@ -99,169 +99,4 @@ void uf::Camera::setProjection( const pod::Matrix4& mat, uint_fast8_t i ) { } void uf::Camera::update( bool override ) { uf::camera::update( this->m_pod, override ); -} - -#if 0 -bool uf::Camera::modified() const { - return this->m_pod.modified; -} -pod::Transform<>& uf::Camera::getTransform() { - return this->m_pod.transform; -} -const pod::Transform<>& uf::Camera::getTransform() const { - return this->m_pod.transform; -} - -pod::Matrix4& uf::Camera::getView( size_t eye ) { - if ( eye >= this->m_pod.matrices.views.size() ) eye = 0; - return this->m_pod.matrices.views[eye]; -} -pod::Matrix4& uf::Camera::getProjection( size_t eye ) { - if ( eye >= this->m_pod.matrices.projections.size() ) eye = 0; - return this->m_pod.matrices.projections[eye]; -} -const pod::Matrix4& uf::Camera::getView( size_t eye ) const { - if ( eye >= this->m_pod.matrices.views.size() ) eye = 0; - return this->m_pod.matrices.views[eye]; -} -const pod::Matrix4& uf::Camera::getProjection( size_t eye ) const { - if ( eye >= this->m_pod.matrices.projections.size() ) eye = 0; - return this->m_pod.matrices.projections[eye]; -} - -pod::Vector3f uf::Camera::getEye( size_t eye ) const { - pod::Vector3f position = uf::transform::flatten( this->m_pod.transform ).position; -#if UF_USE_OPENVR - if ( this->m_pod.stereoscopic && ext::openvr::context ) { - position += ext::openvr::hmdPosition( eye == 0 ? vr::Eye_Left : vr::Eye_Right ); - } -#endif - return position; -} - -void uf::Camera::setTransform( const pod::Transform<>& transform ) { - this->m_pod.transform = transform; - this->update(true); -} -void uf::Camera::setView( const pod::Matrix4& mat, size_t i ) { - if ( i >= uf::camera::maxViews ) { - for ( i = 0; i < this->m_pod.matrices.views.size(); ++i ) - this->m_pod.matrices.views[i] = mat; - return; - } - if ( i >= this->m_pod.matrices.views.size() ) this->m_pod.matrices.views.resize( i, uf::matrix::identity() ); - this->m_pod.matrices.views[i] = mat; -} -void uf::Camera::setProjection( const pod::Matrix4& mat, size_t i ) { - if ( i >= uf::camera::maxViews ) { - for ( i = 0; i < this->m_pod.matrices.projections.size(); ++i ) - this->m_pod.matrices.projections[i] = mat; - return; - } - if ( i >= this->m_pod.matrices.projections.size() ) this->m_pod.matrices.projections.resize( i, uf::matrix::identity() ); - this->m_pod.matrices.projections[i] = mat; -} - -void uf::Camera::setStereoscopic(bool settings) { - this->m_pod.stereoscopic = settings; -} -void uf::Camera::update(bool override) { -/* - if ( !override && !this->modified() ) return; - this->updateView(); - this->updateProjection(); - this->m_pod.modified = true; -*/ -} -void uf::Camera::updateView() { - uf::camera::updateView( this->m_pod ); -/* - auto& transform = this->getTransform(); -#if UF_USE_OPENVR - if ( this->m_pod.stereoscopic && ext::openvr::context ) { - transform.orientation = uf::quaternion::identity(); - pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( transform, false, 1 ) ); - transform.orientation = ext::openvr::hmdQuaternion(); - - this->setView( ext::openvr::hmdViewMatrix(vr::Eye_Left, view ), 0 ); - this->setView( ext::openvr::hmdViewMatrix(vr::Eye_Right, view ), 1 ); - } else { -#else - { -#endif - pod::Matrix4t<> view = uf::matrix::inverse( uf::transform::model( transform, false, 1 ) ); - this->setView( view ); - } -*/ -} -void uf::Camera::updateProjection() { -/* -#if UF_USE_OPENVR - if ( this->m_pod.stereoscopic && ext::openvr::context ) { - this->setProjection( ext::openvr::hmdProjectionMatrix( vr::Eye_Left, this->m_pod.settings.perspective.bounds.x, this->m_pod.settings.perspective.bounds.y ), 0 ); - this->setProjection( ext::openvr::hmdProjectionMatrix( vr::Eye_Right, this->m_pod.settings.perspective.bounds.x, this->m_pod.settings.perspective.bounds.y ), 1 ); - return; - } -#endif - if ( this->m_pod.settings.mode < 0 ) { - // Maintain aspect ratio - if ( this->m_pod.settings.ortho.lr.x == this->m_pod.settings.ortho.bt.x && this->m_pod.settings.ortho.lr.y == this->m_pod.settings.ortho.bt.y && this->m_pod.settings.ortho.bt.x == -this->m_pod.settings.ortho.bt.y ) { - float raidou = this->m_pod.settings.perspective.size.x / this->m_pod.settings.perspective.size.y; - float range = this->m_pod.settings.ortho.bt.y - this->m_pod.settings.ortho.bt.x; - float correction = raidou * range / 2.0; - this->setProjection(uf::matrix::ortho( - -correction, correction, - this->m_pod.settings.ortho.bt.x, this->m_pod.settings.ortho.bt.y, - this->m_pod.settings.ortho.nf.x, this->m_pod.settings.ortho.nf.y - )); - return; - } - this->setProjection(uf::matrix::ortho( - this->m_pod.settings.ortho.lr.x, this->m_pod.settings.ortho.lr.y, - this->m_pod.settings.ortho.bt.x, this->m_pod.settings.ortho.bt.y, - this->m_pod.settings.ortho.nf.x, this->m_pod.settings.ortho.nf.y - )); - return; - } - float zNear = this->m_pod.settings.perspective.bounds.x; - float zFar = this->m_pod.settings.perspective.bounds.y; - float fov = this->m_pod.settings.perspective.fov * (3.14159265358f / 180.0f); - float raidou = (float) this->m_pod.settings.perspective.size.x / (float) this->m_pod.settings.perspective.size.y; - if ( uf::camera::reverseInfiniteProjection ) { - float f = 1.0f / tan( 0.5f * fov ); - #if UF_USE_OPENGL - this->setProjection({ - f / raidou, 0.0f, 0.0f, 0.0f, - 0.0f, f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, zNear, 0.0f - }); - #elif UF_USE_VULKAN - this->setProjection({ - f / raidou, 0.0f, 0.0f, 0.0f, - 0.0f, -f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, zNear, 0.0f - }); - #endif - } else { - float range = zNear - zFar; - float f = tanf( fov / 2.0 ); - - float Sx = 1.0 / (f * raidou); - float Sy = 1.0 / f; - float Sz = (-zNear - zFar) / range; - float Pz = 2.0 * zFar * zNear / range; - #if UF_USE_VULKAN - Sy = -Sy; - #endif - this->setProjection({ - Sx, 0, 0, 0, - 0, Sy, 0, 0, - 0, 0, Sz, 1, - 0, 0, Pz, 0 - }); - } -*/ -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/engine/src/utils/component/component.cpp b/engine/src/utils/component/component.cpp index 53bb30cd..96385c4d 100644 --- a/engine/src/utils/component/component.cpp +++ b/engine/src/utils/component/component.cpp @@ -1,6 +1,6 @@ #include -UF_API uf::MemoryPool uf::component::memoryPool; +uf::MemoryPool uf::component::memoryPool; uf::Component::~Component() { this->destroyComponents(); } diff --git a/engine/src/utils/image/image.cpp b/engine/src/utils/image/image.cpp index 0319ba76..d0af474c 100644 --- a/engine/src/utils/image/image.cpp +++ b/engine/src/utils/image/image.cpp @@ -269,9 +269,6 @@ void uf::Image::copy( const uf::Image& copy ) { this->m_format = copy.m_format; } // D-tor -uf::Image::~Image() { - this->clear(); -} // empties pixel container void uf::Image::clear() { this->m_pixels.clear(); @@ -319,12 +316,12 @@ uf::stl::string uf::Image::getHash() const { } uf::Image::pixel_t uf::Image::at( const uf::Image::vec2_t& at ) { std::size_t i = at.x * this->m_channels + this->m_dimensions.x*this->m_channels*at.y; - uf::Image::pixel_t pixel; - pixel.r = this->m_pixels[i++]; - pixel.g = this->m_pixels[i++]; - pixel.b = this->m_pixels[i++]; - pixel.a = this->m_pixels[i++]; - return pixel; + return { + this->m_pixels[i++], + this->m_pixels[i++], + this->m_pixels[i++], + this->m_pixels[i++], + }; } // Modifiers // to file diff --git a/engine/src/utils/io/file.cpp b/engine/src/utils/io/file.cpp index a8f65490..92c99033 100644 --- a/engine/src/utils/io/file.cpp +++ b/engine/src/utils/io/file.cpp @@ -22,24 +22,24 @@ const uf::stl::string uf::io::root = UF_IO_ROOT; -uf::stl::string UF_API uf::io::absolute( const uf::stl::string& path ) { +uf::stl::string uf::io::absolute( const uf::stl::string& path ) { char buff[FILENAME_MAX]; GetCurrentDir( buff, FILENAME_MAX ); return uf::stl::string(buff) + path; } -uf::stl::string UF_API uf::io::filename( const uf::stl::string& str ) { +uf::stl::string uf::io::filename( const uf::stl::string& str ) { return str.substr( str.find_last_of('/') + 1 ); } -uf::stl::string UF_API uf::io::basename( const uf::stl::string& filename ) { +uf::stl::string uf::io::basename( const uf::stl::string& filename ) { uf::stl::string str = uf::io::filename( filename ); uf::stl::string extension = uf::io::extension( filename ); return uf::string::replace( str, "." + extension, "" ); } -uf::stl::string UF_API uf::io::extension( const uf::stl::string& str ) { +uf::stl::string uf::io::extension( const uf::stl::string& str ) { uf::stl::string filename = uf::io::filename(str); return filename.substr( filename.find_last_of('.') + 1 ); } -uf::stl::string UF_API uf::io::extension( const uf::stl::string& str, int32_t count ) { +uf::stl::string uf::io::extension( const uf::stl::string& str, int32_t count ) { uf::stl::string filename = uf::io::filename(str); uf::stl::string extension = ""; auto split = uf::string::split( filename, "." ); @@ -55,16 +55,16 @@ uf::stl::string UF_API uf::io::extension( const uf::stl::string& str, int32_t co } return extension; } -uf::stl::string UF_API uf::io::directory( const uf::stl::string& str ) { +uf::stl::string uf::io::directory( const uf::stl::string& str ) { return str.substr( 0, str.find_last_of('/') ) + "/"; } -size_t UF_API uf::io::size( const uf::stl::string& filename ) { +size_t uf::io::size( const uf::stl::string& filename ) { std::ifstream is(filename, std::ios::binary | std::ios::in | std::ios::ate); if ( !is.is_open() ) return 0; is.seekg(0, std::ios::end); return is.tellg(); } -uf::stl::string UF_API uf::io::sanitize( const uf::stl::string& str, const uf::stl::string& _root ) { +uf::stl::string uf::io::sanitize( const uf::stl::string& str, const uf::stl::string& _root ) { // resolve %root% to hard root uf::stl::string path = str; uf::stl::string root = _root; @@ -93,7 +93,7 @@ uf::stl::string UF_API uf::io::sanitize( const uf::stl::string& str, const uf::s return path; } // would just use readAsBuffer and convert to string, but that's double the memory cost -uf::stl::string UF_API uf::io::readAsString( const uf::stl::string& _filename, const uf::stl::string& hash ) { +uf::stl::string uf::io::readAsString( const uf::stl::string& _filename, const uf::stl::string& hash ) { uf::stl::string buffer; uf::stl::string filename = sanitize(_filename); uf::stl::string extension = uf::io::extension( filename ); @@ -117,7 +117,7 @@ uf::stl::string UF_API uf::io::readAsString( const uf::stl::string& _filename, c } return buffer; } -uf::stl::vector UF_API uf::io::readAsBuffer( const uf::stl::string& _filename, const uf::stl::string& hash ) { +uf::stl::vector uf::io::readAsBuffer( const uf::stl::string& _filename, const uf::stl::string& hash ) { uf::stl::vector buffer; uf::stl::string filename = sanitize(_filename); uf::stl::string extension = uf::io::extension( filename ); @@ -140,7 +140,7 @@ uf::stl::vector UF_API uf::io::readAsBuffer( const uf::stl::string& _fi return buffer; } -size_t UF_API uf::io::write( const uf::stl::string& filename, const void* buffer, size_t size ) { +size_t uf::io::write( const uf::stl::string& filename, const void* buffer, size_t size ) { uf::stl::string extension = uf::io::extension( filename ); if ( extension == "gz" || extension == "lz4" ) return uf::io::compress( filename, buffer, size ); @@ -152,14 +152,14 @@ size_t UF_API uf::io::write( const uf::stl::string& filename, const void* buffer } // indirection for different compression formats, currently only using zlib's gzFile shit -uf::stl::vector UF_API uf::io::decompress( const uf::stl::string& filename ) { +uf::stl::vector uf::io::decompress( const uf::stl::string& filename ) { uf::stl::string extension = uf::io::extension( filename ); if ( extension == "gz" ) return ext::zlib::decompressFromFile( filename ); // if ( extension == "lz4" ) return ext::lz4::decompressFromFile( filename ); UF_MSG_ERROR("unsupported compression format requested: {}", extension); return {}; } -size_t UF_API uf::io::compress( const uf::stl::string& filename, const void* buffer, size_t size ) { +size_t uf::io::compress( const uf::stl::string& filename, const void* buffer, size_t size ) { uf::stl::string extension = uf::io::extension( filename ); if ( extension == "gz" ) return ext::zlib::compressToFile( filename, buffer, size ); // if ( extension == "lz4" ) return ext::lz4::compressToFile( filename, buffer, size ); @@ -167,21 +167,21 @@ size_t UF_API uf::io::compress( const uf::stl::string& filename, const void* buf return 0; } -uf::stl::string UF_API uf::io::hash( const uf::stl::string& filename ) { +uf::stl::string uf::io::hash( const uf::stl::string& filename ) { return uf::string::sha256( uf::io::readAsBuffer( filename ) ); } -bool UF_API uf::io::exists( const uf::stl::string& _filename ) { +bool uf::io::exists( const uf::stl::string& _filename ) { uf::stl::string filename = sanitize(_filename); static struct stat buffer; return stat(filename.c_str(), &buffer) == 0; } -size_t UF_API uf::io::mtime( const uf::stl::string& _filename ) { +size_t uf::io::mtime( const uf::stl::string& _filename ) { uf::stl::string filename = sanitize(_filename); static struct stat buffer; if ( stat(filename.c_str(), &buffer) != 0 ) return 0; return buffer.st_mtime; } -bool UF_API uf::io::mkdir( const uf::stl::string& _filename ) { +bool uf::io::mkdir( const uf::stl::string& _filename ) { #if UF_ENV_DREAMCAST return false; #else @@ -190,7 +190,7 @@ bool UF_API uf::io::mkdir( const uf::stl::string& _filename ) { return status != -1; #endif } -uf::stl::string UF_API uf::io::resolveURI( const uf::stl::string& filename, const uf::stl::string& _root ) { +uf::stl::string uf::io::resolveURI( const uf::stl::string& filename, const uf::stl::string& _root ) { uf::stl::string root = _root; if ( filename.substr(0,8) == "https://" ) return filename; const uf::stl::string extension = uf::io::extension(filename); diff --git a/engine/src/utils/io/fmt.cpp b/engine/src/utils/io/fmt.cpp index 5de3f5a0..9c247296 100644 --- a/engine/src/utils/io/fmt.cpp +++ b/engine/src/utils/io/fmt.cpp @@ -10,7 +10,7 @@ #endif -uf::stl::string UF_API uf::io::log( const uf::stl::string& category, const uf::stl::string& file, const uf::stl::string& function, size_t line, const uf::stl::string& message ) { +uf::stl::string uf::io::log( const uf::stl::string& category, const uf::stl::string& file, const uf::stl::string& function, size_t line, const uf::stl::string& message ) { #if UF_USE_FMT auto string = ::fmt::format("[{}] [{}:{}@{}]: {}", category, file, function, line, message); ::fmt::print("{}\n", string); diff --git a/engine/src/utils/io/iostream.cpp b/engine/src/utils/io/iostream.cpp index 96a212f7..b42b2f7a 100644 --- a/engine/src/utils/io/iostream.cpp +++ b/engine/src/utils/io/iostream.cpp @@ -55,17 +55,17 @@ namespace { bool uf::IoStream::ncurses = false; uf::IoStream uf::iostream; -UF_API_CALL uf::IoStream::IoStream() { +uf::IoStream::IoStream() { spec::terminal.setLocale(); } uf::IoStream::~IoStream() { } -void UF_API_CALL uf::IoStream::initialize() { +void uf::IoStream::initialize() { } -void UF_API_CALL uf::IoStream::terminate() { +void uf::IoStream::terminate() { } -void UF_API_CALL uf::IoStream::clear(bool all) { +void uf::IoStream::clear(bool all) { spec::terminal.clear(); } uf::stl::string uf::IoStream::getBuffer() { @@ -74,16 +74,16 @@ uf::stl::string uf::IoStream::getBuffer() { uf::stl::vector uf::IoStream::getHistory() { return ::info.output.history; } -void UF_API_CALL uf::IoStream::back() { +void uf::IoStream::back() { } -char UF_API_CALL uf::IoStream::readChar(const bool& loop) { +char uf::IoStream::readChar(const bool& loop) { auto ch = std::cin.get(); addCh(ch); // ::info.input.history.push_back( std::to_string(ch) ); return ch; } -uf::stl::string UF_API_CALL uf::IoStream::readString(const bool& loop) { +uf::stl::string uf::IoStream::readString(const bool& loop) { uf::stl::string str; std::getline(std::cin, str); @@ -91,7 +91,7 @@ uf::stl::string UF_API_CALL uf::IoStream::readString(const bool& loop) { // ::info.input.history.push_back( str ); return str; } -uf::String UF_API_CALL uf::IoStream::readUString(const bool& loop) { +uf::String uf::IoStream::readUString(const bool& loop) { uf::stl::string str; std::getline(std::cin, str); @@ -99,7 +99,7 @@ uf::String UF_API_CALL uf::IoStream::readUString(const bool& loop) { // ::info.input.history.push_back( str ); return str; } -char UF_API_CALL uf::IoStream::writeChar( char ch ) { +char uf::IoStream::writeChar( char ch ) { addCh(ch); if ( ch == '\n' ) std::cout << std::endl; @@ -107,7 +107,7 @@ char UF_API_CALL uf::IoStream::writeChar( char ch ) { // ::info.input.history.push_back( std::to_string(ch) ); return ch; } -const uf::stl::string& UF_API_CALL uf::IoStream::writeString( const uf::stl::string& str ) { +const uf::stl::string& uf::IoStream::writeString( const uf::stl::string& str ) { addStr(str); if ( str == "\n" ) std::cout << std::endl; @@ -115,7 +115,7 @@ const uf::stl::string& UF_API_CALL uf::IoStream::writeString( const uf::stl::str // ::info.input.history.push_back( str ); return str; } -const uf::String& UF_API_CALL uf::IoStream::writeUString( const uf::String& str ) { +const uf::String& uf::IoStream::writeUString( const uf::String& str ) { addUStr(str); std::cout << (const char*) str.getString().c_str(); @@ -123,85 +123,85 @@ const uf::String& UF_API_CALL uf::IoStream::writeUString( const uf::String& str return str; } -void UF_API_CALL uf::IoStream::operator>> (bool& val) { +void uf::IoStream::operator>> (bool& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (char& val) { +void uf::IoStream::operator>> (char& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (short& val) { +void uf::IoStream::operator>> (short& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (unsigned short& val) { +void uf::IoStream::operator>> (unsigned short& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (int& val) { +void uf::IoStream::operator>> (int& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (unsigned int& val) { +void uf::IoStream::operator>> (unsigned int& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (long& val) { +void uf::IoStream::operator>> (long& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (unsigned long& val) { +void uf::IoStream::operator>> (unsigned long& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (long long& val) { +void uf::IoStream::operator>> (long long& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (unsigned long long& val) { +void uf::IoStream::operator>> (unsigned long long& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (float& val) { +void uf::IoStream::operator>> (float& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (double& val) { +void uf::IoStream::operator>> (double& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (long double& val) { +void uf::IoStream::operator>> (long double& val) { uf::stl::stringstream ss; ss << this->readString(); ss >> val; } -void UF_API_CALL uf::IoStream::operator>> (uf::stl::string& val) { +void uf::IoStream::operator>> (uf::stl::string& val) { val = this->readString(); } -void UF_API_CALL uf::IoStream::operator>> (uf::String& val) { +void uf::IoStream::operator>> (uf::String& val) { val = this->readUString(); } -std::istream& UF_API_CALL uf::IoStream::operator>> ( std::istream& is ) { +std::istream& uf::IoStream::operator>> ( std::istream& is ) { uf::stl::string input; is >> input; this->writeString(input); return is; } -std::istream& UF_API_CALL operator>> ( std::istream& is, uf::IoStream& io ) { +std::istream& operator>> ( std::istream& is, uf::IoStream& io ) { uf::stl::string input; is >> input; io.writeString(input); @@ -210,113 +210,113 @@ std::istream& UF_API_CALL operator>> ( std::istream& is, uf::IoStream& io ) { -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const bool& val) { +uf::IoStream& uf::IoStream::operator<< (const bool& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const char& val) { +uf::IoStream& uf::IoStream::operator<< (const char& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const short& val) { +uf::IoStream& uf::IoStream::operator<< (const short& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const unsigned short& val) { +uf::IoStream& uf::IoStream::operator<< (const unsigned short& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const int& val) { +uf::IoStream& uf::IoStream::operator<< (const int& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const unsigned int& val) { +uf::IoStream& uf::IoStream::operator<< (const unsigned int& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const long& val) { +uf::IoStream& uf::IoStream::operator<< (const long& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const unsigned long& val) { +uf::IoStream& uf::IoStream::operator<< (const unsigned long& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const long long& val) { +uf::IoStream& uf::IoStream::operator<< (const long long& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const unsigned long long& val) { +uf::IoStream& uf::IoStream::operator<< (const unsigned long long& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const float& val) { +uf::IoStream& uf::IoStream::operator<< (const float& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const double& val) { +uf::IoStream& uf::IoStream::operator<< (const double& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const long double& val) { +uf::IoStream& uf::IoStream::operator<< (const long double& val) { uf::stl::stringstream ss; ss << val; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const uf::stl::string& val) { +uf::IoStream& uf::IoStream::operator<< (const uf::stl::string& val) { this->writeString(val); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const uf::String& val) { +uf::IoStream& uf::IoStream::operator<< (const uf::String& val) { this->writeUString(val); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const char* cstr) { +uf::IoStream& uf::IoStream::operator<< (const char* cstr) { this->writeString(uf::stl::string(cstr)); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const uf::Serializer& val) { +uf::IoStream& uf::IoStream::operator<< (const uf::Serializer& val) { this->writeString(val.serialize()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (void* ptr) { +uf::IoStream& uf::IoStream::operator<< (void* ptr) { uf::stl::stringstream ss; ss << ptr; this->writeString(ss.str()); return *this; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< ( std::ostream& os ) { +uf::IoStream& uf::IoStream::operator<< ( std::ostream& os ) { uf::stl::stringstream str; str << os.rdbuf(); this->writeString( str.str() ); return *this; } -std::ostream& UF_API_CALL operator<< ( std::ostream& os, uf::IoStream& io ) { +std::ostream& operator<< ( std::ostream& os, uf::IoStream& io ) { uf::stl::string output = io.readString(); os << output; return os; @@ -325,30 +325,30 @@ std::ostream& UF_API_CALL operator<< ( std::ostream& os, uf::IoStream& io ) { uf::stl::string uf::IoStream::getColor() { return this->m_currentColor; } -void UF_API_CALL uf::IoStream::setColor( const uf::stl::string& str ) { +void uf::IoStream::setColor( const uf::stl::string& str ) { } // manip via stream manipulator -UF_API_CALL uf::IoStream::Color::Manip1::Manip1( uf::IoStream& _io ) : io(_io) {} -uf::IoStream::Color::Manip1 UF_API_CALL uf::IoStream::operator<< ( const uf::IoStream::Color& color) { +uf::IoStream::Color::Manip1::Manip1( uf::IoStream& _io ) : io(_io) {} +uf::IoStream::Color::Manip1 uf::IoStream::operator<< ( const uf::IoStream::Color& color) { return uf::IoStream::Color::Manip1(*this); } -uf::IoStream& UF_API_CALL uf::IoStream::Color::Manip1::operator<<( const uf::stl::string& name ) { +uf::IoStream& uf::IoStream::Color::Manip1::operator<<( const uf::stl::string& name ) { this->io.setColor(name); return this->io; } // manip via function call -UF_API_CALL uf::IoStream::Color::Manip2::Manip2( const uf::stl::string& _name ) : name(_name) {} -uf::IoStream::Color::Manip2 UF_API_CALL uf::IoStream::Color::operator()( const uf::stl::string& name ) const { +uf::IoStream::Color::Manip2::Manip2( const uf::stl::string& _name ) : name(_name) {} +uf::IoStream::Color::Manip2 uf::IoStream::Color::operator()( const uf::stl::string& name ) const { return uf::IoStream::Color::Manip2(name); } -uf::IoStream& UF_API_CALL uf::IoStream::Color::operator()( uf::IoStream& io, const uf::stl::string& name ) const { +uf::IoStream& uf::IoStream::Color::operator()( uf::IoStream& io, const uf::stl::string& name ) const { io.setColor(name); return io; } -uf::IoStream& UF_API_CALL uf::IoStream::operator<< (const uf::IoStream::Color::Manip2& color) { +uf::IoStream& uf::IoStream::operator<< (const uf::IoStream::Color::Manip2& color) { this->setColor(color.name); return *this; } \ No newline at end of file diff --git a/engine/src/utils/math/collider.cpp b/engine/src/utils/math/collider.cpp index d0b14e82..7e6133a5 100644 --- a/engine/src/utils/math/collider.cpp +++ b/engine/src/utils/math/collider.cpp @@ -10,26 +10,26 @@ uf::Collider::~Collider() { this->clear(); } -void UF_API uf::Collider::clear() { +void uf::Collider::clear() { for ( pod::Collider* pointer : this->m_container ) delete pointer; this->m_container.clear(); } -void UF_API uf::Collider::add( pod::Collider* pointer ) { +void uf::Collider::add( pod::Collider* pointer ) { this->m_container.push_back(pointer); } -uf::Collider::container_t& UF_API uf::Collider::getContainer() { +uf::Collider::container_t& uf::Collider::getContainer() { return this->m_container; } -const uf::Collider::container_t& UF_API uf::Collider::getContainer() const { +const uf::Collider::container_t& uf::Collider::getContainer() const { return this->m_container; } -std::size_t UF_API uf::Collider::getSize() const { +std::size_t uf::Collider::getSize() const { return this->m_container.size(); } -uf::stl::vector UF_API uf::Collider::intersects( const uf::Collider& body, bool smart ) const { +uf::stl::vector uf::Collider::intersects( const uf::Collider& body, bool smart ) const { uf::stl::vector manifolds; manifolds.reserve( this->m_container.size() * body.m_container.size() ); for ( const pod::Collider* pointer : body.m_container ) { @@ -39,7 +39,7 @@ uf::stl::vector UF_API uf::Collider::intersects( const return manifolds; } -uf::stl::vector UF_API uf::Collider::intersects( const pod::Collider& body, bool smart ) const { +uf::stl::vector uf::Collider::intersects( const pod::Collider& body, bool smart ) const { // smart = false; uf::stl::vector manifolds; for ( const pod::Collider* pointer : this->m_container ) { diff --git a/engine/src/utils/math/collision/boundingbox.cpp b/engine/src/utils/math/collision/boundingbox.cpp index 8220dc33..26af5eb0 100644 --- a/engine/src/utils/math/collision/boundingbox.cpp +++ b/engine/src/utils/math/collision/boundingbox.cpp @@ -1,7 +1,7 @@ #if UF_USE_UNUSED #include -UF_API uf::BoundingBox::BoundingBox( const pod::Vector3& origin, const pod::Vector3& corner ) { +uf::BoundingBox::BoundingBox( const pod::Vector3& origin, const pod::Vector3& corner ) { this->m_origin = origin; this->m_corner = corner; } @@ -66,8 +66,8 @@ pod::Vector3 uf::BoundingBox::closest( const pod::Vector3f& point ) const { return vector; } -uf::stl::string UF_API uf::BoundingBox::type() const { return "BoundingBox"; } -pod::Vector3* UF_API uf::BoundingBox::expand() const { +uf::stl::string uf::BoundingBox::type() const { return "BoundingBox"; } +pod::Vector3* uf::BoundingBox::expand() const { pod::Vector3* raw = new pod::Vector3[8]; raw[0] = pod::Vector3{ this->m_corner.x, this->m_corner.y, this->m_corner.z}; raw[1] = pod::Vector3{ this->m_corner.x, this->m_corner.y, -this->m_corner.z}; @@ -84,7 +84,7 @@ pod::Vector3* UF_API uf::BoundingBox::expand() const { return raw; } -pod::Vector3 UF_API uf::BoundingBox::support( const pod::Vector3& direction ) const { +pod::Vector3 uf::BoundingBox::support( const pod::Vector3& direction ) const { pod::Vector3f position = this->getPosition() + this->m_origin; // const pod::Vector3f& position = this->m_origin; pod::Vector3 res = { @@ -95,7 +95,7 @@ pod::Vector3 UF_API uf::BoundingBox::support( const pod::Vector3& direction ) co return res; } -pod::Collider::Manifold UF_API uf::BoundingBox::intersects( const uf::BoundingBox& b ) const { +pod::Collider::Manifold uf::BoundingBox::intersects( const uf::BoundingBox& b ) const { const uf::BoundingBox& a = *this; pod::Collider::Manifold manifold(a, b); diff --git a/engine/src/utils/math/collision/gjk.cpp b/engine/src/utils/math/collision/gjk.cpp index df9fe119..f12c0e32 100644 --- a/engine/src/utils/math/collision/gjk.cpp +++ b/engine/src/utils/math/collision/gjk.cpp @@ -20,8 +20,8 @@ void pod::Simplex::set( const pod::Vector3& b, const pod::Vector3& c, const pod: } */ pod::Collider::~Collider(){} -uf::stl::string UF_API pod::Collider::type() const { return ""; } -pod::Collider::Manifold UF_API pod::Collider::intersects( const pod::Collider& y ) const { +uf::stl::string pod::Collider::type() const { return ""; } +pod::Collider::Manifold pod::Collider::intersects( const pod::Collider& y ) const { const pod::Collider& x = *this; pod::Simplex::SupportPoint a; diff --git a/engine/src/utils/math/collision/modular.cpp b/engine/src/utils/math/collision/modular.cpp index 7782d75a..0539c934 100644 --- a/engine/src/utils/math/collision/modular.cpp +++ b/engine/src/utils/math/collision/modular.cpp @@ -1,39 +1,39 @@ #if UF_USE_UNUSED #include -UF_API uf::ModularCollider::ModularCollider( uint len, pod::Vector3* container, bool should_free, const uf::ModularCollider::function_expand_t& expand, const uf::ModularCollider::function_support_t& support ) { +uf::ModularCollider::ModularCollider( uint len, pod::Vector3* container, bool should_free, const uf::ModularCollider::function_expand_t& expand, const uf::ModularCollider::function_support_t& support ) { this->m_len = len; this->m_container = container; this->m_should_free = should_free; this->m_function_expand = expand; this->m_function_support = support; } -UF_API uf::ModularCollider::~ModularCollider() { +uf::ModularCollider::~ModularCollider() { if ( this->m_container != NULL && this->m_should_free ) delete[] this->m_container; } -uf::stl::string UF_API uf::ModularCollider::type() const { return "Modular"; } -void UF_API uf::ModularCollider::setExpand( const uf::ModularCollider::function_expand_t& expand ) { +uf::stl::string uf::ModularCollider::type() const { return "Modular"; } +void uf::ModularCollider::setExpand( const uf::ModularCollider::function_expand_t& expand ) { this->m_function_expand = expand; } -void UF_API uf::ModularCollider::setSupport( const uf::ModularCollider::function_support_t& support ) { +void uf::ModularCollider::setSupport( const uf::ModularCollider::function_support_t& support ) { this->m_function_support = support; } -pod::Vector3* UF_API uf::ModularCollider::getContainer() { +pod::Vector3* uf::ModularCollider::getContainer() { return this->m_container; } -uint UF_API uf::ModularCollider::getSize() const { +uint uf::ModularCollider::getSize() const { return this->m_len; } -void UF_API uf::ModularCollider::setContainer( pod::Vector3* container, uint len ) { +void uf::ModularCollider::setContainer( pod::Vector3* container, uint len ) { this->m_container = container; this->m_len = len; } -pod::Vector3* UF_API uf::ModularCollider::expand() const { +pod::Vector3* uf::ModularCollider::expand() const { return this->m_function_expand ? this->m_function_expand() : this->m_container; } -pod::Vector3 UF_API uf::ModularCollider::support( const pod::Vector3& direction ) const { +pod::Vector3 uf::ModularCollider::support( const pod::Vector3& direction ) const { if ( this->m_function_support ) return this->m_function_support(direction); pod::Vector3* points = this->expand(); diff --git a/engine/src/utils/math/collision/sphere.cpp b/engine/src/utils/math/collision/sphere.cpp index 6308c4df..222fd38c 100644 --- a/engine/src/utils/math/collision/sphere.cpp +++ b/engine/src/utils/math/collision/sphere.cpp @@ -1,29 +1,29 @@ #if UF_USE_UNUSED #include -UF_API uf::SphereCollider::SphereCollider( float r, const pod::Vector3& origin ) { +uf::SphereCollider::SphereCollider( float r, const pod::Vector3& origin ) { this->m_radius = r; this->m_origin = origin; } -uf::stl::string UF_API uf::SphereCollider::type() const { return "Sphere"; } -float UF_API uf::SphereCollider::getRadius() const { +uf::stl::string uf::SphereCollider::type() const { return "Sphere"; } +float uf::SphereCollider::getRadius() const { return this->m_radius; } -const pod::Vector3& UF_API uf::SphereCollider::getOrigin() const { +const pod::Vector3& uf::SphereCollider::getOrigin() const { return this->m_origin; } -void UF_API uf::SphereCollider::setRadius( float r ) { +void uf::SphereCollider::setRadius( float r ) { this->m_radius = r; } -void UF_API uf::SphereCollider::setOrigin( const pod::Vector3& origin ) { +void uf::SphereCollider::setOrigin( const pod::Vector3& origin ) { this->m_origin = origin; } -pod::Vector3* UF_API uf::SphereCollider::expand() const { +pod::Vector3* uf::SphereCollider::expand() const { return NULL; } -pod::Vector3 UF_API uf::SphereCollider::support( const pod::Vector3& direction ) const { +pod::Vector3 uf::SphereCollider::support( const pod::Vector3& direction ) const { pod::Vector3f position = this->getPosition() + this->m_origin; // const pod::Vector3f& position = this->m_origin; return position + direction * (this->m_radius/uf::vector::magnitude(direction)); diff --git a/engine/src/utils/math/physics.cpp b/engine/src/utils/math/physics.cpp index 90ca3d5e..10989a6f 100644 --- a/engine/src/utils/math/physics.cpp +++ b/engine/src/utils/math/physics.cpp @@ -10,10 +10,12 @@ float uf::physics::time::clamp = 0; */ -void UF_API uf::physics::initialize() { +void uf::physics::initialize() { uf::physics::impl::initialize(); } -void UF_API uf::physics::tick() { +void uf::physics::tick() { + ++uf::physics::time::frame; + uf::physics::time::previous = uf::physics::time::current; uf::physics::time::current = uf::physics::time::timer.elapsed(); @@ -23,6 +25,6 @@ void UF_API uf::physics::tick() { } uf::physics::impl::tick(); } -void UF_API uf::physics::terminate() { +void uf::physics::terminate() { uf::physics::impl::terminate(); } \ No newline at end of file diff --git a/engine/src/utils/math/rayt.cpp b/engine/src/utils/math/rayt.cpp index 1b285968..fbd12763 100644 --- a/engine/src/utils/math/rayt.cpp +++ b/engine/src/utils/math/rayt.cpp @@ -6,7 +6,7 @@ // compile-time assert to ensure objects are of same size, if using multiple types of objects // takes a vector of primitives and groups them under leaves (end point of a tree) -uf::stl::vector UF_API uf::primitive::populate( const uf::stl::vector& cubes ) { // assert(cubes.size() > 0); +uf::stl::vector uf::primitive::populate( const uf::stl::vector& cubes ) { // assert(cubes.size() > 0); uf::stl::vector trees; uf::stl::vector copy; uf::stl::vector alloced; @@ -79,7 +79,7 @@ uf::stl::vector UF_API uf::primitive::populate( const uf::stl::vector } // takes a list of leaves (ends of trees) and properly populate an entire tree -uf::stl::vector UF_API uf::primitive::populateEntirely( const uf::stl::vector& trees, bool rooted ) { // assert(trees.size() > 0); +uf::stl::vector uf::primitive::populateEntirely( const uf::stl::vector& trees, bool rooted ) { // assert(trees.size() > 0); // generate first layer uf::stl::vector tree = trees; uf::stl::vector referred; diff --git a/engine/src/utils/mesh/grid.cpp b/engine/src/utils/mesh/grid.cpp index 04179724..2d067a84 100644 --- a/engine/src/utils/mesh/grid.cpp +++ b/engine/src/utils/mesh/grid.cpp @@ -8,7 +8,7 @@ namespace { } -void UF_API uf::meshgrid::print( const uf::meshgrid::Grid& grid ) { +void uf::meshgrid::print( const uf::meshgrid::Grid& grid ) { UF_MSG_DEBUG( "== == == =="); float total = 0.0f; for ( auto& pair : grid.nodes ) { auto& node = pair.second; @@ -41,7 +41,7 @@ void UF_API uf::meshgrid::print( const uf::meshgrid::Grid& grid ) { UF_MSG_DEBUG( "== == == =="); */ } -void UF_API uf::meshgrid::cleanup( uf::meshgrid::Grid& grid ) { +void uf::meshgrid::cleanup( uf::meshgrid::Grid& grid ) { uf::stl::vector eraseNodes; for ( auto& pair : grid.nodes ) { auto& node = pair.second; @@ -254,7 +254,7 @@ void uf::meshgrid::partition( uf::meshgrid::Grid& grid, grid.indices += iCount; } -void UF_API uf::meshgrid::partition( uf::meshgrid::Grid& grid, uf::Mesh& mesh, const pod::Primitive& primitive ) { +void uf::meshgrid::partition( uf::meshgrid::Grid& grid, uf::Mesh& mesh, const pod::Primitive& primitive ) { uf::Mesh::Input vertexInput = mesh.vertex; uf::Mesh::Input indexInput = mesh.index; diff --git a/engine/src/utils/string/ext.cpp b/engine/src/utils/string/ext.cpp index 2521f11a..cef7cb92 100644 --- a/engine/src/utils/string/ext.cpp +++ b/engine/src/utils/string/ext.cpp @@ -9,16 +9,16 @@ #include /* -bool UF_API uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) { +bool uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) { std::regex regex(r); std::smatch match; return std::regex_search( str, match, regex ); } */ -bool UF_API uf::string::isRegex( const uf::stl::string& str ) { +bool uf::string::isRegex( const uf::stl::string& str ) { return str.front() == '/' && str.back() == '/'; } -uf::stl::vector UF_API uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) { +uf::stl::vector uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) { std::regex regex(uf::string::isRegex(r) ? r.substr(1,r.length()-2) : r); std::smatch match; uf::stl::vector matches; @@ -30,23 +30,23 @@ uf::stl::vector UF_API uf::string::match( const uf::stl::string return matches; } -bool UF_API uf::string::matched( const uf::stl::string& str, const uf::stl::string& r ) { +bool uf::string::matched( const uf::stl::string& str, const uf::stl::string& r ) { std::regex regex(uf::string::isRegex(r) ? r.substr(1,r.length()-2) : r); std::smatch match; return std::regex_search( str, match, regex ); } -uf::stl::string UF_API uf::string::lowercase( const uf::stl::string& str ) { +uf::stl::string uf::string::lowercase( const uf::stl::string& str ) { uf::stl::string lower = str; std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); return lower; } -uf::stl::string UF_API uf::string::uppercase( const uf::stl::string& str ) { +uf::stl::string uf::string::uppercase( const uf::stl::string& str ) { uf::stl::string upper = str; std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); return upper; } -uf::stl::vector UF_API uf::string::split( const uf::stl::string& str, const uf::stl::string& delim ) { +uf::stl::vector uf::string::split( const uf::stl::string& str, const uf::stl::string& delim ) { uf::stl::vector tokens; size_t prev = 0, pos = 0; do { @@ -70,7 +70,7 @@ uf::stl::vector UF_API uf::string::split( const uf::stl::string */ } /* -uf::stl::string UF_API uf::string::join( const uf::stl::vector& strings, const uf::stl::string& delim, bool trailing ) { +uf::stl::string uf::string::join( const uf::stl::vector& strings, const uf::stl::string& delim, bool trailing ) { uf::stl::stringstream ss; size_t len = strings.size(); for ( size_t i = 0; i < len; ++i ) { @@ -80,7 +80,7 @@ uf::stl::string UF_API uf::string::join( const uf::stl::vector& return ss.str(); } */ -uf::stl::vector UF_API uf::string::cStrings( const uf::stl::vector& strings ) { +uf::stl::vector uf::string::cStrings( const uf::stl::vector& strings ) { uf::stl::vector v; v.reserve( strings.size() ); @@ -91,7 +91,7 @@ uf::stl::vector UF_API uf::string::cStrings( const uf::stl::vector< return v; } -uf::stl::string UF_API uf::string::replace( const uf::stl::string& string, const uf::stl::string& search, const uf::stl::string& replace ) { +uf::stl::string uf::string::replace( const uf::stl::string& string, const uf::stl::string& search, const uf::stl::string& replace ) { uf::stl::string result = string; if ( uf::string::isRegex(search) ) { @@ -104,10 +104,10 @@ uf::stl::string UF_API uf::string::replace( const uf::stl::string& string, const } return result; } -bool UF_API uf::string::contains( const uf::stl::string& string, const uf::stl::string& search ) { +bool uf::string::contains( const uf::stl::string& string, const uf::stl::string& search ) { return string.find(search) != uf::stl::string::npos; } -uf::stl::string UF_API uf::string::si( double value, const uf::stl::string& unit, size_t precision ) { +uf::stl::string uf::string::si( double value, const uf::stl::string& unit, size_t precision ) { int power = floor(std::log10( value )); double base = value / std::pow( 10, power ); diff --git a/engine/src/utils/string/string.cpp b/engine/src/utils/string/string.cpp index 955c3cdd..137b4573 100644 --- a/engine/src/utils/string/string.cpp +++ b/engine/src/utils/string/string.cpp @@ -2,64 +2,64 @@ #include //uf::String uf::locale::current; uf::stl::string uf::locale::current; -UF_API_CALL uf::String::String() { +uf::String::String() { } // ANSI literals/strings -UF_API_CALL uf::String::String( char ch ) { +uf::String::String( char ch ) { // this->m_string += ch; this->parse( ch ); } -UF_API_CALL uf::String::String( const char* c_str ) { +uf::String::String( const char* c_str ) { // this->m_string = (const uint8_t*) c_str; this->parse( c_str ); } -UF_API_CALL uf::String::String( const std::basic_string& str ) { +uf::String::String( const std::basic_string& str ) { // this->m_string = (const uint8_t*) str.c_str(); this->parse( str ); } // Wide literals/strings -UF_API_CALL uf::String::String( wchar_t ch ) { +uf::String::String( wchar_t ch ) { this->parse(ch); } -UF_API_CALL uf::String::String( const wchar_t* c_str ) { +uf::String::String( const wchar_t* c_str ) { this->parse(c_str); } -UF_API_CALL uf::String::String( const std::basic_string& str ) { +uf::String::String( const std::basic_string& str ) { this->parse(str); } // UTF-8 literals/strings -UF_API_CALL uf::String::String( uint8_t ch ) { +uf::String::String( uint8_t ch ) { this->parse(ch); } -UF_API_CALL uf::String::String( const uint8_t* c_str ) { +uf::String::String( const uint8_t* c_str ) { this->parse(c_str); } -UF_API_CALL uf::String::String( const std::basic_string& str ) { +uf::String::String( const std::basic_string& str ) { this->parse(str); } // UTF-16 literals/strings -UF_API_CALL uf::String::String( uint16_t ch ) { +uf::String::String( uint16_t ch ) { this->parse(ch); } -UF_API_CALL uf::String::String( const uint16_t* c_str ) { +uf::String::String( const uint16_t* c_str ) { this->parse(c_str); } -UF_API_CALL uf::String::String( const std::basic_string& str ) { +uf::String::String( const std::basic_string& str ) { this->parse(str); } // UTF-32 literals/strings -UF_API_CALL uf::String::String( uint32_t ch ) { +uf::String::String( uint32_t ch ) { this->parse(ch); } -UF_API_CALL uf::String::String( const uint32_t* c_str ) { +uf::String::String( const uint32_t* c_str ) { this->parse(c_str); } -UF_API_CALL uf::String::String( const std::basic_string& str ) { +uf::String::String( const std::basic_string& str ) { this->parse(str); } // Parses ANSI/ASCII -void UF_API_CALL uf::String::parse( char ch ) { +void uf::String::parse( char ch ) { this->m_string += ch; /* uint32_t codepoint = uf::locale::Ansi::decode( ch, ch ); @@ -68,26 +68,26 @@ void UF_API_CALL uf::String::parse( char ch ) { this->m_string += uf::String::string_t(chars); */ } -void UF_API_CALL uf::String::parse( const char* c_str ) { +void uf::String::parse( const char* c_str ) { // this->m_string = c_str; this->parse(std::basic_string(c_str)); } -void UF_API_CALL uf::String::parse( const std::basic_string& str ) { +void uf::String::parse( const std::basic_string& str ) { // this->m_string = str; for ( auto ch : str ) this->parse(ch); } // Wide literals/strings -void UF_API_CALL uf::String::parse( wchar_t ch ) { +void uf::String::parse( wchar_t ch ) { switch ( sizeof(wchar_t) * 8 ) { case 16: this->parse((uint16_t) ch); break; case 32: this->parse((uint32_t) ch); break; } } -void UF_API_CALL uf::String::parse( const wchar_t* c_str ) { +void uf::String::parse( const wchar_t* c_str ) { this->parse(std::basic_string(c_str)); } -void UF_API_CALL uf::String::parse( const std::basic_string& str ) { +void uf::String::parse( const std::basic_string& str ) { switch ( sizeof(wchar_t) * 8 ) { case 16: for ( auto ch : str ) this->parse((uint16_t)ch); @@ -99,101 +99,101 @@ void UF_API_CALL uf::String::parse( const std::basic_string& str ) { } // UTF-8 literals/strings -void UF_API_CALL uf::String::parse( uint8_t ch ) { +void uf::String::parse( uint8_t ch ) { // this->m_string += ch; uint32_t codepoint = uf::locale::Utf8::decode( &ch, &ch + 1 ); uint8_t chars[4] = { 0, 0, 0, 0 }; String::encoding_t::encode( codepoint, &chars[0] ); this->m_string += uf::String::string_t(chars); } -void UF_API_CALL uf::String::parse( const uint8_t* c_str ) { +void uf::String::parse( const uint8_t* c_str ) { // this->m_string = c_str; this->parse(std::basic_string(c_str)); } -void UF_API_CALL uf::String::parse( const std::basic_string& str ) { +void uf::String::parse( const std::basic_string& str ) { // this->m_string = str; for ( auto ch : str ) this->parse(ch); } // UTF-16 literals/strings -void UF_API_CALL uf::String::parse( uint16_t ch ) { +void uf::String::parse( uint16_t ch ) { uint32_t codepoint = uf::locale::Utf16::decode( &ch, &ch + 1 ); uint8_t chars[4] = { 0, 0, 0, 0 }; String::encoding_t::encode( codepoint, &chars[0] ); this->m_string += uf::String::string_t(chars); } -void UF_API_CALL uf::String::parse( const uint16_t* c_str ) { +void uf::String::parse( const uint16_t* c_str ) { this->parse(std::basic_string(c_str)); } -void UF_API_CALL uf::String::parse( const std::basic_string& str ) { +void uf::String::parse( const std::basic_string& str ) { for ( auto ch : str ) this->parse(ch); } // UTF-32 literals/strings -void UF_API_CALL uf::String::parse( uint32_t ch ) { +void uf::String::parse( uint32_t ch ) { uint32_t codepoint = ch; uint8_t chars[4] = { 0, 0, 0, 0 }; String::encoding_t::encode( codepoint, &chars[0] ); this->m_string += uf::String::string_t(chars); } -void UF_API_CALL uf::String::parse( const uint32_t* c_str ) { +void uf::String::parse( const uint32_t* c_str ) { this->parse(std::basic_string(c_str)); } -void UF_API_CALL uf::String::parse( const std::basic_string& str ) { +void uf::String::parse( const std::basic_string& str ) { for ( auto ch : str ) this->parse(ch); } // -uf::String::string_t& UF_API_CALL uf::String::getString() { +uf::String::string_t& uf::String::getString() { return this->m_string; } -const uf::String::string_t& UF_API_CALL uf::String::getString() const { +const uf::String::string_t& uf::String::getString() const { return this->m_string; } // -uf::String::literal_t* UF_API_CALL uf::String::c_str() { +uf::String::literal_t* uf::String::c_str() { return (uf::String::literal_t*) this->m_string.c_str(); } -const uf::String::literal_t* UF_API_CALL uf::String::c_str() const { +const uf::String::literal_t* uf::String::c_str() const { return (const uf::String::literal_t*) this->m_string.c_str(); } // -void UF_API_CALL uf::String::operator +=( char ch ) { +void uf::String::operator +=( char ch ) { this->parse(ch); } -void UF_API_CALL uf::String::operator +=( wchar_t ch ) { +void uf::String::operator +=( wchar_t ch ) { this->parse(ch); } -void UF_API_CALL uf::String::operator +=( uint8_t ch ) { +void uf::String::operator +=( uint8_t ch ) { this->parse(ch); } -void UF_API_CALL uf::String::operator +=( uint16_t ch ) { +void uf::String::operator +=( uint16_t ch ) { this->parse(ch); } -void UF_API_CALL uf::String::operator +=( uint32_t ch ) { +void uf::String::operator +=( uint32_t ch ) { this->parse(ch); } // Truncate -uf::String& UF_API_CALL uf::String::operator --() { +uf::String& uf::String::operator --() { this->m_string.pop_back(); return *this; } -uf::String UF_API_CALL uf::String::operator --(int) { +uf::String uf::String::operator --(int) { auto before = this->m_string; this->m_string.pop_back(); return before; } -uf::String& UF_API_CALL uf::String::operator -=( std::size_t i ) { +uf::String& uf::String::operator -=( std::size_t i ) { for ( std::size_t ii = 0; ii < i; ++ii ) this->m_string.pop_back(); return *this; } // -UF_API_CALL uf::String::operator uf::stl::string() { +uf::String::operator uf::stl::string() { return uf::stl::string((char*) this->c_str()); } -UF_API_CALL uf::String::operator uf::stl::string() const { +uf::String::operator uf::stl::string() const { return uf::stl::string((const char*) this->c_str()); } // -UF_API_CALL uf::String::operator std::wstring() { +uf::String::operator std::wstring() { switch ( sizeof(wchar_t) * 8 ) { case 16: { std::basic_string w_str = this->translate(); @@ -208,7 +208,7 @@ UF_API_CALL uf::String::operator std::wstring() { for ( auto c : this->m_string ) w_str += c; return w_str; } -UF_API_CALL uf::String::operator std::wstring() const { +uf::String::operator std::wstring() const { switch ( sizeof(wchar_t) * 8 ) { case 16: { std::basic_string w_str = this->translate(); diff --git a/engine/src/utils/thread/thread.cpp b/engine/src/utils/thread/thread.cpp index eac1de26..0a5d41e6 100644 --- a/engine/src/utils/thread/thread.cpp +++ b/engine/src/utils/thread/thread.cpp @@ -13,11 +13,11 @@ uf::stl::string uf::thread::mainThreadName = "Main"; #define UF_THREAD_ANNOUNCE(...) UF_MSG_DEBUG(__VA_ARGS__) -void UF_API uf::thread::start( pod::Thread& thread ) { if ( thread.running ) return; +void uf::thread::start( pod::Thread& thread ) { if ( thread.running ) return; thread.thread = std::thread( uf::thread::tick, std::ref(thread) ); thread.running = true; } -void UF_API uf::thread::quit( pod::Thread& thread ) { if ( !thread.running ) return; +void uf::thread::quit( pod::Thread& thread ) { if ( !thread.running ) return; thread.running = false; thread.conditions.queued.notify_one(); @@ -27,7 +27,7 @@ void UF_API uf::thread::quit( pod::Thread& thread ) { if ( !thread.running ) ret // if ( thread.mutex != NULL ) thread.mutex->unlock(); } -void UF_API uf::thread::tick( pod::Thread& thread ) { +void uf::thread::tick( pod::Thread& thread ) { #if !UF_ENV_DREAMCAST bool res = SetThreadAffinityMask(GetCurrentThread(), (1u << thread.affinity)); // if ( !res ) UF_THREAD_ANNOUNCE("Failed to set affinity of Thread #" << thread.uid << " (" << thread.name << " on core " << pthread_self() << "/" << thread.affinity << ")"); @@ -54,7 +54,7 @@ void UF_API uf::thread::tick( pod::Thread& thread ) { } } -pod::Thread& UF_API uf::thread::fetchWorker( const uf::stl::string& name ) { +pod::Thread& uf::thread::fetchWorker( const uf::stl::string& name ) { static int current = 0; static int limit = uf::thread::workers; int tries = 0; @@ -67,10 +67,10 @@ pod::Thread& UF_API uf::thread::fetchWorker( const uf::stl::string& name ) { } UF_EXCEPTION("cannot find free worker"); } -pod::Thread::Tasks UF_API uf::thread::schedule( bool async, bool wait ) { +pod::Thread::Tasks uf::thread::schedule( bool async, bool wait ) { return schedule( async ? uf::thread::workerThreadName : uf::thread::mainThreadName, wait ); } -pod::Thread::Tasks UF_API uf::thread::schedule( const uf::stl::string& name, bool wait ) { +pod::Thread::Tasks uf::thread::schedule( const uf::stl::string& name, bool wait ) { pod::Thread::Tasks tasks = { .name = name, .waits = wait, @@ -78,7 +78,7 @@ pod::Thread::Tasks UF_API uf::thread::schedule( const uf::stl::string& name, boo return tasks; } -uf::stl::vector UF_API uf::thread::execute( pod::Thread::Tasks& tasks ) { +uf::stl::vector uf::thread::execute( pod::Thread::Tasks& tasks ) { uf::stl::vector workers; if ( tasks.container.empty() ) return workers; @@ -100,18 +100,18 @@ uf::stl::vector UF_API uf::thread::execute( pod::Thread::Tasks& ta } return workers; } -void UF_API uf::thread::wait( uf::stl::vector& workers ) { +void uf::thread::wait( uf::stl::vector& workers ) { for ( auto& worker : workers ) uf::thread::wait( *worker ); workers.clear(); } -void UF_API uf::thread::wait( const uf::stl::vector& workers ) { +void uf::thread::wait( const uf::stl::vector& workers ) { for ( auto& worker : workers ) uf::thread::wait( *worker ); } /* -void UF_API uf::thread::batchWorker( const pod::Thread::function_t& function, const uf::stl::string& name ) { +void uf::thread::batchWorker( const pod::Thread::function_t& function, const uf::stl::string& name ) { return batchWorkers( { function }, false, name ); } -void UF_API uf::thread::batchWorkers( const uf::stl::vector& functions, bool wait, const uf::stl::string& name ) { +void uf::thread::batchWorkers( const uf::stl::vector& functions, bool wait, const uf::stl::string& name ) { uf::stl::vector workers; for ( auto& function : functions ) { auto& worker = uf::thread::fetchWorker( name ); @@ -120,7 +120,7 @@ void UF_API uf::thread::batchWorkers( const uf::stl::vector& functions, bool wait, const uf::stl::string& name ) { +void uf::thread::batchWorkers_Async( const uf::stl::vector& functions, bool wait, const uf::stl::string& name ) { // if ( uf::thread::async ) uf::stl::vector> futures; futures.reserve(functions.size()); @@ -130,31 +130,31 @@ void UF_API uf::thread::batchWorkers_Async( const uf::stl::vectorlock(); queue ? thread.queue.push( function ) : thread.container.push_back( function ); if ( thread.mutex != NULL ) thread.mutex->unlock(); } */ -void UF_API uf::thread::add( pod::Thread& thread, const pod::Thread::function_t& function ) { +void uf::thread::add( pod::Thread& thread, const pod::Thread::function_t& function ) { if ( thread.mutex != NULL ) thread.mutex->lock(); thread.container.emplace_back( function ); if ( thread.mutex != NULL ) thread.mutex->unlock(); } -void UF_API uf::thread::queue( const pod::Thread::container_t& functions ) { +void uf::thread::queue( const pod::Thread::container_t& functions ) { for ( auto& function : functions ) uf::thread::queue( uf::thread::fetchWorker(), function ); } -void UF_API uf::thread::queue( const pod::Thread::function_t& function ) { +void uf::thread::queue( const pod::Thread::function_t& function ) { return uf::thread::queue( uf::thread::fetchWorker(), function ); } -void UF_API uf::thread::queue( pod::Thread& thread, const pod::Thread::function_t& function ) { +void uf::thread::queue( pod::Thread& thread, const pod::Thread::function_t& function ) { if ( thread.mutex != NULL ) thread.mutex->lock(); thread.queue.emplace( function ); thread.conditions.queued.notify_one(); if ( thread.mutex != NULL ) thread.mutex->unlock(); } -void UF_API uf::thread::process( pod::Thread& thread ) { if ( !uf::thread::has(uf::thread::uid(thread)) )return; //ops +void uf::thread::process( pod::Thread& thread ) { if ( !uf::thread::has(uf::thread::uid(thread)) )return; //ops while ( !thread.queue.empty() ) { auto& function = thread.queue.front(); if ( function ) @@ -183,7 +183,7 @@ void UF_API uf::thread::process( pod::Thread& thread ) { if ( !uf::thread::has(u } thread.conditions.finished.notify_one(); } -void UF_API uf::thread::wait( pod::Thread& thread ) { +void uf::thread::wait( pod::Thread& thread ) { if ( thread.mutex != NULL ) { std::unique_lock lock(*thread.mutex); thread.conditions.finished.wait(lock, [&]{return thread.queue.empty();}); @@ -192,27 +192,27 @@ void UF_API uf::thread::wait( pod::Thread& thread ) { while ( !thread.queue.empty() ); } -const uf::stl::string& UF_API uf::thread::name( const pod::Thread& thread ) { +const uf::stl::string& uf::thread::name( const pod::Thread& thread ) { return thread.name; } -std::thread::id UF_API uf::thread::id( const pod::Thread& thread ) { +std::thread::id uf::thread::id( const pod::Thread& thread ) { if ( thread.name == uf::thread::mainThreadName ) return uf::thread::mainThreadId; return thread.thread.get_id(); } -uint UF_API uf::thread::uid( const pod::Thread& thread ) { +uint uf::thread::uid( const pod::Thread& thread ) { return thread.uid; } -bool UF_API uf::thread::running( const pod::Thread& thread ) { +bool uf::thread::running( const pod::Thread& thread ) { return thread.running; } -void UF_API uf::thread::terminate() { +void uf::thread::terminate() { while ( !uf::thread::threads.empty() ) { pod::Thread& thread = **uf::thread::threads.begin(); uf::thread::destroy( thread ); } } -pod::Thread& UF_API uf::thread::create( const uf::stl::string& name, bool start, bool locks ) { +pod::Thread& uf::thread::create( const uf::stl::string& name, bool start, bool locks ) { if ( name == uf::thread::mainThreadName ) start = false; pod::Thread* pointer = NULL; @@ -235,7 +235,7 @@ pod::Thread& UF_API uf::thread::create( const uf::stl::string& name, bool start, return thread; } -void UF_API uf::thread::destroy( pod::Thread& thread ) { +void uf::thread::destroy( pod::Thread& thread ) { if ( !uf::thread::has( uf::thread::uid(thread) ) ) return; // oops // UF_THREAD_ANNOUNCE("Quitting Thread #" << thread.uid << " (" << thread.name << ")"); @@ -250,39 +250,39 @@ void UF_API uf::thread::destroy( pod::Thread& thread ) { break; } } -bool UF_API uf::thread::has( uint uid ) { +bool uf::thread::has( uint uid ) { for ( const pod::Thread* thread : uf::thread::threads ) if ( uf::thread::uid(*thread) == uid ) return true; return false; } -bool UF_API uf::thread::has( std::thread::id id ) { +bool uf::thread::has( std::thread::id id ) { for ( const pod::Thread* thread : uf::thread::threads ) if ( uf::thread::id(*thread) == id ) return true; return false; } -bool UF_API uf::thread::has( const uf::stl::string& name ) { +bool uf::thread::has( const uf::stl::string& name ) { for ( const pod::Thread* thread : uf::thread::threads ) if ( uf::thread::name(*thread) == name ) return true; return false; } -pod::Thread& UF_API uf::thread::get( uint uid ) { +pod::Thread& uf::thread::get( uint uid ) { for ( pod::Thread* thread : uf::thread::threads ) if ( uf::thread::uid(*thread) == uid ) return *thread; UF_EXCEPTION("Thread error: invalid call"); // return uf::thread::get(uf::thread::mainThreadId); } -pod::Thread& UF_API uf::thread::get( std::thread::id id ) { +pod::Thread& uf::thread::get( std::thread::id id ) { for ( pod::Thread* thread : uf::thread::threads ) if ( uf::thread::id(*thread) == id ) return *thread; UF_EXCEPTION("Thread error: invalid call"); // return uf::thread::get(uf::thread::mainThreadId); } -pod::Thread& UF_API uf::thread::get( const uf::stl::string& name ) { +pod::Thread& uf::thread::get( const uf::stl::string& name ) { if ( !uf::thread::has(name) ) return uf::thread::create(name); for ( pod::Thread* thread : uf::thread::threads ) if ( uf::thread::name(*thread) == name ) return *thread; UF_EXCEPTION("Thread error: invalid call"); // return uf::thread::get(uf::thread::mainThreadId); } -bool UF_API uf::thread::isMain() { +bool uf::thread::isMain() { return uf::thread::mainThreadId == std::this_thread::get_id(); } -pod::Thread& UF_API uf::thread::currentThread() { +pod::Thread& uf::thread::currentThread() { std::thread::id id = std::this_thread::get_id(); if ( uf::thread::has(id) ) return uf::thread::get(id); UF_MSG_ERROR("Invalid thread call"); diff --git a/engine/src/utils/time/time.cpp b/engine/src/utils/time/time.cpp index 7789354a..43588fe1 100644 --- a/engine/src/utils/time/time.cpp +++ b/engine/src/utils/time/time.cpp @@ -3,9 +3,10 @@ namespace { uf::Time<> zero = spec::time.getTime(); // Program epoch, used for getting time deltas (without uf::Timer) } -extern UF_API uf::Timer<> timer; // System timer, used for getting time deltas +// extern UF_API uf::Timer<> timer; // System timer, used for getting time deltas uf::Timer<> uf::time::timer; +size_t uf::time::frame = 0; double uf::time::current = 0; double uf::time::previous = 0; float uf::time::delta = 0; diff --git a/engine/src/utils/type/type.cpp b/engine/src/utils/type/type.cpp index 0cf7f038..daa8aa66 100644 --- a/engine/src/utils/type/type.cpp +++ b/engine/src/utils/type/type.cpp @@ -39,7 +39,7 @@ void uf::typeInfo::registerType( const uf::typeInfo::index_t& index, size_t size #endif if ( !exists || pretty != "" ) type.name.pretty = pretty != "" ? pretty : demangle( type.name.compiler ); } -const pod::TypeInfo& UF_API uf::typeInfo::getType( size_t hash ) { +const pod::TypeInfo& uf::typeInfo::getType( size_t hash ) { if ( !uf::typeInfo::types ) uf::typeInfo::types = new uf::stl::unordered_map; auto& types = *uf::typeInfo::types; for ( auto& pair : types ) { diff --git a/engine/src/utils/userdata/pointered.cpp b/engine/src/utils/userdata/pointered.cpp index d802a529..720aeafd 100644 --- a/engine/src/utils/userdata/pointered.cpp +++ b/engine/src/utils/userdata/pointered.cpp @@ -5,13 +5,13 @@ #include // Constructs a pod::PointeredUserdata struct -pod::PointeredUserdata UF_API uf::pointeredUserdata::create( size_t len, void* data ) { +pod::PointeredUserdata uf::pointeredUserdata::create( size_t len, void* data ) { return uf::pointeredUserdata::create( uf::userdata::memoryPool, len, data ); } -void UF_API uf::pointeredUserdata::destroy( pod::PointeredUserdata& userdata ) { +void uf::pointeredUserdata::destroy( pod::PointeredUserdata& userdata ) { return uf::pointeredUserdata::destroy( uf::userdata::memoryPool, userdata ); } -pod::PointeredUserdata UF_API uf::pointeredUserdata::copy( const pod::PointeredUserdata& userdata ) { +pod::PointeredUserdata uf::pointeredUserdata::copy( const pod::PointeredUserdata& userdata ) { return uf::pointeredUserdata::copy( uf::userdata::memoryPool, userdata ); } @@ -20,7 +20,7 @@ size_t uf::pointeredUserdata::size( size_t len, size_t padding ) { } // -pod::PointeredUserdata UF_API uf::pointeredUserdata::create( uf::MemoryPool& requestedMemoryPool, size_t len, void* data ) { +pod::PointeredUserdata uf::pointeredUserdata::create( uf::MemoryPool& requestedMemoryPool, size_t len, void* data ) { if ( len <= 0 ) return {}; size_t requestedLen = size( len ); #if UF_MEMORYPOOL_INVALID_MALLOC @@ -43,7 +43,7 @@ pod::PointeredUserdata UF_API uf::pointeredUserdata::create( uf::MemoryPool& req userdata.type = UF_USERDATA_CTTI(void); return userdata; } -void UF_API uf::pointeredUserdata::destroy( uf::MemoryPool& requestedMemoryPool, pod::PointeredUserdata& userdata ) { +void uf::pointeredUserdata::destroy( uf::MemoryPool& requestedMemoryPool, pod::PointeredUserdata& userdata ) { if ( !userdata.data ) return; #if UF_MEMORYPOOL_INVALID_FREE uf::MemoryPool& memoryPool = requestedMemoryPool.size() > 0 ? requestedMemoryPool : uf::memoryPool::global; @@ -59,17 +59,17 @@ void UF_API uf::pointeredUserdata::destroy( uf::MemoryPool& requestedMemoryPool, userdata.len = 0; userdata.data = NULL; } -pod::PointeredUserdata UF_API uf::pointeredUserdata::copy( uf::MemoryPool& requestedMemoryPool, const pod::PointeredUserdata& userdata ) { +pod::PointeredUserdata uf::pointeredUserdata::copy( uf::MemoryPool& requestedMemoryPool, const pod::PointeredUserdata& userdata ) { if ( !userdata.data || userdata.len <= 0 ) return {}; pod::PointeredUserdata copied = uf::pointeredUserdata::create( userdata.len, const_cast(userdata.data) ); copied.type = userdata.type; return copied; } -uf::stl::string UF_API uf::pointeredUserdata::toBase64( pod::PointeredUserdata& userdata ) { +uf::stl::string uf::pointeredUserdata::toBase64( pod::PointeredUserdata& userdata ) { return uf::base64::encode( static_cast(userdata.data), userdata.len ); } -pod::PointeredUserdata UF_API uf::pointeredUserdata::fromBase64( const uf::stl::string& base64 ) { +pod::PointeredUserdata uf::pointeredUserdata::fromBase64( const uf::stl::string& base64 ) { uf::stl::vector decoded = uf::base64::decode( base64 ); return uf::pointeredUserdata::create( decoded.size(), decoded.data() ); } diff --git a/engine/src/utils/userdata/userdata.cpp b/engine/src/utils/userdata/userdata.cpp index d9a7e8c7..f203e900 100644 --- a/engine/src/utils/userdata/userdata.cpp +++ b/engine/src/utils/userdata/userdata.cpp @@ -8,13 +8,13 @@ uf::MemoryPool uf::userdata::memoryPool; bool uf::userdata::autoDestruct = true; bool uf::userdata::autoValidate = true; // Constructs a pod::Userdata struct -pod::Userdata* UF_API uf::userdata::create( std::size_t len, void* data ) { +pod::Userdata* uf::userdata::create( std::size_t len, void* data ) { return uf::userdata::create( uf::userdata::memoryPool, len, data ); } -void UF_API uf::userdata::destroy( pod::Userdata* userdata ) { +void uf::userdata::destroy( pod::Userdata* userdata ) { return uf::userdata::destroy( uf::userdata::memoryPool, userdata ); } -pod::Userdata* UF_API uf::userdata::copy( const pod::Userdata* userdata ) { +pod::Userdata* uf::userdata::copy( const pod::Userdata* userdata ) { return uf::userdata::copy( uf::userdata::memoryPool, userdata ); } @@ -23,7 +23,7 @@ size_t uf::userdata::size( size_t len, size_t padding ) { } // -pod::Userdata* UF_API uf::userdata::create( uf::MemoryPool& requestedMemoryPool, size_t len, void* data ) { +pod::Userdata* uf::userdata::create( uf::MemoryPool& requestedMemoryPool, size_t len, void* data ) { if ( len <= 0 ) return NULL; size_t requestedLen = size( len ); #if UF_MEMORYPOOL_INVALID_MALLOC @@ -46,7 +46,7 @@ pod::Userdata* UF_API uf::userdata::create( uf::MemoryPool& requestedMemoryPool, userdata->type = UF_USERDATA_CTTI(void); return userdata; } -void UF_API uf::userdata::destroy( uf::MemoryPool& requestedMemoryPool, pod::Userdata* userdata ) { +void uf::userdata::destroy( uf::MemoryPool& requestedMemoryPool, pod::Userdata* userdata ) { #if UF_MEMORYPOOL_INVALID_FREE uf::MemoryPool& memoryPool = requestedMemoryPool.size() > 0 ? requestedMemoryPool : uf::memoryPool::global; memoryPool.free( userdata, size(userdata->len) ); @@ -59,17 +59,17 @@ void UF_API uf::userdata::destroy( uf::MemoryPool& requestedMemoryPool, pod::Use else uf::allocator::free_m(userdata); #endif } -pod::Userdata* UF_API uf::userdata::copy( uf::MemoryPool& requestedMemoryPool, const pod::Userdata* userdata ) { +pod::Userdata* uf::userdata::copy( uf::MemoryPool& requestedMemoryPool, const pod::Userdata* userdata ) { if ( !userdata || userdata->len <= 0 ) return NULL; auto* copied = uf::userdata::create( userdata->len, const_cast((const void*) &userdata->data[0]) ); copied->type = userdata->type; return copied; } -uf::stl::string UF_API uf::userdata::toBase64( pod::Userdata* userdata ) { +uf::stl::string uf::userdata::toBase64( pod::Userdata* userdata ) { return uf::base64::encode( userdata->data, userdata->len ); } -pod::Userdata* UF_API uf::userdata::fromBase64( const uf::stl::string& base64 ) { +pod::Userdata* uf::userdata::fromBase64( const uf::stl::string& base64 ) { uf::stl::vector decoded = uf::base64::decode( base64 ); return uf::userdata::create( decoded.size(), decoded.data() ); } diff --git a/ext/behaviors/light/behavior.cpp b/ext/behaviors/light/behavior.cpp index 3fc3ad32..e62752d8 100644 --- a/ext/behaviors/light/behavior.cpp +++ b/ext/behaviors/light/behavior.cpp @@ -94,7 +94,7 @@ void ext::LightBehavior::initialize( uf::Object& self ) { } if ( radius.y < radius.x ) radius.y = 256; camera.setProjection( uf::matrix::perspective( fov, (float) size.x / (float) size.y, radius.x, radius.y ) ); - camera.update(true); + // camera.update(true); uf::stl::string name = "RT:" + std::to_string((int) this->getUid()); renderMode.blitter.process = false; @@ -222,7 +222,7 @@ void ext::LightBehavior::tick( uf::Object& self ) { camera.setView( uf::matrix::inverse( model ), i ); } } else { - camera.update(true); + // camera.update(true); } } } diff --git a/ext/behaviors/player/behavior.cpp b/ext/behaviors/player/behavior.cpp index f2789552..160bc27e 100644 --- a/ext/behaviors/player/behavior.cpp +++ b/ext/behaviors/player/behavior.cpp @@ -71,7 +71,7 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) { } camera.setProjection( uf::matrix::perspective( fov, raidou, range.x, range.y ) ); } - camera.update(true); + // camera.update(true); } // sloppy @@ -529,7 +529,7 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { } } #endif - camera.update(true); +// camera.update(true); #if UF_ENTITY_METADATA_USE_JSON metadata.serialize(self, metadataJson); diff --git a/ext/behaviors/raytrace/behavior.cpp b/ext/behaviors/raytrace/behavior.cpp index 3023bdf9..850061ff 100644 --- a/ext/behaviors/raytrace/behavior.cpp +++ b/ext/behaviors/raytrace/behavior.cpp @@ -77,7 +77,7 @@ void ext::RayTraceSceneBehavior::initialize( uf::Object& self ) { ); auto& renderMode = uf::renderer::getRenderMode("Compute:RT", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); blitter.material.textures.emplace_back().aliasTexture( ::emptyTexture ); } #endif @@ -104,7 +104,7 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) { bool update = false; auto& renderMode = uf::renderer::getRenderMode("", true); - auto& graphic = metadata.renderer.full ? this->getComponent() : *renderMode.getBlitter(); + auto& graphic = metadata.renderer.full ? this->getComponent() : renderMode.getBlitter(); if ( !metadata.renderer.bound ) { if ( metadata.renderer.full ) { graphic.initialize("Compute:RT"); @@ -240,7 +240,7 @@ void ext::RayTraceSceneBehavior::tick( uf::Object& self ) { auto& image = shader.textures.front(); auto& renderMode = uf::renderer::getRenderMode("Compute:RT", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); if ( blitter.material.hasShader("fragment") ) { auto& shader = blitter.material.getShader("fragment"); diff --git a/ext/behaviors/scene/behavior.cpp b/ext/behaviors/scene/behavior.cpp index 86462c9b..24a6d450 100644 --- a/ext/behaviors/scene/behavior.cpp +++ b/ext/behaviors/scene/behavior.cpp @@ -597,7 +597,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) { #endif /* Update lights */ if ( uf::renderer::settings::pipelines::deferred && !uf::renderer::settings::pipelines::vxgi ) { auto& deferredRenderMode = uf::renderer::getRenderMode("", true); - auto& deferredBlitter = *deferredRenderMode.getBlitter(); + auto& deferredBlitter = deferredRenderMode.getBlitter(); if ( deferredBlitter.material.hasShader("compute", "deferred") ) { ext::ExtSceneBehavior::bindBuffers( *this, "", "compute", "deferred" ); } else { @@ -607,7 +607,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) { /* Update post processing */ { auto& renderMode = uf::renderer::getRenderMode("", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); if ( blitter.material.hasShader("fragment") ) { auto& shader = blitter.material.getShader("fragment"); @@ -780,7 +780,7 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali if ( uf::renderer::settings::pipelines::bloom ) { auto& renderMode = uf::renderer::getRenderMode("", true); - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); auto& shader = blitter.material.getShader("compute", "bloom"); struct UniformDescriptor { @@ -812,9 +812,7 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, const uf::stl::string& renderModeName, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) { auto& renderMode = uf::renderer::getRenderMode(renderModeName, true); - auto blitters = renderMode.getBlitters(); - - bindBuffers( self, *blitters.front(), shaderType, shaderPipeline ); + bindBuffers( self, renderMode.getBlitter(), shaderType, shaderPipeline ); } void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic& graphic, const uf::stl::string& shaderType, const uf::stl::string& shaderPipeline ) { auto/*&*/ graph = this->getGraph(); diff --git a/ext/behaviors/voxelizer/behavior.cpp b/ext/behaviors/voxelizer/behavior.cpp index 83d139e5..cac54e68 100644 --- a/ext/behaviors/voxelizer/behavior.cpp +++ b/ext/behaviors/voxelizer/behavior.cpp @@ -220,23 +220,6 @@ void ext::VoxelizerSceneBehavior::tick( uf::Object& self ) { /*alignas(4)*/ uint32_t padding3; }; - - #if UF_UNIFORMS_REUSE - auto& uniform = shader.getUniform("UBO"); - auto& uniforms = uniform.get(); - - uniforms = UniformDescriptor{ - .matrix = metadata.extents.matrix, - .cascadePower = metadata.cascadePower, - .granularity = metadata.granularity, - .voxelizeScale = 1.0f / (metadata.voxelizeScale * std::max( metadata.voxelSize.x, std::max(metadata.voxelSize.y, metadata.voxelSize.z))), - .occlusionFalloff = metadata.occlusionFalloff, - - .traceStartOffsetFactor = metadata.traceStartOffsetFactor, - .shadows = metadata.shadows, - }; - shader.updateUniform( "UBO", uniform ); - #else UniformDescriptor uniforms = { .matrix = metadata.extents.matrix, .cascadePower = metadata.cascadePower, @@ -248,7 +231,6 @@ void ext::VoxelizerSceneBehavior::tick( uf::Object& self ) { .shadows = metadata.shadows, }; shader.updateBuffer( (const void*) &uniforms, sizeof(uniforms), shader.getUniformBuffer("UBO") ); - #endif } } } @@ -258,7 +240,7 @@ void ext::VoxelizerSceneBehavior::tick( uf::Object& self ) { ext::ExtSceneBehavior::bindBuffers( scene, metadata.renderModeName, "compute", "" ); auto& deferredRenderMode = uf::renderer::getRenderMode("", true); - auto& deferredBlitter = *deferredRenderMode.getBlitter(); + auto& deferredBlitter = deferredRenderMode.getBlitter(); if ( deferredBlitter.material.hasShader("compute", "deferred") ) { ext::ExtSceneBehavior::bindBuffers( scene, "", "compute", "deferred" ); } else { diff --git a/ext/gui/behavior.cpp b/ext/gui/behavior.cpp index 4cbf1309..f307a3cd 100644 --- a/ext/gui/behavior.cpp +++ b/ext/gui/behavior.cpp @@ -67,7 +67,7 @@ namespace { "hoverable" }; - struct /*UF_API*/ GuiMesh { + struct GuiMesh { pod::Vector3f position; pod::Vector2f uv; #if EXT_COLOR_FLOATS diff --git a/ext/gui/manager/behavior.cpp b/ext/gui/manager/behavior.cpp index d82b1396..e394dcb7 100644 --- a/ext/gui/manager/behavior.cpp +++ b/ext/gui/manager/behavior.cpp @@ -121,7 +121,7 @@ void ext::GuiManagerBehavior::tick( uf::Object& self ) { renderModePointer = (uf::renderer::RenderTargetRenderMode*) &uf::renderer::getRenderMode( "Gui", true ); } auto& renderMode = *renderModePointer; - auto& blitter = *renderMode.getBlitter(); + auto& blitter = renderMode.getBlitter(); if ( blitter.material.hasShader("fragment") ) { auto& shader = blitter.material.getShader("fragment"); diff --git a/ext/main.cpp b/ext/main.cpp index ed84404c..f7b2f9c1 100644 --- a/ext/main.cpp +++ b/ext/main.cpp @@ -408,6 +408,7 @@ void EXT_API ext::initialize() { */ #if 1 + uf::renderer::settings::experimental::dedicatedThread = false; ::requestDedicatedRenderThread = configRenderExperimentalJson["dedicated thread"].as( uf::renderer::settings::experimental::dedicatedThread ); #else uf::renderer::settings::experimental::dedicatedThread = configRenderExperimentalJson["dedicated thread"].as( uf::renderer::settings::experimental::dedicatedThread ); @@ -717,11 +718,6 @@ void EXT_API ext::tick() { /* Tick controllers */ { spec::controller::tick(); } -#if UF_USE_FFX_FSR - /* FFX FSR */ if ( ext::fsr::initialized ) { - ext::fsr::tick(); - } -#endif #if UF_USE_OPENVR /* OpenVR */ if ( ext::openvr::context ) { ext::openvr::tick(); @@ -834,7 +830,7 @@ void EXT_API ext::tick() { timer.reset(); } - if ( ::requestDedicatedRenderThread ) { + if ( ::requestDedicatedRenderThread && uf::scene::getCurrentScene().getController().getName() == "Player" ) { ::requestDedicatedRenderThread = false; uf::renderer::settings::experimental::dedicatedThread = true; // uf::renderer::settings::experimental::rebuildOnTickBegin = true; diff --git a/makefiles/default/cc b/makefiles/default/cc index b08d5af5..060d289b 100644 --- a/makefiles/default/cc +++ b/makefiles/default/cc @@ -1 +1 @@ -gcc \ No newline at end of file +clang \ No newline at end of file diff --git a/makefiles/win64.clang.make b/makefiles/win64.clang.make index 16f4c3f4..da3b73db 100644 --- a/makefiles/win64.clang.make +++ b/makefiles/win64.clang.make @@ -2,7 +2,7 @@ ARCH = win64 CDIR = CC = clang CXX = clang++ -OPTIMIZATIONS = -O3 -fstrict-aliasing -flto +OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS -march=native -flto WARNINGS = -g -Wall -Wno-pointer-arith -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder-ctor -Wno-ignored-attributes -Wno-c++11-narrowing -Wno-unknown-pragmas -Wno-nullability-completeness -Wno-defaulted-function-deleted -Wno-mismatched-tags SANITIZE = -fuse-ld=lld # -fsanitize=address -fno-omit-frame-pointer FLAGS += -std=c++17 $(OPTIMIZATIONS) $(WARNINGS) $(SANITIZE) -fcolor-diagnostics -fansi-escape-codes \ No newline at end of file