diff --git a/include/vsg/app/View.h b/include/vsg/app/View.h index f43df3449..20780f254 100644 --- a/include/vsg/app/View.h +++ b/include/vsg/app/View.h @@ -15,11 +15,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include -#include namespace vsg { + // forward declare + class ViewDependentState; + /// View is a Group class that pairs a Camera that defines the view with a subgraph that defines the scene that is being viewed/rendered class VSG_DECLSPEC View : public Inherit { diff --git a/include/vsg/state/ResourceHints.h b/include/vsg/state/ResourceHints.h index a2351e821..d89985bc6 100644 --- a/include/vsg/state/ResourceHints.h +++ b/include/vsg/state/ResourceHints.h @@ -12,8 +12,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include #include +#include namespace vsg { @@ -35,7 +35,7 @@ namespace vsg uivec2 numLightsRange = {8, 1024}; uivec2 numShadowMapsRange = {8, 64}; - uivec2 shadowMapSize = { 2048, 2028 }; + uivec2 shadowMapSize = {2048, 2028}; void read(Input& input) override; void write(Output& output) const override; diff --git a/include/vsg/utils/GraphicsPipelineConfigurator.h b/include/vsg/utils/GraphicsPipelineConfigurator.h index 81553277d..6f1203778 100644 --- a/include/vsg/utils/GraphicsPipelineConfigurator.h +++ b/include/vsg/utils/GraphicsPipelineConfigurator.h @@ -52,15 +52,11 @@ namespace vsg bool assignDescriptor(const std::string& name, ref_ptr data = {}, uint32_t dstArrayElement = 0); bool assignDescriptor(const std::string& name, const BufferInfoList& bufferInfoList, uint32_t dstArrayElement = 0); - [[deprecated("use enableDescriptor(..)")]] - bool enableUniform(const std::string& name) { return enableDescriptor(name); } + [[deprecated("use enableDescriptor(..)")]] bool enableUniform(const std::string& name) { return enableDescriptor(name); } - [[deprecated("use assignDescriptor(..)")]] - bool assignUniform(const std::string& name, ref_ptr data = {}, uint32_t dstArrayElement = 0) { return assignDescriptor(name, data, dstArrayElement); } - - [[deprecated("use assignDescriptor(..)")]] - bool assignUniform(const std::string& name, const BufferInfoList& bufferInfoList, uint32_t dstArrayElement = 0) { return assignDescriptor(name, bufferInfoList, dstArrayElement); } + [[deprecated("use assignDescriptor(..)")]] bool assignUniform(const std::string& name, ref_ptr data = {}, uint32_t dstArrayElement = 0) { return assignDescriptor(name, data, dstArrayElement); } + [[deprecated("use assignDescriptor(..)")]] bool assignUniform(const std::string& name, const BufferInfoList& bufferInfoList, uint32_t dstArrayElement = 0) { return assignDescriptor(name, bufferInfoList, dstArrayElement); } bool assignDescriptor(uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr descriptor); @@ -120,11 +116,9 @@ namespace vsg bool assignDescriptor(const std::string& name, ref_ptr data = {}); bool assignTexture(const std::string& name, ref_ptr textureData = {}, ref_ptr sampler = {}); - [[deprecated("use enableDescriptor(..)")]] - bool enableUniform(const std::string& name) { return enableDescriptor(name); } + [[deprecated("use enableDescriptor(..)")]] bool enableUniform(const std::string& name) { return enableDescriptor(name); } - [[deprecated("use assignDescriptor(..)")]] - bool assignUniform(const std::string& name, ref_ptr data = {}) { return assignDescriptor(name, data); } + [[deprecated("use assignDescriptor(..)")]] bool assignUniform(const std::string& name, ref_ptr data = {}) { return assignDescriptor(name, data); } // setup by assign calls ref_ptr shaderHints; diff --git a/include/vsg/utils/ShaderSet.h b/include/vsg/utils/ShaderSet.h index 7643a43f0..8ab93382a 100644 --- a/include/vsg/utils/ShaderSet.h +++ b/include/vsg/utils/ShaderSet.h @@ -136,9 +136,7 @@ namespace vsg /// add an uniform binding. Not thread safe, should only be called when initially setting up the ShaderSet void addDescriptorBinding(std::string name, std::string define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr data); - [[deprecated("use addDescriptorBinding(..)")]] - void addUniformBinding(std::string name, std::string define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr data) { addDescriptorBinding(name, define, set, binding, descriptorType, descriptorCount, stageFlags, data); } - + [[deprecated("use addDescriptorBinding(..)")]] void addUniformBinding(std::string name, std::string define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr data) { addDescriptorBinding(name, define, set, binding, descriptorType, descriptorCount, stageFlags, data); } /// add a push constant range. Not thread safe, should only be called when initially setting up the ShaderSet void addPushConstantRange(std::string name, std::string define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size); @@ -155,11 +153,9 @@ namespace vsg /// get the const DescriptorBinding associated with name const DescriptorBinding& getDescriptorBinding(const std::string& name) const; - [[deprecated("use getDescriptorBinding(..)")]] - DescriptorBinding& getUniformBinding(const std::string& name) { return getDescriptorBinding(name); } + [[deprecated("use getDescriptorBinding(..)")]] DescriptorBinding& getUniformBinding(const std::string& name) { return getDescriptorBinding(name); } - [[deprecated("use getDescriptorBinding(..)")]] - const DescriptorBinding& getUnifomrBinding(const std::string& name) const { return getDescriptorBinding(name); } + [[deprecated("use getDescriptorBinding(..)")]] const DescriptorBinding& getUnifomrBinding(const std::string& name) const { return getDescriptorBinding(name); } /// get the first ArrayState that has matches with defines in the specified list of defines. ref_ptr getSuitableArrayState(const std::set& defines) const; diff --git a/include/vsg/vk/ResourceRequirements.h b/include/vsg/vk/ResourceRequirements.h index 44f9440ab..5cfbdc24e 100644 --- a/include/vsg/vk/ResourceRequirements.h +++ b/include/vsg/vk/ResourceRequirements.h @@ -90,7 +90,7 @@ namespace vsg uivec2 numLightsRange = {8, 1024}; uivec2 numShadowMapsRange = {8, 64}; - uivec2 shadowMapSize = { 2048, 2028 }; + uivec2 shadowMapSize = {2048, 2028}; }; VSG_type_name(vsg::ResourceRequirements); diff --git a/src/vsg/app/CompileTraversal.cpp b/src/vsg/app/CompileTraversal.cpp index 8d847d92e..8fcc296e4 100644 --- a/src/vsg/app/CompileTraversal.cpp +++ b/src/vsg/app/CompileTraversal.cpp @@ -22,6 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include diff --git a/src/vsg/app/RecordTraversal.cpp b/src/vsg/app/RecordTraversal.cpp index ac24817d1..e8b314a59 100644 --- a/src/vsg/app/RecordTraversal.cpp +++ b/src/vsg/app/RecordTraversal.cpp @@ -32,6 +32,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include #include diff --git a/src/vsg/app/RenderGraph.cpp b/src/vsg/app/RenderGraph.cpp index dfb9a797d..43a05b6e2 100644 --- a/src/vsg/app/RenderGraph.cpp +++ b/src/vsg/app/RenderGraph.cpp @@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include #include diff --git a/src/vsg/app/SecondaryCommandGraph.cpp b/src/vsg/app/SecondaryCommandGraph.cpp index 2613922bf..26dd216be 100644 --- a/src/vsg/app/SecondaryCommandGraph.cpp +++ b/src/vsg/app/SecondaryCommandGraph.cpp @@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include diff --git a/src/vsg/app/View.cpp b/src/vsg/app/View.cpp index 26e9d7c6b..98b7d3d65 100644 --- a/src/vsg/app/View.cpp +++ b/src/vsg/app/View.cpp @@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include using namespace vsg; @@ -27,7 +28,7 @@ static uint32_t getUniqueViewID() uint32_t viewID = 0; for (viewID = 0; viewID < static_cast(s_ActiveViews.size()); ++viewID) { - if (s_ActiveViews[viewID]==0) + if (s_ActiveViews[viewID] == 0) { ++s_ActiveViews[viewID]; return viewID; @@ -76,7 +77,7 @@ View::View(bool assignViewDependentState) : info("View::View(bool) ", this, ", ", viewDependentState, ", ", viewID); } -View::View(const View& view): +View::View(const View& view) : Inherit(view), viewID(sharedViewID(view.viewID)), mask(view.mask) diff --git a/src/vsg/app/Viewer.cpp b/src/vsg/app/Viewer.cpp index 98eecb264..380869b4f 100644 --- a/src/vsg/app/Viewer.cpp +++ b/src/vsg/app/Viewer.cpp @@ -435,7 +435,6 @@ void Viewer::assignRecordAndSubmitTaskAndPresentation(CommandGraphs in_commandGr } }; - // find all the windows struct FindWindows : public Visitor { diff --git a/src/vsg/state/BufferInfo.cpp b/src/vsg/state/BufferInfo.cpp index 4573ac2e9..c962c4c1d 100644 --- a/src/vsg/state/BufferInfo.cpp +++ b/src/vsg/state/BufferInfo.cpp @@ -197,8 +197,10 @@ bool vsg::createBufferAndTransferData(Context& context, const BufferInfoList& bu Device* device = context.device; VkDeviceSize alignment = 4; - if (usage == VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) alignment = device->getPhysicalDevice()->getProperties().limits.minUniformBufferOffsetAlignment; - else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment; + if (usage == VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) + alignment = device->getPhysicalDevice()->getProperties().limits.minUniformBufferOffsetAlignment; + else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) + alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment; VkDeviceSize totalSize = 0; VkDeviceSize offset = 0; @@ -303,8 +305,10 @@ BufferInfoList vsg::createHostVisibleBuffer(Device* device, const DataList& data BufferInfoList bufferInfoList; VkDeviceSize alignment = 4; - if (usage == VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) alignment = device->getPhysicalDevice()->getProperties().limits.minUniformBufferOffsetAlignment; - else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment; + if (usage == VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) + alignment = device->getPhysicalDevice()->getProperties().limits.minUniformBufferOffsetAlignment; + else if (usage == VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) + alignment = device->getPhysicalDevice()->getProperties().limits.minStorageBufferOffsetAlignment; VkDeviceSize totalSize = 0; VkDeviceSize offset = 0; diff --git a/src/vsg/state/ViewDependentState.cpp b/src/vsg/state/ViewDependentState.cpp index 6bae0dda2..e3d065535 100644 --- a/src/vsg/state/ViewDependentState.cpp +++ b/src/vsg/state/ViewDependentState.cpp @@ -14,10 +14,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include -#include +#include #include +#include #include -#include using namespace vsg; @@ -30,8 +30,8 @@ namespace vsg class TraverseChildrenOfNode : public vsg::Inherit { public: - - explicit TraverseChildrenOfNode(vsg::Node* in_node) : node(in_node) {} + explicit TraverseChildrenOfNode(vsg::Node* in_node) : + node(in_node) {} vsg::observer_ptr node; @@ -46,7 +46,7 @@ namespace vsg void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); } }; VSG_type_name(vsg::TraverseChildrenOfNode); -} +} // namespace vsg ////////////////////////////////////// // @@ -179,7 +179,6 @@ void ViewDependentState::init(uint32_t maxNumberLights, uint32_t maxViewports, u shadowMapData = floatArray3D::create(2048, 2048, maxShadowMaps, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}); shadowMapImages = DescriptorImage::create(shadwoMapSampler, shadowMapData, 2); - DescriptorSetLayoutBindings descriptorBindings{ VkDescriptorSetLayoutBinding{0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, // lightData VkDescriptorSetLayoutBinding{1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, // viewportData @@ -189,20 +188,18 @@ void ViewDependentState::init(uint32_t maxNumberLights, uint32_t maxViewports, u descriptorSetLayout = DescriptorSetLayout::create(descriptorBindings); descriptorSet = DescriptorSet::create(descriptorSetLayout, Descriptors{descriptor, shadowMapImages}); - for(uint32_t k = 0; k < shadowMapData->depth(); ++k) + for (uint32_t k = 0; k < shadowMapData->depth(); ++k) { - for(uint32_t j = 0; j < shadowMapData->height(); ++j) + for (uint32_t j = 0; j < shadowMapData->height(); ++j) { float* data = shadowMapData->data(shadowMapData->index(0, j, k)); - for(uint32_t i = 0; i < shadowMapData->width(); ++i) + for (uint32_t i = 0; i < shadowMapData->width(); ++i) { - *(data++) = static_cast(sin(vsg::PI * static_cast(i)/static_cast(shadowMapData->width()-1))); + *(data++) = static_cast(sin(vsg::PI * static_cast(i) / static_cast(shadowMapData->width() - 1))); } } } - - // create a switch to toggle on/off the render to texture subgraphs for each shadowmap layer preRenderSwitch = Switch::create(); @@ -216,7 +213,7 @@ void ViewDependentState::init(uint32_t maxNumberLights, uint32_t maxViewports, u ref_ptr first_view; shadowMaps.resize(maxShadowMaps); - for(auto& shadowMap : shadowMaps) + for (auto& shadowMap : shadowMaps) { if (first_view) { @@ -290,7 +287,6 @@ void ViewDependentState::traverse(RecordTraversal& rt) const // light direction in world coords auto light_direction = normalize(light->direction * (inverse_3x3(mv * inverse(viewMatrix)))); - info(" directional light : light direction in world = ", light_direction, ", light->shadowMaps = ", light->shadowMaps); info(" light->direction in model = ", light->direction); info(" view_direction in world = ", view_direction); @@ -303,8 +299,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const auto light_y = cross(light_x, light_direction); auto light_z = light_direction; - auto computeFrustumBounds = [&](double n, double f, const dmat4& clipToWorld) -> dbox - { + auto computeFrustumBounds = [&](double n, double f, const dmat4& clipToWorld) -> dbox { dbox bounds; bounds.add(clipToWorld * dvec3(-1.0, -1.0, n)); bounds.add(clipToWorld * dvec3(-1.0, 1.0, n)); @@ -318,19 +313,16 @@ void ViewDependentState::traverse(RecordTraversal& rt) const return bounds; }; - auto Clog = [](double n, double f, double i, double m) -> double - { - return n * std::pow((f/n), (i/m)); + auto Clog = [](double n, double f, double i, double m) -> double { + return n * std::pow((f / n), (i / m)); }; - auto Cuniform = [](double n, double f, double i, double m) -> double - { - return n + (f - n) * (i/m); + auto Cuniform = [](double n, double f, double i, double m) -> double { + return n + (f - n) * (i / m); }; - auto Cpractical = [&Clog, &Cuniform](double n, double f, double i, double m, double lambda) -> double - { - return Clog(n, f, i, m) * lambda + Cuniform(n, f, i, m) * (1.0-lambda); + auto Cpractical = [&Clog, &Cuniform](double n, double f, double i, double m, double lambda) -> double { + return Clog(n, f, i, m) * lambda + Cuniform(n, f, i, m) * (1.0 - lambda); }; info(" light_x = ", light_x); @@ -342,7 +334,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const auto n = -(clipToEye * dvec3(0.0, 0.0, 1.0)).z; auto f = -(clipToEye * dvec3(0.0, 0.0, 0.0)).z; -#if 1 +# if 1 // clamp the near and far values double maxShadowDistance = 1000.0; if (n > maxShadowDistance) @@ -355,8 +347,8 @@ void ViewDependentState::traverse(RecordTraversal& rt) const { f = maxShadowDistance; } -#endif - double range = f-n; +# endif + double range = f - n; info(" n = ", n, ", f = ", f, ", range = ", range); auto clipToWorld = inverse(projectionMatrix * viewMatrix); @@ -367,10 +359,10 @@ void ViewDependentState::traverse(RecordTraversal& rt) const { double lambda = 0.5; double m = static_cast(numShadowMapsForThisLight); - for(double i = 0; i < m; i += 1.0) + for (double i = 0; i < m; i += 1.0) { dvec3 eye_near(0.0, 0.0, -Cpractical(n, f, i, m, lambda)); - dvec3 eye_far(0.0, 0.0, -Cpractical(n, f, i+1.0, m, lambda)); + dvec3 eye_far(0.0, 0.0, -Cpractical(n, f, i + 1.0, m, lambda)); auto clip_near = projectionMatrix * eye_near; auto clip_far = projectionMatrix * eye_far; @@ -414,7 +406,6 @@ void ViewDependentState::traverse(RecordTraversal& rt) const auto& camera = shadowMap.view->camera; info(" need to set camera ", camera); } - } #endif @@ -427,7 +418,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const for (auto& [mv, light] : spotLights) { - auto eye_position = mv * light->position; + auto eye_position = mv * light->position; auto eye_direction1 = normalize(light->direction * inverse_3x3(mv)); info(" spot light : light->direction = ", light->direction, ", position = ", eye_position, ", direction = ", eye_direction1, ", light->shadowMaps = ", light->shadowMaps); } diff --git a/src/vsg/vk/ResourceRequirements.cpp b/src/vsg/vk/ResourceRequirements.cpp index e91367406..9f450661a 100644 --- a/src/vsg/vk/ResourceRequirements.cpp +++ b/src/vsg/vk/ResourceRequirements.cpp @@ -23,6 +23,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include #include @@ -34,7 +35,7 @@ using namespace vsg; // ResourceRequirements::ResourceRequirements(ref_ptr hints) { - vsg::info("ResourceRequirements::ResourceRequirements(" , hints, " ) ", this); + vsg::info("ResourceRequirements::ResourceRequirements(", hints, " ) ", this); viewDetailsStack.push(ResourceRequirements::ViewDetails{}); if (hints) apply(*hints); @@ -214,7 +215,7 @@ void CollectResourceRequirements::apply(const DescriptorImage& descriptorImage) void CollectResourceRequirements::apply(const Light& light) { - vsg::info("CollectResourceRequirements::apply(", light.className(),")"); + vsg::info("CollectResourceRequirements::apply(", light.className(), ")"); requirements.viewDetailsStack.top().lights.insert(&light); } @@ -254,7 +255,7 @@ void CollectResourceRequirements::apply(const View& view) vsg::info("CollectResourceRequirements::apply(const View& view) after collecting stats from ", view.viewDependentState); uint32_t numShadowMaps = 0; - for(auto& light : viewDetails.lights) + for (auto& light : viewDetails.lights) { numShadowMaps += light->shadowMaps; }