Perhaps you could talk a bit about the SharedObjects vs ObjectCache a bit more? It looks like ObjectCache just operates at a bit of a higher level but is essentially has the same functionality as the ObjectCache. If I'm reading this right, would it make sense to include SharedObjects directly into the ObjectCache? Or would you use them separate from each other
My next step will be use all these settings to help create the scene graph elements required, this will really shake down whether this approach really is going to be practical.
Consider the case where your application reads a control file to open various datasets for display. I then create a thread for each dataset to build its own 'branch' of the scene graph and then add them all to a root group node in the frame loop when they are ready. They will all need different shader setups and defines. Will setting a define in one thread contaminate another thread? My immediate thought is that I would prefer to set the shader components in vsg::Options.
Hi Robert,
as you know I'm still with OSG and following your VSG development loosely.
Please don't forget the efforts of mesh shaders and textures working on buffer arrays. In my opinion based on my experiences with mesh shades in OSG this is the future of graphics development. In my case 10 times performance on graphics cards and the endless flexibility IS the future.
Thanks
Werner
as you know I'm still with OSG and following your VSG development loosely.
Please don't forget the efforts of mesh shaders and textures working on buffer arrays. In my opinion based on my experiences with mesh shades in OSG this is the future of graphics development. In my case 10 times performance on graphics cards and the endless flexibility IS the future
I haven't yet made ShaderSet's::getShaderStages() method thread safe, but I'll before this work is complete so you'll be able to share a single ShaderSet between loader threads and each one will be able to access the variants safely. SharedObjects is already thread safe.
Tomorrow I'll clean up my vsg::Builder changes and get these checked in. It'll be interesting to compare the two approaches, something that will be easier once we have a clean old Builder.cpp implementation and a new clean Builder.cpp implementation.
Next up I'll port vsgXchange::Assimp across to use vsg::ShaderSet/GraphicsPipelineConfig/SharedObjects. This is the final big test of how well this new functionality is hanging together.
I'm optimistic that I should have something working by the end of tomorrow and check in so others can test it out.
I had a chance to port some easy code over to the StateComposer to give it a try. Currently I have setup the GraphicsPipelineConfig as follows:auto shaderSet = vsg::createFlatShadedShaderSet();
auto graphicsPipelineConfig = vsg::GraphicsPipelineConfig::create(shaderSet);
graphicsPipelineConfig->enableArray("vsg_Vertex", VK_VERTEX_INPUT_RATE_VERTEX, 12);
graphicsPipelineConfig->enableArray("vsg_Normal", VK_VERTEX_INPUT_RATE_VERTEX, 12);
graphicsPipelineConfig->enableArray("vsg_TexCoord0", VK_VERTEX_INPUT_RATE_VERTEX, 8);
graphicsPipelineConfig->init();// accessed by the ReaderWriters to setup pipelines and layouts
options->setObject("SiegeNodeGraphicsPipeline", graphicsPipelineConfig->bindGraphicsPipeline);
options->setObject("SiegeNodeLayout", graphicsPipelineConfig->bindGraphicsPipeline->pipeline->layout);This crashed due to the texture missing from the dataset. With the current implementation you have to assignTexture right on the PipelineConfig. This isn't that flexible as in my loaders I read the layout and assign textures right in the ReaderWriter. This allows me to have the GraphicsPipeline at the top of my graph and then not repeat the pipeline over and over. With the above approach Ill have to a config and do an init() for every unique node that gets loaded.If I'm offbase - help would be appreciated.
> Just taking a look at the changes so far and man this is looking much easier. There is a macro in Builder that is throwing a warning> for me for VSG_COMPARE_PARAMETERS. Can that be removed in favor of the work you did in compare.h for sharing?We can probably remove the compare code completely now as I don't think it'll be used anymore - instead the state sharing provided by vsg::SharedObjects will do this for us.
Sounds similar to what I was brushing up against. I'll take a look at this latest pass with DescriptorConfig and see how it feels in my code base. Will you also be moving over the vsg::Text techniques over prior to the merge to master?
vsg::GraphicsPipeline's aren't yet sharing when I thought they might, so still need to do some more work. If I can get the sharing of pipelines working it will help both initial compile performance and runtime performance.
I have now got GraphicsPipeline sharing, which is working well for standalone loads of models. when loading multiple models together and sharing objects between the successive loads isn't yet working reliably.
Would be good to have those ideas in one place, so that contributors could pick one up. Like a spin-off TODO list.
One loose end might to add support for the vsg::SaderSet to provide a way of providing custom vsg::ArrayState that can be used to enable utilities like the LineSegmentIntersector to handle shaders that modified the vertex coordinates so that normal treatment of modelview matrix and vertex values don't work correctly. Currently applications have to explicitly attach the ArraySet to the StateGroup that provides the BindGraphicsPipleine with the novel vertex shader treatment, the StateGroup::prototypeArrayState member is what does this:
/// if the shaders associated with GraphicsPipeline don't treat the array 0 as xyz vertex then provide a ArrayState prototype to provide custom mapping of arrays to vertices.
ref_ptr<ArrayState> prototypeArrayState;I'm thinking that perhaps vsg::ShaderSet could have this same member variable, with the same naming. and then have the scene graph creation code that is setting up the vsg::StateGroup to assign this member.When serializing the ArrayState one would need to implement the read/write support and register this with the vsg::ObjectFactory to get everything to work when serializing the shader sets.Um... I think I'll add this and wrap it up for the day
I just made build and run tests with the vsgstatecomposer demo. It works well on MacOS 12 and Windows 10, when the Phong shader set is used. PBR needs special treatment I guess.
thanks for the explanation. The new classes will ease the use of vsg a lot, especially for non-experts. I like it.
I haven't yet implemented the internals of the PositionAndDisplacementMapArrayState, PositionArrayState and DisplacementMapArrayState classes used above, so for now vsgintersection can't yet intersection scene graphs generated with instance or displacement maps. This afternoon I'll tackle this and am hoping to finally get vsgintersection to work with all the different combinations of vsgbuilder usage. Once I achieve this I will have finally provided a solution for a long standard challenge with handling vertex shaders in a general purpose way - how to handle vertex shaders that change the vertex positions on the C++ side.



