• Create Account

## Commands Recording

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1yoelshoshan  Members

235
Like
0Likes
Like

Posted 20 May 2014 - 12:55 AM

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, 20 May 2014 - 12:57 AM.

### #2Hodgman  Moderators

49429
Like
2Likes
Like

Posted 20 May 2014 - 01:04 AM

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...

### #3yoelshoshan  Members

235
Like
0Likes
Like

Posted 20 May 2014 - 01:28 AM

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!_D3DXCreateTextureFromFileInMemoryEx@60()	Unknown
...



### #4mhagain  Members

12440
Like
0Likes
Like

Posted 20 May 2014 - 03:26 AM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #5yoelshoshan  Members

235
Like
0Likes
Like

Posted 20 May 2014 - 04:58 AM

Thanks!
D3DPRESENTFLAG_LOCKABLE_BACKBUFFER is not used at the device creation.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.