Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadows #986

Closed
wants to merge 118 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
1164cdc
Preliminary experimenting with collecting data in ViewDependentState
robertosfield Jul 10, 2023
3c84c31
Merge branch 'master' into Shadows
robertosfield Jul 10, 2023
dc0ee00
Added Light::shadowMaps count
robertosfield Jul 18, 2023
95fad80
Merge branch 'master' into Shadows
robertosfield Jul 20, 2023
7c9d9be
Merge branch 'master' into Shadows
robertosfield Jul 20, 2023
9c803d4
Merge branch 'master' into Shadows
robertosfield Jul 28, 2023
9f76bc3
Added test code for collecting light stats needed to initialize the V…
robertosfield Jul 28, 2023
def08b3
Merge branch 'master' into ShadowStats
robertosfield Aug 2, 2023
35549ce
Merge branch 'master' into Shadows
robertosfield Aug 2, 2023
89f15fc
Added shadow map specific entries in vsg::ResourceHints and extra lig…
robertosfield Aug 2, 2023
882c343
Added shadow map settings to ResourceRequirements.
robertosfield Aug 2, 2023
2184829
Updated built-in shaders to reflect extra data additions for shadowmaps
robertosfield Aug 3, 2023
ec9756e
Tempo changes
robertosfield Aug 3, 2023
90c2ffb
Build fix
robertosfield Aug 3, 2023
8f4b9c2
Merge branch 'master' into ShadowNeedToFix
robertosfield Aug 9, 2023
f1fe16e
Fixed binding of shadow map
robertosfield Aug 9, 2023
8bbe4e6
Updated shaders and test shadow map texture2DArray
robertosfield Aug 11, 2023
f81a721
Merge branch 'master' into ShadowNeedToFix
robertosfield Aug 13, 2023
48635bb
Merge branch 'master' into Shadows
robertosfield Aug 13, 2023
b45f00e
Merge branch 'master' into ShadowNeedToFix
robertosfield Aug 14, 2023
df1e7fb
Merge branch 'master' into ShadowNeedToFix
robertosfield Aug 14, 2023
8b368a8
Merge branch 'master' into ShadowNeedToFix
robertosfield Aug 14, 2023
96bfdaa
Merge branch 'ShadowNeedToFix' into Shadows
robertosfield Aug 14, 2023
72fc92e
Removed unused member
robertosfield Aug 14, 2023
46c782c
Merge branch 'master' into Shadows
robertosfield Aug 16, 2023
bda1d35
Commented out of debug info
robertosfield Aug 18, 2023
e5dd3a1
Merge branch 'master' into Shadows
robertosfield Aug 21, 2023
b1cd23a
Merge branch 'master' into Shadows
robertosfield Aug 21, 2023
934c840
Merge branch 'master' into Shadows
robertosfield Aug 21, 2023
4de096d
Merge branch 'master' into Shadows
robertosfield Aug 22, 2023
b84d1ff
Merge branch 'master' into Shadows
robertosfield Aug 22, 2023
615d739
Merge branch 'master' into Shadows
robertosfield Aug 23, 2023
d65ff28
Merge branch 'master' into Shadows
robertosfield Aug 24, 2023
807faac
Merge branch 'master' into Shadows
robertosfield Aug 24, 2023
3bfadbf
Merge branch 'master' into Shadows
robertosfield Aug 24, 2023
fd0416e
Merge branch 'master' into Shadows
robertosfield Aug 30, 2023
5c05554
Merge branch 'master' into Shadows
robertosfield Aug 30, 2023
a606241
Merge branch 'master' into Shadows
robertosfield Aug 31, 2023
854fde1
Merge branch 'master' into Shadows
robertosfield Sep 4, 2023
2511be2
Added members for render backend for shadowmap
robertosfield Sep 4, 2023
4922344
Merge branch 'master' into Shadows
robertosfield Sep 6, 2023
6bd481e
Merge branch 'master' into Shadows
robertosfield Sep 7, 2023
ded6126
Added experimental Light Space computation code
robertosfield Sep 8, 2023
080c5e0
Updated ShaderSets
robertosfield Sep 8, 2023
8e5f3f2
Fixed computing of light direction in world coords
robertosfield Sep 11, 2023
a67666a
Added use of view y axis rather the view z direction to compute the l…
robertosfield Sep 11, 2023
aa653ae
Added computing of split positions of cascaded shadow maps
robertosfield Sep 11, 2023
120e1e3
Added reporting of cascaded shadow map extents.
robertosfield Sep 11, 2023
9e3a37f
Reordered to quieten warnings
robertosfield Sep 11, 2023
ef40962
Simplified compteuFrustumBounds(..) lambda function and added debug o…
robertosfield Sep 12, 2023
4dbe214
Fixed typos
robertosfield Sep 12, 2023
efcba9a
Cleaned up light space setup
robertosfield Sep 12, 2023
addb994
Added View constructor option to enable whether the ViewDependentStat…
robertosfield Sep 12, 2023
1e6e1e2
Added default constructor
robertosfield Sep 12, 2023
25e3be2
Fleshed out pre rendering CommandGraph/RenderGraph for ShadowMaps
robertosfield Sep 12, 2023
13a40ff
Set submitOrder to -1 to ensure pre-rendering
robertosfield Sep 12, 2023
ad8ad20
Fixed warning
robertosfield Sep 12, 2023
0f15fdb
Removed unneccessary includes
robertosfield Sep 13, 2023
9ca066f
Restructured how ViewDependentState is included
robertosfield Sep 13, 2023
3c8ffdf
Removed unneccessary vsg:: and added include
robertosfield Sep 13, 2023
0fd2f7e
Added includes to fix Windows shared libary build
robertosfield Sep 13, 2023
5a20383
Added include to fix Windows build
robertosfield Sep 13, 2023
50d3d20
Added experiments with setting up the rendering back end for shadow maps
robertosfield Sep 14, 2023
e0afaa5
Unified the camera setup
robertosfield Sep 15, 2023
365b333
Removed gcc specific debugging output
robertosfield Sep 15, 2023
2c56e78
Removed verbose debug info
robertosfield Sep 15, 2023
b611d6a
Removed debug info
robertosfield Sep 15, 2023
50ae831
Quitened down debug output and fixed typo
robertosfield Sep 15, 2023
faee768
Merge branch 'master' into ShadowExperiments
robertosfield Sep 16, 2023
a505e41
Converted shadow map texture setup to use the same vsg::Image/ImageVi…
robertosfield Sep 16, 2023
7fa26dd
Simplified the shadow map renderinb back end to just set up the requi…
robertosfield Sep 16, 2023
17bb45a
Added texgen matrix computation
robertosfield Sep 17, 2023
62fb13f
Restructured the assignment of the light data so that it's done as pa…
robertosfield Sep 17, 2023
c6c7264
Implemented passing of the shadow map texgen matrix to the GPU
robertosfield Sep 18, 2023
84d15b1
Update phong shader set to enable basic shadow mapping
robertosfield Sep 18, 2023
ea76b77
Updated phong ShaderSet to support multiple lights with shadow maps
robertosfield Sep 18, 2023
e4a7fe7
Added hardware PCF code path,
robertosfield Sep 18, 2023
61b78dd
Fixed sizing of the LightData.
robertosfield Sep 18, 2023
56578a2
Enabled control over maximum shadow distance when using cascaded shad…
robertosfield Sep 18, 2023
fae0efc
Add colours to simple shadow model shapes
robertosfield Sep 18, 2023
0a8bc7b
Added shadowMapBias paramter into shadow map texgen matrix.
robertosfield Sep 19, 2023
938f0da
Updated phong shaders
robertosfield Sep 19, 2023
67b3714
Merge pull request #974 from vsg-dev/ShadowExperiments
robertosfield Sep 19, 2023
b484e6d
Merge branch 'master' into ShadowExperiments
robertosfield Sep 19, 2023
6627a23
Merge pull request #975 from vsg-dev/ShadowExperiments
robertosfield Sep 19, 2023
66260bd
Quietened debug messages
robertosfield Sep 19, 2023
032eb03
Merge branch 'master' into Shadows
robertosfield Sep 19, 2023
312ed94
Quietened down debug messages
robertosfield Sep 19, 2023
081d3f5
Changed default shadow map bias
robertosfield Sep 19, 2023
756b19d
Removed shadowmap entries for point and spot lights as they don't yet…
robertosfield Sep 19, 2023
18d7204
Updated PBR and Phong ShaderSet with Shadow Mapping support
robertosfield Sep 19, 2023
6e03d7e
Merge branch 'master' into Shadows
robertosfield Sep 25, 2023
e2f843d
Ran clang-format
robertosfield Sep 26, 2023
44c7f04
Quietended cppcheck warnings
robertosfield Sep 26, 2023
ebc5d01
Fixed render to texture render pass settings
robertosfield Sep 26, 2023
6d581d3
Tightened up shadow map settings
robertosfield Sep 26, 2023
f961247
Tightened up shadow map texture settings and implemented support for …
robertosfield Sep 26, 2023
cb48b13
Added fixed fallback for shadow map texture
robertosfield Sep 27, 2023
bc7a064
Added image pipeline barrier to ensure the shadow map texture has an …
robertosfield Sep 27, 2023
892442c
Moved lambda parameter into ViewDependentState.
robertosfield Sep 27, 2023
2c2c9e8
Added support to vsg::Builder for decorating created subgraphs with C…
robertosfield Sep 27, 2023
bed64ae
Added lihnks for soft shadows
robertosfield Sep 27, 2023
d3e2a3f
updated built in shaders
robertosfield Sep 28, 2023
8aee613
Merge branch 'master' into Shadows
robertosfield Sep 28, 2023
2e457a0
Ran clang-format
robertosfield Sep 28, 2023
4e335d3
Updated built-in text ShaderSet
robertosfield Sep 28, 2023
4ece958
Updated the near vs max shadow distance check to just skip generation…
robertosfield Sep 29, 2023
c512bd6
Added missing vsg:: from implementation of vsg::determinant() that wa…
robertosfield Sep 29, 2023
7308488
Fixed bug in vsg::decompose(...)
robertosfield Sep 29, 2023
116f95d
Implemented RecordAnimationPathHandler that enables recording and pla…
robertosfield Sep 29, 2023
b79a2e0
Disabled the playing model when the path is 1 or less in size
robertosfield Sep 29, 2023
becb279
Fixed vsg::orthogaphic(..) depth range
robertosfield Oct 3, 2023
93b1fbf
Fixed cppcheck warning
robertosfield Oct 4, 2023
7f5232e
Updated built-in shaders
robertosfield Oct 4, 2023
96a94cf
Added support for use of vsg::ResourceRequirements and ResourceHints …
robertosfield Oct 4, 2023
118a7ec
Ran clang-format
robertosfield Oct 4, 2023
bc6c0ce
Updated version check
robertosfield Oct 4, 2023
531402d
Fixed Windows warnings
robertosfield Oct 4, 2023
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
1 change: 1 addition & 0 deletions include/vsg/app/CommandGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace vsg
class VSG_DECLSPEC CommandGraph : public Inherit<Group, CommandGraph>
{
public:
CommandGraph();
CommandGraph(ref_ptr<Device> in_device, int family);
explicit CommandGraph(ref_ptr<Window> in_window, ref_ptr<Node> child = {});

Expand Down
8 changes: 5 additions & 3 deletions include/vsg/app/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/app/Camera.h>
#include <vsg/app/Window.h>
#include <vsg/nodes/Group.h>
#include <vsg/state/ViewDependentState.h>

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<Group, View>
{
public:
View();
View(bool activeViewDependentState = true);

// share the specified view's children, viewID, mask and camera ViewportState
View(const View& view);

explicit View(ref_ptr<Camera> in_camera, ref_ptr<Node> in_scenegraph = {});
explicit View(ref_ptr<Camera> in_camera, ref_ptr<Node> in_scenegraph = {}, bool activeViewDependentState = true);

template<class N, class V>
static void t_accept(N& node, V& visitor)
Expand Down
18 changes: 9 additions & 9 deletions include/vsg/app/WindowResizeHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ 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.
class VSG_DECLSPEC UpdateGraphicsPipelines : public vsg::Inherit<vsg::Visitor, UpdateGraphicsPipelines>
class VSG_DECLSPEC UpdateGraphicsPipelines : public Inherit<Visitor, UpdateGraphicsPipelines>
{
public:
UpdateGraphicsPipelines();

vsg::ref_ptr<vsg::Context> context;
std::set<std::pair<const vsg::Object*, uint32_t>> visited;
ref_ptr<Context> context;
std::set<std::pair<const Object*, uint32_t>> visited;

bool visit(const Object* object, uint32_t index);

void apply(vsg::Object& object) override;
void apply(vsg::BindGraphicsPipeline& bindPipeline) override;
void apply(vsg::StateGroup& sg) override;
void apply(vsg::View& view) override;
void apply(Object& object) override;
void apply(BindGraphicsPipeline& bindPipeline) override;
void apply(StateGroup& sg) override;
void apply(View& view) override;
};
VSG_type_name(vsg::UpdateGraphicsPipelines);
VSG_type_name(UpdateGraphicsPipelines);

/// WindowResizeHandler class for updating viewport/scissor and attachments to fit with new window dimensions.
class VSG_DECLSPEC WindowResizeHandler : public Inherit<Visitor, WindowResizeHandler>
Expand Down Expand Up @@ -70,6 +70,6 @@ namespace vsg
void apply(ClearAttachments& clearAttachments) override;
void apply(View& view) override;
};
VSG_type_name(vsg::WindowResizeHandler);
VSG_type_name(WindowResizeHandler);

} // namespace vsg
2 changes: 1 addition & 1 deletion include/vsg/maths/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace vsg
return t_mat4<T>(2.0 / (right - left), 0.0, 0.0, 0.0,
0.0, 2.0 / (bottom - top), 0.0, 0.0,
0.0, 0.0, 1.0 / (zFar - zNear), 0.0,
-(right + left) / (right - left), -(bottom + top) / (bottom - top), zFar / (zFar - zNear), 1.0);
-(right + left) / (right - left), -(bottom + top) / (bottom - top), 0.5 - (zNear + zFar) / (2.0 * (zFar - zNear)), 1.0);
}

