Skip to content

Commit

Permalink
xrRenderDX10/dx10ResourceManager_Resources.cpp: removed code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Sep 30, 2018
1 parent bba8744 commit 46bc819
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class ECORE_API CResourceManager
T* CreateShader(const char* name, const char* filename = nullptr, const bool searchForEntryAndTarget = false);

template <typename T>
void DestroyShader(const T* sh);
bool DestroyShader(const T* sh);
};

#endif // ResourceManagerH
8 changes: 5 additions & 3 deletions src/Layers/xrRender/ShaderResourceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ inline T* CResourceManager::CreateShader(const char* name, const char* filename
}

template <typename T>
inline void CResourceManager::DestroyShader(const T* sh)
bool CResourceManager::DestroyShader(const T* sh)
{
if (0 == (sh->dwFlags & xr_resource_flagged::RF_REGISTERED))
return;
return false;

ShaderTypeTraits<T>::MapType& sh_map = GetShaderMap<ShaderTypeTraits<T>::MapType>();

Expand All @@ -439,7 +439,9 @@ inline void CResourceManager::DestroyShader(const T* sh)
if (iterator != sh_map.end())
{
sh_map.erase(iterator);
return;
return true;
}

Msg("! ERROR: Failed to find compiled shader '%s'", sh->cName.c_str());
return false;
}
22 changes: 5 additions & 17 deletions src/Layers/xrRenderDX10/dx10ResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,19 @@ SVS* CResourceManager::_CreateVS(LPCSTR _name)

void CResourceManager::_DeleteVS(const SVS* vs)
{
// XXX: try to use code below
// DestroyShader(vs);

if (0 == (vs->dwFlags & xr_resource_flagged::RF_REGISTERED))
return;
LPSTR N = LPSTR(*vs->cName);
map_VS::iterator I = m_vs.find(N);
if (I != m_vs.end())
if (DestroyShader(vs))
{
m_vs.erase(I);
xr_vector<SDeclaration*>::iterator iDecl;
for (iDecl = v_declarations.begin(); iDecl != v_declarations.end(); ++iDecl)
for (const auto& iDecl : v_declarations)
{
xr_map<ID3DBlob*, ID3DInputLayout*>::iterator iLayout;
iLayout = (*iDecl)->vs_to_layout.find(vs->signature->signature);
if (iLayout != (*iDecl)->vs_to_layout.end())
const auto iLayout = iDecl->vs_to_layout.find(vs->signature->signature);
if (iLayout != iDecl->vs_to_layout.end())
{
// Release vertex layout
_RELEASE(iLayout->second);
(*iDecl)->vs_to_layout.erase(iLayout);
iDecl->vs_to_layout.erase(iLayout);
}
}
return;
}
Msg("! ERROR: Failed to find compiled vertex-shader '%s'", *vs->cName);
}

//--------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 46bc819

Please sign in to comment.