I'm probably out of my depth on this, but I remember a few years ago when I first started experimenting with Vulkan I wrote a small program that used texture2D (as an array) and a sampler in GLSL, but it was very hacky (and static). Maybe it could be helpful... if relevant - maybe not. The code is like this (global):
uniform texture2D textures[1024]
uniform sampler texsampler
vec4 color = texture(sampler2D(textures[texid], texsampler), texcoord)
where the 'texid' was from the vertex shader (vertex attribute)
For specific pipeline:
fragment:
I then hardcoded shaders and modified the text where: "outColor = inColor*texture(sampler2D(textures[" --some indexer as a string -- "], texsampler), inUV)"
Then on launch all of my textures get loaded into a global array, using a function that loads an image from file and fills the texture struct containing vk image, vk device memory, and vk image view
The function also indexes each texture (to an id that corresponds to textures[id] in the shaders). Per vertex texture id is maybe not the right way, but there's always another way.
Not sure if that little hack is helpful.
I also just wanted to say I really have been enjoying using VSG for my small project. It's appreciated since it saves me a lot of time and hard work.
I've been working on a small game engine and hopefully to become a full game. I had been keeping up with StateComposer branch specifically since it's very useful when it comes to a resource loader/manager in a game engine.
Well... good luck with the work today - and I don't want to lie, I don't fully understand what's going on under the hood, nor do I want to - I trust your design and everything seems well-crafted - I guess that was the intention right? Thanks for VSG. I'll probably be releasing some of my work soon, specifically my VSG SDL integration, which might be sought after by anyone who likes SDL! Again, thanks for this library.

The testing showed that the vsg::ComputeBounds traversal doesn't yet handle displacement mapping and instancing that the vsg::LineSegmentIntersector can handle so I'll need to adapt ComputeBouns to utilize the full capabilities of vsg::ArrayState.


