mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 01:54:16 +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) {
|
||||
if (ptr == nullptr)
|
||||
return nullptr;
|
||||
|
||||
D3DRESOURCETYPE type = ptr->GetType();
|
||||
if (type == D3DRTYPE_TEXTURE)
|
||||
return static_cast<D3D9Texture2D*> (ptr)->GetCommonTexture();
|
||||
else if (type == D3DRTYPE_CUBETEXTURE)
|
||||
return static_cast<D3D9TextureCube*>(ptr)->GetCommonTexture();
|
||||
else //if(type == D3DRTYPE_VOLUMETEXTURE)
|
||||
return static_cast<D3D9Texture3D*> (ptr)->GetCommonTexture();
|
||||
// We can avoid needing to get the type as m_texture has the same offset
|
||||
// no matter the texture type.
|
||||
// The compiler is not smart enough to eliminate the call to GetType as it is
|
||||
// not marked const.
|
||||
return static_cast<D3D9TextureGeneric*>(ptr)->GetCommonTexture();
|
||||
}
|
||||
|
||||
inline D3D9CommonTexture* GetCommonTexture(D3D9Surface* ptr) {
|
||||
@ -224,13 +228,11 @@ namespace dxvk {
|
||||
if (tex == nullptr)
|
||||
return;
|
||||
|
||||
D3DRESOURCETYPE type = tex->GetType();
|
||||
if (type == D3DRTYPE_TEXTURE)
|
||||
return CastRefPrivate<D3D9Texture2D> (tex, AddRef);
|
||||
else if (type == D3DRTYPE_CUBETEXTURE)
|
||||
return CastRefPrivate<D3D9TextureCube>(tex, AddRef);
|
||||
else //if(type == D3DRTYPE_VOLUMETEXTURE)
|
||||
return CastRefPrivate<D3D9Texture3D> (tex, AddRef);
|
||||
// We can avoid needing to get the type as m_refCount has the same offset
|
||||
// no matter the texture type.
|
||||
// The compiler is not smart enough to eliminate the call to GetType as it is
|
||||
// not marked const.
|
||||
return CastRefPrivate<D3D9TextureGeneric>(tex, AddRef);
|
||||
}
|
||||
|
||||
inline void TextureChangePrivate(IDirect3DBaseTexture9*& dst, IDirect3DBaseTexture9* src) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user