Skip to content

Commit

Permalink
Step 5
Browse files Browse the repository at this point in the history
  • Loading branch information
fstrugar-nv committed Jan 24, 2024
1 parent c1cb281 commit dce238e
Show file tree
Hide file tree
Showing 117 changed files with 6,362 additions and 5,757 deletions.
2 changes: 1 addition & 1 deletion pt_sdk/AccelerationStructureUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace bvh
}

// don't compact acceleration structures that are built per frame
if (mesh.skinPrototype != nullptr)
if (mesh.skinPrototype.use_count() != 0)
{
blasDesc.buildFlags = nvrhi::rt::AccelStructBuildFlags::PreferFastBuild;
}
Expand Down
6 changes: 2 additions & 4 deletions pt_sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ donut_compile_shaders(

add_executable(${project} WIN32 ${sources})

if(NVRHI_WITH_SHADER_COMPILER)
add_dependencies(${project} pt_sdk_shaders nrd_shaders omm_sdk_shaders)
endif()

if(STREAMLINE_INTEGRATION)
set(SL_DLLS
Expand All @@ -50,9 +48,9 @@ add_compile_definitions(STREAMLINE_INTEGRATION)
add_library(sl.interposer STATIC IMPORTED)
set_property(TARGET sl.interposer PROPERTY IMPORTED_LOCATION ../../external/Streamline/lib/x64/sl.interposer.lib)
file(COPY ${SL_DLLS} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
target_link_libraries(${project} donut_render donut_app donut_engine NRD rtxdi-sdk omm-sdk omm-sdk-nvrhi sl.interposer)
target_link_libraries(${project} cxxopts donut_render donut_app donut_engine NRD rtxdi-sdk omm-sdk omm-sdk-nvrhi sl.interposer )
else()
target_link_libraries(${project} donut_render donut_app donut_engine NRD rtxdi-sdk omm-sdk omm-sdk-nvrhi)
target_link_libraries(${project} cxxopts donut_render donut_app donut_engine NRD rtxdi-sdk omm-sdk omm-sdk-nvrhi)
endif()

set_target_properties(${project} PROPERTIES FOLDER ${folder})
Expand Down
62 changes: 62 additions & 0 deletions pt_sdk/CommandLine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

#include "CommandLine.h"
#include <cxxopts.hpp>
#include <donut/core/log.h>
#include <filesystem>

bool CommandLineOptions::InitFromCommandLine(int _argc, char** _argv)
{
using namespace cxxopts;

try
{
std::filesystem::path exe_path = _argv[0];
Options options(exe_path.filename().string(), "Path Tracing SDK is a code sample that strives to embody years of ray tracing and neural graphics research and experience. It is intended as a starting point for a path tracer integration, as a reference for various integrated SDKs, and/or for learning and experimentation.");

bool help = false;

options.add_options()
("s,scene", "Preferred scene to load (.scene.json)", value(scene))
("nonInteractive", "Indicates that pt_sdk will start in non-interactive mode, disabling popups and windows that require input", value(nonInteractive))
("noWindow", "Start PT-SDK without a window. This mode is useful when generating screenshots from command line.", value(noWindow))
("noStreamline", "No streamline", value(noStreamline))
("d,debug", "Enables the D3D12/VK debug layer and NVRHI validation layer", value(debug))
("width", "Window width", value(width))
("height", "Window height", value(height))
("f,fullscreen", "run in fullscreen mode", value(fullscreen))
("a,adapter", "-adapter must be followed by a string used to match the preferred adapter, e.g -adapter NVIDIA or -adapter RTX", value(adapter))
("screenshotFileName", "Will save a screenshot with the specified name.", value(screenshotFileName))
("screenshotFrameIndex", "Will capture a screenshot at this specific frame index. Application will terminate after screenshot is taken.", value(screenshotFrameIndex))
("h,help", "Print the help message", value(help))
("d3d12", "Render using DirectX 12 (default)")
("vk", "Render using Vulkan", value(useVulkan));

int argc = _argc;
char** argv = _argv;
options.parse(argc, argv);

if (help)
{
std::string helpMessage = options.help();
donut::log::info("%s", helpMessage.c_str());
return false;
}

return true;
}
catch (const exceptions::exception& e)
{
std::string errorMessage = e.what();
donut::log::error("%s", errorMessage.c_str());
return false;
}
}
34 changes: 34 additions & 0 deletions pt_sdk/CommandLine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

#pragma once

#include <string>
#include <optional>

struct CommandLineOptions
{
std::string scene;
bool nonInteractive = false;
bool noWindow = false;
bool noStreamline = false;
bool debug = false;
uint32_t width = 1920;
uint32_t height = 1080;
bool fullscreen = false;
std::string adapter;
std::string screenshotFileName;
uint32_t screenshotFrameIndex = 0xFFFFFFFF;
bool useVulkan = false;

CommandLineOptions(){}

bool InitFromCommandLine(int argc, char** argv);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@
#include <donut/shaders/vulkan.hlsli>

#include "SampleConstantBuffer.h"
#include "ShaderResourceBindings.hlsli"

RaytracingAccelerationStructure SceneBVH : register(t0);
StructuredBuffer<SubInstanceData> t_SubInstanceData : register(t1);
StructuredBuffer<InstanceData> t_InstanceData : register(t2);
StructuredBuffer<GeometryData> t_GeometryData : register(t3);
StructuredBuffer<GeometryDebugData> t_GeometryDebugData : register(t4);
StructuredBuffer<MaterialConstants> t_MaterialConstants : register(t5);
Texture2D<float4> t_EnvironmentMap : register(t6);
Texture2D<float> t_ImportanceMap : register(t7);
TextureCube<float4> t_EnvironmentMap : register(t6);
Texture2D<float> t_EnvironmentMapImportanceMap : register(t7);
Buffer<uint2> t_PresampledEnvMapBuffer : register(t8);


SamplerState s_MaterialSampler : register(s0);
SamplerState s_EnvironmentMapSampler : register(s1);
SamplerState s_ImportanceSampler : register(s2);
SamplerState s_EnvironmentMapImportanceSampler : register(s2);

VK_BINDING(0, 1) ByteAddressBuffer t_BindlessBuffers[] : register(t0, space1);
VK_BINDING(1, 1) Texture2D t_BindlessTextures[] : register(t0, space2);
Expand Down
6 changes: 3 additions & 3 deletions pt_sdk/ExportVisibilityBuffer.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

#define NON_PATH_TRACING_PASS 1

#include "ShaderResourceBindings.hlsli"

#include "PathTracerBridgeDonut.hlsli"
#include "PathTracer/PathTracer.hlsli"
#include "RTXDI/SurfaceData.hlsli"

#include "ShaderResourceBindings.hlsli"

[numthreads(NUM_COMPUTE_THREADS_PER_DIM, NUM_COMPUTE_THREADS_PER_DIM, 1)]
void main( uint2 dispatchThreadID : SV_DispatchThreadID )
{
Expand All @@ -39,7 +39,7 @@ void main( uint2 dispatchThreadID : SV_DispatchThreadID )

const Ray cameraRay = Bridge::computeCameraRay( pixelPos, 0 );
const HitInfo hit = HitInfo(packedHitInfo);
bool hitSurface = hit.isValid() && hit.getType() == HitType::Triangle;
bool hitSurface = hit.isValid();// && hit.getType() == HitType::Triangle;

#if 0 // for testing correctness: compute first hit surface motion vector
{
Expand Down
2 changes: 2 additions & 0 deletions pt_sdk/ExtendedScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void MaterialPatch::Load(const Json::Value& node)
node["psdExclude"] >> psdExclude;
node["psdDominantDeltaLobe"] >> psdDominantDeltaLobe;
node["emissiveIntensity"] >> emissiveIntensity;
node["shadowNoLFadeout"] >> shadowNoLFadeout;

SceneGraphLeaf::Load(node);
}
Expand Down Expand Up @@ -277,6 +278,7 @@ void MaterialPatch::Patch(Material& mat)
MAT_VALUE_OR(psdExclude);
MAT_VALUE_OR(psdDominantDeltaLobe);
MAT_VALUE_OR(emissiveIntensity);
MAT_VALUE_OR(shadowNoLFadeout);
}

std::shared_ptr<SceneGraphLeaf> SampleSettings::Clone()
Expand Down
1 change: 1 addition & 0 deletions pt_sdk/ExtendedScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace donut::engine
std::optional<bool> psdExclude;
std::optional<int> psdDominantDeltaLobe;
std::optional<float> emissiveIntensity;
std::optional<float> shadowNoLFadeout;

[[nodiscard]] std::shared_ptr<SceneGraphLeaf> Clone() override;
void Load(const Json::Value& node) override;
Expand Down
Loading

0 comments on commit dce238e

Please sign in to comment.