Jump to content
  • Advertisement
Sign in to follow this  
yoelshoshan

Commands Recording

This topic is 1673 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 all,

I need to serialize DX9 commands to file.

 

It generally works quite well, but I encountered a case which I don't really understand,

and would really appreciate your help.

 

In a certain game (not mine, a commercial game), there is a LockRect() called on a surface.

The surface details are:

Format	D3DFMT_A8R8G8B8 (21)	_D3DFORMAT
Type	D3DRTYPE_SURFACE (1)	_D3DRESOURCETYPE
Usage	1	unsigned long
Pool	D3DPOOL_DEFAULT (0)	_D3DPOOL
MultiSampleType	D3DMULTISAMPLE_NONE (0)	_D3DMULTISAMPLE_TYPE
MultiSampleQuality	0	unsigned long
Width	1280	unsigned int
Height	720	unsigned int

However, when the LockRect() function returns, the returned pitch is 1024.
This kinda destroys all I understood about pitch :/

I thought that the pitch should be at least width * pixel_size, which in this case is (1280 * 4) = .5120, which is much higher than 1024 ...

Note:
1. As you can see, this is not a compressed format.
2. The lock flag contain only D3DLOCK_NOSYSLOCK.
Which AFAIK, apart from describing not doing a sys-lock, also means it's both read+write,
since there's no other flag.
3. The "RECT* pRect" argument in LockRect() is NULL.

Can you help me understand what is going on?

Thanks,
Yoel.

Edited by yoelshoshan

Share this post


Link to post
Share on other sites
Advertisement

Those are very strange results indeed!

 

However, note that usage is 1 (AKA D3DUSAGE_RENDERTARGET) and the pool is D3DPOOL_DEFAULT. It's not valid to call LockRect on such a surface! What's the returned HRESULT value? It should be D3DERR_INVALIDCALL.

 

This game should be using GetRenderTargetData instead of LockRect...

Share this post


Link to post
Share on other sites

Sorry, I forgot to mention, the ret value is S_OK.

 

When I switch to Directx debug runtime, it doesn't happen anymore, which leaves me even more puzzled.

 

When I use the DirectX release RT, the call stack is:

 

Recorder.dll!IDirect3DSurface9_Recorder::LockRect(_D3DLOCKED_RECT * pLockedRect, const tagRECT * pRect, unsigned long Flags) Line 495	C++
D3DX9_43.dll!D3DXTex::CLockSurface::Lock(struct D3DX_BLT *,struct IDirect3DSurface9 *,struct tagPALETTEENTRY const *,struct tagRECT const *,unsigned long,unsigned long)	Unknown
 D3DX9_43.dll!_D3DXLoadSurfaceFromMemory@40()	Unknown
 D3DX9_43.dll!_D3DXLoadVolumeFromResourceW@36()	Unknown
 D3DX9_43.dll!_D3DXCreateTextureFromFileInMemoryEx@60()	Unknown
...

Share this post


Link to post
Share on other sites

I believe that this is allowed with D3DPRESENTFLAG_LOCKABLE_BACKBUFFER, so maybe you've got that at device creation time?  If so, S_OK is expected, but still doesn't explain the weird pitch value.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!