//--------------------------------------------------------------------- bool D3D11DepthBuffer::isCompatible( RenderTarget *renderTarget ) const { //TODO: //Urgh! This bit of "isTexture" is a bit ugly and potentially unsafe bool isTexture = true; renderTarget->getCustomAttribute( "isTexture", &isTexture ); ID3D11Texture2D *D3D11texture; if( isTexture ) { D3D11HardwarePixelBuffer *pBuffer; renderTarget->getCustomAttribute( "BUFFER", &pBuffer ); D3D11texture = static_cast<ID3D11Texture2D*>( pBuffer->getParentTexture()->getTextureResource() ); } else { renderTarget->getCustomAttribute( "ID3D11Texture2D", &D3D11texture ); } D3D11_TEXTURE2D_DESC BBDesc; D3D11texture->GetDesc( &BBDesc ); //TODO: Needs to check format too! if( mFsaa == BBDesc.SampleDesc.Count && mMultiSampleQuality == BBDesc.SampleDesc.Quality && this->getWidth() == renderTarget->getWidth() && this->getHeight() == renderTarget->getHeight() ) { return true; } return false; }
//--------------------------------------------------------------------- bool D3D11DepthBuffer::isCompatible( RenderTarget *renderTarget ) const { D3D11_TEXTURE2D_DESC BBDesc; bool isTexture = false; renderTarget->getCustomAttribute( "isTexture", &isTexture ); if(isTexture) { ID3D11Texture2D *D3D11texture; D3D11HardwarePixelBuffer *pBuffer; renderTarget->getCustomAttribute( "BUFFER", &pBuffer ); D3D11texture = static_cast<ID3D11Texture2D*>( pBuffer->getParentTexture()->getTextureResource() ); D3D11texture->GetDesc(&BBDesc); } else { ID3D11Texture2D* pBack[OGRE_MAX_MULTIPLE_RENDER_TARGETS]; memset( pBack, 0, sizeof(pBack) ); renderTarget->getCustomAttribute( "DDBACKBUFFER", &pBack ); if( pBack[0] ) { pBack[0]->GetDesc(&BBDesc); } else { ID3D11Texture2D *D3D11texture; renderTarget->getCustomAttribute( "ID3D11Texture2D", &D3D11texture ); D3D11texture->GetDesc( &BBDesc ); } } /* ID3D11Texture2D *D3D11texture = NULL; renderTarget->getCustomAttribute( "ID3D11Texture2D", &D3D11texture ); D3D11_TEXTURE2D_DESC BBDesc; D3D11texture->GetDesc( &BBDesc ); */ //RenderSystem will determine if bitdepths match (i.e. 32 bit RT don't like 16 bit Depth) //This is the same function used to create them. Note results are usually cached so this should //be quick //TODO: Needs to check format too! if( mFsaa == BBDesc.SampleDesc.Count && mMultiSampleQuality == BBDesc.SampleDesc.Quality && this->getWidth() == renderTarget->getWidth() && this->getHeight() == renderTarget->getHeight() ) { return true; } return false; }
//--------------------------------------------------------------------- void D3D11MultiRenderTarget::bindSurfaceImpl(size_t attachment, RenderTexture *target) { assert(attachment<OGRE_MAX_MULTIPLE_RENDER_TARGETS); /// Get buffer and surface to bind to D3D11HardwarePixelBuffer *buffer = 0; target->getCustomAttribute("BUFFER", &buffer); assert(buffer); /// Find first non-null target int y; for(y=0; y<OGRE_MAX_MULTIPLE_RENDER_TARGETS && !targets[y]; ++y) ; if(y!=OGRE_MAX_MULTIPLE_RENDER_TARGETS) { /// If there is another target bound, compare sizes if(targets[y]->getWidth() != buffer->getWidth() || targets[y]->getHeight() != buffer->getHeight() || PixelUtil::getNumElemBits(targets[y]->getFormat()) != PixelUtil::getNumElemBits(buffer->getFormat())) { OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "MultiRenderTarget surfaces are not of same size or bit depth", "D3D11MultiRenderTarget::bindSurface" ); } } targets[attachment] = buffer; mRenderTargets[attachment] = target; ID3D11RenderTargetView** v; target->getCustomAttribute( "ID3D11RenderTargetView", &v ); mRenderTargetViews[attachment] = *v; if(mNumberOfViews >= OGRE_MAX_MULTIPLE_RENDER_TARGETS) mNumberOfViews++; checkAndUpdate(); }