Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Huidong Chen committed Feb 5, 2020
1 parent fb60543 commit 4dd8081
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/render/vp2RenderDelegate/basisCurves.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//
// Copyright 2018 Pixar
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
29 changes: 20 additions & 9 deletions lib/render/vp2RenderDelegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ namespace
const MString _pointSizeParameterName = "pointSize"; //!< Shader parameter name
const MString _structOutputName = "outSurfaceFinal"; //!< Output struct name of the fallback shader

//! Name of the fallback shaders
const MString _fallbackShaderNames[3] =
//! Enum class for fallback shader types
enum class FallbackShaderType
{
Common = 0,
BasisCurvesLinear,
BasisCurvesCubic,
Count
};

//! Array of shader fragment names indexed by FallbackShaderType
const MString _fallbackShaderNames[FallbackShaderType::Count] =
{
"FallbackShader",
"BasisCurvesLinearFallbackShader",
Expand Down Expand Up @@ -220,12 +229,13 @@ namespace
\return A new or existing copy of shader instance with given color
*/
MHWRender::MShaderInstance* GetFallbackShader(const MColor& color, unsigned int index)
MHWRender::MShaderInstance* GetFallbackShader(const MColor& color, FallbackShaderType type)
{
if (index >= sizeof(_fallbackShaders) / sizeof(_fallbackShaders[0])) {
if (type >= FallbackShaderType::Count) {
return nullptr;
}

const unsigned int index = static_cast<unsigned int>(type);
auto& shaderMap = _fallbackShaders[index];

// Look for it first with reader lock
Expand Down Expand Up @@ -268,8 +278,9 @@ namespace
private:
bool _isInitialized { false }; //!< Whether the shader cache is initialized

MShaderMap _fallbackShaders[3]; //!< Shader registry used by fallback shaders
MShaderMap _3dSolidShaders; //!< Shader registry used by fallback shaders
//! Shader registry used by fallback shaders
MShaderMap _fallbackShaders[FallbackShaderType::Count];
MShaderMap _3dSolidShaders;

MHWRender::MShaderInstance* _fallbackCPVShader { nullptr }; //!< Fallback shader with CPV support
MHWRender::MShaderInstance* _3dFatPointShader { nullptr }; //!< 3d shader for points
Expand Down Expand Up @@ -683,7 +694,7 @@ MString HdVP2RenderDelegate::GetLocalNodeName(const MString& name) const {
MHWRender::MShaderInstance* HdVP2RenderDelegate::GetFallbackShader(
const MColor& color) const
{
return sShaderCache.GetFallbackShader(color, 0);
return sShaderCache.GetFallbackShader(color, FallbackShaderType::Common);
}

/*! \brief Returns a fallback shader instance when no material is bound.
Expand All @@ -698,7 +709,7 @@ MHWRender::MShaderInstance* HdVP2RenderDelegate::GetFallbackShader(
MHWRender::MShaderInstance*
HdVP2RenderDelegate::GetBasisCurvesLinearFallbackShader(const MColor& color) const
{
return sShaderCache.GetFallbackShader(color, 1);
return sShaderCache.GetFallbackShader(color, FallbackShaderType::BasisCurvesLinear);
}

/*! \brief Returns a fallback shader instance when no material is bound.
Expand All @@ -713,7 +724,7 @@ HdVP2RenderDelegate::GetBasisCurvesLinearFallbackShader(const MColor& color) con
MHWRender::MShaderInstance*
HdVP2RenderDelegate::GetBasisCurvesCubicFallbackShader(const MColor& color) const
{
return sShaderCache.GetFallbackShader(color, 2);
return sShaderCache.GetFallbackShader(color, FallbackShaderType::BasisCurvesCubic);
}

/*! \brief Returns a fallback CPV shader instance when no material is bound.
Expand Down
3 changes: 3 additions & 0 deletions lib/render/vp2ShaderFragments/BasisCurvesCubicDomain_Cg.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!--
========================================================================
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
4 changes: 4 additions & 0 deletions lib/render/vp2ShaderFragments/BasisCurvesCubicDomain_GLSL.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!--
========================================================================
Copyright 2018 Pixar
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
4 changes: 4 additions & 0 deletions lib/render/vp2ShaderFragments/BasisCurvesCubicDomain_HLSL.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!--
========================================================================
Copyright 2018 Pixar
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!--
========================================================================
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
3 changes: 3 additions & 0 deletions lib/render/vp2ShaderFragments/BasisCurvesLinearDomain_Cg.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!--
========================================================================
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!--
========================================================================
Copyright 2018 Pixar
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!--
========================================================================
Copyright 2018 Pixar
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!--
========================================================================
Copyright 2020 Autodesk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down

0 comments on commit 4dd8081

Please sign in to comment.