Skip to content

Commit

Permalink
Currected usage of CUdevice vs. device ordinal in CUDA Driver API fun…
Browse files Browse the repository at this point in the history
…ction arguments.

(Not really a functional change because these values are usually identical.)
Made console output about CUDA devices consistent.
  • Loading branch information
droettger committed Nov 9, 2023
1 parent 44a1775 commit 2169b5f
Show file tree
Hide file tree
Showing 37 changed files with 928 additions and 828 deletions.
3 changes: 2 additions & 1 deletion apps/MDL_renderer/inc/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class Device

public:
// Constructor arguments:
int m_ordinal; // The ordinal number of this CUDA device.
int m_ordinal; // The ordinal number of this CUDA device. Used to get the CUdevice handle m_cudaDevice.
int m_index; // The index inside the m_devicesActive vector.
int m_count; // The number of active devices.
TypeLight m_typeEnv; // Type of environment miss shader to use.
Expand All @@ -503,6 +503,7 @@ class Device
DeviceAttribute m_deviceAttribute; // CUDA
DeviceProperty m_deviceProperty; // OptiX

CUdevice m_cudaDevice; // The CUdevice handle of the CUDA device ordinal. (Usually identical to m_ordinal.)
CUcontext m_cudaContext;
CUstream m_cudaStream;

Expand Down
24 changes: 15 additions & 9 deletions apps/MDL_renderer/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ bool Application::render()
}
#endif

if (m_presentAtSecond < seconds || flush || finish) // Print performance every second or when the rendering is complete or the benchmark finished.
// Present an updated image once a second or when rendering completed or the benchmark finished.
if (m_presentAtSecond < seconds || flush || finish)
{
m_presentAtSecond = ceil(seconds);
m_presentNext = true; // Present at least every second.
Expand Down Expand Up @@ -525,6 +526,8 @@ void Application::benchmark()

m_timer.restart();

// This renders all sub-frames as fast as possible by pushing all kernel launches into the CUDA stream asynchronously.
// Benchmark with m_interop == INTEROP_MODE_OFF to get the raw raytracing performance.
while (iterationIndex < spp)
{
iterationIndex = m_raytracer->render(m_mode);
Expand Down Expand Up @@ -592,7 +595,7 @@ void Application::guiEventHandler()
{
const ImGuiIO& io = ImGui::GetIO();

if (ImGui::IsKeyPressed(' ', false)) // Key Space: Toggle the GUI window display.
if (ImGui::IsKeyPressed(' ', false)) // Key Space: Toggle the GUI window display (in interactive mode only).
{
m_isVisibleGUI = !m_isVisibleGUI;
}
Expand Down Expand Up @@ -677,7 +680,8 @@ void Application::guiEventHandler()

void Application::guiWindow()
{
if (!m_isVisibleGUI || m_mode == 1) // Use SPACE to toggle the display of the GUI window.
// Do not display the GUI window when it has been toggled to off with SPACE key or when running in benchmark mode.
if (!m_isVisibleGUI || m_mode == 1)
{
return;
}
Expand All @@ -704,7 +708,7 @@ void Application::guiWindow()
}
if (ImGui::Checkbox("Present", &m_present))
{
// No action needed, happens automatically.
// No action needed, happens automatically on next render invocation.
}
if (ImGui::Checkbox("Direct Lighting", &m_useDirectLighting))
{
Expand Down Expand Up @@ -988,12 +992,14 @@ void Application::guiWindow()
}
}
break;

case Param_info::PK_STRING:
case Param_info::PK_TEXTURE:
case Param_info::PK_LIGHT_PROFILE:
case Param_info::PK_BSDF_MEASUREMENT:
// Currently not supported by this example
// Editing these parameter types is currently not supported by this example
break;

default:
break;
}
Expand Down Expand Up @@ -1345,7 +1351,7 @@ int Application::findMaterial(const std::string& reference)
std::map<std::string, MaterialDeclaration>::const_iterator itd = m_mapReferenceToDeclaration.find(reference);
if (itd != m_mapReferenceToDeclaration.end())
{
// Only material declarations which are referenced inside the scene will loaded later.
// Only material declarations which are referenced inside the scene will be loaded later.
indexMaterial = static_cast<int>(m_materialsMDL.size());

m_mapReferenceToMaterialIndex[reference] = indexMaterial;
Expand Down Expand Up @@ -1589,11 +1595,11 @@ bool Application::loadSceneDescription(const std::string& filename)
MaterialDeclaration decl;

tokenType = parser.getNextToken(decl.nameReference); // Internal material reference name. If there are duplicates the first name wins.
//MY_ASSERT(tokenType == PTT_ID); // Allow any type of identifier, including strings and numbers.
//MY_ASSERT(tokenType == PTT_ID); // Allow any type of identifier, including strings and numbers.
tokenType = parser.getNextToken(decl.nameMaterial); // MDL material name
MY_ASSERT(tokenType == PTT_ID); // Must be a standard identifier. MDL doesn't allow other names.
MY_ASSERT(tokenType == PTT_ID); // Must be a standard identifier. MDL doesn't allow other names.
tokenType = parser.getNextToken(decl.pathMaterial); // Path to *.mdl file containing the above material name (relative to search paths).
MY_ASSERT(tokenType == PTT_STRING); // Must be a string given in quotation marks.
MY_ASSERT(tokenType == PTT_STRING); // Must be a string given in quotation marks.

convertPath(decl.pathMaterial); // Convert slashes or backslashes to the resp. OS format.

Expand Down
6 changes: 3 additions & 3 deletions apps/MDL_renderer/src/Assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ std::shared_ptr<sg::Group> Application::createASSIMP(const std::string& filename

const aiScene* scene = importer.ReadFile(filename, postProcessSteps);

// If the import failed, report it
// If the import failed, report it.
if (!scene)
{
Assimp::DefaultLogger::get()->info(importer.GetErrorString());
Assimp::DefaultLogger::kill(); // Kill it after the work is done
Assimp::DefaultLogger::kill(); // Kill it after the work is done.

std::shared_ptr<sg::Group> group(new sg::Group(m_idGroup++));
m_mapGroups[filename] = group; // Allow instancing of this whole model (to fail again quicker next time).
Expand Down Expand Up @@ -269,7 +269,7 @@ std::shared_ptr<sg::Group> Application::traverseScene(const struct aiScene *scen
float(m.c1), float(m.c2), float(m.c3), float(m.c4)
};

// Need to do a depth first traversal here to attach the bottom most nodes to each node's group.
// Need to do a depth-first traversal here to attach the bottom-most nodes to each node's group.
for (unsigned int iChild = 0; iChild < node->mNumChildren; ++iChild)
{
std::shared_ptr<sg::Group> child = traverseScene(scene, indexSceneBase, node->mChildren[iChild]);
Expand Down
3 changes: 1 addition & 2 deletions apps/MDL_renderer/src/Curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool Curves::createHair(std::string const& filename, const float scale)
// push
// scale 0.01 0.01 0.01
// rotate 1 0 0 -90
// model hair 1.0 bsdf_hair "file.hair"
// model hair 1.0 material_reference "file.hair"
// pop

Hair hair;
Expand All @@ -145,7 +145,6 @@ bool Curves::createHair(std::string const& filename, const float scale)
std::vector<float3> texcoords;
texcoords.resize(numStrands);

// Simply do some spherical mapping to the center of the root points.
// Calculate the center of the root points.
float3 center = make_float3(0.0f);

Expand Down
Loading

0 comments on commit 2169b5f

Please sign in to comment.