-- Build files have been written to: /Volumes/Ramdisk/vsgXchange
[16/32] Building CXX object src/CMakeFiles/vsgXchange.dir/Release/stbi/stbi.cpp.o
FAILED: src/CMakeFiles/vsgXchange.dir/Release/stbi/stbi.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DASSIMP_VERSION_MAJOR=5 -DASSIMP_VERSION_MINOR=2 -DASSIMP_VERSION_PATCH=0 -DBASISD_SUPPORT_FXT1=0 -DBASISU_NO_ITERATOR_DEBUG_LEVEL -DKHRONOS_STATIC -DKTX_FEATURE_KTX1 -DKTX_FEATURE_KTX2 -DLIBKTX -DUSE_FREETYPE -DCMAKE_INTDIR=\"Release\" -I/Users/rainerge/Documents/GitHub/vsgXchange/include -I/Volumes/Ramdisk/vsgXchange/include -I/Users/rainerge/Documents/GitHub/vsgXchange/src/ktx/libktx -I/opt/homebrew/include/freetype2 -isystem /Users/rainerge/Soft/Packs/VSG/include -isystem /usr/local/include -isystem /Users/rainerge/Soft/Packs/Deps/include -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fPIC -std=gnu++17 -MD -MT src/CMakeFiles/vsgXchange.dir/Release/stbi/stbi.cpp.o -MF src/CMakeFiles/vsgXchange.dir/Release/stbi/stbi.cpp.o.d -o src/CMakeFiles/vsgXchange.dir/Release/stbi/stbi.cpp.o -c /Users/rainerge/Documents/GitHub/vsgXchange/src/stbi/stbi.cpp
/Users/rainerge/Documents/GitHub/vsgXchange/src/stbi/stbi.cpp:16:10: fatal error: 'vsg/io/ObjectCache.h' file not found
#include <vsg/io/ObjectCache.h>
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[17/32] Building CXX object src/CMakeFiles/vsgXchange.dir/Release/dds/dds.cpp.o
FAILED: src/CMakeFiles/vsgXchange.dir/Release/dds/dds.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DASSIMP_VERSION_MAJOR=5 -DASSIMP_VERSION_MINOR=2 -DASSIMP_VERSION_PATCH=0 -DBASISD_SUPPORT_FXT1=0 -DBASISU_NO_ITERATOR_DEBUG_LEVEL -DKHRONOS_STATIC -DKTX_FEATURE_KTX1 -DKTX_FEATURE_KTX2 -DLIBKTX -DUSE_FREETYPE -DCMAKE_INTDIR=\"Release\" -I/Users/rainerge/Documents/GitHub/vsgXchange/include -I/Volumes/Ramdisk/vsgXchange/include -I/Users/rainerge/Documents/GitHub/vsgXchange/src/ktx/libktx -I/opt/homebrew/include/freetype2 -isystem /Users/rainerge/Soft/Packs/VSG/include -isystem /usr/local/include -isystem /Users/rainerge/Soft/Packs/Deps/include -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fPIC -std=gnu++17 -MD -MT src/CMakeFiles/vsgXchange.dir/Release/dds/dds.cpp.o -MF src/CMakeFiles/vsgXchange.dir/Release/dds/dds.cpp.o.d -o src/CMakeFiles/vsgXchange.dir/Release/dds/dds.cpp.o -c /Users/rainerge/Documents/GitHub/vsgXchange/src/dds/dds.cpp
/Users/rainerge/Documents/GitHub/vsgXchange/src/dds/dds.cpp:16:10: fatal error: 'vsg/io/ObjectCache.h' file not found
#include <vsg/io/ObjectCache.h>
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[25/32] Building CXX object src/CMakeFiles/vsgXchange.dir/Release/ktx/ktx.cpp.o
ninja: build stopped: subcommand failed.
Thanks for the testing. Looks like my local header install still has the ObjectCache.h which has no been removed, so vsgXchange has kept compiling even though it shouldn't have. I'll scrub my include install and do a fresh build of everything.
There are also further opportunities to leverage vsg::ShaderSet to stream line the VSG code base and shaders. For instance I think it would be good to merge the Cpu and GpuLayoutTechinques ShaderSets and use #pragma(tic) shader composition to specialize the vertex shaders.
thanks, I tried it and it builds and works now.
--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BUBq9XdnS-GS5ntyfb94pfJKrPFERueV84LPAb_AQdj9w%40mail.gmail.com.
Just pulled vsg, vsgXchange and vsgImgui. Everything builds and runs using StateComposer branches on Kubuntu 20.04. I've only tested using my application, but it uses many StateComposer features.
The only possible problem I've noted is that I open a DXF file via vsgXchange and the TwoSided option doesn't appear to be working with StateComposer branch. I'm fairly certain this used to come in OK in the past. I'll investigate it more thoroughly - I'm in git branch disarray at present.
--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BUcmEZFY9rQpxa0dTonXvQGdmFKZFxmvUuVpEY-%3D_7%3D%2Bg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BVgMVFG4ZZeJhG09a5SvgvnUdYd9%2BCRTwAc8yJ2xz%3D_EA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BVgMVFG4ZZeJhG09a5SvgvnUdYd9%2BCRTwAc8yJ2xz%3D_EA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BXD73k6QtvGisJTgrmBcti9H4ZGsExNwgaw%2BE%3DrLRkg-w%40mail.gmail.com.
So now I'm getting your model lit on the one side and shadow on the other, despite the VSG_TWO_SIDED_LIGHTING #define's being enabled in the shader. I'll dig into the shaders.
I have dug into the PBR shaders and my quick change to support two sided lighting was modifying the normal orientation based on the wrong light direction. There was a light direction value set by the old pre vsg::Light code paths that I was used and this old code pat is hardwired for a headlight direction. I didn't see the problem because I was using the default headlight in testing.I am going to rip out the old hardwired lighting code to avoid these potential pitfalls of mixing and matching old and new. I should be able to resolve this all today.
--
You received this message because you are subscribed to the Google Groups "vsg-users : VulkanSceneGraph Developer Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vsg-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vsg-users/CAFN7Y%2BUXDYXayLHFcU3qZyFD9OFFHvZaGfYWHCktRc2PgP8hTQ%40mail.gmail.com.