From 343ed65b7cd41bba14e78f2b3960d4bd19568a82 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Oct 2018 17:01:02 +0100 Subject: [PATCH 1/9] Added vsg::Allocator base class. --- include/vsg/core/Allocator.h | 33 ++++++++++++++++++++++++++++ include/vsg/core/Auxiliary.h | 13 +++++------ include/vsg/core/Object.h | 4 ++++ src/vsg/CMakeLists.txt | 1 + src/vsg/core/Allocator.cpp | 42 ++++++++++++++++++++++++++++++++++++ src/vsg/core/Auxiliary.cpp | 2 +- src/vsg/core/Object.cpp | 37 ++++++++++++++++++++++++++++--- 7 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 include/vsg/core/Allocator.h create mode 100644 src/vsg/core/Allocator.cpp diff --git a/include/vsg/core/Allocator.h b/include/vsg/core/Allocator.h new file mode 100644 index 0000000000..299b6a0fe7 --- /dev/null +++ b/include/vsg/core/Allocator.h @@ -0,0 +1,33 @@ +#pragma once + +/* + +Copyright(c) 2018 Robert Osfield + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + */ + +#include + +namespace vsg +{ + + class Allocator : public vsg::Object + { + public: + virtual void* allocate(std::size_t n, const void* hint ); + + virtual void* allocate(std::size_t size); + + virtual void deallocate(const void* ptr, std::size_t size=0); + + protected: + virtual ~Allocator(); + }; + +} diff --git a/include/vsg/core/Auxiliary.h b/include/vsg/core/Auxiliary.h index 152bbfec4b..453e652e00 100644 --- a/include/vsg/core/Auxiliary.h +++ b/include/vsg/core/Auxiliary.h @@ -12,11 +12,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include +#include #include #include -#include namespace vsg { @@ -43,6 +42,9 @@ namespace vsg ObjectMap& getObjectMap() { return _objectMap; } const ObjectMap& getObjectMap() const { return _objectMap; } + void setAllocator(Allocator* allocator) { _allocator = allocator; } + Allocator* getAllocator() { return _allocator; } + protected: virtual ~Auxiliary(); @@ -56,10 +58,9 @@ namespace vsg friend class Object; mutable std::atomic_uint _referenceCount; - - std::atomic _connectedObject; - - ObjectMap _objectMap; + std::atomic _connectedObject; + ref_ptr _allocator; + ObjectMap _objectMap; }; diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index fbc07cfe8a..34b5e3c112 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -26,6 +26,7 @@ namespace vsg class Auxiliary; class Visitor; class DispatchTraversal; + class Allocator; class VSG_EXPORT Object { @@ -78,10 +79,13 @@ namespace vsg Object* getObject(const Key& key); const Object* getObject(const Key& key) const; + void setAuxiliary(Auxiliary* auxiliary); Auxiliary* getOrCreateAuxiliary(); Auxiliary* getAuxiliary() { return _auxiliary; } const Auxiliary* getAuxiliary() const { return _auxiliary; } + Allocator* getAllocator() const; + protected: virtual ~Object(); diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 9af405f0ca..de7b2f1c2f 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -7,6 +7,7 @@ INCLUDE_DIRECTORIES( SET(SOURCES + core/Allocator.cpp core/Auxiliary.cpp core/Object.cpp core/Result.cpp diff --git a/src/vsg/core/Allocator.cpp b/src/vsg/core/Allocator.cpp new file mode 100644 index 0000000000..e767e6b1c0 --- /dev/null +++ b/src/vsg/core/Allocator.cpp @@ -0,0 +1,42 @@ +/* + +Copyright(c) 2018 Robert Osfield + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + */ + +#include + +#include + +using namespace vsg; + + +Allocator::~Allocator() +{ +} + +void* Allocator::allocate(std::size_t n, const void* hint ) +{ + std::cout<<"Allocator::allocate(std::size_t "<(ptr)); +} diff --git a/src/vsg/core/Auxiliary.cpp b/src/vsg/core/Auxiliary.cpp index eb8b8556a8..39ce16b304 100644 --- a/src/vsg/core/Auxiliary.cpp +++ b/src/vsg/core/Auxiliary.cpp @@ -57,7 +57,7 @@ void Auxiliary::setConnectedObject(Object* object) bool Auxiliary::signalConnectedObjectToBeDeleted() { Object* previousPtr = _connectedObject.exchange(0); - if (previousPtr->referenceCount()>0) + if (previousPtr && previousPtr->referenceCount()>0) { // referenceCount has been incremented by another thread, so now restore the _connectedObject _connectedObject.exchange(previousPtr); diff --git a/src/vsg/core/Object.cpp b/src/vsg/core/Object.cpp index 9aa21aefff..efcd08b3a1 100644 --- a/src/vsg/core/Object.cpp +++ b/src/vsg/core/Object.cpp @@ -28,6 +28,8 @@ Object::Object() : Object::~Object() { + std::cout<<"Object::~Object() "<setConnectedObject(0); @@ -43,9 +45,21 @@ void Object::_delete() const // if no auxiliary is attached then go straight ahead and delete. if (_auxiliary==nullptr || _auxiliary->signalConnectedObjectToBeDeleted()) { - //std::cout<<"Object::_delete() "< allocator = getAllocator(); + if (allocator) + { + std::cout<<"Calling this->~Object();"<~Object(); + + std::cout<<"After Calling this->~Object();"<deallocate(this); + } + else + { + delete this; + } } else { @@ -80,6 +94,19 @@ const Object* Object::getObject(const Key& key) const return _auxiliary->getObject(key); } +void Object::setAuxiliary(Auxiliary* auxiliary) +{ + if (_auxiliary) + { + _auxiliary->setConnectedObject(nullptr); + _auxiliary->unref(); + } + _auxiliary = auxiliary; + if (auxiliary) + { + auxiliary->ref(); + } +} Auxiliary* Object::getOrCreateAuxiliary() { @@ -93,3 +120,7 @@ Auxiliary* Object::getOrCreateAuxiliary() } +Allocator* Object::getAllocator() const +{ + return _auxiliary ? _auxiliary->getAllocator() : 0; +} From 437a650678d7a47a4c5c15053de6578c35b158c1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Oct 2018 10:35:47 +0100 Subject: [PATCH 2/9] Added Auxuliary constructors to streamline creation process. --- include/vsg/core/Auxiliary.h | 11 ++++++----- src/vsg/core/Auxiliary.cpp | 12 ++++++++++-- src/vsg/core/Object.cpp | 5 ++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/vsg/core/Auxiliary.h b/include/vsg/core/Auxiliary.h index 453e652e00..cbf6e59205 100644 --- a/include/vsg/core/Auxiliary.h +++ b/include/vsg/core/Auxiliary.h @@ -24,7 +24,8 @@ namespace vsg class VSG_EXPORT Auxiliary { public: - Auxiliary(); + Auxiliary(Allocator* allocator); + Auxiliary(Object* object, Allocator* allocator=nullptr); Object* getConnectedObject() { return _connectedObject; } const Object* getConnectedObject() const { return _connectedObject; } @@ -57,10 +58,10 @@ namespace vsg friend class Object; - mutable std::atomic_uint _referenceCount; - std::atomic _connectedObject; - ref_ptr _allocator; - ObjectMap _objectMap; + mutable std::atomic_uint _referenceCount; + std::atomic _connectedObject; + ref_ptr _allocator; + ObjectMap _objectMap; }; diff --git a/src/vsg/core/Auxiliary.cpp b/src/vsg/core/Auxiliary.cpp index 39ce16b304..7d2368689e 100644 --- a/src/vsg/core/Auxiliary.cpp +++ b/src/vsg/core/Auxiliary.cpp @@ -14,13 +14,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI using namespace vsg; -Auxiliary::Auxiliary() : +Auxiliary::Auxiliary(Allocator* allocator) : _referenceCount(0), - _connectedObject(0) + _connectedObject(0), + _allocator(allocator) { //std::cout<<"Auxiliary::Auxiliary() "<setConnectedObject(0); + _auxiliary->setConnectedObject(nullptr); _auxiliary->unref(); } } @@ -112,9 +112,8 @@ Auxiliary* Object::getOrCreateAuxiliary() { if (!_auxiliary) { - _auxiliary = new Auxiliary; + _auxiliary = new Auxiliary(this); _auxiliary->ref(); - _auxiliary->setConnectedObject(this); } return _auxiliary; } From 9cc71f3797a21b59485ea67d901f2944c94deb1a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Oct 2018 11:16:09 +0100 Subject: [PATCH 3/9] Replaced the Auxiliary::setConnectedObject(..) with resetConnectedObject() --- include/vsg/core/Auxiliary.h | 4 ++-- src/vsg/core/Auxiliary.cpp | 12 +++++------- src/vsg/core/Object.cpp | 5 +++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/vsg/core/Auxiliary.h b/include/vsg/core/Auxiliary.h index cbf6e59205..5faef9f124 100644 --- a/include/vsg/core/Auxiliary.h +++ b/include/vsg/core/Auxiliary.h @@ -50,12 +50,12 @@ namespace vsg virtual ~Auxiliary(); - void setConnectedObject(Object* object); - /// reset the ConnectedObject pointer to 0 unless the ConnectedObject referenceCount goes back above 0, /// return true if ConnectedObject should still be deleted, or false if the object should be kept. bool signalConnectedObjectToBeDeleted(); + void resetConnectedObject(); + friend class Object; mutable std::atomic_uint _referenceCount; diff --git a/src/vsg/core/Auxiliary.cpp b/src/vsg/core/Auxiliary.cpp index 7d2368689e..430e7fdc95 100644 --- a/src/vsg/core/Auxiliary.cpp +++ b/src/vsg/core/Auxiliary.cpp @@ -55,13 +55,6 @@ void Auxiliary::unref_nodelete() const --_referenceCount; } - -void Auxiliary::setConnectedObject(Object* object) -{ - _connectedObject = object; - //std::cout<<"Auxiliary::setConnectedObject("< +#include + using namespace vsg; Auxiliary::Auxiliary(Allocator* allocator) : @@ -19,7 +21,7 @@ Auxiliary::Auxiliary(Allocator* allocator) : _connectedObject(0), _allocator(allocator) { - //std::cout<<"Auxiliary::Auxiliary() "<second.get(); else return nullptr; @@ -93,7 +96,7 @@ Object* Auxiliary::getObject(const Object::Key& key) const Object* Auxiliary::getObject(const Object::Key& key) const { - //std::cout<<"Auxiliary::getObject( ["<second.get(); else return nullptr; diff --git a/src/vsg/core/Object.cpp b/src/vsg/core/Object.cpp index 3802cdbd13..11d664da68 100644 --- a/src/vsg/core/Object.cpp +++ b/src/vsg/core/Object.cpp @@ -78,7 +78,7 @@ void Object::accept(DispatchTraversal& visitor) const void Object::setObject(const Key& key, Object* object) { - getOrCreateAuxiliary()->setObject(key, object); + getOrCreateUniqueAuxiliary()->setObject(key, object); } Object* Object::getObject(const Key& key) @@ -109,13 +109,30 @@ void Object::setAuxiliary(Auxiliary* auxiliary) } } -Auxiliary* Object::getOrCreateAuxiliary() +Auxiliary* Object::getOrCreateUniqueAuxiliary() { + std::cout<<"Object::getOrCreateUniqueAuxiliary() _auxiliary="<<_auxiliary<ref(); } + else + { + if (_auxiliary->getConnectedObject()!=this) + { + + + Auxiliary* previousAuxiliary = _auxiliary; + + _auxiliary = new Auxiliary(this, _auxiliary->getAllocator()); + _auxiliary->ref(); + + std::cout<<"Object::getOrCreateUniqueAuxiliary() _auxiliary="<<_auxiliary<<" replaces previousAuxiliary="<unref(); + } + } return _auxiliary; } From 475ac5e70fccd3af7168aba69b3975a7b097233c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Oct 2018 12:22:23 +0100 Subject: [PATCH 5/9] Added Allocator::getOrCreateSharedAuxiliary() and detachSharedAuxiliary() to enable easier reuse of Auxiliary between muliple Objects that have been allocated. --- include/vsg/core/Allocator.h | 6 ++++++ src/vsg/core/Allocator.cpp | 28 ++++++++++++++++++++++++++++ src/vsg/core/Auxiliary.cpp | 1 + src/vsg/core/Object.cpp | 2 -- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/vsg/core/Allocator.h b/include/vsg/core/Allocator.h index 299b6a0fe7..2a7558c2f5 100644 --- a/include/vsg/core/Allocator.h +++ b/include/vsg/core/Allocator.h @@ -26,8 +26,14 @@ namespace vsg virtual void deallocate(const void* ptr, std::size_t size=0); + Auxiliary* getOrCreateSharedAuxiliary(); + + void detachSharedAuxiliary(Auxiliary* auxiliary); + protected: virtual ~Allocator(); + + Auxiliary* _sharedAuxiliary; }; } diff --git a/src/vsg/core/Allocator.cpp b/src/vsg/core/Allocator.cpp index 7c956ff796..8ca31bee41 100644 --- a/src/vsg/core/Allocator.cpp +++ b/src/vsg/core/Allocator.cpp @@ -11,6 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ #include +#include #include @@ -41,3 +42,30 @@ void Allocator::deallocate(const void* ptr, std::size_t size) std::cout<<"Allocator::deallocate("<(ptr)); } + +Auxiliary* Allocator::getOrCreateSharedAuxiliary() +{ + if (!_sharedAuxiliary) + { + _sharedAuxiliary = new Auxiliary(this); + std::cout<<"Allocator::getOrCreateSharedAuxiliary() creating new : "<<_sharedAuxiliary<detachSharedAuxiliary(this); } void Auxiliary::ref() const diff --git a/src/vsg/core/Object.cpp b/src/vsg/core/Object.cpp index 11d664da68..fe2059943e 100644 --- a/src/vsg/core/Object.cpp +++ b/src/vsg/core/Object.cpp @@ -121,8 +121,6 @@ Auxiliary* Object::getOrCreateUniqueAuxiliary() { if (_auxiliary->getConnectedObject()!=this) { - - Auxiliary* previousAuxiliary = _auxiliary; _auxiliary = new Auxiliary(this, _auxiliary->getAllocator()); From a231c0973451c734141a80c433e4ff489e44e381 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Oct 2018 13:30:16 +0100 Subject: [PATCH 6/9] Added Allocator::create<> template to standardize allocation of objects. Moved Auxiliar creation methods into private/protected space and added friends to prevent the configuration of Auxiliary objects from being mishandled. --- include/vsg/core/Allocator.h | 11 +++++++++++ include/vsg/core/Auxiliary.h | 7 ++++--- include/vsg/core/Object.h | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/vsg/core/Allocator.h b/include/vsg/core/Allocator.h index 2a7558c2f5..c8efa610fc 100644 --- a/include/vsg/core/Allocator.h +++ b/include/vsg/core/Allocator.h @@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ #include +#include namespace vsg { @@ -30,6 +31,16 @@ namespace vsg void detachSharedAuxiliary(Auxiliary* auxiliary); + template + ref_ptr create(Args&&... args) + { + // need to think about alignment... + void* ptr = allocate(sizeof(T)); + T* object = new (ptr) T(std::forward(args)...); + object->setAuxiliary(getOrCreateSharedAuxiliary()); + return object; + } + protected: virtual ~Allocator(); diff --git a/include/vsg/core/Auxiliary.h b/include/vsg/core/Auxiliary.h index 5faef9f124..1be737e779 100644 --- a/include/vsg/core/Auxiliary.h +++ b/include/vsg/core/Auxiliary.h @@ -24,9 +24,6 @@ namespace vsg class VSG_EXPORT Auxiliary { public: - Auxiliary(Allocator* allocator); - Auxiliary(Object* object, Allocator* allocator=nullptr); - Object* getConnectedObject() { return _connectedObject; } const Object* getConnectedObject() const { return _connectedObject; } @@ -48,6 +45,9 @@ namespace vsg protected: + Auxiliary(Allocator* allocator); + Auxiliary(Object* object, Allocator* allocator=nullptr); + virtual ~Auxiliary(); /// reset the ConnectedObject pointer to 0 unless the ConnectedObject referenceCount goes back above 0, @@ -57,6 +57,7 @@ namespace vsg void resetConnectedObject(); friend class Object; + friend class Allocator; mutable std::atomic_uint _referenceCount; std::atomic _connectedObject; diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index d962f73c90..178b4eb677 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -79,12 +79,10 @@ namespace vsg Object* getObject(const Key& key); const Object* getObject(const Key& key) const; - void setAuxiliary(Auxiliary* auxiliary); + Auxiliary* getOrCreateUniqueAuxiliary(); Auxiliary* getAuxiliary() { return _auxiliary; } const Auxiliary* getAuxiliary() const { return _auxiliary; } - Auxiliary* getOrCreateUniqueAuxiliary(); - Allocator* getAllocator() const; protected: @@ -93,6 +91,11 @@ namespace vsg private: virtual void _delete() const; + friend class Allocator; + friend class Auxiliary; + + void setAuxiliary(Auxiliary* auxiliary); + mutable std::atomic_uint _referenceCount; Auxiliary* _auxiliary; From 63928ef5a9942faa9669c0f600a6f7faab6e485d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 10 Oct 2018 12:01:07 +0100 Subject: [PATCH 7/9] Added vsg::Inherit template that utilizes the Curiously Reacurring Template Pattern to provide the standard accept and getSizeOf() implementations for the range of subclasses from vsg::Object --- include/vsg/core/Allocator.h | 21 +++++++++++++---- include/vsg/core/Array.h | 2 ++ include/vsg/core/Auxiliary.h | 2 ++ include/vsg/core/Data.h | 2 ++ include/vsg/core/Inherit.h | 35 ++++++++++++++++++++++++++++ include/vsg/core/Object.h | 6 +++-- include/vsg/core/Value.h | 2 ++ include/vsg/nodes/FixedGroup.h | 5 +--- include/vsg/nodes/Group.h | 6 ++--- include/vsg/nodes/LOD.h | 12 ++++------ include/vsg/nodes/Node.h | 9 ++----- include/vsg/nodes/QuadGroup.h | 5 +--- include/vsg/nodes/StateGroup.h | 7 ++---- include/vsg/viewer/GraphicsStage.h | 2 +- include/vsg/viewer/Viewer.h | 2 +- include/vsg/viewer/Window.h | 2 +- include/vsg/vk/AllocationCallbacks.h | 4 ++-- include/vsg/vk/BindIndexBuffer.h | 4 +--- include/vsg/vk/BindVertexBuffers.h | 4 +--- include/vsg/vk/Buffer.h | 2 +- include/vsg/vk/BufferView.h | 2 +- include/vsg/vk/Command.h | 4 +--- include/vsg/vk/CommandBuffer.h | 2 +- include/vsg/vk/CommandPool.h | 2 +- include/vsg/vk/ComputePipeline.h | 4 +--- include/vsg/vk/Descriptor.h | 14 +++++------ include/vsg/vk/DescriptorPool.h | 2 +- include/vsg/vk/DescriptorSet.h | 2 +- include/vsg/vk/DescriptorSetLayout.h | 2 +- include/vsg/vk/Device.h | 2 +- include/vsg/vk/DeviceMemory.h | 2 +- include/vsg/vk/Draw.h | 8 ++----- include/vsg/vk/Fence.h | 2 +- include/vsg/vk/Framebuffer.h | 2 +- include/vsg/vk/GraphicsPipeline.h | 22 ++++++++--------- include/vsg/vk/Image.h | 4 ++-- include/vsg/vk/ImageView.h | 2 +- include/vsg/vk/Instance.h | 2 +- include/vsg/vk/MemoryManager.h | 2 +- include/vsg/vk/PhysicalDevice.h | 2 +- include/vsg/vk/Pipeline.h | 6 ++--- include/vsg/vk/PipelineLayout.h | 2 +- include/vsg/vk/PushConstants.h | 8 +++---- include/vsg/vk/RenderPass.h | 3 +-- include/vsg/vk/Sampler.h | 2 +- include/vsg/vk/Semaphore.h | 2 +- include/vsg/vk/ShaderModule.h | 4 ++-- include/vsg/vk/State.h | 4 ++-- include/vsg/vk/Surface.h | 2 +- include/vsg/vk/Swapchain.h | 2 +- src/vsg/core/Allocator.cpp | 20 ++++++++++++---- src/vsg/core/Auxiliary.cpp | 17 +++++++++++++- src/vsg/core/Object.cpp | 16 +++++++++++-- src/vsg/vk/ComputePipeline.cpp | 2 +- src/vsg/vk/GraphicsPipeline.cpp | 2 +- 55 files changed, 184 insertions(+), 126 deletions(-) create mode 100644 include/vsg/core/Inherit.h diff --git a/include/vsg/core/Allocator.h b/include/vsg/core/Allocator.h index c8efa610fc..f79a46fa30 100644 --- a/include/vsg/core/Allocator.h +++ b/include/vsg/core/Allocator.h @@ -12,13 +12,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include +#include #include +#include + namespace vsg { - class Allocator : public vsg::Object + class Allocator : public Inherit { public: virtual void* allocate(std::size_t n, const void* hint ); @@ -35,16 +37,27 @@ namespace vsg ref_ptr create(Args&&... args) { // need to think about alignment... - void* ptr = allocate(sizeof(T)); + std::size_t size = sizeof(T); + void* ptr = allocate(size); T* object = new (ptr) T(std::forward(args)...); object->setAuxiliary(getOrCreateSharedAuxiliary()); + + std::size_t new_size = object->getSizeOf(); + if (new_size != size) + { + std::cout<<"Warning: Allocator::create("< l) : _size(l.size()), _data(new value_type[l.size()]) { value_type* ptr = _data; for (value_type const & v : l) { (*ptr++) = v; } } Array(const Array& rhs) : _data(rhs.data) {} + std::size_t getSizeOf() const noexcept override { return sizeof(Data); } + // implementation provided by Visitor.h void accept(Visitor& visitor) override ; diff --git a/include/vsg/core/Auxiliary.h b/include/vsg/core/Auxiliary.h index 1be737e779..3a8299d02d 100644 --- a/include/vsg/core/Auxiliary.h +++ b/include/vsg/core/Auxiliary.h @@ -27,6 +27,8 @@ namespace vsg Object* getConnectedObject() { return _connectedObject; } const Object* getConnectedObject() const { return _connectedObject; } + virtual std::size_t getSizeOf() const { return sizeof(Auxiliary); } + void ref() const; void unref() const; void unref_nodelete() const; diff --git a/include/vsg/core/Data.h b/include/vsg/core/Data.h index 9d1973f48f..854b9a0fdf 100644 --- a/include/vsg/core/Data.h +++ b/include/vsg/core/Data.h @@ -22,6 +22,8 @@ namespace vsg Data() {}; + std::size_t getSizeOf() const noexcept override { return sizeof(Data); } + virtual std::size_t valueSize() const = 0; virtual std::size_t valueCount() const = 0; diff --git a/include/vsg/core/Inherit.h b/include/vsg/core/Inherit.h new file mode 100644 index 0000000000..ea0d6ae053 --- /dev/null +++ b/include/vsg/core/Inherit.h @@ -0,0 +1,35 @@ +#pragma once + +/* + +Copyright(c) 2018 Robert Osfield + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + */ + +#include +#include + +namespace vsg +{ + + // Use the Curiously Reacurring Template Pattern + // to provide the classes versions of accept(..) and getSizeOf() + template + class Inherit : public ParentClass + { + public: + template + Inherit(Args&&... args) : ParentClass(std::forward(args)...) {} + + void accept(Visitor& visitor) override { visitor.apply(static_cast(*this)); } + void accept(DispatchTraversal& visitor) const override { visitor.apply(static_cast(*this)); } + std::size_t getSizeOf() const noexcept override { return sizeof(Subclass); } + }; + +} diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index 178b4eb677..088e231cd3 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -36,6 +36,8 @@ namespace vsg Object(const Object&) = delete; Object& operator = (const Object&) = delete; + virtual std::size_t getSizeOf() const noexcept { return sizeof(Object); } + virtual void accept(Visitor& visitor); virtual void traverse(Visitor&) {} @@ -91,11 +93,11 @@ namespace vsg private: virtual void _delete() const; + void setAuxiliary(Auxiliary* auxiliary); + friend class Allocator; friend class Auxiliary; - void setAuxiliary(Auxiliary* auxiliary); - mutable std::atomic_uint _referenceCount; Auxiliary* _auxiliary; diff --git a/include/vsg/core/Value.h b/include/vsg/core/Value.h index 265c83fee9..e1c8d810cf 100644 --- a/include/vsg/core/Value.h +++ b/include/vsg/core/Value.h @@ -31,6 +31,8 @@ namespace vsg Value(const value_type& in_value) : _value(in_value) {} Value(const Value& rhs) : _value(rhs._value) {} + std::size_t getSizeOf() const noexcept override { return sizeof(Value); } + // implementation provided by Visitor.h void accept(Visitor& visitor) override; diff --git a/include/vsg/nodes/FixedGroup.h b/include/vsg/nodes/FixedGroup.h index 26afdaa9da..a2516f07be 100644 --- a/include/vsg/nodes/FixedGroup.h +++ b/include/vsg/nodes/FixedGroup.h @@ -21,17 +21,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { template - class FixedGroup : public vsg::Node + class FixedGroup : public Inherit> { public: FixedGroup() {} template static void t_traverse(N& node, V& visitor) { for (auto& child : node._children) child->accept(visitor); } - void accept(Visitor& visitor) override { visitor.apply(*this); } void traverse(Visitor& visitor) override { t_traverse(*this, visitor); } - - void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } void traverse(DispatchTraversal& visitor) const override { t_traverse(*this, visitor); } void setChild(std::size_t pos, vsg::Node* node) { _children[pos] = node; } diff --git a/include/vsg/nodes/Group.h b/include/vsg/nodes/Group.h index e3e7c3fed1..5a7ffd414c 100644 --- a/include/vsg/nodes/Group.h +++ b/include/vsg/nodes/Group.h @@ -21,17 +21,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Group : public vsg::Node + class VSG_EXPORT Group : public Inherit { public: Group(size_t numChildren=0); template static void t_traverse(N& node, V& visitor) { for (auto& child : node._children) child->accept(visitor); } - void accept(Visitor& visitor) override { visitor.apply(*this); } void traverse(Visitor& visitor) override { t_traverse(*this, visitor); } - - void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } void traverse(DispatchTraversal& visitor) const override { t_traverse(*this, visitor); } std::size_t addChild(vsg::Node* child) { std::size_t pos = _children.size(); _children.push_back(child); return pos; } @@ -55,4 +52,5 @@ namespace vsg Children _children; }; + } diff --git a/include/vsg/nodes/LOD.h b/include/vsg/nodes/LOD.h index 9597ea3dd5..9af3c0f2cc 100644 --- a/include/vsg/nodes/LOD.h +++ b/include/vsg/nodes/LOD.h @@ -31,16 +31,14 @@ namespace vsg double radius; }; - class VSG_EXPORT LOD : public vsg::Node + class VSG_EXPORT LOD : public Inherit { public: LOD() {} template static void t_traverse(N& node, V& visitor) { for (auto& child : node._children) child->accept(visitor); } - inline void accept(Visitor& visitor) override { visitor.apply(*this); } inline void traverse(Visitor& visitor) override { t_traverse(*this, visitor); } - inline void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } inline void traverse(DispatchTraversal& visitor) const override { t_traverse(*this, visitor); } /// set the BondingSphere to use in culling/computation of which child is active. @@ -53,9 +51,9 @@ namespace vsg void setMinimumArea(std::size_t pos, double area) { _minimumAreas[pos] = area; } double getMinimumArea(std::size_t pos) const { return _minimumAreas[pos]; } - void setChild(std::size_t pos, vsg::Node* node) { _children[pos] = node;} - vsg::Node* getChild(std::size_t pos) { return _children[pos].get(); } - const vsg::Node* getChild(std::size_t pos) const { return _children[pos].get(); } + void setChild(std::size_t pos, Node* node) { _children[pos] = node;} + Node* getChild(std::size_t pos) { return _children[pos].get(); } + const Node* getChild(std::size_t pos) const { return _children[pos].get(); } std::size_t getNumChildren() const { return 2; } @@ -63,7 +61,7 @@ namespace vsg MinimumAreas& getMinimumAreas() { return _minimumAreas; } const MinimumAreas& getMinimumAreas() const { return _minimumAreas; } - using Children = std::array< ref_ptr< vsg::Node>, 2 >; + using Children = std::array< ref_ptr, 2 >; Children& getChildren() { return _children; } const Children& getChildren() const { return _children; } diff --git a/include/vsg/nodes/Node.h b/include/vsg/nodes/Node.h index e1c62ce280..c7efcb8fe0 100644 --- a/include/vsg/nodes/Node.h +++ b/include/vsg/nodes/Node.h @@ -12,20 +12,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include -#include -#include +#include namespace vsg { - class VSG_EXPORT Node : public vsg::Object + class VSG_EXPORT Node : public Inherit { public: Node(); - void accept(Visitor& visitor) override { visitor.apply(*this); } - void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } - protected: virtual ~Node(); diff --git a/include/vsg/nodes/QuadGroup.h b/include/vsg/nodes/QuadGroup.h index 780db15a8a..4f4ddef954 100644 --- a/include/vsg/nodes/QuadGroup.h +++ b/include/vsg/nodes/QuadGroup.h @@ -23,17 +23,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT QuadGroup : public vsg::Node + class VSG_EXPORT QuadGroup : public Inherit { public: QuadGroup(); template static void t_traverse(N& node, V& visitor) { for(int i=0; i<4; ++i) node._children[i]->accept(visitor); } - void accept(Visitor& visitor) override { visitor.apply(*this); } void traverse(Visitor& visitor) override { t_traverse(*this, visitor); } - - void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } void traverse(DispatchTraversal& visitor) const override { t_traverse(*this, visitor); } void setChild(std::size_t pos, vsg::Node* node) { _children[pos] = node; } diff --git a/include/vsg/nodes/StateGroup.h b/include/vsg/nodes/StateGroup.h index 6d61019ff9..8b0f83d163 100644 --- a/include/vsg/nodes/StateGroup.h +++ b/include/vsg/nodes/StateGroup.h @@ -20,7 +20,7 @@ namespace vsg class State; class CommandBuffer; - class StateComponent : public Object + class StateComponent : public Inherit { public: StateComponent() {} @@ -34,14 +34,11 @@ namespace vsg virtual ~StateComponent() {} }; - class VSG_EXPORT StateGroup : public Group + class VSG_EXPORT StateGroup : public Inherit { public: StateGroup(); - void accept(Visitor& visitor) override { visitor.apply(*this); } - void accept(DispatchTraversal& visitor) const override { visitor.apply(*this); } - using StateComponents = std::vector>; void add(StateComponent* component) { _stateComponents.push_back(component); } diff --git a/include/vsg/viewer/GraphicsStage.h b/include/vsg/viewer/GraphicsStage.h index 31f613fec6..0c5bc8a3eb 100644 --- a/include/vsg/viewer/GraphicsStage.h +++ b/include/vsg/viewer/GraphicsStage.h @@ -36,7 +36,7 @@ namespace vsg }; - class VSG_EXPORT GraphicsStage : public Stage + class VSG_EXPORT GraphicsStage : public Inherit { public: diff --git a/include/vsg/viewer/Viewer.h b/include/vsg/viewer/Viewer.h index b2e3d3f4c7..cb63b6e6dc 100644 --- a/include/vsg/viewer/Viewer.h +++ b/include/vsg/viewer/Viewer.h @@ -19,7 +19,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Viewer : public Object + class VSG_EXPORT Viewer : public Inherit { public: Viewer(); diff --git a/include/vsg/viewer/Window.h b/include/vsg/viewer/Window.h index 92cc190c11..60d77a29ad 100644 --- a/include/vsg/viewer/Window.h +++ b/include/vsg/viewer/Window.h @@ -22,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Window : public Object + class VSG_EXPORT Window : public Inherit { public: diff --git a/include/vsg/vk/AllocationCallbacks.h b/include/vsg/vk/AllocationCallbacks.h index 40e07023e2..a5af4ff214 100644 --- a/include/vsg/vk/AllocationCallbacks.h +++ b/include/vsg/vk/AllocationCallbacks.h @@ -12,14 +12,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include +#include #include namespace vsg { - class AllocationCallbacks : public vsg::Object, public VkAllocationCallbacks + class AllocationCallbacks : public Inherit, public VkAllocationCallbacks { public: AllocationCallbacks() : diff --git a/include/vsg/vk/BindIndexBuffer.h b/include/vsg/vk/BindIndexBuffer.h index ad4068cbe0..f39d9143c1 100644 --- a/include/vsg/vk/BindIndexBuffer.h +++ b/include/vsg/vk/BindIndexBuffer.h @@ -19,7 +19,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT BindIndexBuffer : public StateComponent + class VSG_EXPORT BindIndexBuffer : public Inherit { public: @@ -27,8 +27,6 @@ namespace vsg BindIndexBuffer(const BufferData& bufferData, VkIndexType indexType) : _bufferData(bufferData), _indexType(indexType) {} - void accept(Visitor& visitor) override { visitor.apply(*this); } - void pushTo(State& state) override; void popFrom(State& state) override; void dispatch(CommandBuffer& commandBuffer) const override; diff --git a/include/vsg/vk/BindVertexBuffers.h b/include/vsg/vk/BindVertexBuffers.h index 052a633246..7c788ebf4c 100644 --- a/include/vsg/vk/BindVertexBuffers.h +++ b/include/vsg/vk/BindVertexBuffers.h @@ -19,7 +19,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT BindVertexBuffers : public StateComponent + class VSG_EXPORT BindVertexBuffers : public Inherit { public: @@ -33,8 +33,6 @@ namespace vsg } } - void accept(Visitor& visitor) override { visitor.apply(*this); } - void setFirstBinding(uint32_t firstBinding) { _firstBinding = firstBinding; } uint32_t getFirstBinding() const { return _firstBinding; } diff --git a/include/vsg/vk/Buffer.h b/include/vsg/vk/Buffer.h index 388ea1ddc5..64d0dca132 100644 --- a/include/vsg/vk/Buffer.h +++ b/include/vsg/vk/Buffer.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Buffer : public Object + class VSG_EXPORT Buffer : public Inherit { public: Buffer(VkBuffer Buffer, VkBufferUsageFlags usage, VkSharingMode sharingMode, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/BufferView.h b/include/vsg/vk/BufferView.h index bd9eea5c2d..a6d3b633c8 100644 --- a/include/vsg/vk/BufferView.h +++ b/include/vsg/vk/BufferView.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT BufferView : public Object + class VSG_EXPORT BufferView : public Inherit { public: BufferView(VkBufferView bufferView, Device* device, Buffer* buffer=nullptr, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Command.h b/include/vsg/vk/Command.h index 2a2fa3ffe8..1af9b66905 100644 --- a/include/vsg/vk/Command.h +++ b/include/vsg/vk/Command.h @@ -20,13 +20,11 @@ namespace vsg { class CommandBuffer; - class Command : public Node + class Command : public Inherit { public: Command() {} - virtual void accept(Visitor& visitor) { visitor.apply(*this); } - virtual void dispatch(CommandBuffer& commandBuffer) const = 0; }; } diff --git a/include/vsg/vk/CommandBuffer.h b/include/vsg/vk/CommandBuffer.h index c29f213cde..2f34bbc239 100644 --- a/include/vsg/vk/CommandBuffer.h +++ b/include/vsg/vk/CommandBuffer.h @@ -19,7 +19,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT CommandBuffer : public Object + class VSG_EXPORT CommandBuffer : public Inherit { public: CommandBuffer(Device* device, CommandPool* commandPool, VkCommandBuffer commandBuffer, VkCommandBufferUsageFlags flags); diff --git a/include/vsg/vk/CommandPool.h b/include/vsg/vk/CommandPool.h index e8d8c928a9..7a7ddb6a14 100644 --- a/include/vsg/vk/CommandPool.h +++ b/include/vsg/vk/CommandPool.h @@ -18,7 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT CommandPool : public Object + class VSG_EXPORT CommandPool : public Inherit { public: CommandPool(VkCommandPool CommandPool, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/ComputePipeline.h b/include/vsg/vk/ComputePipeline.h index 018078793a..72f60bc3bf 100644 --- a/include/vsg/vk/ComputePipeline.h +++ b/include/vsg/vk/ComputePipeline.h @@ -19,11 +19,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT ComputePipeline : public Pipeline + class VSG_EXPORT ComputePipeline : public Inherit { public: - virtual void accept(Visitor& visitor) { visitor.apply(*this); } - using Result = vsg::Result; /** Crreate a ComputePipeline.*/ diff --git a/include/vsg/vk/Descriptor.h b/include/vsg/vk/Descriptor.h index f8898badc5..8a34862470 100644 --- a/include/vsg/vk/Descriptor.h +++ b/include/vsg/vk/Descriptor.h @@ -22,7 +22,7 @@ namespace vsg using DescriptorBufferInfos = std::vector; - class Descriptor : public Object + class Descriptor : public Inherit { public: Descriptor(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType): @@ -84,12 +84,12 @@ namespace vsg using ImageDataList = std::vector; - class VSG_EXPORT DescriptorImage : public Descriptor + class VSG_EXPORT DescriptorImage : public Inherit { public: DescriptorImage(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType, const ImageDataList& imageDataList) : - Descriptor(dstBinding, dstArrayElement, descriptorType), + Inherit(dstBinding, dstArrayElement, descriptorType), _imageDataList(imageDataList) { // convert from VSG to Vk @@ -118,12 +118,12 @@ namespace vsg }; - class VSG_EXPORT DescriptorBuffer : public Descriptor + class VSG_EXPORT DescriptorBuffer : public Inherit { public: DescriptorBuffer(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType, const BufferDataList& bufferDataList) : - Descriptor(dstBinding, dstArrayElement, descriptorType), + Inherit(dstBinding, dstArrayElement, descriptorType), _bufferDataList(bufferDataList) { // convert from VSG to Vk @@ -153,12 +153,12 @@ namespace vsg using BufferViewList = std::vector>; - class VSG_EXPORT DescriptorTexelBufferView : public Descriptor + class VSG_EXPORT DescriptorTexelBufferView : public Inherit { public: DescriptorTexelBufferView(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType, const BufferViewList& texelBufferViews) : - Descriptor(dstBinding, dstArrayElement, descriptorType), + Inherit(dstBinding, dstArrayElement, descriptorType), _texelBufferViewList(texelBufferViews) { _texelBufferViews.resize(_texelBufferViewList.size()); diff --git a/include/vsg/vk/DescriptorPool.h b/include/vsg/vk/DescriptorPool.h index 4de3e6512d..5c7dd72e45 100644 --- a/include/vsg/vk/DescriptorPool.h +++ b/include/vsg/vk/DescriptorPool.h @@ -19,7 +19,7 @@ namespace vsg using DescriptorPoolSizes = std::vector; - class VSG_EXPORT DescriptorPool : public vsg::Object + class VSG_EXPORT DescriptorPool : public Inherit { public: DescriptorPool(VkDescriptorPool descriptorPool, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/DescriptorSet.h b/include/vsg/vk/DescriptorSet.h index e032cef575..faa1bc8b21 100644 --- a/include/vsg/vk/DescriptorSet.h +++ b/include/vsg/vk/DescriptorSet.h @@ -47,7 +47,7 @@ namespace vsg using DescriptorSets = std::vector>; - class VSG_EXPORT BindDescriptorSets : public StateComponent + class VSG_EXPORT BindDescriptorSets : public Inherit { public: diff --git a/include/vsg/vk/DescriptorSetLayout.h b/include/vsg/vk/DescriptorSetLayout.h index 43ae40ebd8..4f68c7809b 100644 --- a/include/vsg/vk/DescriptorSetLayout.h +++ b/include/vsg/vk/DescriptorSetLayout.h @@ -18,7 +18,7 @@ namespace vsg { using DescriptorSetLayoutBindings = std::vector; - class VSG_EXPORT DescriptorSetLayout : public vsg::Object + class VSG_EXPORT DescriptorSetLayout : public Inherit { public: DescriptorSetLayout(Device* device, VkDescriptorSetLayout DescriptorSetLayout, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Device.h b/include/vsg/vk/Device.h index 3d44a02a59..b9e1c6e26c 100644 --- a/include/vsg/vk/Device.h +++ b/include/vsg/vk/Device.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Device : public Object + class VSG_EXPORT Device : public Inherit { public: Device(VkDevice device, PhysicalDevice* physicalDevice, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/DeviceMemory.h b/include/vsg/vk/DeviceMemory.h index 168a4889ac..f6a579016d 100644 --- a/include/vsg/vk/DeviceMemory.h +++ b/include/vsg/vk/DeviceMemory.h @@ -20,7 +20,7 @@ namespace vsg class Buffer; class Image; - class VSG_EXPORT DeviceMemory : public Object + class VSG_EXPORT DeviceMemory : public Inherit { public: DeviceMemory(VkDeviceMemory DeviceMemory, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Draw.h b/include/vsg/vk/Draw.h index 65b30ce4d0..4b4ee0b7fe 100644 --- a/include/vsg/vk/Draw.h +++ b/include/vsg/vk/Draw.h @@ -18,7 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class Draw : public Command + class Draw : public Inherit { public: Draw(uint32_t in_vertexCount, uint32_t in_instanceCount, uint32_t in_firstVertex, uint32_t in_firstInstance): @@ -27,8 +27,6 @@ namespace vsg firstVertex(in_firstVertex), firstInstance(in_firstInstance) {} - void accept(Visitor& visitor) override { visitor.apply(*this); } - void dispatch(CommandBuffer& commandBuffer) const override { vkCmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance); @@ -40,7 +38,7 @@ namespace vsg uint32_t firstInstance; }; - class DrawIndexed : public Command + class DrawIndexed : public Inherit { public: DrawIndexed(uint32_t in_indexCount, uint32_t in_instanceCount, uint32_t in_firstIndex, int32_t in_vertexOffset, uint32_t in_firstInstance): @@ -50,8 +48,6 @@ namespace vsg vertexOffset(in_vertexOffset), firstInstance(in_firstInstance) {} - void accept(Visitor& visitor) override { visitor.apply(*this); } - void dispatch(CommandBuffer& commandBuffer) const override { vkCmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); diff --git a/include/vsg/vk/Fence.h b/include/vsg/vk/Fence.h index 6567d6f99d..26b7507b84 100644 --- a/include/vsg/vk/Fence.h +++ b/include/vsg/vk/Fence.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Fence : public Object + class VSG_EXPORT Fence : public Inherit { public: Fence(VkFence Fence, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Framebuffer.h b/include/vsg/vk/Framebuffer.h index 6a1354e503..314ad03a7a 100644 --- a/include/vsg/vk/Framebuffer.h +++ b/include/vsg/vk/Framebuffer.h @@ -18,7 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Framebuffer : public Object + class VSG_EXPORT Framebuffer : public Inherit { public: Framebuffer(VkFramebuffer framebuffer, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/GraphicsPipeline.h b/include/vsg/vk/GraphicsPipeline.h index 9029c1695c..d6404ca20d 100644 --- a/include/vsg/vk/GraphicsPipeline.h +++ b/include/vsg/vk/GraphicsPipeline.h @@ -22,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class GraphicsPipelineState : public Object + class GraphicsPipelineState : public Inherit { public: GraphicsPipelineState() {} @@ -38,11 +38,9 @@ namespace vsg using GraphicsPipelineStates = std::vector>; - class VSG_EXPORT GraphicsPipeline : public Pipeline + class VSG_EXPORT GraphicsPipeline : public Inherit { public: - void accept(Visitor& visitor) override { visitor.apply(*this); } - using Result = vsg::Result; /** Crreate a GraphicsPipeline.*/ @@ -58,7 +56,7 @@ namespace vsg }; - class VSG_EXPORT ShaderStages : public GraphicsPipelineState + class VSG_EXPORT ShaderStages : public Inherit { public: ShaderStages(const ShaderModules& shaderModules); @@ -86,7 +84,7 @@ namespace vsg }; - class VSG_EXPORT VertexInputState : public GraphicsPipelineState, public VkPipelineVertexInputStateCreateInfo + class VSG_EXPORT VertexInputState : public Inherit, public VkPipelineVertexInputStateCreateInfo { public: using Bindings = std::vector; @@ -111,7 +109,7 @@ namespace vsg }; - class VSG_EXPORT InputAssemblyState : public GraphicsPipelineState, public VkPipelineInputAssemblyStateCreateInfo + class VSG_EXPORT InputAssemblyState : public Inherit, public VkPipelineInputAssemblyStateCreateInfo { public: InputAssemblyState(); @@ -125,7 +123,7 @@ namespace vsg }; - class VSG_EXPORT ViewportState : public GraphicsPipelineState, public VkPipelineViewportStateCreateInfo + class VSG_EXPORT ViewportState : public Inherit, public VkPipelineViewportStateCreateInfo { public: ViewportState(const VkExtent2D& extent); @@ -145,7 +143,7 @@ namespace vsg }; - class VSG_EXPORT RasterizationState : public GraphicsPipelineState, public VkPipelineRasterizationStateCreateInfo + class VSG_EXPORT RasterizationState : public Inherit, public VkPipelineRasterizationStateCreateInfo { public: RasterizationState(); @@ -159,7 +157,7 @@ namespace vsg }; - class VSG_EXPORT MultisampleState : public GraphicsPipelineState, public VkPipelineMultisampleStateCreateInfo + class VSG_EXPORT MultisampleState : public Inherit, public VkPipelineMultisampleStateCreateInfo { public: MultisampleState(); @@ -173,7 +171,7 @@ namespace vsg }; - class VSG_EXPORT DepthStencilState : public GraphicsPipelineState, public VkPipelineDepthStencilStateCreateInfo + class VSG_EXPORT DepthStencilState : public Inherit, public VkPipelineDepthStencilStateCreateInfo { public: DepthStencilState(); @@ -187,7 +185,7 @@ namespace vsg }; - class VSG_EXPORT ColorBlendState : public GraphicsPipelineState, public VkPipelineColorBlendStateCreateInfo + class VSG_EXPORT ColorBlendState : public Inherit, public VkPipelineColorBlendStateCreateInfo { public: ColorBlendState(); diff --git a/include/vsg/vk/Image.h b/include/vsg/vk/Image.h index dd25c57e31..92b925d6c4 100644 --- a/include/vsg/vk/Image.h +++ b/include/vsg/vk/Image.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Image : public Object + class VSG_EXPORT Image : public Inherit { public: Image(VkImage Image, Device* device, AllocationCallbacks* allocator=nullptr); @@ -53,7 +53,7 @@ namespace vsg VkDeviceSize _memoryOffset; }; - class VSG_EXPORT ImageMemoryBarrier : public Object, public VkImageMemoryBarrier + class VSG_EXPORT ImageMemoryBarrier : public Inherit, public VkImageMemoryBarrier { public: diff --git a/include/vsg/vk/ImageView.h b/include/vsg/vk/ImageView.h index 1688c211bb..809c4b1362 100644 --- a/include/vsg/vk/ImageView.h +++ b/include/vsg/vk/ImageView.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT ImageView : public Object + class VSG_EXPORT ImageView : public Inherit { public: ImageView(VkImageView imageView, Device* device, Image* image=nullptr, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Instance.h b/include/vsg/vk/Instance.h index 720600a9b3..99fbaa2f53 100644 --- a/include/vsg/vk/Instance.h +++ b/include/vsg/vk/Instance.h @@ -27,7 +27,7 @@ namespace vsg extern VSG_EXPORT Names validateInstancelayerNames(const Names& names); - class VSG_EXPORT Instance : public vsg::Object + class VSG_EXPORT Instance : public Inherit { public: Instance(VkInstance instance, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/MemoryManager.h b/include/vsg/vk/MemoryManager.h index 3b829000af..e33375c369 100644 --- a/include/vsg/vk/MemoryManager.h +++ b/include/vsg/vk/MemoryManager.h @@ -18,7 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT MemoryManager : public Object + class VSG_EXPORT MemoryManager : public Inherit { public: MemoryManager(Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/PhysicalDevice.h b/include/vsg/vk/PhysicalDevice.h index 52a2f89b5f..95ca5e98c1 100644 --- a/include/vsg/vk/PhysicalDevice.h +++ b/include/vsg/vk/PhysicalDevice.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT PhysicalDevice : public vsg::Object + class VSG_EXPORT PhysicalDevice : public Inherit { public: PhysicalDevice(Instance* instance, VkPhysicalDevice device, int graphicsFamily, int presentFamily, int computeFamily, Surface* surface); diff --git a/include/vsg/vk/Pipeline.h b/include/vsg/vk/Pipeline.h index 2eacccf94c..241539d3a6 100644 --- a/include/vsg/vk/Pipeline.h +++ b/include/vsg/vk/Pipeline.h @@ -18,13 +18,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Pipeline : public Object + class VSG_EXPORT Pipeline : public Inherit { public: Pipeline(VkPipeline pipeline, VkPipelineBindPoint bindPoint, Device* device, PipelineLayout* pipelineLayout, AllocationCallbacks* allocator=nullptr); - void accept(Visitor& visitor) override { visitor.apply(*this); } - operator VkPipeline () const { return _pipeline; } VkPipelineBindPoint getBindPoint() const { return _bindPoint; } @@ -45,7 +43,7 @@ namespace vsg ref_ptr _allocator; }; - class VSG_EXPORT BindPipeline : public StateComponent + class VSG_EXPORT BindPipeline : public Inherit { public: BindPipeline(Pipeline* pipeline); diff --git a/include/vsg/vk/PipelineLayout.h b/include/vsg/vk/PipelineLayout.h index fcb2346bc3..cc32b39e27 100644 --- a/include/vsg/vk/PipelineLayout.h +++ b/include/vsg/vk/PipelineLayout.h @@ -20,7 +20,7 @@ namespace vsg using DescriptorSetLayouts = std::vector>; using PushConstantRanges = std::vector; - class VSG_EXPORT PipelineLayout : public vsg::Object + class VSG_EXPORT PipelineLayout : public Inherit { public: PipelineLayout(VkPipelineLayout pipelineLayout, const DescriptorSetLayouts& descrtorSetLayouts, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/PushConstants.h b/include/vsg/vk/PushConstants.h index 76251af255..11f4d2e900 100644 --- a/include/vsg/vk/PushConstants.h +++ b/include/vsg/vk/PushConstants.h @@ -19,15 +19,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT PushConstants : public StateComponent + class VSG_EXPORT PushConstants : public Inherit { public: PushConstants(VkShaderStageFlags shaderFlags, uint32_t offset, Data* data); - void accept(Visitor& visitor) override { visitor.apply(*this); } - - Data* getData() { return _data; } - const Data* getData() const { return _data; } + Data* getData() noexcept { return _data; } + const Data* getData() const noexcept { return _data; } void pushTo(State& state) override; void popFrom(State& state) override; diff --git a/include/vsg/vk/RenderPass.h b/include/vsg/vk/RenderPass.h index 6884cd4588..70854e7726 100644 --- a/include/vsg/vk/RenderPass.h +++ b/include/vsg/vk/RenderPass.h @@ -13,12 +13,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ #include -#include namespace vsg { - class VSG_EXPORT RenderPass : public Object + class VSG_EXPORT RenderPass : public Inherit { public: RenderPass(VkRenderPass renderPass, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Sampler.h b/include/vsg/vk/Sampler.h index 7cb34fb1c0..482cd23b3c 100644 --- a/include/vsg/vk/Sampler.h +++ b/include/vsg/vk/Sampler.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Sampler : public Object + class VSG_EXPORT Sampler : public Inherit { public: Sampler(VkSampler Sampler, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Semaphore.h b/include/vsg/vk/Semaphore.h index d75c7420b7..5b59e09270 100644 --- a/include/vsg/vk/Semaphore.h +++ b/include/vsg/vk/Semaphore.h @@ -16,7 +16,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Semaphore : public Object + class VSG_EXPORT Semaphore : public Inherit { public: Semaphore(VkSemaphore Semaphore, Device* device, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/ShaderModule.h b/include/vsg/vk/ShaderModule.h index 76269db74c..a43367f211 100644 --- a/include/vsg/vk/ShaderModule.h +++ b/include/vsg/vk/ShaderModule.h @@ -36,7 +36,7 @@ namespace vsg return true; } - class VSG_EXPORT Shader : public Object + class VSG_EXPORT Shader : public Inherit { public: using Contents = std::vector; @@ -58,7 +58,7 @@ namespace vsg Contents _contents; }; - class VSG_EXPORT ShaderModule : public vsg::Object + class VSG_EXPORT ShaderModule : public Inherit { public: ShaderModule(VkShaderModule shaderModule, Device* device, Shader* shader, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/State.h b/include/vsg/vk/State.h index bd8438b6ce..71a70364a9 100644 --- a/include/vsg/vk/State.h +++ b/include/vsg/vk/State.h @@ -55,7 +55,7 @@ namespace vsg }; - class State : public Object + class State : public Inherit { public: State() : dirty(false) {} @@ -90,7 +90,7 @@ namespace vsg class Framebuffer; class Renderpass; - class Stage : public Object + class Stage : public Inherit { public: Stage() {} diff --git a/include/vsg/vk/Surface.h b/include/vsg/vk/Surface.h index 6707f41669..51187ba6c2 100644 --- a/include/vsg/vk/Surface.h +++ b/include/vsg/vk/Surface.h @@ -17,7 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT Surface : public vsg::Object + class VSG_EXPORT Surface : public Inherit { public: Surface(VkSurfaceKHR surface, Instance* instance, AllocationCallbacks* allocator=nullptr); diff --git a/include/vsg/vk/Swapchain.h b/include/vsg/vk/Swapchain.h index 808c277153..208d1bdee5 100644 --- a/include/vsg/vk/Swapchain.h +++ b/include/vsg/vk/Swapchain.h @@ -29,7 +29,7 @@ namespace vsg extern VSG_EXPORT VkExtent2D selectSwapExtent(SwapChainSupportDetails& details, uint32_t width, uint32_t height); extern VSG_EXPORT VkPresentModeKHR selectSwapPresentMode(SwapChainSupportDetails& details); - class VSG_EXPORT Swapchain : public vsg::Object + class VSG_EXPORT Swapchain : public Inherit { public: Swapchain(VkSwapchainKHR swapchain, Device* device, Surface* surface, AllocationCallbacks* allocator=nullptr); diff --git a/src/vsg/core/Allocator.cpp b/src/vsg/core/Allocator.cpp index 8ca31bee41..8337803ba4 100644 --- a/src/vsg/core/Allocator.cpp +++ b/src/vsg/core/Allocator.cpp @@ -21,19 +21,26 @@ using namespace vsg; Allocator::~Allocator() { std::cout<<"Allocator::~Allocator() "<(ptr)); + _bytesDeallocated += size; + ++_countDeallocated; } Auxiliary* Allocator::getOrCreateSharedAuxiliary() { if (!_sharedAuxiliary) { - _sharedAuxiliary = new Auxiliary(this); + void* ptr = allocate(sizeof(Auxiliary)); + _sharedAuxiliary = new (ptr) Auxiliary(this); std::cout<<"Allocator::getOrCreateSharedAuxiliary() creating new : "<<_sharedAuxiliary< allocator = _allocator; + + std::size_t size = getSizeOf(); + + std::cout<<" Calling this->~Auxiliary();"<~Auxiliary(); + + std::cout<<" After Calling this->~Auxiliary();"<deallocate(this, size); + } + else + { + delete this; + } } } diff --git a/src/vsg/core/Object.cpp b/src/vsg/core/Object.cpp index fe2059943e..7611dd5a7f 100644 --- a/src/vsg/core/Object.cpp +++ b/src/vsg/core/Object.cpp @@ -49,11 +49,13 @@ void Object::_delete() const ref_ptr allocator = getAllocator(); if (allocator) { + std::size_t size = getSizeOf(); + std::cout<<"Calling this->~Object();"<~Object(); std::cout<<"After Calling this->~Object();"<deallocate(this); + allocator->deallocate(this, size); } else { @@ -122,8 +124,18 @@ Auxiliary* Object::getOrCreateUniqueAuxiliary() if (_auxiliary->getConnectedObject()!=this) { Auxiliary* previousAuxiliary = _auxiliary; + Allocator* allocator = previousAuxiliary->getAllocator(); + if (allocator) + { + void* ptr = allocator->allocate(sizeof(Auxiliary)); + _auxiliary = new (ptr) Auxiliary(this, allocator); + std::cout<<" used Allocator to allocate _auxiliary="<<_auxiliary<getAllocator()); _auxiliary->ref(); std::cout<<"Object::getOrCreateUniqueAuxiliary() _auxiliary="<<_auxiliary<<" replaces previousAuxiliary="< Date: Wed, 10 Oct 2018 12:26:12 +0100 Subject: [PATCH 8/9] Added vsg::Inherit usage --- include/vsg/vk/CommandBuffer.h | 2 +- include/vsg/vk/DescriptorSet.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/vsg/vk/CommandBuffer.h b/include/vsg/vk/CommandBuffer.h index 2f34bbc239..746b1e3bee 100644 --- a/include/vsg/vk/CommandBuffer.h +++ b/include/vsg/vk/CommandBuffer.h @@ -97,7 +97,7 @@ namespace vsg dispatchCommandsToQueue(device, commandPool, nullptr, 0, queue, function); } - class VSG_EXPORT CommandBuffers : public Object + class VSG_EXPORT CommandBuffers : public Inherit { public: using Buffers = std::vector; diff --git a/include/vsg/vk/DescriptorSet.h b/include/vsg/vk/DescriptorSet.h index faa1bc8b21..2d18f6891f 100644 --- a/include/vsg/vk/DescriptorSet.h +++ b/include/vsg/vk/DescriptorSet.h @@ -21,7 +21,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { - class VSG_EXPORT DescriptorSet : public vsg::Object + class VSG_EXPORT DescriptorSet : public Inherit { public: DescriptorSet(VkDescriptorSet descriptorSet, Device* device, DescriptorPool* descriptorPool, DescriptorSetLayout* descriptorSetLayout, const Descriptors& descriptors); From cc8beacb03e78ee4bbe8703ee289d5e8686f48db Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 10 Oct 2018 13:06:12 +0100 Subject: [PATCH 9/9] Quietened down debug output from Object and Auxuliary and removed iostream from headers --- include/vsg/core/Allocator.h | 5 ++--- include/vsg/vk/State.h | 4 ---- src/vsg/core/Auxiliary.cpp | 26 ++++++++++++++++---------- src/vsg/core/Object.cpp | 23 +++++++++++++++-------- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/include/vsg/core/Allocator.h b/include/vsg/core/Allocator.h index f79a46fa30..90481361bd 100644 --- a/include/vsg/core/Allocator.h +++ b/include/vsg/core/Allocator.h @@ -14,8 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include - -#include +#include namespace vsg { @@ -45,7 +44,7 @@ namespace vsg std::size_t new_size = object->getSizeOf(); if (new_size != size) { - std::cout<<"Warning: Allocator::create("< #include -#include - namespace vsg { template @@ -47,7 +45,6 @@ namespace vsg { if (dirty && !stack.empty()) { - std::cout<<"StateStack::dispatch() "< +#if 1 #include +#define DEBUG_NOTIFY if (false) std::cout +#else +#include +#define DEBUG_NOTIFY std::cout +#endif using namespace vsg; @@ -21,7 +27,7 @@ Auxiliary::Auxiliary(Allocator* allocator) : _connectedObject(0), _allocator(allocator) { - std::cout<<"Auxiliary::Auxiliary(Allocator = "<detachSharedAuxiliary(this); } void Auxiliary::ref() const { ++_referenceCount; - std::cout<<"Auxiliary::ref() "<~Auxiliary();"<~Auxiliary();"<~Auxiliary(); - std::cout<<" After Calling this->~Auxiliary();"<~Auxiliary();"<deallocate(this, size); } else @@ -99,12 +105,12 @@ void Auxiliary::resetConnectedObject() void Auxiliary::setObject(const Object::Key& key, Object* object) { _objectMap[key] = object; - std::cout<<"Auxiliary::setObject( ["<second.get(); else return nullptr; @@ -112,7 +118,7 @@ Object* Auxiliary::getObject(const Object::Key& key) const Object* Auxiliary::getObject(const Object::Key& key) const { - std::cout<<"Auxiliary::getObject( ["<second.get(); else return nullptr; diff --git a/src/vsg/core/Object.cpp b/src/vsg/core/Object.cpp index 7611dd5a7f..acfa61bebe 100644 --- a/src/vsg/core/Object.cpp +++ b/src/vsg/core/Object.cpp @@ -16,10 +16,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include -#include using namespace vsg; +#if 1 +#include +#define DEBUG_NOTIFY if (false) std::cout +#else +#include +#define DEBUG_NOTIFY std::cout +#endif + Object::Object() : _referenceCount(0), _auxiliary(nullptr) @@ -28,7 +35,7 @@ Object::Object() : Object::~Object() { - std::cout<<"Object::~Object() "<signalConnectedObjectToBeDeleted()) { - std::cout<<"Object::_delete() "< allocator = getAllocator(); if (allocator) { std::size_t size = getSizeOf(); - std::cout<<"Calling this->~Object();"<~Object();"<~Object(); - std::cout<<"After Calling this->~Object();"<~Object();"<deallocate(this, size); } else @@ -113,7 +120,7 @@ void Object::setAuxiliary(Auxiliary* auxiliary) Auxiliary* Object::getOrCreateUniqueAuxiliary() { - std::cout<<"Object::getOrCreateUniqueAuxiliary() _auxiliary="<<_auxiliary<