Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5528a38
Renamed StateComponent to StateCommand to better reflect it's functio…
robertosfield Feb 28, 2019
517f2b8
Refactored StateGroup to manage a vector of StateCommands, and for St…
robertosfield Feb 28, 2019
7729316
Fixed copy and paste bug.
robertosfield Feb 28, 2019
e416a09
Refactored PipelineLayout so that the the main public class is now a …
robertosfield Mar 1, 2019
1fa3bf5
Refaced DescriptorSetLayout into new Interface::Implementation arrang…
robertosfield Mar 1, 2019
6fd10e5
Refactor of Pipeline/ComputePipeline/GraphicsPipeline, PipelineLayout…
robertosfield Mar 3, 2019
11d2dab
Refactored GraphicsPipeline, ComputePipeline, PushConstant, Pipeline,…
robertosfield Mar 5, 2019
a803c9a
Added beginnings of read/write support to GraphicsPipeline classes
robertosfield Mar 5, 2019
6c72c1c
Added serializer support for ShaderStages
robertosfield Mar 5, 2019
ef3e209
Added vsg::Texture descriptor from osg2vsg project
robertosfield Mar 6, 2019
ad19af9
Added MatrixTransform node
robertosfield Mar 6, 2019
7a22893
Improved PushConstants support for pushing/popping state
robertosfield Mar 6, 2019
937b02a
Added support for MatrixTransform and Commands
robertosfield Mar 6, 2019
0054327
Update all.h
robertosfield Mar 6, 2019
4994377
Fixed struct first seen as class warning related to forward declarati…
tomhog Mar 6, 2019
ceb98d8
Moved vsg::Geometry from osg2vsg to core VSG
robertosfield Mar 6, 2019
64e823d
Merge branch 'InterfaceImplementation' into topic-multitexturing-ii
tomhog Mar 6, 2019
f78a1d0
Changed struct to class to address warning
robertosfield Mar 6, 2019
d331690
Removed GraphicsNode and add Geometry and MatrixTransform to the Visi…
robertosfield Mar 6, 2019
5c54653
Added Uniform desctiptor type and UniformValue for adding values to t…
tomhog Mar 7, 2019
dd8b7a4
Merge branch 'InterfaceImplementation' into topic-uniforms
tomhog Mar 7, 2019
8ee8c4d
Revert "Fixed struct first seen as class warning related to forward d…
tomhog Mar 7, 2019
687bde4
Fix cast warning
tomhog Mar 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/vsg/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

// Node header files
#include <vsg/nodes/Commands.h>
#include <vsg/nodes/Geometry.h>
#include <vsg/nodes/Group.h>
#include <vsg/nodes/LOD.h>
#include <vsg/nodes/MatrixTransform.h>
#include <vsg/nodes/Node.h>
#include <vsg/nodes/QuadGroup.h>
#include <vsg/nodes/StateGroup.h>

// Traversal header files
#include <vsg/traversals/CompileTraversal.h>
#include <vsg/traversals/CullTraversal.h>
#include <vsg/traversals/DispatchTraversal.h>

Expand Down Expand Up @@ -99,7 +102,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/vk/Instance.h>
#include <vsg/vk/MemoryManager.h>
#include <vsg/vk/PhysicalDevice.h>
#include <vsg/vk/Pipeline.h>
#include <vsg/vk/PipelineLayout.h>
#include <vsg/vk/PushConstants.h>
#include <vsg/vk/RenderPass.h>
Expand All @@ -109,6 +111,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/vk/State.h>
#include <vsg/vk/Surface.h>
#include <vsg/vk/Swapchain.h>
#include <vsg/vk/Uniform.h>

// Input/Output header files
#include <vsg/io/AsciiInput.h>
Expand Down
10 changes: 8 additions & 2 deletions include/vsg/core/ConstVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ namespace vsg
class QuadGroup;
class LOD;
class StateGroup;
class MatrixTransform;
class Geometry;

// forward declare vulkan classes
class Command;
class CommandBuffer;
class RenderPass;
class BindPipeline;
class BindComputePipeline;
class BindGraphicsPipeline;
class GraphicsPipeline;
class ComputePipeline;
class Draw;
Expand Down Expand Up @@ -142,12 +145,15 @@ namespace vsg
virtual void apply(const QuadGroup&);
virtual void apply(const LOD&);
virtual void apply(const StateGroup&);
virtual void apply(const MatrixTransform&);
virtual void apply(const Geometry&);

