mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[d3d9] Use if/else in GetCommonTexture and TextureRefPrivate
These are the only things it can be, and they all end up calling what the compiler will optimize to the same function so we can avoid a branch here.
This commit is contained in:
parent
3f2b582d5f
commit
409eac9d20
@ -189,15 +189,13 @@ namespace dxvk {
|
|||||||
if (ptr == nullptr)
|
if (ptr == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
switch (ptr->GetType()) {
|
D3DRESOURCETYPE type = ptr->GetType();
|
||||||
case D3DRTYPE_TEXTURE: return static_cast<D3D9Texture2D*> (ptr)->GetCommonTexture();
|
if (type == D3DRTYPE_TEXTURE)
|
||||||
case D3DRTYPE_CUBETEXTURE: return static_cast<D3D9TextureCube*>(ptr)->GetCommonTexture();
|
return static_cast<D3D9Texture2D*> (ptr)->GetCommonTexture();
|
||||||
case D3DRTYPE_VOLUMETEXTURE: return static_cast<D3D9Texture3D*> (ptr)->GetCommonTexture();
|
else if (type == D3DRTYPE_CUBETEXTURE)
|
||||||
default:
|
return static_cast<D3D9TextureCube*>(ptr)->GetCommonTexture();
|
||||||
Logger::warn("Unknown texture resource type."); break;
|
else //if(type == D3DRTYPE_VOLUMETEXTURE)
|
||||||
}
|
return static_cast<D3D9Texture3D*> (ptr)->GetCommonTexture();
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline D3D9CommonTexture* GetCommonTexture(D3D9Surface* ptr) {
|
inline D3D9CommonTexture* GetCommonTexture(D3D9Surface* ptr) {
|
||||||
@ -215,13 +213,13 @@ namespace dxvk {
|
|||||||
if (tex == nullptr)
|
if (tex == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (tex->GetType()) {
|
D3DRESOURCETYPE type = tex->GetType();
|
||||||
case D3DRTYPE_TEXTURE: CastRefPrivate<D3D9Texture2D> (tex, AddRef); break;
|
if (type == D3DRTYPE_TEXTURE)
|
||||||
case D3DRTYPE_CUBETEXTURE: CastRefPrivate<D3D9TextureCube>(tex, AddRef); break;
|
return CastRefPrivate<D3D9Texture2D> (tex, AddRef);
|
||||||
case D3DRTYPE_VOLUMETEXTURE: CastRefPrivate<D3D9Texture3D> (tex, AddRef); break;
|
else if (type == D3DRTYPE_CUBETEXTURE)
|
||||||
default:
|
return CastRefPrivate<D3D9TextureCube>(tex, AddRef);
|
||||||
Logger::warn("Unknown texture resource type."); break;
|
else //if(type == D3DRTYPE_VOLUMETEXTURE)
|
||||||
}
|
return CastRefPrivate<D3D9Texture3D> (tex, AddRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TextureChangePrivate(IDirect3DBaseTexture9*& dst, IDirect3DBaseTexture9* src) {
|
inline void TextureChangePrivate(IDirect3DBaseTexture9*& dst, IDirect3DBaseTexture9* src) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user