Vertex texture sampling support in Direct3D 9 now controlled via texture-flag ETCF_SUPPORT_VERTEXT_TEXTURE

It's no longer enabled by default as it causes some costs to all texture switches.
Thanks @ edo9300 for reporting (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=52721)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6219 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2021-06-04 12:17:01 +00:00
parent ca48a1ac69
commit 224d7c5e2c
5 changed files with 31 additions and 12 deletions

View File

@ -698,12 +698,6 @@ bool CD3D9Driver::setActiveTexture(u32 stage, const video::ITexture* texture)
if (CurrentTexture[stage] == texture)
return true;
if (texture && texture->getDriverType() != EDT_DIRECT3D9)
{
os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR);
return false;
}
CurrentTexture[stage] = texture;
if (!texture)
@ -711,13 +705,20 @@ bool CD3D9Driver::setActiveTexture(u32 stage, const video::ITexture* texture)
pID3DDevice->SetTexture(stage, 0);
pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
}
else
else if (texture->getDriverType() == EDT_DIRECT3D9)
{
pID3DDevice->SetTexture(stage, ((const CD3D9Texture*)texture)->getDX9BaseTexture());
if (stage <= 4)
if (((const CD3D9Texture*)texture)->HasVertexTextureSupport() && stage < 4 )
pID3DDevice->SetTexture(D3DVERTEXTEXTURESAMPLER0 + stage, ((const CD3D9Texture*)texture)->getDX9BaseTexture());
}
else
{
os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR);
setActiveTexture(stage, 0);
return false;
}
return true;
}

View File

@ -38,17 +38,19 @@ CD3D9Texture::CD3D9Texture(const io::path& name, const core::array<IImage*>& ima
DWORD flags = 0;
LPDIRECT3D9 intf = Driver->getExposedVideoData().D3D9.D3D9;
D3DDISPLAYMODE d3ddm;
intf->GetAdapterDisplayMode(Driver->Params.DisplayAdapter, &d3ddm);
if (HasMipMaps && HardwareMipMaps)
{
LPDIRECT3D9 intf = Driver->getExposedVideoData().D3D9.D3D9;
D3DDISPLAYMODE d3ddm;
intf->GetAdapterDisplayMode(Driver->Params.DisplayAdapter, &d3ddm);
if (D3D_OK == intf->CheckDeviceFormat(Driver->Params.DisplayAdapter, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, InternalFormat))
flags = D3DUSAGE_AUTOGENMIPMAP;
else
HardwareMipMaps = false;
}
VertexTextureSupport = Driver->getTextureCreationFlag(ETCF_SUPPORT_VERTEXT_TEXTURE)
&& (D3D_OK == intf->CheckDeviceFormat(Driver->Params.DisplayAdapter, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, InternalFormat));
HRESULT hr = 0;

View File

@ -42,6 +42,11 @@ public:
IDirect3DTexture9* getDX9Texture() const;
IDirect3DCubeTexture9* getDX9CubeTexture() const;
inline bool HasVertexTextureSupport() const
{
return VertexTextureSupport;
}
private:
friend class CD3D9Driver;
@ -77,6 +82,7 @@ private:
u32 MipLevelLocked;
bool HardwareMipMaps;
bool VertexTextureSupport;
IDirect3DDevice9* Device;
IDirect3DTexture9* Texture;