Skip to content

Commit

Permalink
Storm: moving determination of whether the material uses any ptex fro…
Browse files Browse the repository at this point in the history
…m HdSt_MaterialBufferSourceAndTextureHelper to HdStMaterial.

Note that the new code is using the texture type that is coming from the material network to make the determination whereas the old one looks at the type coming from the texture resource.

Those should give the result for all sane cases. Corner cases where it might now report there is a ptex (and quadrangulate) is if the texture resource cannot be found.

(Internal change: 2052127)
  • Loading branch information
unhyperbolic authored and pixar-oss committed Mar 31, 2020
1 parent 5052505 commit 73ab1e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pxr/imaging/hdSt/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ HdStMaterial::Sync(HdSceneDelegate *sceneDelegate,
if (param.IsPrimvar() || param.IsFallback()) {
sourcesAndTextures.ProcessPrimvarOrFallbackMaterialParam(param);
} else if (param.IsTexture()) {
if (param.textureType == HdTextureType::Ptex) {
hasPtex = true;
}
sourcesAndTextures.ProcessTextureMaterialParam(
param,
_GetTextureResourceHandle(sceneDelegate, param),
&hasPtex);
_GetTextureResourceHandle(sceneDelegate, param));
}
}

Expand Down
6 changes: 1 addition & 5 deletions pxr/imaging/hdSt/materialBufferSourceAndTextureHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ class HdSt_BindlessSamplerBufferSource final : public HdBufferSource
void
HdSt_MaterialBufferSourceAndTextureHelper::ProcessTextureMaterialParam(
HdSt_MaterialParam const &param,
HdStTextureResourceHandleSharedPtr const &handle,
bool * isPtex)
HdStTextureResourceHandleSharedPtr const &handle)
{
if (!(handle && handle->GetTextureResource())) {
// we were unable to get the requested resource or
Expand All @@ -125,9 +124,6 @@ HdSt_MaterialBufferSourceAndTextureHelper::ProcessTextureMaterialParam(

const HdTextureType textureType = texResource->GetTextureType();
if (textureType == HdTextureType::Ptex) {
if (isPtex) {
*isPtex = true;
}
tex.type =
HdStShaderCode::TextureDescriptor::TEXTURE_PTEX_TEXEL;
textures.push_back(tex);
Expand Down
5 changes: 1 addition & 4 deletions pxr/imaging/hdSt/materialBufferSourceAndTextureHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ struct HdSt_MaterialBufferSourceAndTextureHelper

/// Process material param of type HdSt_MaterialParam::ParamTypeTexture
/// given the texture requested by the param.
///
/// isPtex is set to true if texture request by param is ptex.
void ProcessTextureMaterialParam(
HdSt_MaterialParam const &param,
HdStTextureResourceHandleSharedPtr const &handle,
bool * isPtex = nullptr);
HdStTextureResourceHandleSharedPtr const &handle);

/// The buffer sources created by the above methods.
HdBufferSourceSharedPtrVector sources;
Expand Down

0 comments on commit 73ab1e2

Please sign in to comment.