Commands Recording

Started by
3 comments, last by yoelshoshan 9 years, 11 months ago

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.

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

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

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thanks!
D3DPRESENTFLAG_LOCKABLE_BACKBUFFER is not used at the device creation.

This topic is closed to new replies.

Advertisement