template<typename T>
Expand Down
1 change: 1 addition & 0 deletions include/vsg/nodes/Light.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace vsg
std::string name;
vec3 color = vec3(1.0f, 1.0f, 1.0f);
float intensity = 1.0f;
uint32_t shadowMaps = 0;

void read(Input& input) override;
void write(Output& output) const override;
Expand Down
5 changes: 5 additions & 0 deletions include/vsg/state/ResourceHints.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

</editor-fold> */

#include <vsg/maths/vec2.h>
#include <vsg/vk/DescriptorPool.h>

namespace vsg
Expand All @@ -32,6 +33,10 @@ namespace vsg
VkDeviceSize minimumBufferSize = 16 * 1024 * 1024;
VkDeviceSize minimumDeviceMemorySize = 16 * 1024 * 1024;

uivec2 numLightsRange = {8, 1024};
uivec2 numShadowMapsRange = {0, 64};
uivec2 shadowMapSize = {2048, 2028};

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

Expand Down
1 change: 1 addition & 0 deletions include/vsg/state/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

namespace vsg
{
// forward declare
class Context;

/// Sampler encapsulates the VkSampler and the VkSamplerCreateInfo settings used to set it up.
Expand Down
41 changes: 38 additions & 3 deletions include/vsg/state/ViewDependentState.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

</editor-fold> */

#include <vsg/app/CommandGraph.h>
#include <vsg/app/RenderGraph.h>
#include <vsg/io/Logger.h>
#include <vsg/nodes/Light.h>
#include <vsg/nodes/Switch.h>
#include <vsg/state/BindDescriptorSet.h>
#include <vsg/state/DescriptorBuffer.h>
#include <vsg/state/DescriptorImage.h>

namespace vsg
{
Expand Down Expand Up @@ -86,6 +91,9 @@ namespace vsg
};
VSG_type_name(vsg::BindViewDescriptorSets);

// forward declare
class ResourceRequirements;

/// ViewDependentState to manage lighting, clip planes and texture projection
/// By default assigned to the vsg::View, for standard usage you don't need to create or modify the ViewDependentState
/// If you wish to override the standard lighting support provided by ViewDependentState you can subclass it.
Expand All @@ -96,38 +104,65 @@ namespace vsg
class VSG_DECLSPEC ViewDependentState : public Inherit<Object, ViewDependentState>
{
public:
ViewDependentState(uint32_t maxNumberLights = 64, uint32_t maxViewports = 1);
ViewDependentState(View* view, bool in_active);

template<class N, class V>
static void t_traverse(N& node, V& visitor)
{
node.descriptorSet->accept(visitor);
if (node.preRenderCommandGraph) node.preRenderCommandGraph->accept(visitor);
}

void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
void traverse(RecordTraversal& rt) const override;

// containers filled in by RecordTraversal
std::vector<std::pair<dmat4, const AmbientLight*>> ambientLights;
std::vector<std::pair<dmat4, const DirectionalLight*>> directionalLights;
std::vector<std::pair<dmat4, const PointLight*>> pointLights;
std::vector<std::pair<dmat4, const SpotLight*>> spotLights;

virtual void compile(Context& context);
virtual void init(ResourceRequirements& requirements);

virtual void clear();
virtual void pack();
virtual void bindDescriptorSets(CommandBuffer& commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet);

virtual void compile(Context& context);

View* view = nullptr;
bool active = true;

ref_ptr<vec4Array> lightData;
ref_ptr<BufferInfo> lightDataBufferInfo;

ref_ptr<vec4Array> viewportData;
ref_ptr<BufferInfo> viewportDataBufferInfo;

ref_ptr<Image> shadowDepthImage;
ref_ptr<DescriptorImage> shadowMapImages;

ref_ptr<DescriptorSetLayout> descriptorSetLayout;
ref_ptr<DescriptorBuffer> descriptor;
ref_ptr<DescriptorSet> descriptorSet;

// shadow map hints
double maxShadowDistance = 1e8;
double shadowMapBias = 0.005;
double lambda = 0.5;

// Shadow backend.
ref_ptr<CommandGraph> preRenderCommandGraph;
ref_ptr<Switch> preRenderSwitch;

struct ShadowMap
{
ref_ptr<RenderGraph> renderGraph;
ref_ptr<View> view;
};

mutable std::vector<ShadowMap> shadowMaps;

protected:
~ViewDependentState();
};
Expand Down
35 changes: 35 additions & 0 deletions include/vsg/utils/AnimationPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ namespace vsg

ref_ptr<Object> object;
ref_ptr<AnimationPath> path;

KeySymbol resetKey = KEY_Space;

clock::time_point startPoint;
double time = 0.0;

Expand All @@ -85,4 +87,37 @@ namespace vsg
};
VSG_type_name(vsg::AnimationPathHandler);

