mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d9] Optimize GetCommonTexture
This commit is contained in:
parent
85468a5526
commit
3f78bde928
@ -196,17 +196,21 @@ namespace dxvk {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using D3D9TextureGeneric = D3D9BaseTexture<D3D9Surface, IDirect3DBaseTexture9>;
|
||||||
|
|
||||||
|
static_assert(sizeof(D3D9Texture2D) == sizeof(D3D9Texture3D) &&
|
||||||
|
sizeof(D3D9Texture2D) == sizeof(D3D9TextureCube) &&
|
||||||
|
sizeof(D3D9Texture2D) == sizeof(D3D9TextureGeneric));
|
||||||
|
|
||||||
inline D3D9CommonTexture* GetCommonTexture(IDirect3DBaseTexture9* ptr) {
|
inline D3D9CommonTexture* GetCommonTexture(IDirect3DBaseTexture9* ptr) {
|
||||||
if (ptr == nullptr)
|
if (ptr == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
D3DRESOURCETYPE type = ptr->GetType();
|
// We can avoid needing to get the type as m_texture has the same offset
|
||||||
if (type == D3DRTYPE_TEXTURE)
|
// no matter the texture type.
|
||||||
return static_cast<D3D9Texture2D*> (ptr)->GetCommonTexture();
|
// The compiler is not smart enough to eliminate the call to GetType as it is
|
||||||
else if (type == D3DRTYPE_CUBETEXTURE)
|
// not marked const.
|
||||||
return static_cast<D3D9TextureCube*>(ptr)->GetCommonTexture();
|
return static_cast<D3D9TextureGeneric*>(ptr)->GetCommonTexture();
|
||||||
else //if(type == D3DRTYPE_VOLUMETEXTURE)
|
|
||||||
return static_cast<D3D9Texture3D*> (ptr)->GetCommonTexture();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline D3D9CommonTexture* GetCommonTexture(D3D9Surface* ptr) {
|
inline D3D9CommonTexture* GetCommonTexture(D3D9Surface* ptr) {
|
||||||
@ -224,13 +228,11 @@ namespace dxvk {
|
|||||||
if (tex == nullptr)
|
if (tex == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
D3DRESOURCETYPE type = tex->GetType();
|
// We can avoid needing to get the type as m_refCount has the same offset
|
||||||
if (type == D3DRTYPE_TEXTURE)
|
// no matter the texture type.
|
||||||
return CastRefPrivate<D3D9Texture2D> (tex, AddRef);
|
// The compiler is not smart enough to eliminate the call to GetType as it is
|
||||||
else if (type == D3DRTYPE_CUBETEXTURE)
|
// not marked const.
|
||||||
return CastRefPrivate<D3D9TextureCube>(tex, AddRef);
|
return CastRefPrivate<D3D9TextureGeneric>(tex, AddRef);
|
||||||
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