// Vulkan nodes
virtual void apply(const Command&);
virtual void apply(const CommandBuffer&);
virtual void apply(const RenderPass&);
virtual void apply(const BindPipeline&);
virtual void apply(const BindComputePipeline&);
virtual void apply(const BindGraphicsPipeline&);
virtual void apply(const GraphicsPipeline&);
virtual void apply(const ComputePipeline&);
virtual void apply(const GraphicsPipelineState&);
Expand Down
10 changes: 8 additions & 2 deletions include/vsg/core/Visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ namespace vsg
class QuadGroup;
class LOD;
class StateGroup;
class MatrixTransform;
class Geometry;

// forward declare vulkan classes
class Command;
class CommandBuffer;
class RenderPass;
class BindPipeline;
class BindComputePipeline;
class BindGraphicsPipeline;
class GraphicsPipeline;
class ComputePipeline;
class Draw;
Expand Down Expand Up @@ -142,12 +145,15 @@ namespace vsg
virtual void apply(QuadGroup&);
virtual void apply(LOD&);
virtual void apply(StateGroup&);
virtual void apply(MatrixTransform&);
virtual void apply(Geometry&);

// Vulkan nodes
virtual void apply(Command&);
virtual void apply(CommandBuffer&);
virtual void apply(RenderPass&);
virtual void apply(BindPipeline&);
virtual void apply(BindComputePipeline&);
virtual void apply(BindGraphicsPipeline&);
virtual void apply(GraphicsPipeline&);
virtual void apply(ComputePipeline&);
virtual void apply(GraphicsPipelineState&);
Expand Down
47 changes: 47 additions & 0 deletions include/vsg/nodes/Geometry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

/* <editor-fold desc="MIT License">

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.

</editor-fold> */

#include <vsg/nodes/Node.h>

#include <vsg/vk/GraphicsPipeline.h>
#include <vsg/vk/PushConstants.h>
#include <vsg/vk/CommandPool.h>
#include <vsg/vk/DescriptorSet.h>
#include <vsg/vk/DescriptorPool.h>
#include <vsg/traversals/CompileTraversal.h>

namespace vsg
{
class Geometry : public Inherit<Node, Geometry>
{
public:
Geometry(Allocator* allocator = nullptr);

void accept(DispatchTraversal& dv) const override;

void compile(Context& context);

using Commands = std::vector<ref_ptr<Command>>;

// settings
DataList _arrays;
ref_ptr<Data> _indices;
Commands _commands;

// compiled objects
ref_ptr<Group> _renderImplementation;
};
VSG_type_name(vsg::Geometry)

}
47 changes: 47 additions & 0 deletions include/vsg/nodes/MatrixTransform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

/* <editor-fold desc="MIT License">

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.

</editor-fold> */

#include <vsg/nodes/Group.h>
#include <vsg/vk/PushConstants.h>

namespace vsg
{

class MatrixTransform : public Inherit<Group, MatrixTransform>
{
public:
MatrixTransform(Allocator* allocator = nullptr);
MatrixTransform(const mat4& matrix, Allocator* allocator = nullptr);

void setMatrix(const mat4& matrix) { (*_matrix) = matrix; }
mat4& getMatrix() { return _matrix->value(); }
const mat4& getMatrix() const { return _matrix->value(); }

inline void pushTo(State& state) const
{
_pushConstant->pushTo(state);
}

inline void popFrom(State& state) const
{
_pushConstant->popFrom(state);
}

protected:
ref_ptr<mat4Value> _matrix;
ref_ptr<PushConstants> _pushConstant;
};
VSG_type_name(vsg::MatrixTransform);

}
91 changes: 17 additions & 74 deletions include/vsg/nodes/StateGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,110 +14,53 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

#include <vsg/nodes/Group.h>
#include <vsg/vk/Command.h>
#include <vsg/vk/Descriptor.h>
#include <vsg/vk/DescriptorSet.h>

#include <vsg/traversals/CompileTraversal.h>

