void GFXD3D11TextureTarget::activate() { GFXDEBUGEVENT_SCOPE( GFXPCD3D11TextureTarget_activate, ColorI::RED ); AssertFatal( mTargets[GFXTextureTarget::Color0], "GFXD3D11TextureTarget::activate() - You can never have a NULL primary render target!" ); // Clear the state indicator. stateApplied(); // Now set all the new surfaces into the appropriate slots. ID3D11RenderTargetView* rtViews[MaxRenderSlotId] = { NULL, NULL, NULL, NULL, NULL, NULL}; ID3D11DepthStencilView* dsView = (ID3D11DepthStencilView*)(mTargetViews[GFXTextureTarget::DepthStencil]); for (U32 i = 0; i < 4; i++) { rtViews[i] = (ID3D11RenderTargetView*)mTargetViews[GFXTextureTarget::Color0 + i]; } D3D11DEVICECONTEXT->OMSetRenderTargets(MaxRenderSlotId, rtViews, dsView); }
void GFXPCD3D9TextureTarget::activate() { GFXDEBUGEVENT_SCOPE( GFXPCD3D9TextureTarget_activate, ColorI::RED ); AssertFatal( mTargets[GFXTextureTarget::Color0], "GFXPCD3D9TextureTarget::activate() - You can never have a NULL primary render target!" ); const U32 NumRenderTargets = getMin( mDevice->getNumRenderTargets(), (U32)Color4 - Color0 ); LPDIRECT3DDEVICE9 d3dDevice = mDevice->getDevice(); // Clear the state indicator. stateApplied(); IDirect3DSurface9 *depth = mTargets[GFXTextureTarget::DepthStencil]; // In debug lets do a complete test to be sure we don't // have a bad depth format for this display mode. #ifdef TORQUE_DEBUG if ( depth && mTargets[GFXTextureTarget::Color0] ) { D3DSURFACE_DESC desc; D3D9Assert( mTargets[GFXTextureTarget::Color0]->GetDesc( &desc ), "GFXPCD3D9TextureTarget::activate() - Failed to get surface description!"); D3DFORMAT renderFormat = desc.Format; D3D9Assert( depth->GetDesc( &desc ), "GFXPCD3D9TextureTarget::activate() - Failed to get surface description!"); D3DFORMAT depthFormat = desc.Format; HRESULT hr = mDevice->getD3D()->CheckDepthStencilMatch( mDevice->getAdaterIndex(), D3DDEVTYPE_HAL, mDevice->mDisplayMode.Format, renderFormat, depthFormat ); D3D9Assert( hr, "GFXPCD3D9TextureTarget::activate() - Bad depth format for this target!" ); } #endif // First clear the non-primary targets to make the debug DX runtime happy. for(U32 i = 1; i < NumRenderTargets; i++) D3D9Assert(d3dDevice->SetRenderTarget( i, NULL ), avar("GFXPCD3D9TextureTarget::activate() - failed to clear texture target %d!", i) ); // Now set all the new surfaces into the appropriate slots. for(U32 i = 0; i < NumRenderTargets; i++) { IDirect3DSurface9 *target = mTargets[GFXTextureTarget::Color0 + i]; if ( target ) { D3D9Assert(d3dDevice->SetRenderTarget(i, target), avar("GFXPCD3D9TextureTarget::activate() - failed to set slot %d for texture target!", i) ); } } // TODO: This is often the same shared depth buffer used by most // render targets. Are we getting performance hit from setting it // multiple times... aside from the function call? D3D9Assert(d3dDevice->SetDepthStencilSurface( depth ), "GFXPCD3D9TextureTarget::activate() - failed to set depthstencil target!" ); }