Skip to content

Commit

Permalink
[hdSt] Removed unused GS methods from material network
Browse files Browse the repository at this point in the history
These methods are no longer used and can be deleted now that
we've completed the work to distinguish displacement shading
from which shader stage is executing displacement.

(Internal change: 2339997)
  • Loading branch information
davidgyu authored and pixar-oss committed Sep 9, 2024
1 parent a4df052 commit c59fd55
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 41 deletions.
14 changes: 2 additions & 12 deletions pxr/imaging/hdSt/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ HdStMaterial::Sync(HdSceneDelegate *sceneDelegate,
bool markBatchesDirty = false;

std::string fragmentSource;
std::string geometrySource;
std::string displacementSource;
std::string volumeSource;
VtDictionary materialMetadata;
Expand All @@ -208,7 +207,6 @@ HdStMaterial::Sync(HdSceneDelegate *sceneDelegate,
resourceRegistry.get());
fragmentSource = _networkProcessor.GetFragmentCode();
volumeSource = _networkProcessor.GetVolumeCode();
geometrySource = _networkProcessor.GetGeometryCode();
displacementSource = _networkProcessor.GetDisplacementCode();
materialMetadata = _networkProcessor.GetMetadata();
materialTag = _networkProcessor.GetMaterialTag();
Expand All @@ -218,16 +216,12 @@ HdStMaterial::Sync(HdSceneDelegate *sceneDelegate,
}

// Use fallback shader when there is no source for
// fragment and geometry and displacement shader.
// fragment and displacement shader.
if (fragmentSource.empty() &&
geometrySource.empty() &&
displacementSource.empty()) {

_InitFallbackShader();
fragmentSource = _fallbackGlslfx->GetSurfaceSource();
// Note that we don't want displacement on purpose for the
// fallback material.
geometrySource = std::string();
materialMetadata = _fallbackGlslfx->GetMetadata();
}

Expand All @@ -250,21 +244,17 @@ HdStMaterial::Sync(HdSceneDelegate *sceneDelegate,
}
}

// If we're updating the fragment or geometry source, we need to
// If we're updating the fragment or displacement source, we need to
// rebatch anything that uses this material.
std::string const& oldFragmentSource =
_materialNetworkShader->GetSource(HdShaderTokens->fragmentShader);
std::string const& oldGeometrySource =
_materialNetworkShader->GetSource(HdShaderTokens->geometryShader);
std::string const& oldDisplacementSource =
_materialNetworkShader->GetSource(HdShaderTokens->displacementShader);

markBatchesDirty |= (oldFragmentSource!=fragmentSource) ||
(oldGeometrySource!=geometrySource) ||
(oldDisplacementSource!=displacementSource);

_materialNetworkShader->SetFragmentSource(fragmentSource);
_materialNetworkShader->SetGeometrySource(geometrySource);
_materialNetworkShader->SetDisplacementSource(displacementSource);

bool hasDisplacement = !(displacementSource.empty());
Expand Down
7 changes: 0 additions & 7 deletions pxr/imaging/hdSt/materialNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,6 @@ HdStMaterialNetwork::ProcessMaterialNetwork(
HD_TRACE_FUNCTION();

_fragmentSource.clear();
_geometrySource.clear();
_displacementSource.clear();
_materialMetadata.clear();
_materialParams.clear();
Expand Down Expand Up @@ -1155,12 +1154,6 @@ HdStMaterialNetwork::GetVolumeCode() const
return _volumeSource;
}

std::string const&
HdStMaterialNetwork::GetGeometryCode() const
{
return _geometrySource;
}

std::string const&
HdStMaterialNetwork::GetDisplacementCode() const
{
Expand Down
4 changes: 0 additions & 4 deletions pxr/imaging/hdSt/materialNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class HdStMaterialNetwork final
HDST_API
std::string const& GetVolumeCode() const;

HDST_API
std::string const& GetGeometryCode() const;

HDST_API
std::string const& GetDisplacementCode() const;

Expand Down Expand Up @@ -99,7 +96,6 @@ class HdStMaterialNetwork final
TfToken _materialTag;
std::string _fragmentSource;
std::string _volumeSource;
std::string _geometrySource;
std::string _displacementSource;
VtDictionary _materialMetadata;
HdSt_MaterialParamVector _materialParams;
Expand Down
16 changes: 1 addition & 15 deletions pxr/imaging/hdSt/materialNetworkShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ _CollectPrimvarNames(const HdSt_MaterialParamVector &params);
HdSt_MaterialNetworkShader::HdSt_MaterialNetworkShader()
: HdStShaderCode()
, _fragmentSource()
, _geometrySource()
, _params()
, _paramSpec()
, _paramArray()
Expand All @@ -64,9 +63,6 @@ HdSt_MaterialNetworkShader::_SetSource(
if (shaderStageKey == HdShaderTokens->fragmentShader) {
_fragmentSource = source;
_isValidComputedHash = false;
} else if (shaderStageKey == HdShaderTokens->geometryShader) {
_geometrySource = source;
_isValidComputedHash = false;
} else if (shaderStageKey == HdShaderTokens->displacementShader) {
_displacementSource = source;
_isValidComputedHash = false;
Expand All @@ -83,8 +79,6 @@ HdSt_MaterialNetworkShader::GetSource(TfToken const &shaderStageKey) const
{
if (shaderStageKey == HdShaderTokens->fragmentShader) {
return _fragmentSource;
} else if (shaderStageKey == HdShaderTokens->geometryShader) {
return _geometrySource;
} else if (shaderStageKey == HdShaderTokens->displacementShader) {
return _displacementSource;
}
Expand Down Expand Up @@ -179,7 +173,6 @@ HdSt_MaterialNetworkShader::_ComputeHash() const

hash = TfHash::Combine(hash,
ArchHash(_fragmentSource.c_str(), _fragmentSource.size()),
ArchHash(_geometrySource.c_str(), _geometrySource.size()),
ArchHash(_displacementSource.c_str(), _displacementSource.size())
);

Expand Down Expand Up @@ -228,13 +221,6 @@ HdSt_MaterialNetworkShader::SetFragmentSource(const std::string &source)
_isValidComputedHash = false;
}

void
HdSt_MaterialNetworkShader::SetGeometrySource(const std::string &source)
{
_geometrySource = source;
_isValidComputedHash = false;
}

void
HdSt_MaterialNetworkShader::SetDisplacementSource(const std::string &source)
{
Expand All @@ -245,7 +231,7 @@ HdSt_MaterialNetworkShader::SetDisplacementSource(const std::string &source)
void
HdSt_MaterialNetworkShader::SetParams(const HdSt_MaterialParamVector &params)
{
_params = params;
_params = params;
_primvarNames = _CollectPrimvarNames(_params);
_isValidComputedHash = false;
}
Expand Down
3 changes: 0 additions & 3 deletions pxr/imaging/hdSt/materialNetworkShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ class HdSt_MaterialNetworkShader : public HdStShaderCode
HDST_API
void SetFragmentSource(const std::string &source);
HDST_API
void SetGeometrySource(const std::string &source);
HDST_API
void SetDisplacementSource(const std::string &source);
HDST_API
void SetParams(const HdSt_MaterialParamVector &params);
Expand Down Expand Up @@ -139,7 +137,6 @@ class HdSt_MaterialNetworkShader : public HdStShaderCode

private:
std::string _fragmentSource;
std::string _geometrySource;
std::string _displacementSource;

// Shader Parameters
Expand Down

0 comments on commit c59fd55

Please sign in to comment.