简体   繁体   English

DirectDraw游戏可以在不锁定的情况下访问后备缓冲区吗?

[英]Can DirectDraw game access a backbuffer without locking it?

I'm modding an old Windows DirectDraw game. 我正在修改一个旧的Windows DirectDraw游戏。 I've created a DirectDraw proxy. 我已经创建了一个DirectDraw代理。 It logs every IDirectDraw and IDirectDrawSurface call. 它记录每个IDirectDraw和IDirectDrawSurface调用。 The backbuffer looks like this after one BltFast call: 一次BltFast调用 ,backbuffer看起来像这样:

在此输入图像描述

And like this before the next BltFast call: 在下一次BltFast调用之前就像这样:

在此输入图像描述

These pictures are dumped by Lock ing-copying- Unlock ing the backbuffer before and after any BltFast call. 这些图片通过Lock复制转储 - 在任何BltFast呼叫之前和之后Unlock后备缓冲区。 There are no other IDirectDraw(Surface) calls between these two BltFast calls, especially no Lock / Unlock calls. 这两个BltFast调用之间没有其他IDirectDraw(Surface)调用,尤其是没有Lock / Unlock调用。 How is this possible? 这怎么可能?

As far as I can tell, it looks like the game might be drawing in multiple stages, and you are catching it in-between. 据我所知,看起来游戏可能会在多个阶段进行绘制,而你正在中间捕捉它。 IE, the game calls blit once to render its background, then again (possibly multiple times) to render interactive 'sprites'. IE,游戏调用blit一次渲染其背景,然后再次(可能多次)渲染交互式“精灵”。 (However, the order could well be reversed, meaning that the second frame you capture is actually the first layer of the next loop.) (但是,顺序很可能会被颠倒,这意味着您捕获的第二帧实际上是下一个循环的第一层。)

As far as the backbufer goes, I was able to find this in MSDNs documentation for DirectDraw: https://msdn.microsoft.com/en-us/library/windows/desktop/gg426183(v=vs.85).aspx 对于backbufer来说,我能够在DirectDraw的MSDNs文档中找到它: https ://msdn.microsoft.com/en-us/library/windows/desktop/gg426183(v = vs。85)。aspx

BltFast always attempts an asynchronous blit if it is supported by the hardware. 如果硬件支持BltFast,则它总是尝试异步blit。

So it could be a race, possibly, but I would imagine that any attempt to lock would block until this completes. 所以它可能是一场比赛,但我想,任何锁定的尝试都会阻止,直到完成。

And also... https://msdn.microsoft.com/en-us/library/windows/desktop/gg426208%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 还有... https://msdn.microsoft.com/en-us/library/windows/desktop/gg426208%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

Do not call DirectDraw bitblt functions to bitblt from a locked region of a surface. 不要将DirectDraw bitblt函数从表面的锁定区域调用bitblt。 If you do, the bitblt returns either DDERR_SURFACEBUSY or DDERR_LOCKEDSURFACES. 如果这样做,bitblt将返回DDERR_SURFACEBUSY或DDERR_LOCKEDSURFACES。 GDI blit functions also silently fail when used on a locked video memory surface. 在锁定的视频内存表面上使用时,GDI blit函数也会无声地失败。

This implies that bitblt itself has locking semantics. 这意味着bitblt本身具有锁定语义。 Given that GDI is not allowed to access a surface that is explicitly locked, it's also likely that it cannot access a surface in the middle of an asynchronous blit operation. 鉴于不允许GDI访问明确锁定的表面,它也可能无法在异步blit操作的中间访问表面。

So to specifically answer your question, it appears GDI might be able to access a surface without locking it. 因此,要专门回答您的问题,GDI似乎可以在不锁定表面的情况下访问表面。

Of course, there's all kinds of weird things that can be done in the name of performance, so who knows what other kind of hacks they might have done? 当然,可以用性能的名义进行各种奇怪的事情,所以谁知道他们可能做了哪些其他类型的黑客攻击呢?

I will say though, that I am not an expert by any means at DirectDraw, and am operating under the assumption that the backbuffer is just like any other surface. 我会说,我不是DirectDraw的专家,并且假设后备缓冲器就像任何其他表面一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM