Skip to content

Commit e6f4981

Browse files
committed
KlayGE: Rendering: Enable to load a RenderMaterial without a valid RenderFactory
1 parent 1a7987d commit e6f4981

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

KlayGE/Core/Src/Render/RenderMaterial.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,17 +1032,20 @@ namespace KlayGE
10321032

10331033
void RenderMaterial::LoadTextureSlots()
10341034
{
1035-
auto& rf = Context::Instance().RenderFactoryInstance();
1036-
for (size_t i = 0; i < RenderMaterial::TS_NumTextureSlots; ++i)
1035+
if (Context::Instance().RenderFactoryValid())
10371036
{
1038-
auto slot = static_cast<RenderMaterial::TextureSlot>(i);
1039-
auto const& tex_name = textures_[slot].first;
1040-
if (!tex_name.empty())
1037+
auto& rf = Context::Instance().RenderFactoryInstance();
1038+
for (size_t i = 0; i < RenderMaterial::TS_NumTextureSlots; ++i)
10411039
{
1042-
if (!ResLoader::Instance().Locate(tex_name).empty()
1043-
|| !ResLoader::Instance().Locate(tex_name + ".dds").empty())
1040+
auto slot = static_cast<RenderMaterial::TextureSlot>(i);
1041+
auto const& tex_name = textures_[slot].first;
1042+
if (!tex_name.empty())
10441043
{
1045-
this->Texture(slot, rf.MakeTextureSrv(ASyncLoadTexture(tex_name, EAH_GPU_Read | EAH_Immutable)));
1044+
if (!ResLoader::Instance().Locate(tex_name).empty()
1045+
|| !ResLoader::Instance().Locate(tex_name + ".dds").empty())
1046+
{
1047+
this->Texture(slot, rf.MakeTextureSrv(ASyncLoadTexture(tex_name, EAH_GPU_Read | EAH_Immutable)));
1048+
}
10461049
}
10471050
}
10481051
}

0 commit comments

Comments
 (0)