PDA

View Full Version : Rendertarget not working in low resolution! [SOLVED]



NecroDOME
12-08-2007, 02:08 AM
System: Windows XP, nVidia 6800 SLI
Compiler/IDE: Turbo Delphi
API: DirectX 9

Hi all,

Im rendering onto a render target texture, but nothing happens when the resolution of my screen is lower that the resolution of my render target.

For example: My render target is 512x512 and my screen resolution is 800x600 everything is fine. When I set my screen resolution to anything below 512x512 the render target does not get updated!

The rest of the scene what is NOT rendered to a render target is renderd correctly!

This is how I create my render target:

if Succeeded( Device.Screen.device.CreateTexture(FParam.Width, FParam.Height, FParam.MipMapCount,
D3DUSAGE_RENDERTARGET,
Necro3DFMTToD3DFMT(FParam.Format),
D3DPOOL_DEFAULT,
Texture,
nil) ) then
begin
Loaded := true;
end else
Loaded := false;


The begin-scene code: (the beginning when I try to render to my render target):

if Texture<>nil then
begin
FRenderTargetIndex &#58;= Index;
Device &#58;= TNecro3D_Device9&#40; GetDevice &#41;;

Device.Screen.Device.GetRenderTarget&#40;Index, FOldRenderTarget&#41;;
Texture.GetSurfaceLevel&#40;0, FRenderTarget&#41;;
Device.Screen.Device.SetRenderTarget&#40;Index, FRenderTarget&#41;;
Device.Screen.Device.BeginScene;
FCanRender &#58;= true;
end;

Comment: FCanRender is always true just for testing...

And this is called whenever I finish rendering to my render target:

if FCanRender then
begin
Device &#58;= TNecro3D_Device9&#40; GetDevice &#41;;
Device.Screen.Device.EndScene;

Device.Screen.Device.SetRenderTarget&#40;FRenderTarget Index, FOldRenderTarget&#41;;
FOldRenderTarget &#58;= nil;
FRenderTarget &#58;= nil;
end;

LP
12-08-2007, 03:10 AM
Are you updating the viewport (IDirect3DDevice9.SetViewport) when rendering to render target? If not, you should do so.

Also, is nothing rendered to your render target or do you get garbage pixels? Any suspicious output from debug runtime?

NecroDOME
12-08-2007, 12:13 PM
Garbage pixels yeah.

I also don't set the view port. So I will take a look at that.

NecroDOME
12-08-2007, 01:16 PM
Well, it seems to be a problem with the Z-buffer.


Debug Output: Direct3D9: (ERROR) :DepthStencil Buffer must be at least as big as the RenderTarget. Process Sandbox.exe (3160)

Also I don't need to call Device.BeginScene() and Device.EndScene().

When I maximize the screen everything is OK.
When I restore it to its normal size, I get this error.

NecroDOME
12-08-2007, 01:44 PM
Ok, I fixed it. I just created a new depth surface for my render target.

Edit: I just tested it without the viewport and it works fine. So, viewport is not needed. Thanks anyway!!