Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rendered object not becoming visible until mouse-press

Started by collie Oct 15, 2016 at 1:32 PM 0 replies 1.8k views
Original Post
collie
collie

Hello,

I am trying to speed up a D3D11 graphics engine I am working on by limiting the amount of DrawIndexedInstanced() calls.
My newly modified code only does a DrawIndexedInstanced() when A) a buffer is filled up B) an object has changed or C) there are no more objects to render.

The pseudo code would be like this...

{
loop (objects)
{
if (new-object OR buffer-filled)
{
// A
IASetInputLayout()

IASetVertexBuffers()
DrawIndexedInstanced()

hresult = Map (D3D11_MAP_WRITE_DISCARD)
}
else
{
// B
hresult = Map (D3D11_MAP_WRITE_NO_OVERWRITE)
}

memcpy buffer
UnMap
}

// no more objects
IASetInputLayout()

IASetVertexBuffers()
DrawIndexedInstanced()
}


I am currently rendering two different sized objects into a small window.
Everything appears to be rendering correctly if I capture a frame via the Graphics debugger; I see both objects.
The problem is that only one object is actually being displayed within the small window...that is *until* I use the mouse to press the windows title bar (or press prtscr).

When I do the second object appears (rendered correctly). When I release the mouse the second object disappears again.

It appears that when you grab the caption the DX application is paused until the mouse is released. If both objects share the same buffer could this be causing an issue; where the pause allows more time for it to be processed? Has anyone got any ideas whats happening?

Thank you

collie
collie

If anyone is interested the error appeared to arise from the order I was calling the different Map's.

Previously it was calling the Maps in the order of...

D3D11_MAP_WRITE_NO_OVERWRITE <- Obj 1

D3D11_MAP_WRITE_DISCARD <- Obj 2

Simply switching them around allowed both objects to render correctly.

I'm still unsure why pressing the mouse or prtscr allowed the rendering to be correct; but at least it works now.

Thank you.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.