diff --git a/CMakeLists.txt b/CMakeLists.txt index 86628e60bb..c5db77b015 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(vsg - VERSION 1.1.10 + VERSION 1.1.11 DESCRIPTION "VulkanSceneGraph library" LANGUAGES CXX ) diff --git a/cmake/cppcheck-suppression-list.txt b/cmake/cppcheck-suppression-list.txt index 0c8b0c7a7c..9483d412b4 100644 --- a/cmake/cppcheck-suppression-list.txt +++ b/cmake/cppcheck-suppression-list.txt @@ -29,6 +29,7 @@ useStlAlgorithm:*/src/vsg/nodes/VertexIndexDraw.cpp useStlAlgorithm:*/src/vsg/nodes/Switch.cpp useStlAlgorithm:*/src/vsg/nodes/LOD.cpp useStlAlgorithm:*/src/vsg/state/DescriptorBuffer.cpp +useStlAlgorithm:*/src/vsg/state/GraphicsPipeline.cpp useStlAlgorithm:*/src/vsg/state/PipelineLayout.cpp useStlAlgorithm:*/src/vsg/state/StateSwitch.cpp useStlAlgorithm:*/src/vsg/state/ViewDependentState.cpp @@ -60,7 +61,6 @@ useStlAlgorithm:*/src/vsg/io/Path.cpp useStlAlgorithm:*/src/vsg/utils/PolytopeIntersector.cpp useStlAlgorithm:*/src/vsg/vk/PhysicalDevice.cpp - // suppress the warning about valid C++17 if (init; condition) usage syntaxError:*/include/vsg/core/Inherit.h syntaxError:*/src/vsg/io/AsciiOutput.cpp diff --git a/include/vsg/app/RenderGraph.h b/include/vsg/app/RenderGraph.h index b72c68ae12..e4ea4102f5 100644 --- a/include/vsg/app/RenderGraph.h +++ b/include/vsg/app/RenderGraph.h @@ -47,9 +47,12 @@ namespace vsg /// Get the Extent2D of the attached Framebuffer or Window. VkExtent2D getExtent() const; - /// RenderArea settings for VkRenderPassBeginInfo.renderArea passed to the vkCmdBeginRenderPass, usually matches the ViewportState's scissor + /// RenderArea settings for VkRenderPassBeginInfo.renderArea passed to the vkCmdBeginRenderPass VkRect2D renderArea; + // Default ViewportState to use for graphics pipelines under this RenderGraph, this be will synced with the renderArea. + ref_ptr viewportState; + /// RenderPass to use passed to the vkCmdBeginRenderPass in place of the framebuffer's or window's renderPass. renderPass must be compatible with the render pass used to create the window or framebuffer. ref_ptr renderPass; diff --git a/include/vsg/app/WindowResizeHandler.h b/include/vsg/app/WindowResizeHandler.h index fe99165c21..236245dcc7 100644 --- a/include/vsg/app/WindowResizeHandler.h +++ b/include/vsg/app/WindowResizeHandler.h @@ -23,6 +23,7 @@ namespace vsg /// Utility class for updating a scene graph when a View's camera ViewportState has been updated so that associated GraphicsPipelines in the /// scene graph can be recompiled and correctly reflect the new ViewportState. + /// As viewport size and scissor is dynamic by default, this is only necessary when opting out of that or when the viewport count has changed. class VSG_DECLSPEC UpdateGraphicsPipelines : public Inherit { public: @@ -43,7 +44,6 @@ namespace vsg class VSG_DECLSPEC WindowResizeHandler : public Inherit { public: - ref_ptr context; VkRect2D renderArea; VkExtent2D previous_extent; VkExtent2D new_extent; @@ -63,7 +63,6 @@ namespace vsg /// return true if the object was visited bool visit(const Object* object, uint32_t index = 0); - void apply(BindGraphicsPipeline& bindPipeline) override; void apply(Object& object) override; void apply(ClearAttachments& clearAttachments) override; void apply(View& view) override; diff --git a/include/vsg/io/stream.h b/include/vsg/io/stream.h index 176e4eac4a..f0a4bbb353 100644 --- a/include/vsg/io/stream.h +++ b/include/vsg/io/stream.h @@ -287,12 +287,12 @@ namespace vsg inline std::istream& operator>>(std::istream& input, CoordinateSpace& coordinateSpace) { - std::string value; - input >> value; + std::string str; + input >> str; - if (value == "LINEAR") + if (str == "LINEAR") coordinateSpace = CoordinateSpace::LINEAR; - else if (value == "sRGB") + else if (str == "sRGB") coordinateSpace = CoordinateSpace::sRGB; else coordinateSpace = CoordinateSpace::NO_PREFERENCE; diff --git a/include/vsg/state/DynamicState.h b/include/vsg/state/DynamicState.h index 06397f2250..420025129b 100644 --- a/include/vsg/state/DynamicState.h +++ b/include/vsg/state/DynamicState.h @@ -18,6 +18,7 @@ namespace vsg { /// DynamicState encapsulates VkPipelineDynamicStateCreateInfo settings passed when setting up GraphicsPipeline + /// By default, viewport and scissor are set to dynamic class VSG_DECLSPEC DynamicState : public Inherit { public: diff --git a/include/vsg/state/GraphicsPipeline.h b/include/vsg/state/GraphicsPipeline.h index 6e3e20da88..81fd7f79be 100644 --- a/include/vsg/state/GraphicsPipeline.h +++ b/include/vsg/state/GraphicsPipeline.h @@ -25,7 +25,7 @@ namespace vsg /// Base class for setting up the various pipeline states with the VkGraphicsPipelineCreateInfo /// Subclasses are ColorBlendState, DepthStencilState, DynamicState, InputAssemblyState, /// MultisampleState, RasterizationState, TessellationState, VertexInputState and ViewportState. - class VSG_DECLSPEC GraphicsPipelineState : public Inherit + class VSG_DECLSPEC GraphicsPipelineState : public Inherit { public: GraphicsPipelineState() {} @@ -36,6 +36,7 @@ namespace vsg Mask mask = MASK_ALL; virtual void apply(Context& context, VkGraphicsPipelineCreateInfo& pipelineInfo) const = 0; + void record(CommandBuffer&) const override {}; public: int compare(const Object& rhs) const override; @@ -95,6 +96,7 @@ namespace vsg virtual ~Implementation(); + GraphicsPipelineStates _pipelineStates; VkPipeline _pipeline; ref_ptr _device; diff --git a/include/vsg/state/ViewportState.h b/include/vsg/state/ViewportState.h index 1d6a8991a1..89ac086340 100644 --- a/include/vsg/state/ViewportState.h +++ b/include/vsg/state/ViewportState.h @@ -51,6 +51,9 @@ namespace vsg void write(Output& output) const override; void apply(Context& context, VkGraphicsPipelineCreateInfo& pipelineInfo) const override; + /// enable ViewportState to be recorded via vkCmdSetScissor and vkCmdSetViewport + void record(CommandBuffer& commandBuffer) const override; + protected: virtual ~ViewportState(); }; diff --git a/include/vsg/vk/ResourceRequirements.h b/include/vsg/vk/ResourceRequirements.h index dd1a0b28b2..9a1df52bca 100644 --- a/include/vsg/vk/ResourceRequirements.h +++ b/include/vsg/vk/ResourceRequirements.h @@ -130,6 +130,7 @@ namespace vsg void apply(const DescriptorImage& descriptorImage) override; void apply(const PagedLOD& plod) override; void apply(const Light& light) override; + void apply(const RenderGraph& rg) override; void apply(const View& view) override; void apply(const DepthSorted& depthSorted) override; void apply(const Layer& layer) override; diff --git a/include/vsg/vk/State.h b/include/vsg/vk/State.h index 49b7549a6f..b82f4eabc3 100644 --- a/include/vsg/vk/State.h +++ b/include/vsg/vk/State.h @@ -299,6 +299,36 @@ namespace vsg } } + inline void push(const StateCommands& commands) + { + for (auto& command : commands) + { + stateStacks[command->slot].push(command); + } + dirty = true; + } + + inline void pop(const StateCommands& commands) + { + for (const auto& command : commands) + { + stateStacks[command->slot].pop(); + } + dirty = true; + } + + inline void push(ref_ptr command) + { + stateStacks[command->slot].push(command); + dirty = true; + } + + inline void pop(ref_ptr command) + { + stateStacks[command->slot].pop(); + dirty = true; + } + inline void pushFrustum() { _frustumStack.push(Frustum(_frustumProjected, modelviewMatrixStack.top())); diff --git a/src/vsg/app/CompileTraversal.cpp b/src/vsg/app/CompileTraversal.cpp index 9cab1e388f..387909821f 100644 --- a/src/vsg/app/CompileTraversal.cpp +++ b/src/vsg/app/CompileTraversal.cpp @@ -386,15 +386,9 @@ void CompileTraversal::apply(RenderGraph& renderGraph) auto previousDefaultPipelineStates = context->defaultPipelineStates; auto previousOverridePipelineStates = context->overridePipelineStates; + mergeGraphicsPipelineStates(context->mask, context->defaultPipelineStates, renderGraph.viewportState); + context->renderPass = renderGraph.getRenderPass(); - if (renderGraph.window) - { - mergeGraphicsPipelineStates(context->mask, context->defaultPipelineStates, ViewportState::create(renderGraph.window->extent2D())); - } - else if (renderGraph.framebuffer) - { - mergeGraphicsPipelineStates(context->mask, context->defaultPipelineStates, ViewportState::create(renderGraph.framebuffer->extent2D())); - } if (context->renderPass) { @@ -438,7 +432,7 @@ void CompileTraversal::apply(View& view) } // assign view specific pipeline states - if (view.camera && view.camera->viewportState) mergeGraphicsPipelineStates(context->mask, context->defaultPipelineStates, view.camera->viewportState); + mergeGraphicsPipelineStates(context->mask, context->defaultPipelineStates, view.camera->viewportState); mergeGraphicsPipelineStates(context->mask, context->overridePipelineStates, view.overridePipelineStates); view.traverse(*this); diff --git a/src/vsg/app/RecordTraversal.cpp b/src/vsg/app/RecordTraversal.cpp index ed47544ad9..2254b04bfa 100644 --- a/src/vsg/app/RecordTraversal.cpp +++ b/src/vsg/app/RecordTraversal.cpp @@ -484,19 +484,11 @@ void RecordTraversal::apply(const StateGroup& stateGroup) //debug("Visiting StateGroup"); - for (auto& command : stateGroup.stateCommands) - { - _state->stateStacks[command->slot].push(command); - } - _state->dirty = true; + _state->push(stateGroup.stateCommands); stateGroup.traverse(*this); - for (const auto& command : stateGroup.stateCommands) - { - _state->stateStacks[command->slot].pop(); - } - _state->dirty = true; + _state->pop(stateGroup.stateCommands); } void RecordTraversal::apply(const Commands& commands) @@ -575,27 +567,40 @@ void RecordTraversal::apply(const View& view) _state->inheritViewForLODScaling = (view.features & INHERIT_VIEWPOINT) != 0; _state->setProjectionAndViewMatrix(view.camera->projectionMatrix->transform(), view.camera->viewMatrix->transform()); - if (_viewDependentState && _viewDependentState->viewportData && view.camera->viewportState) + if (const auto& viewportState = view.camera->viewportState) { - auto& viewportData = _viewDependentState->viewportData; - auto& viewports = view.camera->viewportState->viewports; + _state->push(viewportState); - auto dest_itr = viewportData->begin(); - for (auto src_itr = viewports.begin(); - dest_itr != viewportData->end() && src_itr != viewports.end(); - ++dest_itr, ++src_itr) + if (_viewDependentState) { - auto& dest_viewport = *dest_itr; - vec4 src_viewport(src_itr->x, src_itr->y, src_itr->width, src_itr->height); - if (dest_viewport != src_viewport) + auto& viewportData = _viewDependentState->viewportData; + if (viewportData) { - dest_viewport = src_viewport; - viewportData->dirty(); + auto& viewports = viewportState->viewports; + auto dest_itr = viewportData->begin(); + for (auto src_itr = viewports.begin(); + dest_itr != viewportData->end() && src_itr != viewports.end(); + ++dest_itr, ++src_itr) + { + auto& dest_viewport = *dest_itr; + vec4 src_viewport(src_itr->x, src_itr->y, src_itr->width, src_itr->height); + if (dest_viewport != src_viewport) + { + dest_viewport = src_viewport; + viewportData->dirty(); + } + } } } - } - view.traverse(*this); + view.traverse(*this); + + _state->pop(viewportState); + } + else + { + view.traverse(*this); + } } else { diff --git a/src/vsg/app/RenderGraph.cpp b/src/vsg/app/RenderGraph.cpp index 6fbdcec0cc..2803c03479 100644 --- a/src/vsg/app/RenderGraph.cpp +++ b/src/vsg/app/RenderGraph.cpp @@ -22,14 +22,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI using namespace vsg; RenderGraph::RenderGraph() : + viewportState(ViewportState::create()), windowResizeHandler(WindowResizeHandler::create()) { } RenderGraph::RenderGraph(ref_ptr in_window, ref_ptr in_view) : - window(in_window), - windowResizeHandler(WindowResizeHandler::create()) + RenderGraph() { + window = in_window; if (in_view) { @@ -48,6 +49,8 @@ RenderGraph::RenderGraph(ref_ptr in_window, ref_ptr in_view) : renderArea.extent = window->extent2D(); } + viewportState->set(renderArea.offset.x, renderArea.offset.y, renderArea.extent.width, renderArea.extent.height); + // set up the clearValues based on the RenderPass's attachments. setClearValues(window->clearColor(), VkClearDepthStencilValue{0.0f, 0}); } @@ -144,9 +147,15 @@ void RenderGraph::accept(RecordTraversal& recordTraversal) const VkCommandBuffer vk_commandBuffer = *(recordTraversal.getState()->_commandBuffer); vkCmdBeginRenderPass(vk_commandBuffer, &renderPassInfo, contents); + // sync the viewportState and push + viewportState->set(renderArea.offset.x, renderArea.offset.y, renderArea.extent.width, renderArea.extent.height); + recordTraversal.getState()->push(viewportState); + // traverse the subgraph to place commands into the command buffer. traverse(recordTraversal); + recordTraversal.getState()->pop(viewportState); + vkCmdEndRenderPass(vk_commandBuffer); } @@ -155,30 +164,15 @@ void RenderGraph::resized() if (!windowResizeHandler) return; if (!window && !framebuffer) return; - auto activeRenderPass = getRenderPass(); - if (!activeRenderPass) return; - - auto device = activeRenderPass->device; - - if (!windowResizeHandler->context) windowResizeHandler->context = vsg::Context::create(device); + if (!getRenderPass()) return; auto extent = getExtent(); - windowResizeHandler->context->commandPool = nullptr; - windowResizeHandler->context->renderPass = activeRenderPass; windowResizeHandler->renderArea = renderArea; windowResizeHandler->previous_extent = previous_extent; windowResizeHandler->new_extent = extent; windowResizeHandler->visited.clear(); - if (activeRenderPass->maxSamples != VK_SAMPLE_COUNT_1_BIT) - { - windowResizeHandler->context->overridePipelineStates.emplace_back(vsg::MultisampleState::create(activeRenderPass->maxSamples)); - } - - // make sure the device is idle before we recreate any Vulkan objects - vkDeviceWaitIdle(*(device)); - traverse(*windowResizeHandler); windowResizeHandler->scale_rect(renderArea); diff --git a/src/vsg/app/WindowResizeHandler.cpp b/src/vsg/app/WindowResizeHandler.cpp index da831f4a1d..a7ed833786 100644 --- a/src/vsg/app/WindowResizeHandler.cpp +++ b/src/vsg/app/WindowResizeHandler.cpp @@ -89,40 +89,6 @@ bool WindowResizeHandler::visit(const Object* object, uint32_t index) return true; } -void WindowResizeHandler::apply(vsg::BindGraphicsPipeline& bindPipeline) -{ - GraphicsPipeline* graphicsPipeline = bindPipeline.pipeline; - - if (!visit(graphicsPipeline, context->viewID)) - { - return; - } - - if (graphicsPipeline) - { - struct ContainsViewport : public ConstVisitor - { - bool foundViewport = false; - void apply(const ViewportState&) override { foundViewport = true; } - bool operator()(const GraphicsPipeline& gp) - { - for (auto& pipelineState : gp.pipelineStates) - { - pipelineState->accept(*this); - } - return foundViewport; - } - } containsViewport; - - bool needToRegenerateGraphicsPipeline = !containsViewport(*graphicsPipeline); - if (needToRegenerateGraphicsPipeline) - { - graphicsPipeline->release(context->viewID); - graphicsPipeline->compile(*context); - } - } -} - void WindowResizeHandler::apply(vsg::Object& object) { object.traverse(*this); @@ -143,8 +109,6 @@ void WindowResizeHandler::apply(vsg::View& view) { if (!visit(&view)) return; - context->viewID = view.viewID; - if (!view.camera) { view.traverse(*this); @@ -177,9 +141,5 @@ void WindowResizeHandler::apply(vsg::View& view) } } - context->defaultPipelineStates.emplace_back(viewportState); - view.traverse(*this); - - context->defaultPipelineStates.pop_back(); } diff --git a/src/vsg/core/ConstVisitor.cpp b/src/vsg/core/ConstVisitor.cpp index ffe3fca006..82a576d6a2 100644 --- a/src/vsg/core/ConstVisitor.cpp +++ b/src/vsg/core/ConstVisitor.cpp @@ -818,7 +818,7 @@ void ConstVisitor::apply(const RayTracingPipeline& value) } void ConstVisitor::apply(const GraphicsPipelineState& value) { - apply(static_cast(value)); + apply(static_cast(value)); } void ConstVisitor::apply(const ShaderStage& value) { diff --git a/src/vsg/core/Visitor.cpp b/src/vsg/core/Visitor.cpp index 9a274f3dfe..c0fb6d98a6 100644 --- a/src/vsg/core/Visitor.cpp +++ b/src/vsg/core/Visitor.cpp @@ -818,7 +818,7 @@ void Visitor::apply(RayTracingPipeline& value) } void Visitor::apply(GraphicsPipelineState& value) { - apply(static_cast(value)); + apply(static_cast(value)); } void Visitor::apply(ShaderStage& value) { diff --git a/src/vsg/state/DynamicState.cpp b/src/vsg/state/DynamicState.cpp index 475c87907f..3932258934 100644 --- a/src/vsg/state/DynamicState.cpp +++ b/src/vsg/state/DynamicState.cpp @@ -16,7 +16,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI using namespace vsg; -DynamicState::DynamicState() +DynamicState::DynamicState() : + dynamicStates({VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR}) { } diff --git a/src/vsg/state/GraphicsPipeline.cpp b/src/vsg/state/GraphicsPipeline.cpp index d8ba6d5c50..b81914aa83 100644 --- a/src/vsg/state/GraphicsPipeline.cpp +++ b/src/vsg/state/GraphicsPipeline.cpp @@ -54,7 +54,7 @@ void GraphicsPipelineState::write(Output& output) const void vsg::mergeGraphicsPipelineStates(Mask mask, GraphicsPipelineStates& dest_PipelineStates, ref_ptr src_PipelineState) { - if ((mask & src_PipelineState->mask) == 0) return; + if (!src_PipelineState || (mask & src_PipelineState->mask) == 0) return; // replace any entries in the dest_PipelineStates that have the same type as src_PipelineState for (auto& original_pipelineState : dest_PipelineStates) @@ -139,6 +139,21 @@ void GraphicsPipeline::compile(Context& context) if (!_implementation[viewID]) { + GraphicsPipelineStates combined_pipelineStates; + combined_pipelineStates.reserve(context.defaultPipelineStates.size() + pipelineStates.size() + context.overridePipelineStates.size()); + mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, context.defaultPipelineStates); + mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, pipelineStates); + mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, context.overridePipelineStates); + + for (const auto& imp : _implementation) + { + if (imp && vsg::compare_pointer_container(imp->_pipelineStates, combined_pipelineStates) == 0) + { + _implementation[viewID] = imp; + return; + } + } + // compile shaders if required bool requiresShaderCompiler = false; for (const auto& shaderStage : stages) @@ -173,12 +188,6 @@ void GraphicsPipeline::compile(Context& context) shaderStage->compile(context); } - GraphicsPipelineStates combined_pipelineStates; - combined_pipelineStates.reserve(context.defaultPipelineStates.size() + pipelineStates.size() + context.overridePipelineStates.size()); - mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, context.defaultPipelineStates); - mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, pipelineStates); - mergeGraphicsPipelineStates(context.mask, combined_pipelineStates, context.overridePipelineStates); - _implementation[viewID] = GraphicsPipeline::Implementation::create(context, context.device, context.renderPass, layout, stages, combined_pipelineStates, subpass); } } @@ -188,6 +197,7 @@ void GraphicsPipeline::compile(Context& context) // GraphicsPipeline::Implementation // GraphicsPipeline::Implementation::Implementation(Context& context, Device* device, const RenderPass* renderPass, const PipelineLayout* pipelineLayout, const ShaderStages& shaderStages, const GraphicsPipelineStates& pipelineStates, uint32_t subpass) : + _pipelineStates(pipelineStates), _device(device) { VkGraphicsPipelineCreateInfo pipelineInfo = {}; diff --git a/src/vsg/state/ViewDependentState.cpp b/src/vsg/state/ViewDependentState.cpp index 2c41804876..50bb8e4848 100644 --- a/src/vsg/state/ViewDependentState.cpp +++ b/src/vsg/state/ViewDependentState.cpp @@ -394,6 +394,8 @@ void ViewDependentState::init(ResourceRequirements& requirements) Mask shadowMask = 0x1; // TODO: do we inherit from main scene? how? + auto viewportState = ViewportState::create(VkExtent2D{shadowWidth, shadowHeight}); + ref_ptr first_view; shadowMaps.resize(maxShadowMaps); for (auto& shadowMap : shadowMaps) @@ -411,6 +413,7 @@ void ViewDependentState::init(ResourceRequirements& requirements) shadowMap.view->mask = shadowMask; shadowMap.view->camera = Camera::create(); shadowMap.view->addChild(tcon); + shadowMap.view->camera->viewportState = viewportState; shadowMap.renderGraph = RenderGraph::create(); shadowMap.renderGraph->addChild(shadowMap.view); diff --git a/src/vsg/state/ViewportState.cpp b/src/vsg/state/ViewportState.cpp index ebaad250d4..c2f4a25a81 100644 --- a/src/vsg/state/ViewportState.cpp +++ b/src/vsg/state/ViewportState.cpp @@ -18,6 +18,7 @@ using namespace vsg; ViewportState::ViewportState() { + slot = 8; } ViewportState::ViewportState(const ViewportState& vs) : @@ -27,12 +28,14 @@ ViewportState::ViewportState(const ViewportState& vs) : { } -ViewportState::ViewportState(const VkExtent2D& extent) +ViewportState::ViewportState(const VkExtent2D& extent) : + ViewportState() { set(0, 0, extent.width, extent.height); } -ViewportState::ViewportState(int32_t x, int32_t y, uint32_t width, uint32_t height) +ViewportState::ViewportState(int32_t x, int32_t y, uint32_t width, uint32_t height) : + ViewportState() { set(x, y, width, height); } @@ -136,6 +139,12 @@ void ViewportState::apply(Context& context, VkGraphicsPipelineCreateInfo& pipeli pipelineInfo.pViewportState = viewportState; } +void ViewportState::record(CommandBuffer& commandBuffer) const +{ + vkCmdSetScissor(commandBuffer, 0, static_cast(scissors.size()), scissors.data()); + vkCmdSetViewport(commandBuffer, 0, static_cast(viewports.size()), viewports.data()); +} + VkViewport& ViewportState::getViewport() { if (viewports.empty()) diff --git a/src/vsg/text/shaders/text_ShaderSet.cpp b/src/vsg/text/shaders/text_ShaderSet.cpp index 33c66da1a7..a106043468 100644 --- a/src/vsg/text/shaders/text_ShaderSet.cpp +++ b/src/vsg/text/shaders/text_ShaderSet.cpp @@ -2,7 +2,7 @@ #include static auto text_ShaderSet = []() { static const uint8_t data[] = { -35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 48, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, +35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 49, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 101, 116, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 16, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 116, 97, 103, 101, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 3, 0, 0, 0, 17, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 77, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 245, 16, 0, 0, diff --git a/src/vsg/utils/GraphicsPipelineConfigurator.cpp b/src/vsg/utils/GraphicsPipelineConfigurator.cpp index 13ecf03394..698139c635 100644 --- a/src/vsg/utils/GraphicsPipelineConfigurator.cpp +++ b/src/vsg/utils/GraphicsPipelineConfigurator.cpp @@ -78,9 +78,9 @@ struct AssignGraphicsPipelineStates : public vsg::Visitor vertexInputState = VertexInputState::create(ias); config->pipelineStates.push_back(vertexInputState); } - void apply(vsg::ViewportState& ias) override + void apply(vsg::ViewportState& vs) override { - viewportState = ViewportState::create(ias); + viewportState = ViewportState::create(vs); config->pipelineStates.push_back(viewportState); } }; @@ -167,7 +167,7 @@ bool DescriptorConfigurator::assignTexture(const std::string& name, const ImageI // set up bindings if (!textureBinding.define.empty()) defines.insert(textureBinding.define); - for (auto& imageInfo : imageInfoList) + for (const auto& imageInfo : imageInfoList) { if (imageInfo->imageView && imageInfo->imageView->image) { diff --git a/src/vsg/utils/shaders/flat_ShaderSet.cpp b/src/vsg/utils/shaders/flat_ShaderSet.cpp index 664f8afb65..e29957694c 100644 --- a/src/vsg/utils/shaders/flat_ShaderSet.cpp +++ b/src/vsg/utils/shaders/flat_ShaderSet.cpp @@ -2,7 +2,7 @@ #include static auto flat_ShaderSet = []() { static const uint8_t data[] = { -35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 48, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, +35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 49, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 101, 116, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 16, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 116, 97, 103, 101, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 3, 0, 0, 0, 17, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 77, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 71, 17, 0, 0, diff --git a/src/vsg/utils/shaders/pbr_ShaderSet.cpp b/src/vsg/utils/shaders/pbr_ShaderSet.cpp index ab85e9eb62..d6e9695f89 100644 --- a/src/vsg/utils/shaders/pbr_ShaderSet.cpp +++ b/src/vsg/utils/shaders/pbr_ShaderSet.cpp @@ -2,7 +2,7 @@ #include static auto pbr_ShaderSet = []() { static const uint8_t data[] = { -35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 48, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, +35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 49, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 101, 116, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 16, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 116, 97, 103, 101, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 3, 0, 0, 0, 17, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 77, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 71, 17, 0, 0, diff --git a/src/vsg/utils/shaders/phong_ShaderSet.cpp b/src/vsg/utils/shaders/phong_ShaderSet.cpp index d1cb88e04c..2575ae8a63 100644 --- a/src/vsg/utils/shaders/phong_ShaderSet.cpp +++ b/src/vsg/utils/shaders/phong_ShaderSet.cpp @@ -2,7 +2,7 @@ #include static auto phong_ShaderSet = []() { static const uint8_t data[] = { -35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 48, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, +35, 118, 115, 103, 98, 32, 49, 46, 49, 46, 49, 49, 10, 1, 0, 0, 0, 14, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 101, 116, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 16, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 83, 116, 97, 103, 101, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 3, 0, 0, 0, 17, 0, 0, 0, 118, 115, 103, 58, 58, 83, 104, 97, 100, 101, 114, 77, 111, 100, 117, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 71, 17, 0, 0, diff --git a/src/vsg/vk/Context.cpp b/src/vsg/vk/Context.cpp index 2b42ffe29b..68c3c078d2 100644 --- a/src/vsg/vk/Context.cpp +++ b/src/vsg/vk/Context.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 #include @@ -129,6 +130,8 @@ Context::Context(Device* in_device, const ResourceRequirements& in_resourceRequi { vsg::debug("Context::Context() reusing descriptorPools = ", descriptorPools); } + + defaultPipelineStates.push_back(DynamicState::create()); } Context::Context(const Context& context) : diff --git a/src/vsg/vk/ResourceRequirements.cpp b/src/vsg/vk/ResourceRequirements.cpp index aacda91060..b9947f2778 100644 --- a/src/vsg/vk/ResourceRequirements.cpp +++ b/src/vsg/vk/ResourceRequirements.cpp @@ -155,7 +155,6 @@ void CollectResourceRequirements::apply(const PagedLOD& plod) void CollectResourceRequirements::apply(const StateCommand& stateCommand) { if (stateCommand.slot > requirements.maxSlot) requirements.maxSlot = stateCommand.slot; - stateCommand.traverse(*this); } @@ -212,8 +211,15 @@ void CollectResourceRequirements::apply(const Light& light) requirements.viewDetailsStack.top().lights.insert(&light); } +void CollectResourceRequirements::apply(const RenderGraph& rg) +{ + if (rg.viewportState) rg.viewportState->accept(*this); + rg.traverse(*this); +} + void CollectResourceRequirements::apply(const View& view) { + if (view.camera && view.camera->viewportState) view.camera->viewportState->accept(*this); if (auto itr = requirements.views.find(&view); itr != requirements.views.end()) {