Jump to content
  • Advertisement
Sign in to follow this  
jrh2365

[DX10] Partial buffer lock? Also, PIX slowness?

This topic is 2914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

1) Is it possible to lock only part of a buffer for updating? I use a somewhat large buffer for drawing sprites (using NO_OVERWRITE), and it seems inefficient to lock the entire buffer every frame.

2) I like using PIX to capture all the calls I make for every frame, so that I can check that all resources have been released by the time my game exits. However, now the file size of the data PIX collects seems to be growing really fast, and it also starts to lag really bad after only a second or two. Perhaps this is related to locking the entire buffer several times?

The file size of a 35 frame capture is 235 MB, and I'm making ~170 calls per frame.

Any thoughts why this might be happening / how to improve it?

Here are the calls I make on a typical frame:

<0x05785EE0> ID3D10Device::ClearRenderTargetView(0x057923E8, 0x001AF748)
<0x05785EE0> ID3D10Device::ClearDepthStencilView(0x05792D08, 3, 1.000f, 0)
<0x05785EE0> ID3D10Device::IASetInputLayout(0x0578B9A0)
<0x05785EE0> ID3D10Device::IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST)
<0x05785EE0> ID3D10Device::IASetVertexBuffers(0, 1, 0x009C9980 --> { 0x057877F0 }, 0x001AF3BC, 0x001AF3B0)
<0x05785EE0> ID3D10Device::VSSetShader(0x057937C0)
<0x05785EE0> ID3D10Device::GSSetShader(0x057935A0)
<0x05785EE0> ID3D10Device::GSSetConstantBuffers(0, 1, 0x009C997C --> { 0x0578BB08 })
<0x05785EE0> ID3D10Device::PSSetShader(0x05793710)
<0x0578BB08> ID3D10Buffer::Map(D3D10_MAP_WRITE_DISCARD, 0, 0x001AF3A4 --> 0x18792300)
<0x0578BB08> ID3D10Buffer::Unmap()
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009CA1F0 --> { 0x057E6620 })
<0x05785EE0> ID3D10Device::Draw(1, 6)
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009CA038 --> { 0x057E6430 })
<0x05785EE0> ID3D10Device::Draw(1, 7)
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009CA0F8 --> { 0x057E6528 })
<0x05785EE0> ID3D10Device::Draw(1, 8)
<0x05785EE0> ID3D10Device::GSSetShader(NULL)
<0x05785EE0> ID3D10Device::IASetInputLayout(0x0578B9A0)
<0x05785EE0> ID3D10Device::IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST)
<0x05785EE0> ID3D10Device::IASetVertexBuffers(0, 1, 0x009C9980 --> { 0x057877F0 }, 0x001AF510, 0x001AF504)
<0x05785EE0> ID3D10Device::VSSetShader(0x057937C0)
<0x05785EE0> ID3D10Device::GSSetShader(0x057935A0)
<0x05785EE0> ID3D10Device::GSSetConstantBuffers(0, 1, 0x009C997C --> { 0x0578BB08 })
<0x05785EE0> ID3D10Device::PSSetShader(0x05793710)
<0x0578BB08> ID3D10Buffer::Map(D3D10_MAP_WRITE_DISCARD, 0, 0x001AF4F8 --> 0x18792380)
<0x0578BB08> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::GSSetShader(NULL)
<0x05785EE0> ID3D10Device::IASetInputLayout(0x0578B9A0)
<0x05785EE0> ID3D10Device::IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST)
<0x05785EE0> ID3D10Device::IASetVertexBuffers(0, 1, 0x009C9980 --> { 0x057877F0 }, 0x001AF3F0, 0x001AF3E4)
<0x05785EE0> ID3D10Device::VSSetShader(0x057937C0)
<0x05785EE0> ID3D10Device::GSSetShader(0x057935A0)
<0x05785EE0> ID3D10Device::GSSetConstantBuffers(0, 1, 0x009C997C --> { 0x0578BB08 })
<0x05785EE0> ID3D10Device::PSSetShader(0x05793710)
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009C9F5C --> { 0x057E6338 })
<0x05785EE0> ID3D10Device::Draw(1, 9)
<0x05785EE0> ID3D10Device::GSSetShader(NULL)
<0x05785EE0> ID3D10Device::IASetInputLayout(0x0578B9A0)
<0x05785EE0> ID3D10Device::IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST)
<0x05785EE0> ID3D10Device::IASetVertexBuffers(0, 1, 0x009C9980 --> { 0x057877F0 }, 0x001AF3F0, 0x001AF3E4)
<0x05785EE0> ID3D10Device::VSSetShader(0x057937C0)
<0x05785EE0> ID3D10Device::GSSetShader(0x057935A0)
<0x05785EE0> ID3D10Device::GSSetConstantBuffers(0, 1, 0x009C997C --> { 0x0578BB08 })
<0x05785EE0> ID3D10Device::PSSetShader(0x05793710)
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009C9F5C --> { 0x057E6338 })
<0x05785EE0> ID3D10Device::Draw(1, 10)
<0x05785EE0> ID3D10Device::GSSetShader(NULL)
<0x05785EE0> ID3D10Device::OMSetBlendState(0x05781790, NULL, -1)
<0x05785EE0> ID3D10Device::IASetInputLayout(0x0578B9A0)
<0x05785EE0> ID3D10Device::IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST)
<0x05785EE0> ID3D10Device::IASetVertexBuffers(0, 1, 0x009C9980 --> { 0x057877F0 }, 0x001AF430, 0x001AF424)
<0x05785EE0> ID3D10Device::VSSetShader(0x057937C0)
<0x05785EE0> ID3D10Device::GSSetShader(0x057935A0)
<0x05785EE0> ID3D10Device::GSSetConstantBuffers(0, 1, 0x009C997C --> { 0x0578BB08 })
<0x05785EE0> ID3D10Device::PSSetShader(0x05793710)
<0x057877F0> ID3D10Buffer::Map(D3D10_MAP_WRITE_NO_OVERWRITE, 0, 0x009C9A18 --> 0x170AF000)
<0x057877F0> ID3D10Buffer::Unmap()
<0x05785EE0> ID3D10Device::PSSetShaderResources(0, 1, 0x009CA308 --> { 0x057FC908 })
<0x05785EE0> ID3D10Device::Draw(1, 11)
<0x05785EE0> ID3D10Device::GSSetShader(NULL)
<0x05785EE0> ID3D10Device::OMSetBlendState(0x057811B8, NULL, -1)
<0x05791C00> IDXGISwapChain::Present(1, 0)

