Vulkan sample rendering 3D with 'worker-threads'
C++ C Other
Switch branches/tags
Nothing to show
Clone or download
Latest commit 88f4a96 Oct 28, 2016
Permalink
Failed to load latest commit information.
GLSL First shot of public version Feb 16, 2016
doc re-phrased and warning on the image that is not optimal Feb 25, 2016
mt changes to make the sample Linux compliant. Still issues to solve Oct 22, 2016
shared_external @ fe4b022 submodule changes Oct 27, 2016
shared_sources @ abab42d submodule changes Oct 27, 2016
.gitattributes 🎊 Added .gitattributes & .gitignore files Feb 16, 2016
.gitignore First shot of public version Feb 16, 2016
.gitmodules added submodule shared_external Oct 27, 2016
CMakeLists.txt () Oct 27, 2016
GLSLShader.cpp First shot of public version Feb 16, 2016
GLSLShader.h First shot of public version Feb 16, 2016
NVK.cpp making NVK Linux friendly Oct 25, 2016
NVK.h making NVK Linux friendly Oct 25, 2016
README.md wrong link Feb 25, 2016
bk3dBase.h Merge branch 'master' of https://github.com/nvpro-samples/gl_vk_bk3dt… Oct 25, 2016
bk3dDefs.h First shot of public version Feb 16, 2016
bk3dEx.h bk3d mesh linux-friendly Oct 25, 2016
bk3d_glcommandlist.cpp fixed errors on conversion Oct 25, 2016
bk3d_glstandard.cpp fixed errors in precision conversion Oct 25, 2016
bk3d_vk.cpp added wait for Idle so no crash Oct 26, 2016
gl_nv_command_list.cpp First shot of public version Feb 16, 2016
gl_nv_command_list.h First shot of public version Feb 16, 2016
gl_nv_commandlist_helpers.h First shot of public version Feb 16, 2016
gl_vk_bk3dthreaded.cpp clean termination. replaced some tabs with spaces Oct 26, 2016
gl_vk_bk3dthreaded.h clean implementation of many cmdBufferPools Oct 12, 2016
helper_fbo.h First shot of public version Feb 16, 2016
nv_dds.cpp First shot of public version Feb 16, 2016
nv_dds.h First shot of public version Feb 16, 2016
svcmfcui.h First shot of public version Feb 16, 2016

README.md

Vulkan & OpenGL & Command-list Sample using "Thread-Workers"

With the official release of Vulkan, NVIDIA and the "Devtech-Proviz" Team released new samples on professional graphics repository.

The Purpose of this Blog post is to give more details on what is happening in the Sample called gl_vk_bk3dthreaded (available here).

Example

How to build the sample

For now, I am sorry to say that the sample might only run on Windows. I didn't consolidate it for Linux, yet.

This sample requires the following:

  • LunarG SDK v1.0.3.1 : just install it from https://vulkan.lunarg.com : cmake should be able to locate it
  • shared sources : this folder contains few helper files and additional cmake information needed to build the project
  • shared external : this folder a is a convenient way to gather all external tool that our samples rely on. Rather than trying to find back the right versions of zlib, AntTweakbar etc, this folder contains all the needed external projects that our samples need:
    • zlib: to read gz files (3D model(s) )
    • SvcMfCUI: a simple UI based on Windows MFC. No fancy but convenient
    • AntTweakBar (not used in this sample... yet. SvcMfCUI used instead)
    • Optionally: NSight nvTX custom markers
  • the submarine model: when you will configure the project with cmake, cmake script will perform a wget to get the model and store it locally: MODEL_DOWNLOAD_SUBMARINE Checked. The model is 32Mb and will be stored in a shared folder called downloaded_resources

Optionally, be aware that other bk3d models could be used in this sample. But to avoid heavy download, only the submarine will be taken by default. Check MODEL_DOWNLOAD_MORE On for more models...

How does the sample work

The sample will run by default with the submarine model and some camera animation. So if you want to freely move the camera, don't forget to stop the animation (UI or 'a' key)

If you give as cmd-line argument another model (*.bk3d.gz or *.bk3d), the sample should be able to render it but the animation will be turned off; and it is possible that the camera won't focus exactly over the new model...

Vulkan renderer will be the default one at startup. You can switch between:

  • OpenGL & Command-lists: an example on how to feed the token-buffers
  • OpenGL: a basic implementation of how would you render 3D with OpenGL
  • Vulkan: the default renderer

toggles

Note: toggles are preceded by a character between quotes: when the viewport has the focus, you can use the keyboard instead.

  • Use Workers: checked for multi-threading. Unchecked: only the main thread will update the draw commands (cmd-buffers)
  • command-buffer amount: by default, 16 secondary command-buffers will be created to render everything. In the multi-threading case, thread-workers will get spawned and will work on building them: when 'c' toggle is checked (command-buffer continuous refresh)
  • Cmd-buf-style: this model came from a CAD application. It turns out that at the time this model was created, primitives were issued depending on their 'parts', rather than depending on their primitive type and/or materials (hence shaders). "sort on primitive type" would allow to first render triangles; then strips; then lines...
  • MSAA: Multispampling mode
  • 'c', &g_bRefreshCmdBuffers, "c: toggles command buffer continuous refresh\n");
  • , &m_realtime.bNonStopRendering, "space: toggles continuous rendering\n");
  • toggles from 'o'to '5' are obvious options... just give a try

###cmd-line arguments

  • -v (VBO max Size)
  • -m (bk3d model)
  • -c 0 or 1 : use command-lists
  • -o 0 or 1 : display meshes
  • -g 0 or 1 : display grid
  • -s 0 or 1 : stats
  • -a 0 or 1 : animate camera
  • -d 0 or 1 : debug stuff (ui)
  • -m (bk3d file) : load a specific model
  • (bk3d file name) : load a specific model
  • -q (msaa) : MSAA

mouse

special Key with the mouse allows few to move around the model. The camera is always targeting a focus point and is essentially working in "polar coordinates" (TODO: I need to display the focus point with a cross...)

  • mouse wheel: zoom in/out from the focus point
  • left mouse button: rotate around the focus point
  • right mouse button: rotate around Ox axis and zoom in/out from focus point
  • right mouse button + Ctrl: will push forward/backward the focus point
  • middle mouse button: pan left/right up/down the focus point along camera axis
  • arrows: rotate around the focus point
  • Pg-up/Pg-down: zoom in/out
  • Pg-up/Pg-down + Ctrl: push forward/backward the focus point along camera axis

3D model(s)

the 3D model comes from a pre-baked format (see here ). There is no value to understand how it is working: main interest is that it loads fast (baked format... saving us parsing time) and that I managed to 'capture' some models as they were issued by various applications.

The sample will load the model, then attach it to the renderers. The resource creation will thus depend on which Graphic API is being used.

More technical details

Here are more details in separate sub-sections :

    Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
     * Neither the name of NVIDIA CORPORATION nor the names of its
       contributors may be used to endorse or promote products derived
       from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.