Skip to content

Commit

Permalink
KlayGE: Rendering: Enable to load a RenderMaterial without a valid Re…
Browse files Browse the repository at this point in the history
…nderFactory
  • Loading branch information
gongminmin committed Dec 31, 2019
1 parent 1a7987d commit e6f4981
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions KlayGE/Core/Src/Render/RenderMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,17 +1032,20 @@ namespace KlayGE

void RenderMaterial::LoadTextureSlots()
{
auto& rf = Context::Instance().RenderFactoryInstance();
for (size_t i = 0; i < RenderMaterial::TS_NumTextureSlots; ++i)
if (Context::Instance().RenderFactoryValid())
{
auto slot = static_cast<RenderMaterial::TextureSlot>(i);
auto const& tex_name = textures_[slot].first;
if (!tex_name.empty())
auto& rf = Context::Instance().RenderFactoryInstance();
for (size_t i = 0; i < RenderMaterial::TS_NumTextureSlots; ++i)
{
if (!ResLoader::Instance().Locate(tex_name).empty()
|| !ResLoader::Instance().Locate(tex_name + ".dds").empty())
auto slot = static_cast<RenderMaterial::TextureSlot>(i);
auto const& tex_name = textures_[slot].first;
if (!tex_name.empty())
{
this->Texture(slot, rf.MakeTextureSrv(ASyncLoadTexture(tex_name, EAH_GPU_Read | EAH_Immutable)));
if (!ResLoader::Instance().Locate(tex_name).empty()
|| !ResLoader::Instance().Locate(tex_name + ".dds").empty())
{
this->Texture(slot, rf.MakeTextureSrv(ASyncLoadTexture(tex_name, EAH_GPU_Read | EAH_Immutable)));
}
}
}
}
Expand Down

0 comments on commit e6f4981

Please sign in to comment.