Skip to content

Refactor PBRT MDL material pipeline into focused components - #113

Open
nv-rthomson wants to merge 21 commits into
NVIDIA:masterfrom
nv-rthomson:pbrt-mdl-refactor
Open

Refactor PBRT MDL material pipeline into focused components#113
nv-rthomson wants to merge 21 commits into
NVIDIA:masterfrom
nv-rthomson:pbrt-mdl-refactor

Conversation

@nv-rthomson

Copy link
Copy Markdown
Collaborator

Summary

  • Decompose MdlShaderCache into focused components for key construction, material-model generation, parameter binding, and texture-graph generation.
  • Centralize MDL SDK session management, handle types, compilation utilities, diagnostics, and argument-block capture.
  • Replace repeated PBRT material-type string comparisons with centralized material descriptors and capabilities.
  • Unify PBRT color and float texture graph traversal, constant folding, composition, and runtime binding.
  • Restructure MDL target-code compilation and closest-hit shading into named pipeline steps.
  • Refactor Fourier BSDF table loading and sampling into focused operations with shared test utilities.
  • Simplify MDL SDK tests through common fixtures and helpers.
  • Rename MdlSmokeMaterial.cu to MdlMaterial.cu to reflect its production role.
  • Remove an unused material graph parameter and clarify the ignored PBRT film-resolution warning.

Motivation

Reduce duplication, localize material and texture policies, and make the MDL pipeline easier to understand, test, and maintain.

Drop the unused material type parameter from material graph reference
collection. Update direct and named-material callers to use the simplified
interface.
Extract hit loading, payload initialization, texture-coordinate setup,
tinting, bump mapping, BSDF shading, and fallback handling into focused
device helpers. Keep the closest-hit program as a concise description of
the shading pipeline.
Extract context creation, material compilation, backend setup, tint
translation, result capture, and BSDF generation into focused helpers.
Manage session and transaction lifetimes with checked RAII, and pass
aliased MDL handles by const reference to keep the orchestration concise.
Extract platform library loading, factory lookup, SDK startup, shutdown,
and error reporting into a production MdlSdkSession component. Use it from
ProgramGroups and the MDL SDK tests to replace parallel implementations.
Replace parallel source-key and instance-key recursion with one templated
material and texture graph traversal. Parameterize node formatting with
stateless source and instance emitters while preserving each key's fields.
Extract the repeated SDK session, database, scope, transaction, factory,
and execution-context lifecycle into a fixture. Add a fixture helper for
compiling generated materials and convert SDK-dependent tests to use it.

Introduce aliases for MDL handle types, remove redundant scopes, and
organize each test into setup, execute, verify, and teardown phases. Keep
header-only checks in a separate suite and drop assertions that exercised
only the test-only source-description formatter.
Add MdlHandleTypes.h as the single declaration site for all 32 MDL SDK
handle wrappers used by DemandPbrtScene. Move NeurayHandle from
MdlSdkSession and replace local aliases and raw Handle specializations in
production code and tests with the shared names.

Register the header with the MDL source set.
Move material parameter specifications into a table used by both root and
named materials. Extract the root and named-material binding steps so
makeMdlBoundMaterialParameters reads as their ordered composition.
Centralize execution-context diagnostics, failure handling, and target
argument-block capture in MdlUtils. Use the same implementations from
material compilation, BSDF compilation, and the MDL SDK tests.
Define shader and texture-binding defaults at their declarations. Delegate
specialized constructors from the base callable constructor, eliminating
repeated member initialization and texture-binding cleanup.
Describe generated MDL texture parameters in one table used by support
detection and runtime binding. Compose support from map discovery,
foldability, runtime binding, exceptions, and flag validation so the two
paths cannot drift.
Extract value and folding traits for color and float texture graphs. Use
one implementation for constant folding, direct binding, scale composition,
mix composition, and recursive dispatch. Replace the Boolean mix flag with
an explicit traversal policy.
Rename file-local named-material runtime binding and texture support helpers
to concise names that rely on their narrow module context. Update all local
callers.
Capture the complete expected mix-material geometry matcher once and reuse
it for SBT-offset lookup and shader-realization expectations. This keeps
both mock calls aligned as the binding set changes.
Extract header reading, metadata validation, array loading, span
validation, and finalization into focused free functions. Combine file
opening, header decoding, and metadata reading as one preamble step. Return
load status directly from every step.
Extract the little-endian Fourier table writer and common minimal and
order-shape builders into a reusable test helper. Use it from the Fourier
table and material resolver tests to remove duplicate binary serialization
code.

Qualify Google Mock matchers to distinguish them from the project testing
namespace.
Extract Catmull-Rom segment selection and integration, Fourier recurrence
evaluation, and safeguarded Newton iteration into device helpers. Share
convergence and Newton-update logic between the sampling paths.

Scope the DemandPbrtScene namespace import to the Fourier table tests and
avoid an MSVC lookup collision in Google Mock's Each matcher.
Parse material type names into a centralized kind and capability
descriptor. Dispatch MDL source generation, support checks, runtime texture
binding, parameter selection, and gap policy by material kind.

This removes repeated string comparisons and localizes material behavior.
Extract key construction, material-model generation, parameter binding,
and texture-graph generation into focused components. Leave
MdlShaderCache.cpp responsible only for cache orchestration.

Move MdlTextureGraphGenerator behind a private implementation and place
each component interface in its corresponding header.
Rename MdlSmokeMaterial.cu to MdlMaterial.cu now that it contains the
production MDL closest-hit implementation. Update CUDA embedding and
generated symbol references to match.
State that image-film parameters are ignored and rendering resolution is
controlled by the application window. Avoid implying that parsed
xresolution and yresolution values affect output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant