Skip to content

Commit 5f2f31f

Browse files
GLTF Viewer and USD Viewer: a few minor updates
1 parent 685b17a commit 5f2f31f

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ GLTFViewer::CommandLineStatus GLTFViewer::ProcessCommandLine(int argc, const cha
239239
ArgsParser.Parse("use_cache", m_bUseResourceCache);
240240
ArgsParser.Parse("model", m_ModelPath);
241241
ArgsParser.Parse("compute_bounds", m_bComputeBoundingBoxes);
242+
ArgsParser.ParseEnum<PBR_Renderer::SHADER_TEXTURE_ARRAY_MODE>(
243+
"tex_array", 0,
244+
{
245+
{"none", PBR_Renderer::SHADER_TEXTURE_ARRAY_MODE_NONE},
246+
{"static", PBR_Renderer::SHADER_TEXTURE_ARRAY_MODE_STATIC},
247+
},
248+
m_TextureArrayMode);
242249

243250
std::string ExtraModelsDir;
244251
ArgsParser.Parse("dir", 'd', ExtraModelsDir);
@@ -455,6 +462,8 @@ void GLTFViewer::CreateGLTFRenderer()
455462
RendererCI.SheenAlbedoScalingLUTPath = "textures/sheen_albedo_scaling.jpg";
456463
RendererCI.PreintegratedCharlieBRDFPath = "textures/charlie_preintegrated.jpg";
457464

465+
RendererCI.ShaderTexturesArrayMode = m_TextureArrayMode;
466+
458467
m_RenderParams.Flags =
459468
GLTF_PBR_Renderer::PSO_FLAG_DEFAULT |
460469
GLTF_PBR_Renderer::PSO_FLAG_ENABLE_CLEAR_COAT |
@@ -1225,7 +1234,6 @@ void GLTFViewer::Render()
12251234

12261235
{
12271236
HLSL::ScreenSpaceReflectionAttribs SSRAttribs{};
1228-
SSRAttribs.IBLFactor = m_ShaderAttribs.IBLScale;
12291237
SSRAttribs.RoughnessChannel = 0;
12301238
SSRAttribs.IsRoughnessPerceptual = true;
12311239

Samples/GLTFViewer/src/GLTFViewer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ class GLTFViewer final : public SampleBase
191191
bool m_bComputeBoundingBoxes = false;
192192
bool m_bWireframeSupported = false;
193193
bool m_bEnablePostProcessing = false;
194+
195+
PBR_Renderer::SHADER_TEXTURE_ARRAY_MODE m_TextureArrayMode = PBR_Renderer::SHADER_TEXTURE_ARRAY_MODE_NONE;
194196
};
195197

196198
} // namespace Diligent

Samples/USDViewer/src/USDViewer.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ SampleBase::CommandLineStatus USDViewer::ProcessCommandLine(int argc, const char
119119
ArgsParser.Parse("usd_path", 'u', m_UsdFileName);
120120
ArgsParser.Parse("vertex_pool", m_UseVertexPool);
121121
ArgsParser.Parse("index_pool", m_UseIndexPool);
122-
ArgsParser.Parse("texture_atlas", m_UseTextureAtlas);
122+
ArgsParser.Parse("atlas_dim", m_TextureAtlasDim);
123123
LOG_INFO_MESSAGE("USD Viewer Arguments:",
124124
"\n USD Path: ", m_UsdFileName,
125125
"\n Use vertex pool: ", m_UseVertexPool ? "Yes" : "No",
126126
"\n Use index pool: ", m_UseIndexPool ? "Yes" : "No",
127-
"\n Use tex atlas: ", m_UseTextureAtlas ? "Yes" : "No");
127+
"\n Tex atlas dim: ", m_TextureAtlasDim);
128128

