Refactor PBRT MDL material pipeline into focused components - #113
Open
nv-rthomson wants to merge 21 commits into
Open
Refactor PBRT MDL material pipeline into focused components#113nv-rthomson wants to merge 21 commits into
nv-rthomson wants to merge 21 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MdlShaderCacheinto focused components for key construction, material-model generation, parameter binding, and texture-graph generation.MdlSmokeMaterial.cutoMdlMaterial.cuto reflect its production role.Motivation
Reduce duplication, localize material and texture policies, and make the MDL pipeline easier to understand, test, and maintain.