namespace vsg
{
// forward declare
class State;
class CommandBuffer;
class Context;

class StateComponent : public Inherit<Command, StateComponent>
{
public:
StateComponent(Allocator* allocator = nullptr) : Inherit(allocator) {}

virtual void compile(Context& /*context*/) {}

virtual void pushTo(State& state) const = 0;
virtual void popFrom(State& state) const = 0;

protected:
virtual ~StateComponent() {}
};
VSG_type_name(vsg::StateComponent);

class VSG_DECLSPEC StateSet : public Inherit<Object, StateSet>
class VSG_DECLSPEC StateGroup : public Inherit<Group, StateGroup>
{
public:
StateSet(Allocator* allocator = nullptr);
StateGroup(Allocator* allocator = nullptr);

void read(Input& input) override;
void write(Output& output) const override;

using StateComponents = std::vector<ref_ptr<StateComponent>>;
using StateCommands = std::vector<ref_ptr<StateCommand>>;

virtual void compile(Context& context)
void add(ref_ptr<StateCommand> stateCommand)
{
for(auto& component : _stateComponents)
{
component->compile(context);
}
_stateCommands.push_back(stateCommand);
}

virtual void pushTo(State& state) const
inline void pushTo(State& state) const
{
for(auto& component : _stateComponents)
for(auto& stateCommand : _stateCommands)
{
component->pushTo(state);
stateCommand->pushTo(state);
}
}

virtual void popFrom(State& state) const
inline void popFrom(State& state) const
{
for(auto& component : _stateComponents)
for(auto& stateCommand : _stateCommands)
{
component->popFrom(state);
stateCommand->popFrom(state);
}
}

inline void add(ref_ptr<StateComponent> component)
{
_stateComponents.push_back(component);
}

StateComponents _stateComponents;

protected:
virtual ~StateSet();
};
VSG_type_name(vsg::StateSet);


class VSG_DECLSPEC StateGroup : public Inherit<Group, StateGroup>
{
public:
StateGroup(Allocator* allocator = nullptr);

StateGroup(StateSet* stateset);

void read(Input& input) override;
void write(Output& output) const override;

using StateComponents = std::vector<ref_ptr<StateComponent>>;

void add(ref_ptr<StateComponent> component)
{
_stateset->add(component);
}

void setStateSet(ref_ptr<StateSet> stateset) { _stateset = stateset; }
StateSet* getStateSet() { return _stateset; }
const StateSet* getStateSet() const { return _stateset; }

inline void pushTo(State& state) const
{
_stateset->pushTo(state);
}
inline void popFrom(State& state) const
{
_stateset->popFrom(state);
}
virtual void compile(Context& context);

protected:
virtual ~StateGroup();

ref_ptr<StateSet> _stateset;
StateCommands _stateCommands;
};
VSG_type_name(vsg::StateGroup);

Expand Down
25 changes: 6 additions & 19 deletions include/vsg/traversals/CompileTraversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,39 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <memory>
#include <vsg/core/Object.h>

#include <vsg/nodes/Group.h>

#include <vsg/vk/CommandPool.h>
#include <vsg/vk/GraphicsPipeline.h>
#include <vsg/vk/DescriptorPool.h>

namespace vsg
{
struct Context
class Context
{
public:
ref_ptr<Device> device;
ref_ptr<CommandPool> commandPool;
ref_ptr<RenderPass> renderPass;
ref_ptr<ViewportState> viewport;
VkQueue graphicsQueue = 0;

ref_ptr<DescriptorPool> descriptorPool;
DescriptorSetLayouts descriptorSetLayouts;
ref_ptr<PipelineLayout> pipelineLayout;

ref_ptr<mat4Value> projMatrix;
ref_ptr<mat4Value> viewMatrix;
};

class GraphicsNode : public Inherit<Group, GraphicsNode>
{
public:
GraphicsNode(Allocator* allocator = nullptr):
Inherit(allocator) {}

void read(Input& input) override;
void write(Output& output) const override;

virtual void compile(Context& context) = 0;
};
VSG_type_name(vsg::GraphicsNode)


class VSG_DECLSPEC CompileTraversal : public Visitor
{
public:
explicit CompileTraversal();
~CompileTraversal();

void apply(Object& object);
void apply(Group& group);
void apply(Command& command);
void apply(StateGroup& stateGroup);
void apply(GraphicsNode& graphics);
void apply(Geometry& geometry);

Context context;
};
Expand Down
Loading