Make CD3D9RenderTarget::setTexture code more similar to COpenGLCoreRenderTarget::setTexture.

Add log warnings when users try to set depth/stencil textures which have no depth color format.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5845 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2019-08-15 20:18:45 +00:00
parent 8a33852395
commit 3469582bac
2 changed files with 107 additions and 101 deletions

View File

@ -51,15 +51,12 @@ namespace irr
void CD3D9RenderTarget::setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces) void CD3D9RenderTarget::setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces)
{ {
bool textureUpdate = (Texture != texture) || (CubeSurfaces != cubeSurfaces) ? true : false; bool needSizeUpdate = false;
bool depthStencilUpdate = (DepthStencil != depthStencil) ? true : false;
if (textureUpdate || depthStencilUpdate)
{
// Set color attachments. // Set color attachments.
if ((Texture != texture) || (CubeSurfaces != cubeSurfaces))
if (textureUpdate)
{ {
needSizeUpdate = true;
CubeSurfaces = cubeSurfaces; CubeSurfaces = cubeSurfaces;
if (texture.size() > Driver->ActiveRenderTarget.size()) if (texture.size() > Driver->ActiveRenderTarget.size())
@ -136,7 +133,7 @@ namespace irr
// Set depth and stencil attachments. // Set depth and stencil attachments.
if (depthStencilUpdate) if (DepthStencil != depthStencil)
{ {
if (DepthStencilSurface) if (DepthStencilSurface)
{ {
@ -152,22 +149,17 @@ namespace irr
DepthStencilSurface = 0; DepthStencilSurface = 0;
} }
needSizeUpdate = true;
CD3D9Texture* currentTexture = (depthStencil && depthStencil->getDriverType() == DriverType) ? static_cast<CD3D9Texture*>(depthStencil) : 0; CD3D9Texture* currentTexture = (depthStencil && depthStencil->getDriverType() == DriverType) ? static_cast<CD3D9Texture*>(depthStencil) : 0;
IDirect3DTexture9* textureID = 0;
if (currentTexture) if (currentTexture)
{ {
if (currentTexture->getType() == ETT_2D) if (currentTexture->getType() == ETT_2D)
textureID = currentTexture->getDX9Texture(); {
else IDirect3DTexture9* textureID = currentTexture->getDX9Texture();
os::Printer::log("This driver doesn't support depth/stencil to cubemaps.", ELL_WARNING);
}
if (textureID) if (textureID)
{ {
const ECOLOR_FORMAT textureFormat = (depthStencil) ? depthStencil->getColorFormat() : ECF_UNKNOWN; const ECOLOR_FORMAT textureFormat = depthStencil->getColorFormat();
if (IImage::isDepthFormat(textureFormat)) if (IImage::isDepthFormat(textureFormat))
{ {
DepthStencil = depthStencil; DepthStencil = depthStencil;
@ -178,9 +170,19 @@ namespace irr
DepthStencilSurface = currentSurface; DepthStencilSurface = currentSurface;
} }
else
{
os::Printer::log("Ignoring depth/stencil texture without depth color format.", ELL_WARNING);
}
}
}
else
os::Printer::log("This driver doesn't support depth/stencil to cubemaps.", ELL_WARNING);
} }
} }
if (needSizeUpdate)
{
// Set size required for a viewport. // Set size required for a viewport.
bool sizeDetected = false; bool sizeDetected = false;

View File

@ -134,6 +134,10 @@ public:
DepthStencil = depthStencil; DepthStencil = depthStencil;
DepthStencil->grab(); DepthStencil->grab();
} }
else
{
os::Printer::log("Ignoring depth/stencil texture without depth color format.", ELL_WARNING);
}
} }
else else
{ {