Share this post


Link to post
Share on other sites
Advertisement
1) You can't lock a part of a buffer. The only thing you can do is use D3D10_MAP_WRITE_NO_OVERWRITE, which you seem to be doing already.

2) That sounds about right. PIX has to capture a ton of state, and for complex frames it gets even worse.

Share this post


Link to post
Share on other sites
DirectX (without pix) can already tell you what resources are not released if you use the debug device and run your app in a debugger. At app exist the SDKLayers will print a table of unreleased objects if any have yet to be freed. -- PIX uses the same mechanism to get this data.

Calling map no overwrite should be nearly free, with no penalty for calling it many times a frame. Dynamic resources are backed by a CPU side copy and since you're making the guarantee of not changing data already added to the buffer, then there's really no work that needs to be done by DirectX or the driver. It just gives you the data pointer.

Share this post


Link to post
Share on other sites
@MJP:
Ok, thank you. Though my frame isn't even very complex, and it pauses for 1 - 1.5 seconds at a time, and then works for less than 0.5 seconds, before it pauses again, etc, starting about 1 second after the first frame is rendered. =/

@DieterVW
I believe I am using the debug layer and running in the debugger, but I don't get any output related to unreleased resources when there are resources that have not been released. Could this be because I am using DX10.1, which also has a different tab in the control panel? I have forced the debug layer on and added my executable to the scope list. The only debug I receive is:

D3D10: INFO: ID3D10Device:: ... The currently bound ... is being deleted; so naturally, will no longer be bound [STATE_SETTING INFO #...]


The way I draw my sprites is:
-Lock the buffer
-Load in all the sprites that use the same texture
-Unlock the buffer
-Draw all those sprites in 1 draw call (or 2 if I have reached the end of the buffer, and some sprites have wrapped around to the beginning)
-Repeat for all the different textures.

Does this seem like a decent method to you? Do you know of a better way? You say that using NO_OVERWRITE should make mapping almost free, so I probably wouldn't gain much from loading all my sprites into the buffer at once, right, and then making all the draw calls after that?

This is how I'm using the buffer, where the numbers inside are which frame the vertex was used for:
Frame 1: {111........}
Frame 2: {111222.....}
Frame 3: {111222333..}
Frame 4: {41122233344}
Frame 5: {45552233344}
Frame 6: {45556663344}

Thank you.

Share this post


Link to post
Share on other sites
Quote:
Original post by DieterVW
DirectX (without pix) can already tell you what resources are not released if you use the debug device and run your app in a debugger. At app exist the SDKLayers will print a table of unreleased objects if any have yet to be freed. -- PIX uses the same mechanism to get this data.


That’s true for DX 9 and 11. 10 don’t report reference leaks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!