/// RecordAnimationPathHandler event handler records the camera
class VSG_DECLSPEC RecordAnimationPathHandler : public Inherit<Visitor, RecordAnimationPathHandler>
{
public:
explicit RecordAnimationPathHandler(ref_ptr<Object> in_object, const Path& in_filename = "saved_animation.vsgt", ref_ptr<Options> in_options = {});

ref_ptr<Object> object;
Path filename;
ref_ptr<Options> options;

ref_ptr<AnimationPath> path;
KeySymbol toggleRecordingKey = KEY_r;
KeySymbol togglePlaybackKey = KEY_p;

bool recording = false;
bool playing = false;
clock::time_point startPoint;
double time = 0.0;

bool printFrameStatsToConsole = false;
clock::time_point statsStartPoint;
double frameCount = 0.0;

void apply(Camera& camera) override;
void apply(MatrixTransform& transform) override;

void apply(KeyPressEvent& keyPress) override;
void apply(FrameEvent& frame) override;

protected:
};
VSG_type_name(vsg::RecordAnimationPathHandler);

} // namespace vsg
16 changes: 5 additions & 11 deletions include/vsg/utils/GraphicsPipelineConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ namespace vsg
bool assignDescriptor(const std::string& name, ref_ptr<Data> 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> 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> 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> descriptor);