129129
std::string ModelsDir;
130130
ArgsParser.Parse("usd_dir", 'd', ModelsDir);
@@ -238,8 +238,23 @@ void USDViewer::LoadStage()
238238
DelegateCI.pRenderStateCache = nullptr;
239239
DelegateCI.UseVertexPool = m_UseVertexPool;
240240
DelegateCI.UseIndexPool = m_UseIndexPool;
241-
DelegateCI.TextureAtlasDim = m_UseTextureAtlas ? 2048 : 0;
242-
m_Stage.RenderDelegate = USD::HnRenderDelegate::Create(DelegateCI);
241+
if (m_pDevice->GetDeviceInfo().Features.BindlessResources)
242+
{
243+
m_BindingMode = USD::HN_MATERIAL_TEXTURES_BINDING_MODE_DYNAMIC;
244+
245+
DelegateCI.TexturesArraySize = 256;
246+
}
247+
else
248+
{
249+
m_BindingMode = m_TextureAtlasDim != 0 ?
250+
USD::HN_MATERIAL_TEXTURES_BINDING_MODE_ATLAS :
251+
USD::HN_MATERIAL_TEXTURES_BINDING_MODE_LEGACY;
252+
253+
DelegateCI.TextureAtlasDim = m_TextureAtlasDim;
254+
}
255+
DelegateCI.TextureBindingMode = m_BindingMode;
256+
257+
m_Stage.RenderDelegate = USD::HnRenderDelegate::Create(DelegateCI);
243258
m_Stage.RenderIndex.reset(pxr::HdRenderIndex::New(m_Stage.RenderDelegate.get(), pxr::HdDriverVector{}));
244259

245260
const pxr::SdfPath SceneDelegateId = pxr::SdfPath::AbsoluteRootPath();
@@ -694,6 +709,7 @@ void USDViewer::UpdateUI()
694709
{
695710
const auto MemoryStats = m_Stage.RenderDelegate->GetMemoryStats();
696711
ImGui::TextDisabled("Task time\n"
712+
"Binding\n"
697713
"Num draws\n"
698714
"Tris\n"
699715
"Lines\n"
@@ -715,7 +731,17 @@ void USDViewer::UpdateUI()
715731
const std::string IndPoolCommittedSizeStr = GetMemorySizeString(MemoryStats.IndexPool.CommittedSize).c_str();
716732
const std::string IndPoolUsedSizeStr = GetMemorySizeString(MemoryStats.IndexPool.UsedSize).c_str();
717733
const std::string AtlasCommittedSizeStr = GetMemorySizeString(MemoryStats.Atlas.CommittedSize).c_str();
734+
735+
const char* TextureBindingModeStr = "";
736+
switch (m_BindingMode)
737+
{
738+
case USD::HN_MATERIAL_TEXTURES_BINDING_MODE_LEGACY: TextureBindingModeStr = "Legacy"; break;
739+
case USD::HN_MATERIAL_TEXTURES_BINDING_MODE_ATLAS: TextureBindingModeStr = "Atlas"; break;
740+
case USD::HN_MATERIAL_TEXTURES_BINDING_MODE_DYNAMIC: TextureBindingModeStr = "Dynamic"; break;
741+
}
742+
718743
ImGui::TextDisabled("%.1f ms\n"
744+
"%s\n"
719745
"%d\n"
720746
"%d\n"
721747
"%d\n"
@@ -731,6 +757,7 @@ void USDViewer::UpdateUI()
731757
"%s / %s (%d allocs)\n"
732758
"%s (%.1lf%%, %d allocs)",
733759
m_Stats.TaskRunTime * 1000.f,
760+
TextureBindingModeStr,
734761
m_Stats.NumDrawCommands,
735762
m_Stats.NumTriangles,
736763
m_Stats.NumLines,

Samples/USDViewer/src/USDViewer.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ class USDViewer final : public SampleBase
126126

127127
std::string m_UsdFileName;
128128

129-
bool m_UseIndexPool = true;
130-
bool m_UseVertexPool = true;
131-
bool m_UseTextureAtlas = true;
129+
bool m_UseIndexPool = true;
130+
bool m_UseVertexPool = true;
131+
Uint32 m_TextureAtlasDim = 2048;
132+
133+
USD::HN_MATERIAL_TEXTURES_BINDING_MODE m_BindingMode = USD::HN_MATERIAL_TEXTURES_BINDING_MODE_LEGACY;
132134

133135
RefCntAutoPtr<ITextureView> m_EnvironmentMapSRV;
134136

0 commit comments

Comments
 (0)