Sharing viewID, mask and ViewportState between vsg::View for better scaling of render to texture techniques #959
robertosfield
started this conversation in
General
Replies: 1 comment
-
I have checked in a change to the new vsgrendertexturearray to hare a single BindGraphicsPipeline between all the results textured quads, this lowers the noise of the number of vkPipeline required as now just 1 is used for the results window. Running the same models/lz.vsgt test above without sharing we now see just 49 vkPipelines used rather than 63: $ vsgrendertotexturearray models/lz.vsgt --numLayers 15
number of vsg::View 17
view = 0x7f654dc31048, viewID = 0, count = 1
view = 0x7f654dc31378, viewID = 1, count = 1
view = 0x7f654dc314e0, viewID = 2, count = 1
view = 0x7f654dc31658, viewID = 3, count = 1
view = 0x7f654dc317d8, viewID = 4, count = 1
view = 0x7f654dc31930, viewID = 5, count = 1
view = 0x7f654dc31ad8, viewID = 6, count = 1
view = 0x7f654dc31c30, viewID = 7, count = 1
view = 0x7f654dc31d88, viewID = 8, count = 1
view = 0x7f654dc31ef0, viewID = 9, count = 1
view = 0x7f654dc320d8, viewID = 10, count = 1
view = 0x7f654dc32230, viewID = 11, count = 1
view = 0x7f654dc32388, viewID = 12, count = 1
view = 0x7f654dc324e0, viewID = 13, count = 1
view = 0x7f654dc32638, viewID = 14, count = 1
view = 0x7f654dc327a0, viewID = 15, count = 1
view = 0x7f654dc342d0, viewID = 16, count = 1
number of vsg::GraphicsPipelines 4
pipeline = 0x7f654dd2aa40, count = 1536 pipeline->vk(0) = 0x55d30ed980f0 pipeline->vk(1) = 0x55d30e91b3a0 pipeline->vk(2) = 0x55d30e920170 pipeline->vk(3) = 0x55d30e925010 pipeline->vk(4) = 0x55d30e9e47e0 pipeline->vk(5) = 0x55d30e9e9510 pipeline->vk(6) = 0x55d30e9ee3a0 pipeline->vk(7) = 0x55d30ed796e0 pipeline->vk(8) = 0x55d30ed7e510 pipeline->vk(9) = 0x55d30ed834c0 pipeline->vk(10) = 0x55d30ed88350 pipeline->vk(11) = 0x55d30ed8d1e0 pipeline->vk(12) = 0x55d30eca26d0 pipeline->vk(13) = 0x55d30eca6a60 pipeline->vk(14) = 0x55d30ecab8b0 pipeline->vk(15) = 0x55d30ecb0740
pipeline = 0x7f654dd337a8, count = 16 pipeline->vk(0) = 0x55d30edce140 pipeline->vk(1) = 0x55d30e91ccb0 pipeline->vk(2) = 0x55d30e921a80 pipeline->vk(3) = 0x55d30e926920 pipeline->vk(4) = 0x55d30e9e60b0 pipeline->vk(5) = 0x55d30e9eae20 pipeline->vk(6) = 0x55d30e9efcb0 pipeline->vk(7) = 0x55d30ed7afb0 pipeline->vk(8) = 0x55d30ed7feb0 pipeline->vk(9) = 0x55d30ed84dd0 pipeline->vk(10) = 0x55d30ed89c60 pipeline->vk(11) = 0x55d30ed8eaf0 pipeline->vk(12) = 0x55d30eca38c0 pipeline->vk(13) = 0x55d30eca8330 pipeline->vk(14) = 0x55d30ecad1c0 pipeline->vk(15) = 0x55d30ecb2050
pipeline = 0x7f654dd33f30, count = 16 pipeline->vk(0) = 0x55d30e917dd0 pipeline->vk(1) = 0x55d30e91e5c0 pipeline->vk(2) = 0x55d30e9233c0 pipeline->vk(3) = 0x55d30e9e2f10 pipeline->vk(4) = 0x55d30e9e7980 pipeline->vk(5) = 0x55d30e9ec730 pipeline->vk(6) = 0x55d30e9f15c0 pipeline->vk(7) = 0x55d30ed7c880 pipeline->vk(8) = 0x55d30ed81850 pipeline->vk(9) = 0x55d30ed866e0 pipeline->vk(10) = 0x55d30ed8b570 pipeline->vk(11) = 0x55d30ed90400 pipeline->vk(12) = 0x55d30eca5190 pipeline->vk(13) = 0x55d30eca9c40 pipeline->vk(14) = 0x55d30ecaead0 pipeline->vk(15) = 0x55d30ecb3960
pipeline = 0x7f654dd3be38, count = 1 pipeline->vk(16) = 0x55d30ecb5f70
number of vkPipelines = 49 And when running with sharing the same test results in just 7 vkPipelines required: $ vsgrendertotexturearray models/lz.vsgt --numLayers 15 -s
number of vsg::View 17
view = 0x7f40d0d25048, viewID = 0, count = 1
view = 0x7f40d0d25378, viewID = 1, count = 1
view = 0x7f40d0d254e0, viewID = 1, count = 1
view = 0x7f40d0d25658, viewID = 1, count = 1
view = 0x7f40d0d257d8, viewID = 1, count = 1
view = 0x7f40d0d25930, viewID = 1, count = 1
view = 0x7f40d0d25ad8, viewID = 1, count = 1
view = 0x7f40d0d25c30, viewID = 1, count = 1
view = 0x7f40d0d25d88, viewID = 1, count = 1
view = 0x7f40d0d25ef0, viewID = 1, count = 1
view = 0x7f40d0d260d8, viewID = 1, count = 1
view = 0x7f40d0d26230, viewID = 1, count = 1
view = 0x7f40d0d26388, viewID = 1, count = 1
view = 0x7f40d0d264e0, viewID = 1, count = 1
view = 0x7f40d0d26638, viewID = 1, count = 1
view = 0x7f40d0d267a0, viewID = 1, count = 1
view = 0x7f40d0d282d0, viewID = 2, count = 1
number of vsg::GraphicsPipelines 4
pipeline = 0x7f40d0e1ea40, count = 1536 pipeline->vk(0) = 0x55deeab2ee70 pipeline->vk(1) = 0x55deea84c820
pipeline = 0x7f40d0e277a8, count = 16 pipeline->vk(0) = 0x55deeac83eb0 pipeline->vk(1) = 0x55deea84e130
pipeline = 0x7f40d0e27f30, count = 16 pipeline->vk(0) = 0x55deeac88500 pipeline->vk(1) = 0x55deea84fa40
pipeline = 0x7f40d0e2e2a8, count = 1 pipeline->vk(2) = 0x55deea851f00
number of vkPipelines = 7 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have just completed a refactor of vsg::View that enables multiple vsg::View to share the same viewID, this is useful because the vsg::GraphicsPipeline creates a dedicated vkPipeline per viewID, so if we can share the viewID we can also reduce the number vkPipeline that we need to create and how many the GPU has to deal with when rendering.
This capability is especially important when doing effects like shadows where we can multiple shadow maps that we are rendering per frame, and in cases where the shadow maps having the same dimensions means we can ensure that the VSG only creates the unique vkPipeline when required, rather multiplying up the number of required vkPipeline as the number of shadow maps increases.
For instance is a 3d scene on it's own has 100 vkPipeline, but we add 16 shadow maps to render, then we'd need original 100 plus 1600 more if the VSG required a separate viewID per shadow map rendering. With the new sharing of viewID we can keep the additional number of vkPipeline down to 200.
The changes required for this new capability is now checked into VSG master, I also bumped the version to 1.0.10-rc1 to differentiate it from the 1.0.9 stable release:
Changes to VulkanSceneGraph for shared View::viewID
To test this functionality I wrote a vsgrendertotexturearray example that is now merged with vsgExamples master.
vsgrendertotexturearray example
This example by default creates a texture 2D array style vkImage with 5125x512 with 4 layers, you can set the num of layers with --numLaayers
The example has some very basic scene stats collected that report the number of vkPipeline that are required and for the above test the results reported to the console are:
By default this example doesn't share the viewID so 15 layers we have on vsg::View for the main 3D window, another for the results window, and then another 15 views for the render to texture to each of the layers of the vkImage.
To enable sharing add -s to command line and the visual results are identical but you can see how the number of viewID has dropped to just 3 and with many less pipelines required:
These are just very simple models, for game/simulator scale applications we can expect many more vkPipeline and many render to texture effects so the scale of saving can be significant.
This example also illustrates how to set of a render to texture for a texture 2D array, and how to create an interactive results window, the following screenshot illustrates this results window zoomed into one of the image layers rendered as a quad.
The example doesn't do anything fancy with the view and projection matrices of the rendering to texture View's so all the layers just have the same image for now. The results window also create the pipeline for every quad which is inefficient as well so some parts aren't an ideal illustration of how to do things with the VSG. My focus so far for this example is to test out the SharedViewID work. I'll be revisiting this example to refine it future so these short comings should be addressed soon.
Sharing of the viewID is only appropriate for vsg::View that share the same ViewportState and mask, when this is satisfied you either share the details via the vsg::View copy constructor:
Or you can share the view's viewID, mask and ViewportState details by calling the View::share(const View&) method:
Beta Was this translation helpful? Give feedback.
All reactions