PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

how to render into the frontbuffer using Direct3D Mobile?

Hi!

I made some trials with my Axim x51v and D3DM, the result is a very low framerate because the method 'Present' seems to be too slow (I tried all SwapEffects). How can I render directly to the frontbuffer? if not (or this is not the correct question)... How can I speed up the 'Present' method?

Thanks and regards
How are you timing the Present call?

Realize that D3DM buffers all of your rendering commands until it absolutely must send them to the driver. For most games, this will be when the app calls Present. For this reason, if you are simply recording the elapsed time of Present, you are also measuring the time it takes the driver to parse and execute everything already in the command buffer since the last flush of commands to the driver.

If you want to measure the speed of the Present call alone, then you can force a flush of the command buffer by adding a call to lock/unlock the back buffer just prior to starting your timing of Present.

The Present operation from the back buffer to the front buffer should be performed in hardware on the 2700G, so that shouldn't be a bottleneck in your app.

For most games, optimum performance will occur when running fullscreen, with the swapeffect set to discard, and the presentation interval set to immediate (this could cause tearing though).

If you're running in a window, make sure that your back buffer is the same size as the window's client rect and that the pixel format is the same as the primary surface. You don't want the driver to do any sort of conversion (stretch/shink/color) during each Present.
Digby wrote:if you are simply recording the elapsed time of Present, you are also measuring the time it takes the driver to parse and execute everything already in the command buffer since the last flush of commands to the driver.


That's exactly as I was thinking.. some time ago I posted here my experience with OpenGL and finally the results seem to be the same using DirectDraw. It's something frustrating: I tried to do a program that fills a 240x320 box using direct access to the framebuffer for the Ipaq 2750 and it gets 270fps, but the same program running on the Axim using DirectDraw or framebuffer never gets more that 90/120fps, the result is worst using Direct3DM or OpenGL with 30/40fps... obviously I don't need more than 60fps but translating those routines to my program, the Ipaq 2750 gets 60ftps and a smoothly execution but the Axim does not get more that 24/30fps :cry: so, the video is the bottleneck for the Axim.

Digby wrote:
For most games, optimum performance will occur when running fullscreen, with the swapeffect set to discard, and the presentation interval set to immediate (this could cause tearing though).


I tried ALL, and the Axim can't enter in fullscreen. I only can work in window mode, I'm passing this initialization:

Code:

d3dmpp.Windowed = TRUE;
d3dmpp.SwapEffect = D3DMSWAPEFFECT_DISCARD;
d3dmpp.BackBufferFormat = D3DMFMT_R5G6B5;
d3dmpp.EnableAutoDepthStencil = FALSE;
d3dmpp.AutoDepthStencilFormat = D3DMFMT_D16;
d3dmpp.FullScreen_PresentationInterval = D3DMPRESENT_INTERVAL_IMMEDIATE;

g_pD3DM->CreateDevice( uAdapter, D3DMDEVTYPE_DEFAULT, hWnd, 0, &d3dmpp;, &g;_pd3dmDevice );

g_pd3dmDevice->SetRenderState( D3DMRS_CULLMODE, D3DMCULL_NONE );
g_pd3dmDevice->SetRenderState( D3DMRS_LIGHTING, FALSE);
g_pd3dmDevice->SetRenderState( D3DMRS_ZENABLE, FALSE );


Thanks a lot for your answer Digby

Regards
I'm rather puzzled why you're having trouble getting the Axim device to run in fullscreen mode using D3DM. If CreateDevice is failing when you attempt this, what is the returned HRESULT?

I don't have an Axim X51v here, but on an 300mhz iPaq (QVGA), the D3DM reference driver (which is horribly slow at most anything it does) can perform a fullscreen present in ~3 msecs.
Digby wrote:I'm rather puzzled why you're having trouble getting the Axim device to run in fullscreen mode using D3DM. If CreateDevice is failing when you attempt this, what is the returned HRESULT?


CreateDevice returns D3DMERR_INVALIDCALL :cry:

I tried using an example included in the SDK (Tut06_fixedpoint) with the same result.

regards
Jam this bit of code in your app and let me know if you still see the problem:

Code:

hr = pD3DM->GetAdapterDisplayMode(D3DMADAPTER_DEFAULT, &dm;);
assert(SUCCEEDED(hr));

pp.BackBufferWidth = dm.Width;
pp.BackBufferHeight = dm.Height;
pp.BackBufferFormat = dm.Format;
pp.BackBufferCount = 1;
pp.MultiSampleType = D3DMMULTISAMPLE_NONE;
pp.SwapEffect = D3DMSWAPEFFECT_DISCARD;
pp.Windowed = FALSE;
pp.EnableAutoDepthStencil = FALSE;
pp.AutoDepthStencilFormat = D3DMFMT_UNKNOWN;
pp.Flags = 0;
pp.FullScreen_PresentationInterval = D3DMPRESENT_INTERVAL_DEFAULT;

// create the d3dm device
hr = pD3DM->CreateDevice(
D3DMADAPTER_DEFAULT,
D3DMDEVTYPE_DEFAULT,
hWnd,
0,
&pp;,
&pD3DMDev; );
assert(SUCCEEDED(hr));

Digby wrote:Jam this bit of code in your app and let me know if you still see the problem


Thanks! it worked to enter in full screen mode, but the speed issue continues, it is not faster.

To change 'D3DMSWAPEFFECT_DISCARD' by 'D3DMSWAPEFFECT_FLIP' and 'D3DMPRESENT_INTERVAL_DEFAULT' by 'D3DMPRESENT_INTERVAL_IMMEDIATE' speeds up from 32fps to 40fps, but it's the best result than I can get :cry:

In any case, thank you very much Digby.

Regards
I managed to get my hands on an X50v and ran a test and am seeing similar performance problems with D3DM's Present API on this device.

However, if I write a DDraw app that creates a fullscreen flipping chain, the frame rate is in the thousands per second.

From what you've said regarding the poor performance when locking and writing to a DDraw primary surface directly, it looks suspiciously like the Intel D3DM driver is not using the 2700G to perform a hardware page flip when running fullscreen and instead is using the XScale CPU to do some sort of software blit to the primary surface.