Skip to content

Commit

Permalink
MDL SDK 2020.1.1 (334300.4226)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkettnerNV committed Oct 9, 2020
1 parent 3ef37d8 commit cf90e46
Show file tree
Hide file tree
Showing 69 changed files with 1,905 additions and 911 deletions.
49 changes: 48 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
Change Log
==========
MDL SDK 2020.1 (334300.2228): 11 Aug 2020
MDL SDK 2020.1.1 (334300.4226): 29 Sep 2020
-----------------------------------------------

ABI compatible with the MDL SDK 2020.1.1 (334300.4226) binary release
(see [https://developer.nvidia.com/mdl-sdk](https://developer.nvidia.com/mdl-sdk))

**Added and Changed Features**

- General

- Thumbnail paths are now resolved when they are requested. Before, the resolving was done
during the module loading.
- A new backend option `eval_dag_ternary_strictly` has been added, which enables strict
evaluation of ternary operators (?:) on the DAG to reduce code size. By default it is enabled.

- MDL Compiler and Backends

- Added single-init mode for a set of functions added to a link unit, allowing all these
functions to reuse values calculated in the init function and stored in the texture results
field of the state struct. To enable this mode, the first path in the target function
description list given to `ILink_unit::add_material()` must be `"init"`. (Note: the init
function will not be marked as `ITarget_code::DK_BSDF` anymore.)

- MDL SDK examples

- Examples Shared
- Enabled CMake option for linking MSVC dynamic runtime (/MD) instead of static (/MT) by
default.

- Example Code Generation
- Updated MaterialX support to incorporate latest changes from the MaterialX github
repository (branch 1.3.8).

- Example DXR
- Added `-e` option to specify which expressions to compile.

**Fixed Bugs**

- MDL Compiler and Backends

- Fixed `IFunction_call::get_arguments()` for the array constructor, such that it always
uses `"0"`, `"1"`, and so on as argument names.
- Fixed failing MDLE export if the `tex::gamma_mode` type is only referenced by an
annotation.
- Fixed storing matrices in texture results taking up all the space without much benefit.


MDL SDK 2020.1 (334300.2228): 11 Aug 2020
-----------------------------------------

ABI compatible with the MDL SDK 2020.1 (334300.2228) binary release
(see [https://developer.nvidia.com/mdl-sdk](https://developer.nvidia.com/mdl-sdk))

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ select particular logging information:
[ON/OFF] enable/disable the logging of files that are copied to the output folder.

- **MDL_MSVC_DYNAMIC_RUNTIME_EXAMPLES**
[ON/OFF] links the MSCV dynamic runtime (\\MD) instead of static (\\MT) when
[ON/OFF] links the MSCV dynamic runtime (/MD) instead of static (/MT) when
creating the example executables.

By default, all options are set to ON. For any help request, please attach
Expand Down
2 changes: 1 addition & 1 deletion cmake/setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ if(MDL_LOG_PLATFORM_INFOS)
MESSAGE(STATUS "[INFO] CMAKE_CXX_FLAGS_RELWITHDEBINFO: " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
endif()

option(MDL_MSVC_DYNAMIC_RUNTIME_EXAMPLES "Links the MSCV dynamic runtime (\\MD) instead of static (\\MT)." OFF)
option(MDL_MSVC_DYNAMIC_RUNTIME_EXAMPLES "Links the MSCV dynamic runtime (\\MD) instead of static (\\MT)." ON)

# check for dependencies
# pre-declare all options that are used
Expand Down
2 changes: 1 addition & 1 deletion doc/base_module/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h3>Edge</h3>

</div><div id="blackfooter">
<span class="footeritem">
11&#160;August&#160;2020,&#160;19:59,&#160;rev.334300.2228
29&#160;September&#160;2020,&#160;20:15,&#160;rev.334300.4226
</span>
<span class="footeritem">
<a href="https://www.nvidia.com/en-us/about-nvidia/legal-info/" target="_blank" shape="rect">&copy; 2020 NVIDIA&nbsp;Corporation.</a> All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion doc/build/doxygen_footer_1_8_4.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path">
<span class="footeritem">MDL SDK 2020.1 (334300.2228): $datetime</span>
<span class="footeritem">MDL SDK 2020.1.1 (334300.4226): $datetime</span>
<span class="footeritem">
<a href="http://www.nvidia.com/">
&copy;&#160;2020&#160;NVIDIA&#160;Corporation.</a>
Expand Down
6 changes: 3 additions & 3 deletions doc/core_definitions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ <h2>Page cannot be loaded</h2>
bottom of the page or from the following links:</p>

<div style="padding-left:2em;">
<a href="mdl_core_definitions.200811.A4.pdf">View documentation in A4 format</a><br>
<a href="mdl_core_definitions.200811.LTR.pdf">View documentation in US Letter format</a><br>
<a href="mdl_core_definitions.200929.A4.pdf">View documentation in A4 format</a><br>
<a href="mdl_core_definitions.200929.LTR.pdf">View documentation in US Letter format</a><br>
</div>
<h3>Overriding security settings</h3>

Expand Down Expand Up @@ -240,7 +240,7 @@ <h3>Edge</h3>
<span class="footeritem">
</span>
<span class="footeritem">
11&#160;August&#160;2020,&#160;19:59,&#160;rev.334300.2228
29&#160;September&#160;2020,&#160;20:16,&#160;rev.334300.4226
</span>
<span class="footeritem">
<a href="https://www.nvidia.com/en-us/about-nvidia/legal-info/" target="_blank" shape="rect">&copy; 2020 NVIDIA&nbsp;Corporation.</a> All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</div>
<div id="blackfooter">
<span class="footeritem">
MDL SDK 2020.1 (334300.2228): 11 Aug 2020
MDL SDK 2020.1.1 (334300.4226): 29 Sep 2020
</span>
<span class="footeritem">
<a href="http://www.nvidia.com/">
Expand Down
2 changes: 1 addition & 1 deletion doc/mdl_coreapi/example_df_cuda.dox
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ typedef void (Bsdf_pdf_function)(
void const *exception_state,
char const *arg_block_data);
\endcode
The functions can be generated by \link ILink_unit::add(IDistribution_function const *, ICall_name_resolver const *, size_t *, size_t *) ILink_unit::add() \endlink.
The functions can be generated by \link ILink_unit::add(IDistribution_function const *, ICall_name_resolver const *, size_t *, size_t *, size_t) ILink_unit::add() \endlink.
Both functions have a parameter \c include_geometry_normal that can be specified to make the initialization function replace \c state->normal by the result of the expression connected to \c geometry.normal of the material.
The final function names are specified by a base name that will suffixed by \c _init, \c _sample, \c _evaluate, and \c _pdf.

Expand Down
26 changes: 25 additions & 1 deletion doc/mdl_sdkapi/example_code_gen.dox
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
/******************************************************************************
* Copyright 2020 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

/*! \page mi_neuray_example_code_gen Example for Generating Shader Code for an MDL Material
Expand Down
26 changes: 25 additions & 1 deletion doc/mdl_sdkapi/example_optix7.dox
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
/******************************************************************************
* Copyright 2020 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

/*! \page mi_neuray_example_optix7 Example for Inlining MDL Code into Shaders (OptiX 7)
Expand Down
3 changes: 3 additions & 0 deletions doc/mdl_sdkapi/example_topics.dox
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ index.
\if MDL_BIN_RELEASE
- \ref mi_neuray_example_distilling "Material distilling"
- \ref mi_neuray_example_distilling "Baking material sub-expressions"

- \ref mi_neuray_example_distilling_unity "Compiling into one link unit"
- \ref mi_neuray_example_distilling_unity "Baking material to Unity texture channel layout"

- \ref mi_neuray_example_distilling_glsl "Mapping distilled materials to a GLSL shader"
\endif
Expand Down
3 changes: 3 additions & 0 deletions doc/mdl_sdkapi/examples.dox
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ Section for a description of how the example programs can be compiled.
- \subpage mi_neuray_example_distilling <br>
Distilling of compiled materials and baking of material sub-expressions.

- \subpage mi_neuray_example_distilling_unity <br>
Distilling of compiled materials and baking of material sub-expressions for Unity

- \subpage mi_neuray_example_distilling_glsl <br>
Mapping distilled materials to a GLSL shader.
\endif
Expand Down
46 changes: 30 additions & 16 deletions examples/mdl_core/shared/example_cuda_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,16 @@ class Resource_collection : public mi::mdl::ILambda_resource_enumerator,
/// Collect and map all resources used by the given distribution function.
void collect(mi::mdl::IDistribution_function *dist_func)
{
mi::base::Handle<mi::mdl::ILambda_function> main_df(dist_func->get_main_df());
mi::base::Handle<mi::mdl::ILambda_function> root_lambda(dist_func->get_root_lambda());
mi::base::Handle<mi::mdl::ILambda_function> old_lambda = m_cur_lambda;

// all resources will be registered in the main lambda
m_cur_lambda = mi::base::make_handle_dup(main_df.get());
m_cur_lambda = mi::base::make_handle_dup(root_lambda.get());

main_df->enumerate_resources(m_call_resolver, *this, main_df->get_body());
for (size_t i = 0, n = dist_func->get_main_function_count(); i < n; ++i) {
mi::base::Handle<mi::mdl::ILambda_function> main_func(dist_func->get_main_function(i));
root_lambda->enumerate_resources(m_call_resolver, *this, main_func->get_body());
}

for (size_t i = 0, n = dist_func->get_expr_lambda_count(); i < n; ++i) {
mi::base::Handle<mi::mdl::ILambda_function> expr_lambda(dist_func->get_expr_lambda(i));
Expand Down Expand Up @@ -1850,11 +1853,6 @@ bool Material_ptx_compiler::add_material(
return false;
}

// Create new distribution function object and access the main lambda
mi::base::Handle<mi::mdl::IDistribution_function> dist_func(
m_dag_be->create_distribution_function());
mi::base::Handle<mi::mdl::ILambda_function> main_df(dist_func->get_main_df());

// check if the distribution function is the default one, e.g. 'bsdf()'
// if that's the case we don't need to translate as the evaluation of the function
// will result in zero
Expand All @@ -1866,30 +1864,41 @@ bool Material_ptx_compiler::add_material(
break;
}

// Set the base function name for the generated functions in the main lambda
main_df->set_name(function_name.c_str());
// Create new distribution function object and access the main lambda
mi::base::Handle<mi::mdl::IDistribution_function> dist_func(
m_dag_be->create_distribution_function());
mi::base::Handle<mi::mdl::ILambda_function> root_lambda(
dist_func->get_root_lambda());

// set the name of the init function
std::string init_name = function_name + "_init";
root_lambda->set_name(init_name.c_str());

// Add all material parameters to the lambda function
for (size_t i = 0, n = mat_instance->get_parameter_count(); i < n; ++i)
{
mi::mdl::IValue const *value = mat_instance->get_parameter_default(i);

size_t idx = main_df->add_parameter(
size_t idx = root_lambda->add_parameter(
value->get_type(),
mat_instance->get_parameter_name(i));

// Map the i'th material parameter to this new parameter
main_df->set_parameter_mapping(i, idx);
root_lambda->set_parameter_mapping(i, idx);
}

// Import full material into the main lambda
mi::mdl::DAG_node const *material_constructor =
main_df->import_expr(mat_instance->get_constructor());
root_lambda->import_expr(mat_instance->get_constructor());

mi::mdl::IDistribution_function::Requested_function req_func(
function_descriptions[i].path, function_name.c_str());

// Initialize the distribution function
if (dist_func->initialize(
material_constructor,
function_descriptions[i].path,
&req_func,
1,
/*include_geometry_normal=*/ true,
/*calc_derivatives=*/ m_enable_derivatives,
/*allow_double_expr_lambdas=*/ false,
Expand All @@ -1898,19 +1907,24 @@ bool Material_ptx_compiler::add_material(

// Collect the resources of the distribution function and the material arguments
m_res_col.collect(dist_func.get());
collect_material_argument_resources(mat_instance.get(), main_df.get());
collect_material_argument_resources(mat_instance.get(), root_lambda.get());

// Add the lambda function to the link unit
size_t main_func_index;
if (!m_link_unit->add(
dist_func.get(),
&m_module_manager,
&arg_block_index,
&function_descriptions[i].function_index))
&main_func_index,
1))
{
function_descriptions[i].return_code = -1;
continue;
}

// for distribution functions, let function_index point to the init function,
// which does not count as main function
function_descriptions[i].function_index = main_func_index - 1;
break;
}

Expand Down
Loading

0 comments on commit cf90e46

Please sign in to comment.