Skip to content

nvpro-samples/nvpro_core2

Repository files navigation

nvpro_core2

License

A modular C++ framework for Vulkan 1.4+ and OpenGL 4.6 development, designed as the successor to nvpro_core. This framework provides a collection of static libraries that make it easier to create high-performance research and sample graphics applications.

Overview

nvpro_core2 is a collection of modular libraries that provide essential functionality for graphics development.

Vulkan:

  • nvvk: Vulkan helper functions and abstractions
  • nvvkglsl: Vulkan GLSL compiler support (uses shaderc from Vulkan SDK)
  • nvvkgltf: GLTF model loading and rendering support
  • nvapp: Application framework and window management
  • nvshaders: Useful shaders and functions for BxDFs, skies, tonemapping, and more. Many functions can also be used from GLSL or C++ using slang_types.h
  • nvshaders_host: Host code for some pre-defined shader pipelines

OpenGL:

  • nvgl: OpenGL helper functions and legacy application framework

Generic:

  • nvutils: Utility functions and common data structures
  • nvgui: GUI components and ImGui integration
  • nvslang: Slang compiler support (downloads appropriate slang library)
  • nvimageformats: DDS and KTX2 image libraries
  • nvaftermath: NVIDIA Aftermath integration for crash analysis (library has additional features if NVIDIA Aftermath SDK is found, otherwise basic functionality)
  • nvgpu_monitor: GPU performance monitoring using NVML (requires the component from CUDA Toolkit)
  • nvnsight: NVIDIA Nsight Graphics integration with NVTX profiling support (conditional, can be disabled)

nvpro_core2's code is designed so you can extract and use functions from it in your own projects without too much modification.

Key improvements in nvpro_core2 compared to previous nvpro_core:

  • Vulkan 1.4 usage throughout all nvvk helpers
    • Latest core functions, structs and 64-bit flags
    • Adds support for dynamic rendering and states, timeline semaphores, and more
  • Slang support for common shading functions and a rich set of glTF-compatible materials
  • CMake: cleaner and faster system with separate static libraries, rather than a single monolithic library
  • CMake: copy_to_runtime_and_install(AUTO) eases dealing with DLL dependencies
  • Unified classes that had competing APIs in the past
  • nvapp serves as centralized structure of Vulkan applications

Requirements

  • Vulkan 1.4 SDK
  • CMake 3.22 or higher
  • 64-bit Windows or Linux OS
  • Compiler supporting basic C++20 features
    • On Windows, MSVC 2019 is our minimum compiler.
    • On Linux, GCC 10.5 or Clang 14 are our minimum compilers.
    • Other compilers supporting their features should also work.
  • On Linux, you'll also need a few system libraries and headers. The following line installs the required libraries on distros that use apt as their package manager; on other distros, similar commands should work:
sudo apt install libx11-dev libxcb1-dev libxcb-keysyms1-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev libtbb-dev libgl-dev

Building a Sample

  1. Install the required development tools (see Requirements above).

  2. Optionally, clone nvpro_core2 next to your samples or add it as a submodule.

    This is optional because samples automatically download nvpro_core2 if they can't find it. If you're building multiple samples, though, it's more efficient to clone nvpro_core2 once where samples can find it instead of downloading it multiple times.

  3. Configure and build:

    cd TheSampleFolder
    
    # Run CMake's configure step; this will generate your build system's files
    cmake -S . -B build
    
    # Build the project
    cmake --build build --config Release --parallel
  4. Optionally, build a portable version by running the install target:

    cmake --build build --parallel --target install

    This will be created in the _install folder, and includes all runtime dependencies so it can be copied to other computers.

Coding with nvpro_core2

Starting a New Sample

For new samples, the easiest way to get started is to copy the project template. It's set up to build right away, and is easy to customize to your project's needs.

Adding nvpro_core2 to an Existing CMake Project

First, find and include nvpro_core2. There's an easy way to do this, and a manual but more customizable way.

  • Easy Way:

    1. Copy FindNvproCore2.cmake to a cmake/ subdirectory of your project.

    2. Add the following code to your CMakeLists.txt. This will automatically download nvpro_core2 if not found, add its targets, and set appropriate defaults for most samples:

      # Add the cmake folder to the module path
      list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
      find_package(NvproCore2 REQUIRED)
  • Manual Way:

    1. Clone nvpro_core2 next to your project (git clone https://github.com/nvpro-samples/nvpro_core2.git) or add it as a submodule (git submodule add https://github.com/nvpro-samples/nvpro_core2.git).

    2. Manually find and include its Setup.cmake file:

      find_path(NVPRO_CORE2_DIR
        NAMES cmake/Setup.cmake
        PATHS ${CMAKE_CURRENT_LIST_DIR}/nvpro_core2
              ${CMAKE_CURRENT_LIST_DIR}/../nvpro_core2
              ${CMAKE_CURRENT_LIST_DIR}/../../nvpro_core2
        REQUIRED
        DOC "Path to nvpro_core2"
      )
      include(${NVPRO_CORE2_DIR}/cmake/Setup.cmake)

      If you find the defaults in Setup.cmake cause issues, you can instead call add_subdirectory(${NVPRO_CORE2_DIR}) to only add nvpro_core2's targets.

Whichever option you choose, you'll then need to link against the libraries you use:

target_link_libraries(${PROJECT_NAME} PRIVATE
  nvpro2::nvapp
  nvpro2::nvutils
  nvpro2::nvvk
  # Add other libraries as needed
)

Finally, if you're using libraries that rely on DLLs like nvslang, you'll need to copy them to the bin and install directories.

  1. If you didn't use FindNvproCore2 or Setup.cmake, add a call to include(${NVPRO_CORE2_DIR}/cmake/Setup.cmake) before the next statement.

  2. Then at the end of your script, call:

copy_to_runtime_and_install(${PROJECT_NAME} AUTO)

License

nvpro_core2 is licensed under Apache 2.0.

Third-Party Libraries

This project embeds or includes (as filtered third_party subfolders) several open-source libraries and/or code derived from them. All such libraries' licenses are included in the PACKAGE-LICENSES folder.

Key third-party dependencies include:

Contributing

Merge requests to nvpro_core2 are welcome, and use the Developer Certificate of Origin (https://developercertificate.org; included in CONTRIBUTING). When committing, please certify that your contribution adheres to the DCO and use git commit --sign-off. Thank you!

Support

About

A comprehensive collection of modular libraries for high-performance graphics development

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8