Expand Down Expand Up @@ -120,11 +116,9 @@ namespace vsg
bool assignDescriptor(const std::string& name, ref_ptr<Data> data = {});
bool assignTexture(const std::string& name, ref_ptr<Data> textureData = {}, ref_ptr<Sampler> 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> data = {}) { return assignDescriptor(name, data); }
[[deprecated("use assignDescriptor(..)")]] bool assignUniform(const std::string& name, ref_ptr<Data> data = {}) { return assignDescriptor(name, data); }

// setup by assign calls
ref_ptr<ShaderCompileSettings> shaderHints;
Expand Down
10 changes: 3 additions & 7 deletions include/vsg/utils/ShaderSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(const std::string& name, const std::string& define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr<Data> data);

[[deprecated("use addDescriptorBinding(..)")]]
void addUniformBinding(const std::string& name, const std::string& define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr<Data> data) { addDescriptorBinding(name, define, set, binding, descriptorType, descriptorCount, stageFlags, data); }

[[deprecated("use addDescriptorBinding(..)")]] void addUniformBinding(const std::string& name, const std::string& define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr<Data> 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(const std::string& name, const std::string& define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size);
Expand All @@ -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<ArrayState> getSuitableArrayState(const std::set<std::string>& defines) const;
Expand Down
3 changes: 2 additions & 1 deletion include/vsg/vk/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ namespace vsg
class VSG_DECLSPEC Context : public Inherit<Object, Context>
{
public:
explicit Context(Device* in_device, const ResourceRequirements& resourceRequirements = {});
explicit Context(Device* in_device, const ResourceRequirements& in_resourceRequirements = {});

Context(const Context& context);

virtual ~Context();

const uint32_t deviceID = 0;
ref_ptr<Device> device;
ResourceRequirements resourceRequirements;

observer_ptr<View> view;
uint32_t viewID = 0;
Expand Down
14 changes: 10 additions & 4 deletions include/vsg/vk/ResourceRequirements.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ namespace vsg
uint32_t computeNumDescriptorSets() const;
DescriptorPoolSizes computeDescriptorPoolSizes() const;

struct BinDetails
struct ViewDetails
{
std::set<int32_t> indices;
std::set<const Bin*> bins;
std::set<const Light*> lights;
};

using Descriptors = std::set<const Descriptor*>;
using DescriptorSets = std::set<const DescriptorSet*>;
using DescriptorTypeMap = std::map<VkDescriptorType, uint32_t>;
using Views = std::map<const View*, BinDetails>;
using BinStack = std::stack<BinDetails>;
using Views = std::map<const View*, ViewDetails>;
using ViewDetailStack = std::stack<ViewDetails>;

struct DynamicData
{
Expand Down Expand Up @@ -78,14 +79,18 @@ namespace vsg
DescriptorSets descriptorSets;
DescriptorTypeMap descriptorTypeMap;
Views views;
BinStack binStack;
ViewDetailStack viewDetailsStack;

uint32_t maxSlot = 0;
uint32_t externalNumDescriptorSets = 0;
bool containsPagedLOD = false;

VkDeviceSize minimumBufferSize = 16 * 1024 * 1024;
VkDeviceSize minimumDeviceMemorySize = 16 * 1024 * 1024;

uivec2 numLightsRange = {8, 1024};
uivec2 numShadowMapsRange = {0, 64};
uivec2 shadowMapSize = {2048, 2048};
};
VSG_type_name(vsg::ResourceRequirements);

Expand Down Expand Up @@ -114,6 +119,7 @@ namespace vsg
void apply(const DescriptorBuffer& descriptorBuffer) override;
void apply(const DescriptorImage& descriptorImage) override;
void apply(const PagedLOD& plod) override;
void apply(const Light& light) override;
void apply(const View& view) override;
void apply(const DepthSorted& depthSorted) override;
void apply(const Bin& bin) override;
Expand Down
4 changes: 4 additions & 0 deletions src/vsg/app/CommandGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

using namespace vsg;

CommandGraph::CommandGraph()
{
}

CommandGraph::CommandGraph(ref_ptr<Device> in_device, int family) :
device(in_device),
queueFamily(family),
Expand Down
Loading
Loading