### Simple Ray Tracing Setup Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Demonstrates the setup of a simple ray tracing pipeline, including Bottom-Level Acceleration Structure (BLAS) and Top-Level Acceleration Structure (TLAS) creation, state setting, and ray dispatch. ```cpp // Create BLAS with triangle geometry nvrhi::rt::GeometryDesc geomDesc; geomDesc.setTriangles(triangles) .setFlags(nvrhi::rt::GeometryFlags::Opaque); nvrhi::rt::AccelStructDesc blasDesc; blasDesc.addBottomLevelGeometry(geomDesc) .setBuildFlags(nvrhi::rt::AccelStructBuildFlags::PreferFastTrace); nvrhi::rt::AccelStructHandle blas = device->createAccelStruct(blasDesc); // Build BLAS commandList->buildBottomLevelAccelStruct(blas.Get(), &geomDesc, 1); // Create TLAS nvrhi::rt::AccelStructDesc tlasDesc; tlasDesc.setTopLevelMaxInstances(100); nvrhi::rt::AccelStructHandle tlas = device->createAccelStruct(tlasDesc); // Create instance nvrhi::rt::InstanceDesc instanceDesc; instanceDesc.setBLAS(blas.Get()) .setInstanceID(0) .setInstanceMask(0xFF); // Build TLAS commandList->buildTopLevelAccelStruct(tlas.Get(), &instanceDesc, 1); // Set ray tracing state nvrhi::rt::State rtState; rtState.pipeline = rtPipeline; rtState.shaderTable = shaderTableBuffer; rtState.shaderTableSize = shaderTableSize; rtState.shaderTableRecordSize = 32; rtState.bindings = { bindingSet }; commandList->setRayTracingState(rtState); // Dispatch rays nvrhi::rt::DispatchRaysArguments dispatchArgs; dispatchArgs.width = 1920; dispatchArgs.height = 1080; commandList->dispatchRays(dispatchArgs); ``` -------------------------------- ### Create Input Layout Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/draw-state-and-shaders.md Example demonstrating how to define vertex attributes and create an input layout handle. Ensure vertex shader is provided. ```cpp nvrhi::VertexAttributeDesc attributes[] = { nvrhi::VertexAttributeDesc() .setName("POSITION") .setFormat(nvrhi::Format::RGB32_FLOAT) .setBufferIndex(0) .setOffset(0), nvrhi::VertexAttributeDesc() .setName("NORMAL") .setFormat(nvrhi::Format::RGB32_FLOAT) .setBufferIndex(0) .setOffset(12), nvrhi::VertexAttributeDesc() .setName("TEXCOORD") .setFormat(nvrhi::Format::RG32_FLOAT) .setBufferIndex(0) .setOffset(24), }; nvrhi::InputLayoutHandle inputLayout = device->createInputLayout( attributes, 3, vertexShader); ``` -------------------------------- ### Create Graphics Pipeline Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Example demonstrating how to set up a GraphicsPipelineDesc, define framebuffer information, and create a graphics pipeline using the NVRHI device. ```cpp nvrhi::GraphicsPipelineDesc pipelineDesc; pipelineDesc.setVertexShader(vertexShader) .setPixelShader(pixelShader) .setInputLayout(inputLayout) .setPrimType(nvrhi::PrimitiveType::TriangleList) .addBindingLayout(bindingLayout); nvrhi::FramebufferInfo fbInfo; fbInfo.addColorFormat(nvrhi::Format::RGBA8_UNORM); fbInfo.setDepthFormat(nvrhi::Format::D32); nvrhi::GraphicsPipelineHandle pipeline = device->createGraphicsPipeline(pipelineDesc, fbInfo); ``` -------------------------------- ### Create Graphics Pipeline Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Example demonstrating how to create a graphics pipeline using NVRHI. ```APIDOC ## Create Graphics Pipeline Example ### Description Example demonstrating how to create a graphics pipeline using NVRHI. ### Code Example ```cpp nvrhi::GraphicsPipelineDesc pipelineDesc; pipelineDesc.setVertexShader(vertexShader) .setPixelShader(pixelShader) .setInputLayout(inputLayout) .setPrimType(nvrhi::PrimitiveType::TriangleList) .addBindingLayout(bindingLayout); nvrhi::FramebufferInfo fbInfo; fbInfo.addColorFormat(nvrhi::Format::RGBA8_UNORM); fbInfo.setDepthFormat(nvrhi::Format::D32); nvrhi::GraphicsPipelineHandle pipeline = device->createGraphicsPipeline(pipelineDesc, fbInfo); ``` ``` -------------------------------- ### Create Bindless Layout Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Example of creating a bindless layout for textures with a maximum capacity of 1 million. ```cpp nvrhi::BindlessLayoutDesc bindlessDesc; bindlessDesc.resourceType = nvrhi::ResourceType::Texture_SRV; bindlessDesc.maxCapacity = 1000000; // 1M textures nvrhi::BindingLayoutHandle bindlessLayout = device->createBindlessLayout(bindlessDesc); ``` -------------------------------- ### Usage Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/command-list-interface.md A C++ example demonstrating how to create, open, record commands (clear, set state, draw), close, and execute a command list using the NVRHI library. ```cpp #include // Create and open command list nvrhi::CommandListHandle cmdList = device->createCommandList(); cmdList->open(); // Clear render target nvrhi::Color clearColor(0.0f, 0.0f, 0.0f, 1.0f); cmdList->clearTextureFloat(renderTarget, nvrhi::AllSubresources, clearColor); // Set graphics state nvrhi::GraphicsState graphicsState; graphicsState.pipeline = graphicsPipeline; graphicsState.framebuffer = framebuffer; graphicsState.bindings = { bindingSet }; cmdList->setGraphicsState(graphicsState); // Set push constants struct PushConstants { float time; uint32_t frameIndex; } pushData = { currentTime, frameNum }; cmdList->setPushConstants(&pushData, sizeof(pushData)); // Draw call nvrhi::DrawArguments drawArgs; drawArgs.vertexCount = 3; drawArgs.instanceCount = 1; cmdList->draw(drawArgs); // Close and execute cmdList->close(); device->executeCommandList(cmdList); ``` -------------------------------- ### Binding Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md An example demonstrating how to create a binding layout and a binding set using NVRHI. This illustrates the typical workflow for setting up resource bindings. ```APIDOC ## Binding Example ```cpp // Create binding layout nvrhi::BindingLayoutDesc layoutDesc; layoutDesc.addItem(nvrhi::BindingLayoutItem::Texture_SRV(0)); layoutDesc.addItem(nvrhi::BindingLayoutItem::ConstantBuffer(1)); layoutDesc.addItem(nvrhi::BindingLayoutItem::Sampler(2)); nvrhi::BindingLayoutHandle bindingLayout = device->createBindingLayout(layoutDesc); // Create binding set nvrhi::BindingSetDesc bindingSetDesc; bindingSetDesc.addItem(nvrhi::BindingSetItem::Texture_SRV(0, texture)) .addItem(nvrhi::BindingSetItem::ConstantBuffer(1, constantBuffer)) .addItem(nvrhi::BindingSetItem::Sampler(2, sampler)); nvrhi::BindingSetHandle bindingSet = device->createBindingSet(bindingSetDesc, bindingLayout); ``` ``` -------------------------------- ### Create Binding Layout and Binding Set Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Example demonstrating the creation of a binding layout and a corresponding binding set with texture, constant buffer, and sampler items. ```cpp // Create binding layout nvrhi::BindingLayoutDesc layoutDesc; layoutDesc.addItem(nvrhi::BindingLayoutItem::Texture_SRV(0)); layoutDesc.addItem(nvrhi::BindingLayoutItem::ConstantBuffer(1)); layoutDesc.addItem(nvrhi::BindingLayoutItem::Sampler(2)); nvrhi::BindingLayoutHandle bindingLayout = device->createBindingLayout(layoutDesc); // Create binding set nvrhi::BindingSetDesc bindingSetDesc; bindingSetDesc.addItem(nvrhi::BindingSetItem::Texture_SRV(0, texture)) .addItem(nvrhi::BindingSetItem::ConstantBuffer(1, constantBuffer)) .addItem(nvrhi::BindingSetItem::Sampler(2, sampler)); nvrhi::BindingSetHandle bindingSet = device->createBindingSet(bindingSetDesc, bindingLayout); ``` -------------------------------- ### Configure Package Configuration Files Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Sets up CMake package configuration files (nvrhiConfig.cmake and nvrhiConfigVersion.cmake) for installation if NVRHI_INSTALL_EXPORTS is enabled. ```cmake if (NVRHI_INSTALL_EXPORTS) set(nvrhi_CONFIG_PATH "lib/cmake/nvrhi") include(CMakePackageConfigHelpers) configure_package_config_file( src/nvrhiConfig.cmake.in src/nvrhiConfig.cmake INSTALL_DESTINATION "${nvrhi_CONFIG_PATH}" NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file( src/nvrhiConfigVersion.cmake VERSION ${nvrhi_VERSION} COMPATIBILITY ExactVersion) install(FILES "${nvrhi_BINARY_DIR}/src/nvrhiConfig.cmake" "${nvrhi_BINARY_DIR}/src/nvrhiConfigVersion.cmake" DESTINATION "${nvrhi_CONFIG_PATH}") install(EXPORT "nvrhiTargets" FILE "nvrhiTargets.cmake" EXPORT_LINK_INTERFACE_LIBRARIES DESTINATION "${nvrhi_CONFIG_PATH}") endif() ``` -------------------------------- ### Compute Pipeline Creation Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Demonstrates how to create a compute pipeline using NVRHI. This involves setting the compute shader and binding layouts before calling the device's creation function. ```cpp nvrhi::ComputePipelineDesc pipelineDesc; pipelineDesc.setComputeShader(computeShader) .addBindingLayout(bindingLayout); nvrhi::ComputePipelineHandle pipeline = device->createComputePipeline(pipelineDesc); ``` -------------------------------- ### Install NVRHI Headers Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Installs the NVRHI header directory to the specified installation prefix when NVRHI_INSTALL is enabled. ```cmake if (NVRHI_INSTALL) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/nvrhi DESTINATION ${CMAKE_INSTALL_PREFIX}/include) endif() ``` -------------------------------- ### Install NVRHI Target Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Installs the main NVRHI target, specifying runtime, archive, and library destinations. ```cmake install(TARGETS nvrhi EXPORT "nvrhiTargets" RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) ``` -------------------------------- ### Create and Use Timer Query Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Create a timer query using `device->createTimerQuery()`, then start and end the query timing with `beginTimerQuery` and `endTimerQuery`. Retrieve the elapsed time in seconds using `getTimerQueryTime`. ```cpp nvrhi::TimerQueryHandle query = device->createTimerQuery(); cmdList->beginTimerQuery(query.Get()); // ... work ... cmdList->endTimerQuery(query.Get()); float timeSeconds = device->getTimerQueryTime(query.Get()); ``` -------------------------------- ### NVRHI Command List Usage Example Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/command-list-interface.md This snippet demonstrates the typical workflow for using an NVRHI command list. It covers creating, opening, and closing a command list, performing operations like clearing a texture, setting graphics state and push constants, executing a draw call, and finally executing the command list on the device. Ensure NVRHI is properly included and a device object is available. ```cpp #include // Create and open command list nvrhi::CommandListHandle cmdList = device->createCommandList(); cmdList->open(); // Clear render target nvrhi::Color clearColor(0.0f, 0.0f, 0.0f, 1.0f); cmdList->clearTextureFloat(renderTarget, nvrhi::AllSubresources, clearColor); // Set graphics state nvrhi::GraphicsState graphicsState; graphicsState.pipeline = graphicsPipeline; graphicsState.framebuffer = framebuffer; graphicsState.bindings = { bindingSet }; cmdList->setGraphicsState(graphicsState); // Set push constants struct PushConstants { float time; uint32_t frameIndex; } pushData = { currentTime, frameNum }; cmdList->setPushConstants(&pushData, sizeof(pushData)); // Draw call nvrhi::DrawArguments drawArgs; drawArgs.vertexCount = 3; drawArgs.instanceCount = 1; cmdList->draw(drawArgs); // Close and execute cmdList->close(); device->executeCommandList(cmdList); ``` -------------------------------- ### Begin Debug Marker Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Use `beginMarker` to start a debug marker section in the command list. This helps in profiling and debugging by labeling command blocks. ```cpp cmdList->beginMarker("Forward Pass"); ``` -------------------------------- ### Configure Depth-Stencil State Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Configures depth and stencil testing. This example enables depth testing and writing, using a less-than comparison. ```cpp nvrhi::DepthStencilState dsState; dsState.setDepthTestEnable(true) .setDepthWriteEnable(true) .setDepthFunc(nvrhi::ComparisonFunc::Less); ``` -------------------------------- ### Dispatch Rays Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Launches a ray tracing kernel with specified dimensions for the ray grid. Use this to start ray tracing computations. ```cpp struct rt::DispatchRaysArguments { uint32_t width = 0; uint32_t height = 0; uint32_t depth = 1; }; void dispatchRays(const rt::DispatchRaysArguments& args); ``` -------------------------------- ### Begin Tracking Texture State Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Use `beginTrackingTextureState` to start tracking a texture's state changes. This must be followed by `commitBarriers` to finalize the state transition. ```cpp cmdList->beginTrackingTextureState(texture, subresources, nvrhi::ResourceStates::Common); ``` -------------------------------- ### Fetch DirectX Headers and Guids Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Fetches DirectX-Headers and DirectX-Guids if they are not already provided by targets and the fetch option is enabled. Includes messages for status. ```cmake include(FetchContent) message(STATUS "Fetching DirectX-Headers from ${NVRHI_DIRECTX_HEADERS_GIT_REPOSITORY}, tag ${NVRHI_DIRECTX_HEADERS_GIT_TAG}") if(NVRHI_DIRECTX_HEADERS_FETCH_DIR) FetchContent_Declare( directx_headers GIT_REPOSITORY ${NVRHI_DIRECTX_HEADERS_GIT_REPOSITORY} GIT_TAG ${NVRHI_DIRECTX_HEADERS_GIT_TAG} SOURCE_DIR ${NVRHI_DIRECTX_HEADERS_FETCH_DIR}) else() FetchContent_Declare( directx_headers GIT_REPOSITORY ${NVRHI_DIRECTX_HEADERS_GIT_REPOSITORY} GIT_TAG ${NVRHI_DIRECTX_HEADERS_GIT_TAG}) endif() FetchContent_MakeAvailable(directx_headers) ``` -------------------------------- ### NVRHI Project File Structure Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/INDEX.md Overview of the NVRHI project's directory layout. The README.md is the starting point, QUICK-REFERENCE.md contains code snippets, types.md defines all type definitions, and API reference files detail specific interfaces. ```text output/ ├── README.md ← Start here ├── QUICK-REFERENCE.md ← Code snippets & common patterns ├── INDEX.md ← This file ├── MANIFEST.txt ← File descriptions ├── types.md ← All type definitions └── api-reference/ ├── device-interface.md ├── command-list-interface.md ├── pipelines-and-bindings.md ├── draw-state-and-shaders.md ├── resources-and-queries.md └── ray-tracing.md ``` -------------------------------- ### Install Conditional Graphics API Targets Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Conditionally installs targets for specific graphics APIs (DX11, DX12, Vulkan) if NVRHI_BUILD_SHARED is not enabled. ```cmake if (NOT NVRHI_BUILD_SHARED) if (NVRHI_WITH_DX11) install(TARGETS ${nvrhi_d3d11_target} DESTINATION "lib" EXPORT "nvrhiTargets") endif() if (NVRHI_WITH_DX12) install(TARGETS ${nvrhi_d3d12_target} DESTINATION "lib" EXPORT "nvrhiTargets") endif() if (NVRHI_WITH_VULKAN) install(TARGETS ${nvrhi_vulkan_target} DESTINATION "lib" EXPORT "nvrhiTargets") endif() endif() ``` -------------------------------- ### Initialize NVRHI Device (D3D12) Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/README.md Demonstrates the basic steps to create an NVRHI device using the Direct3D 12 backend. Ensure the appropriate backend-specific descriptor is used. ```cpp #include // Create device (backend-specific) nvrhi::D3D12DeviceDesc deviceDesc = {}; nvrhi::DeviceHandle device = nvrhi::createD3D12Device(deviceDesc); ``` -------------------------------- ### Create and Use Staging Buffers Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Demonstrates creating a staging texture, mapping it to CPU-accessible memory, and unmapping it. Ensure data is read/written before unmapping. ```cpp nvrhi::BufferDesc desc; desc.setByteSize(1024).setCpuAccess(nvrhi::CpuAccessMode::Read); nvrhi::StagingTextureHandle stagingTex = device->createStagingTexture(desc, access); void* ptr = device->mapStagingTexture(stagingTex.Get(), slice, access, &rowPitch); // ... read data ... device->unmapStagingTexture(stagingTex.Get()); ``` -------------------------------- ### Set DirectX Headers and Guids Targets Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Sets variables to the CMake targets for DirectX-Headers and DirectX-Guids, checking for common target names. ```cmake if(TARGET Microsoft::DirectX-Headers) set(nvrhi_directx_headers_target Microsoft::DirectX-Headers) elseif(TARGET DirectX-Headers) set(nvrhi_directx_headers_target DirectX-Headers) endif() if(TARGET Microsoft::DirectX-Guids) set(nvrhi_directx_guids_target Microsoft::DirectX-Guids) elseif(TARGET DirectX-Guids) set(nvrhi_directx_guids_target DirectX-Guids) endif() ``` -------------------------------- ### Ray Tracing Commands Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/command-list-interface.md Methods for launching ray tracing kernels and managing acceleration structures, including building, copying, and compacting. ```APIDOC ## Ray Tracing Commands ### `dispatchRays` #### Description Launches ray tracing kernel. #### Signature `void dispatchRays(const rt::DispatchRaysArguments& args)` ### `buildBottomLevelAccelStruct` #### Description Builds or updates BLAS. #### Signature `void buildBottomLevelAccelStruct(rt::IAccelStruct* as, const rt::GeometryDesc* pGeometries, size_t numGeometries, rt::AccelStructBuildFlags buildFlags = rt::AccelStructBuildFlags::None)` ### `buildTopLevelAccelStruct` #### Description Builds or updates TLAS. #### Signature `void buildTopLevelAccelStruct(rt::IAccelStruct* as, const rt::InstanceDesc* pInstances, size_t numInstances, rt::AccelStructBuildFlags buildFlags = rt::AccelStructBuildFlags::None)` ### `buildTopLevelAccelStructFromBuffer` #### Description Builds TLAS from GPU buffer. #### Signature `void buildTopLevelAccelStructFromBuffer(rt::IAccelStruct* as, nvrhi::IBuffer* instanceBuffer, uint64_t instanceBufferOffset, size_t numInstances, rt::AccelStructBuildFlags buildFlags = rt::AccelStructBuildFlags::None)` ### `copyRaytracingAccelerationStructure` #### Description Clones acceleration structure. #### Signature `void copyRaytracingAccelerationStructure(rt::IAccelStruct* destination, rt::IAccelStruct* source)` ### `compactBottomLevelAccelStructs` #### Description Compacts BLAS structures after builds. #### Signature `void compactBottomLevelAccelStructs()` ### `buildOpacityMicromap` #### Description Builds opacity micromap structure. #### Signature `void buildOpacityMicromap(rt::IOpacityMicromap* omm, const rt::OpacityMicromapDesc& desc)` ``` -------------------------------- ### FramebufferInfoEx Structure Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/resources-and-queries.md Extends FramebufferInfo with dimensions (width, height, array size). Provides a method to get the viewport based on Z-range. ```cpp struct FramebufferInfoEx : FramebufferInfo { uint32_t width = 0; uint32_t height = 0; uint32_t arraySize = 1; Viewport getViewport(float minZ = 0.f, float maxZ = 1.f) const; }; ``` -------------------------------- ### Create Textures, Buffers, and Framebuffers Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/resources-and-queries.md Use this code to create various graphics resources including render target textures, depth textures, vertex buffers, index buffers, constant buffers, and framebuffers. Ensure the device and command list are initialized before use. ```cpp // Create a 2D texture for rendering nvrhi::TextureDesc colorTexDesc; colorTexDesc.setWidth(1920).setHeight(1080).setFormat(nvrhi::Format::RGBA8_UNORM) .setIsRenderTarget(true); nvrhi::TextureHandle colorTexture = device->createTexture(colorTexDesc); // Create a depth texture nvrhi::TextureDesc depthTexDesc; depthTexDesc.setWidth(1920).setHeight(1080).setFormat(nvrhi::Format::D32) .setIsRenderTarget(true); nvrhi::TextureHandle depthTexture = device->createTexture(depthTexDesc); // Create vertex buffer nvrhi::BufferDesc vertexBufferDesc; vertexBufferDesc.setByteSize(numVertices * sizeof(Vertex)) .setIsVertexBuffer(true); nvrhi::BufferHandle vertexBuffer = device->createBuffer(vertexBufferDesc); // Create index buffer nvrhi::BufferDesc indexBufferDesc; indexBufferDesc.setByteSize(numIndices * sizeof(uint32_t)) .setIsIndexBuffer(true); nvrhi::BufferHandle indexBuffer = device->createBuffer(indexBufferDesc); // Create constant buffer nvrhi::BufferDesc constantBufferDesc; constantBufferDesc.setByteSize(sizeof(PerFrameConstants)) .setIsConstantBuffer(true); nvrhi::BufferHandle constantBuffer = device->createBuffer(constantBufferDesc); // Create framebuffer nvrhi::FramebufferDesc framebufferDesc; framebufferDesc.addColorAttachment(colorTexture) .setDepthAttachment(depthTexture); nvrhi::FramebufferHandle framebuffer = device->createFramebuffer(framebufferDesc); // Write data to buffers commandList->writeBuffer(vertexBuffer, vertexData, vertexDataSize); commandList->writeBuffer(indexBuffer, indexData, indexDataSize); commandList->writeBuffer(constantBuffer, &cbData, sizeof(cbData)); ``` -------------------------------- ### Set NVRHI Public Include Directories Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Configures public include directories for the NVRHI target, making headers available during build and installation. ```cmake target_include_directories(nvrhi PUBLIC $ $/include>) ``` -------------------------------- ### Configure Blend State Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Defines how colors are blended between the source (newly rendered) and destination (existing) pixels. This example enables alpha blending. ```cpp nvrhi::BlendState blendState; auto& target = blendState.targets[0]; target.setBlendEnable(true) .setSrcBlend(nvrhi::BlendFactor::SrcAlpha) .setDestBlend(nvrhi::BlendFactor::InvSrcAlpha); ``` -------------------------------- ### Dispatch Ray Tracing Rays Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Sets up the ray tracing state, including pipeline, bindings, and shader table, then dispatches rays with specified dimensions. ```cpp nvrhi::rt::State rtState; rtState.pipeline = rtPipeline; rtState.bindings = { bindingSet }; rtState.shaderTable = shaderTableBuffer; rtState.shaderTableSize = 1024; cmdList->setRayTracingState(rtState); nvrhi::rt::DispatchRaysArguments args; args.width = 1920; args.height = 1080; cmdList->dispatchRays(args); ``` -------------------------------- ### NVRHI Device Initialization and Resource Creation Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md This snippet shows how to create a Direct3D 12 device, a texture, and a shader using the NVRHI library. Ensure you have the necessary NVRHI headers and bytecode for shaders. ```cpp #include // Create device for Direct3D 12 nvrhi::D3D12DeviceDesc deviceDesc; nvrhi::DeviceHandle device = nvrhi::createD3D12Device(deviceDesc); // Create a texture nvrhi::TextureDesc textureDesc; textureDesc.setWidth(1024).setHeight(1024).setFormat(nvrhi::Format::RGBA8_UNORM); nvrhi::TextureHandle texture = device->createTexture(textureDesc); // Create a shader nvrhi::ShaderDesc shaderDesc; shaderDesc.setShaderType(nvrhi::ShaderType::Vertex).setDebugName("MyVertexShader"); nvrhi::ShaderHandle shader = device->createShader(shaderDesc, bytecodePtr, bytecodeSize); // Create command list and record commands nvrhi::CommandListHandle commandList = device->createCommandList(); // ... record commands ... // Execute commands device->executeCommandList(commandList); // Wait for GPU to complete device->waitForIdle(); ``` -------------------------------- ### DrawArguments Structure Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/draw-state-and-shaders.md Defines parameters for standard draw calls. Includes vertex and instance counts, starting locations, and optional vertex data. ```cpp struct DrawArguments { uint32_t vertexCount = 0; uint32_t instanceCount = 1; uint32_t startVertexLocation = 0; uint32_t startInstanceLocation = 0; // Optional: can be set per-pipeline-instance or dynamically float* pVertexData = nullptr; uint32_t vertexDataSize = 0; }; ``` -------------------------------- ### Query Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/command-list-interface.md These methods allow you to query the current state of resources managed by the command list and retrieve the owning device or creation parameters. ```APIDOC ## getTextureSubresourceState ### Description Returns current tracked texture subresource state. ### Signature `ResourceStates getTextureSubresourceState(ITexture* texture, ArraySlice arraySlice, MipLevel mipLevel)` ## getBufferState ### Description Returns current tracked buffer state. ### Signature `ResourceStates getBufferState(IBuffer* buffer)` ## getDevice ### Description Returns owning device (does not AddRef). ### Signature `IDevice* getDevice()` ## getDesc ### Description Returns creation parameters. ### Signature `const CommandListParameters& getDesc()` ``` -------------------------------- ### Configure Raster State Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Sets rasterization state, including culling mode and fill mode. This example configures back-face culling and solid fill. ```cpp nvrhi::RasterState rasterState; rasterState.setCullMode(nvrhi::RasterCullMode::Back) .setFillMode(nvrhi::RasterFillMode::Solid); ``` -------------------------------- ### Build Ray Tracing Acceleration Structures Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Builds BLAS from geometry descriptions and TLAS from instance descriptions. Requires command list and appropriate descriptors. ```cpp // Build BLAS nvrhi::rt::GeometryDesc geom; cmdList->buildBottomLevelAccelStruct(blas.Get(), &geom, 1); // Build TLAS nvrhi::rt::InstanceDesc instance; instance.setBLAS(blas.Get()).setInstanceID(0); cmdList->buildTopLevelAccelStruct(tlas.Get(), &instance, 1); ``` -------------------------------- ### Create Command List Source: https://github.com/nvidia-rtx/nvrhi/blob/main/doc/Tutorial.md Creates a command list object used for recording and executing commands. ```c++ nvrhi::CommandListHandle commandList = nvrhiDevice->createCommandList(); ``` -------------------------------- ### Create Virtual Textures and Bind Memory Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Shows how to create a virtual texture without allocating memory initially, then query memory requirements and bind memory later. This allows for deferred memory allocation. ```cpp // Create without memory nvrhi::TextureDesc desc; desc.setIsVirtual(true); nvrhi::TextureHandle vTex = device->createTexture(desc); // Bind memory later nvrhi::MemoryRequirements req = device->getTextureMemoryRequirements(vTex); device->bindTextureMemory(vTex, heap, offset); ``` -------------------------------- ### Create Sampler Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Configure sampler state, including filtering and address modes, using `nvrhi::SamplerDesc` before creating it with `device->createSampler`. ```cpp nvrhi::SamplerDesc desc; desc.setAllFilters(true) .setAllAddressModes(nvrhi::SamplerAddressMode::Wrap); nvrhi::SamplerHandle sampler = device->createSampler(desc); ``` -------------------------------- ### Dispatch Rays Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Launches a ray tracing kernel with specified arguments. ```APIDOC ## dispatchRays ### Description Launches ray tracing kernel. ### Method `void dispatchRays(const rt::DispatchRaysArguments& args);` ### Parameters #### Request Body - **args** (rt::DispatchRaysArguments) - Required - Arguments for dispatching rays. - **width** (uint32_t) - Width of ray grid. - **height** (uint32_t) - Height of ray grid. - **depth** (uint32_t) - Depth of ray grid (typically 1). ``` -------------------------------- ### IAccelStruct Interface Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Interface for accessing acceleration structures, providing methods to retrieve the structure's descriptor, check if it's compacted, and get its GPU device address for shader usage. ```cpp class IAccelStruct : public IResource { public: [[nodiscard]] virtual const AccelStructDesc& getDesc() const = 0; [[nodiscard]] virtual bool isCompacted() const = 0; [[nodiscard]] virtual uint64_t getDeviceAddress() const = 0; }; typedef RefCountPtr AccelStructHandle; ``` -------------------------------- ### Create Compute Pipeline Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Configure a compute pipeline by specifying the compute shader and binding layouts using `nvrhi::ComputePipelineDesc`. ```cpp nvrhi::ComputePipelineDesc desc; desc.setComputeShader(cs) .addBindingLayout(bindingLayout); nvrhi::ComputePipelineHandle pipeline = device->createComputePipeline(desc); ``` -------------------------------- ### Create Binding Set Items Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Helper functions for creating `BindingSetItem` for various resource types including textures (SRV/UAV), structured buffers (SRV/UAV), raw buffers (SRV/UAV), constant buffers, samplers, ray tracing acceleration structures, and push constants. ```cpp // Texture read nvrhi::BindingSetItem::Texture_SRV(slot, texture); // Texture write nvrhi::BindingSetItem::Texture_UAV(slot, texture); // Structured buffer read nvrhi::BindingSetItem::StructuredBuffer_SRV(slot, buffer); // Structured buffer write nvrhi::BindingSetItem::StructuredBuffer_UAV(slot, buffer); // Raw buffer read nvrhi::BindingSetItem::RawBuffer_SRV(slot, buffer); // Raw buffer write nvrhi::BindingSetItem::RawBuffer_UAV(slot, buffer); // Constant buffer nvrhi::BindingSetItem::ConstantBuffer(slot, buffer); // Sampler nvrhi::BindingSetItem::Sampler(slot, sampler); // Ray tracing nvrhi::BindingSetItem::RayTracingAccelStruct(slot, tlas); // Push constants nvrhi::BindingSetItem::PushConstants(slot, sizeInBytes); ``` -------------------------------- ### Create Shader Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Create a shader by specifying its type (e.g., Vertex) and providing the bytecode and size to `device->createShader`. ```cpp nvrhi::ShaderDesc desc; desc.setShaderType(nvrhi::ShaderType::Vertex); nvrhi::ShaderHandle shader = device->createShader(desc, bytecode, size); ``` -------------------------------- ### Create Binding Layout for Resources Source: https://github.com/nvidia-rtx/nvrhi/blob/main/doc/Tutorial.md Defines how resources like constant buffers and textures are bound to shader slots. This example binds a texture to slot t0 and a constant buffer to slot b0, visible to all shader stages. ```c++ auto layoutDesc = nvrhi::BindingLayoutDesc() .setVisibility(nvrhi::ShaderType::All) .addItem(nvrhi::BindingLayoutItem::Texture_SRV(0)) // texture at t0 .addItem(nvrhi::BindingLayoutItem::VolatileConstantBuffer(0)); // constants at b0 nvrhi::BindingLayoutHandle bindingLayout = nvrhiDevice->createBindingLayout(layoutDesc); ``` -------------------------------- ### NVRHI Draw Call Variants Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Demonstrates different ways to issue draw calls, including non-indexed, indexed, indirect, and indexed indirect draws. Specify arguments like vertex count, instance count, and starting locations as needed. ```cpp // Non-indexed nvrhi::DrawArguments args; args.vertexCount = 3; args.instanceCount = 10; args.startVertexLocation = 0; args.startInstanceLocation = 0; cmdList->draw(args); // Indexed nvrhi::DrawArguments args; args.vertexCount = indexCount; cmdList->drawIndexed(args); // Indirect cmdList->drawIndirect(indirectBufferOffset, drawCount); // Indirect indexed cmdList->drawIndexedIndirect(indirectBufferOffset, drawCount); ``` -------------------------------- ### Device Creation Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md Device instances are created through backend-specific factory functions. ```APIDOC ## Device Creation Device instances are created through backend-specific factory functions: ```cpp // For Direct3D 12 DeviceHandle createD3D12Device(const D3D12DeviceDesc& desc); // For Direct3D 11 DeviceHandle createD3D11Device(const D3D11DeviceDesc& desc); // For Vulkan DeviceHandle createVulkanDevice(const VulkanDeviceDesc& desc); ``` ``` -------------------------------- ### Build Acceleration Structures Source: https://github.com/nvidia-rtx/nvrhi/blob/main/doc/Tutorial.md Builds the BLAS and TLAS using a command list. This process involves uploading vertex data and then calling build functions for both structures. Static geometry can be built once at startup. ```c++ commandList->open(); // Upload the vertex data if that hasn't been done earlier commandList->writeBuffer(vertexBuffer, g_Vertices, sizeof(g_Vertices)); // Build the BLAS using the geometry array populated earlier. // It's also possible to obtain the descriptor from the BLAS object using getDesc() // and write the vertex and index buffer references into that descriptor again // because NVRHI erases those when it creates the AS object. commandList->buildBottomLevelAccelStruct(blas, blasDesc.geometries.data(), blasDesc.geometries.size()); // Build the TLAS with one instance. auto instanceDesc = nvrhi::rt::InstanceDesc() .setBLAS(blas) .setFlags(1) .setTransform(nvrhi::rt::c_IdentityTransform); commandList->buildTopLevelAccelStruct(tlas, &instanceDesc, 1); commandList->close(); nvrhiDevice->executeCommandList(commandList); ``` -------------------------------- ### Staging & Copy Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md Methods for creating staging textures and reading back timer query results. ```APIDOC ## createStagingTexture ### Description Creates a CPU-accessible staging texture. ### Signature `StagingTextureHandle createStagingTexture(const TextureDesc& desc, CpuAccessMode access)` ``` ```APIDOC ## readbackQuery ### Description Reads back timer query results to the CPU. ### Signature `bool readbackQuery(ITimerQuery* query)` ``` -------------------------------- ### Build Opacity Micromap Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Builds an opacity micromap structure using the provided opacity micromap object and its description. ```cpp void buildOpacityMicromap( rt::IOpacityMicromap* omm, const rt::OpacityMicromapDesc& desc); ``` -------------------------------- ### Building Opacity Micromap Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/ray-tracing.md Builds an opacity micromap structure. ```APIDOC ## buildOpacityMicromap ### Description Builds opacity micromap structure. ### Method `void buildOpacityMicromap( rt::IOpacityMicromap* omm, const rt::OpacityMicromapDesc& desc );` ``` -------------------------------- ### Create Graphics Pipeline Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Configure a graphics pipeline with shaders, input layout, binding layouts, and framebuffer information using `nvrhi::GraphicsPipelineDesc` and `nvrhi::FramebufferInfo`. ```cpp nvrhi::GraphicsPipelineDesc desc; desc.setVertexShader(vs) .setPixelShader(ps) .setInputLayout(inputLayout) .addBindingLayout(bindingLayout); nvrhi::FramebufferInfo fbInfo; fbInfo.addColorFormat(nvrhi::Format::RGBA8_UNORM); nvrhi::GraphicsPipelineHandle pipeline = device->createGraphicsPipeline(desc, fbInfo); ``` -------------------------------- ### Submission Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md Methods for executing and managing GPU command lists. ```APIDOC ## executeCommandList ### Description Executes a recorded command list on the GPU. ### Signature `void executeCommandList(ICommandList* commandList)` ``` ```APIDOC ## submitCommandList ### Description Submits a command list and returns a frame ID. ### Signature `uint64_t submitCommandList(ICommandList* commandList)` ``` ```APIDOC ## executedCommandListsCleanup ### Description Cleans up completed command lists. ### Signature `void executedCommandListsCleanup()` ``` ```APIDOC ## waitForIdle ### Description Blocks until all GPU work is complete. ### Signature `void waitForIdle()` ``` -------------------------------- ### BindingSetItem Helper Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/pipelines-and-bindings.md Provides helper methods for creating BindingSetItem instances, which represent individual resources to be bound. These methods simplify the process of defining textures, buffers, samplers, and other resources for binding. ```APIDOC ## BindingSetItem Helper Methods Provides helper methods for creating `BindingSetItem` instances, which represent individual resources to be bound. These methods simplify the process of defining textures, buffers, samplers, and other resources for binding. | Method | Description | |-------------------------------------------------------|---------------------------------| | `BindingSetItem::None(slot)` | Empty binding | | `BindingSetItem::Texture_SRV(slot, texture, format, subresources, dimension)` | Texture read | | `BindingSetItem::Texture_UAV(slot, texture, format, subresources, dimension)` | Texture read/write | | `BindingSetItem::TypedBuffer_SRV(slot, buffer, format, range)` | Typed buffer read | | `BindingSetItem::TypedBuffer_UAV(slot, buffer, format, range)` | Typed buffer read/write | | `BindingSetItem::StructuredBuffer_SRV(slot, buffer, format, range)` | Structured buffer read | | `BindingSetItem::StructuredBuffer_UAV(slot, buffer, format, range)` | Structured buffer read/write | | `BindingSetItem::RawBuffer_SRV(slot, buffer, range)` | Raw buffer read | | `BindingSetItem::RawBuffer_UAV(slot, buffer, range)` | Raw buffer read/write | | `BindingSetItem::ConstantBuffer(slot, buffer, range)` | Constant buffer | | `BindingSetItem::Sampler(slot, sampler)` | Texture sampler | | `BindingSetItem::RayTracingAccelStruct(slot, accelStruct)` | Ray tracing TLAS/BLAS | | `BindingSetItem::PushConstants(slot, byteSize)` | Push constants | | `BindingSetItem::SamplerFeedbackTexture_UAV(slot, texture)` | Sampler feedback (DX12) | ``` -------------------------------- ### Ray Tracing Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md Methods for creating and building ray tracing acceleration structures and opacity micromaps. ```APIDOC ## createAccelStruct ### Description Creates a ray tracing acceleration structure. ### Signature `rt::AccelStructHandle createAccelStruct(const rt::AccelStructDesc& desc)` ``` ```APIDOC ## buildBottomLevelAccelStruct ### Description Builds Bottom Level Acceleration Structure (BLAS) on the GPU. ### Signature `void buildBottomLevelAccelStruct(ICommandList* commandList, const rt::AccelStructDesc& desc, IBuffer* scratchBuffer, uint64_t scratchOffset, rt::IAccelStruct* dest)` ``` ```APIDOC ## buildTopLevelAccelStruct ### Description Builds Top Level Acceleration Structure (TLAS) on the GPU. ### Signature `void buildTopLevelAccelStruct(ICommandList* commandList, const rt::InstanceDesc* instances, size_t instanceCount, IBuffer* scratchBuffer, uint64_t scratchOffset, rt::IAccelStruct* dest)` ``` ```APIDOC ## createOpacityMicromap ### Description Creates an opacity micromap structure. ### Signature `rt::OpacityMicromapHandle createOpacityMicromap(const rt::OpacityMicromapDesc& desc)` ``` ```APIDOC ## buildOpacityMicromap ### Description Builds an opacity micromap on the GPU. ### Signature `void buildOpacityMicromap(ICommandList* commandList, const rt::OpacityMicromapDesc& desc, IBuffer* scratchBuffer, uint64_t scratchOffset, rt::IOpacityMicromap* dest)` ``` -------------------------------- ### Create NVRHI Resources Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/README.md Shows how to create essential graphics resources including textures, shaders, and vertex buffers. Configure resource properties like dimensions, format, and usage before creation. ```cpp // Create a texture nvrhi::TextureDesc textureDesc; textureDesc.setWidth(1920).setHeight(1080) .setFormat(nvrhi::Format::RGBA8_UNORM) .setIsRenderTarget(true); nvrhi::TextureHandle texture = device->createTexture(textureDesc); // Create a shader nvrhi::ShaderDesc shaderDesc; shaderDesc.setShaderType(nvrhi::ShaderType::Vertex); nvrhi::ShaderHandle vs = device->createShader(shaderDesc, bytecode, bytecodeSize); // Create a buffer nvrhi::BufferDesc bufferDesc; bufferDesc.setByteSize(sizeof(MyVertex) * vertexCount) .setIsVertexBuffer(true); nvrhi::BufferHandle vertexBuffer = device->createBuffer(bufferDesc); ``` -------------------------------- ### IShaderLibrary Interface Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/draw-state-and-shaders.md Allows dynamic shader selection by entry point and type, particularly useful for ray tracing scenarios. ```APIDOC ## IShaderLibrary Interface ### Description Allows dynamic shader selection by entry point and type, useful for ray tracing. ### Methods - **getBytecode(const void** ppBytecode, size_t* pSize)**: Retrieves the shader library's bytecode and its size. - **getShader(const char* entryName, ShaderType shaderType)**: Returns a `ShaderHandle` for the shader identified by the entry point name and type. ``` -------------------------------- ### Create Shaders and Input Layout Source: https://github.com/nvidia-rtx/nvrhi/blob/main/doc/Tutorial.md Compiles vertex and pixel shaders and defines the input layout for vertex data. Assumes shaders are available as C headers. ```c++ const char g_VertexShader[] = ...; const char g_PixelShader[] = ...; struct Vertex { float position[3]; float texCoord[2]; }; nvrhi::ShaderHandle vertexShader = nvrhiDevice->createShader( nvrhi::ShaderDesc().setShaderType(nvrhi::ShaderType::Vertex), g_VertexShader, sizeof(g_VertexShader)); nvrhi::VertexAttributeDesc attributes[] = { nvrhi::VertexAttributeDesc() .setName("POSITION") .setFormat(nvrhi::Format::RGB32_FLOAT) .setOffset(offsetof(Vertex, position)) .setElementStride(sizeof(Vertex)), nvrhi::VertexAttributeDesc() .setName("TEXCOORD") .setFormat(nvrhi::Format::RG32_FLOAT) .setOffset(offsetof(Vertex, texCoord)) .setElementStride(sizeof(Vertex)), }; nvrhi::InputLayoutHandle inputLayout = nvrhiDevice->createInputLayout( attributes, uint32_t(std::size(attributes)), vertexShader); nvrhi::ShaderHandle pixelShader = nvrhiDevice->createShader( nvrhi::ShaderDesc().setShaderType(nvrhi::ShaderType::Pixel), g_PixelShader, sizeof(g_PixelShader)); ``` -------------------------------- ### Record Graphics Commands Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Opens a command list, sets the graphics state including pipeline and framebuffer, binds resources, sets push constants, and issues a draw call. ```cpp nvrhi::CommandListHandle cmdList = device->createCommandList(); cmdList->open(); // Set state nvrhi::GraphicsState state; state.pipeline = pipeline; state.framebuffer = framebuffer; state.bindings = { bindingSet }; cmdList->setGraphicsState(state); // Write data struct { float time; } pushConstants = {elapsed}; cmdList->setPushConstants(&pushConstants, sizeof(pushConstants)); // Draw nvrhi::DrawArguments args; args.vertexCount = 3; cmdList->draw(args); cmdList->close(); device->executeCommandList(cmdList); ``` -------------------------------- ### Include Aftermath Fetch Script Source: https://github.com/nvidia-rtx/nvrhi/blob/main/CMakeLists.txt Includes a local CMake script to fetch the Aftermath library if NVRHI_WITH_AFTERMATH is enabled and the target does not exist. ```cmake include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchAftermath.cmake") ``` -------------------------------- ### Create Input Layout Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/QUICK-REFERENCE.md Define vertex attributes and their formats using `nvrhi::VertexAttributeDesc` and create the input layout with `device->createInputLayout`. ```cpp nvrhi::VertexAttributeDesc attrs[] = { nvrhi::VertexAttributeDesc().setName("POSITION").setFormat(nvrhi::Format::RGB32_FLOAT) }; nvrhi::InputLayoutHandle layout = device->createInputLayout(attrs, 1, vertexShader); ``` -------------------------------- ### Meshlet Commands Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/command-list-interface.md Methods for launching meshlet kernels, supporting both direct and indirect parameterization, with platform-specific notes. ```APIDOC ## Meshlet Commands ### `dispatchMesh` #### Description Launches meshlet kernel (DX12/Vulkan only). #### Signature `void dispatchMesh(uint32_t groupsX, uint32_t groupsY = 1, uint32_t groupsZ = 1)` ### `dispatchMeshIndirect` #### Description Launches meshlet with indirect parameters. #### Signature `void dispatchMeshIndirect(uint32_t offsetBytes, uint32_t maxDrawCount)` ### `dispatchMeshIndirectCount` #### Description Launches meshlet with count from buffer (Vulkan only). #### Signature `void dispatchMeshIndirectCount(uint32_t paramOffsetBytes, uint32_t countOffsetBytes, uint32_t maxDrawCount)` ``` -------------------------------- ### Queue Methods Source: https://github.com/nvidia-rtx/nvrhi/blob/main/_autodocs/api-reference/device-interface.md Methods for interacting with command queues. ```APIDOC ## getQueueImpl ### Description Gets implementation-specific queue handle. ### Signature `CommandQueue getQueueImpl(CommandQueue queue)` ```