WinXP D3D9上的Xbox360的D3DRS_VIEWPORTENABLE等效功能是什么? [英] What is the Xbox360's D3DRS_VIEWPORTENABLE equivalent on WinXP D3D9?

查看:202
本文介绍了WinXP D3D9上的Xbox360的D3DRS_VIEWPORTENABLE等效功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在维护Xbox360和WinXP的多平台代码库。我在XP上看到一个与Xbox360版本上的D3DRS_VIEWPORTENABLE相关的问题,在WinXP D3D9上没有相同的功能。 这篇文章有一个有趣的想法,但构建一个单位矩阵是为D3DVIEWPORT9 :: X和D3DVIEWPORT9 :: Height提供负数,但它们是无符号数。 (无论如何我都试图输入负数,但没有发生任何有趣的事情)。

因此,如何模拟WinXP / D3D9下D3DRS_VIEWPORTENABLE的行为?



(为了清楚起见,我看到的结果是一个2D屏幕对齐的四边形在Xbox360上工作正常,但在WinXP上偏移/拉伸。实际上,(0,0)从WinXP屏幕的中心开始,而不是在Xbox360的左下角,因为应用了视口转换。)



更新:我没有在写这个问题的时候,我没有一个Xbox360开发工具包,但我从那以后就得到了一个。我注意到禁用了D3DRS_VIEWPORTENABLE状态,并且Xbox360上的结果和WinXP版本完全相同。所以,必须有一些DirectX魔术来弥补这个空白,以便在WinXP上关闭模拟D3DRS_VIEWPORTENABLE。

解决方案

关于如何将负片放入视口矩阵中,从投影矩阵中考虑它。



视口矩阵直接应用于投影矩阵之后。因此,如果您想象将视口设置为身份,并将其与wvp(世界视图投影)矩阵相乘。即

  world * view * projection * viewport 

您现在可以将视口设置为任何您想要的值。



当然,这实际上并不是攻击问题。一些驱动程序可能会根据视口中的条目进行优化(它们实际上可能不会实现矩阵乘法,例如一个)。我不会亲自使用上述系统,我可以预见它会带来太多问题。



那么,这会给你带来什么?



实际上它仍然非常简单。如果将投影矩阵乘以与视口矩阵相反的矩阵,那么您会发现,当应用视口矩阵时,它们相互抵消,并且剩下的就是投影的直接输出。现在,视口已被有效地禁用。


I am maintaining a multiplatform codebase for Xbox360 and WinXP. I am seeing an issue on the XP side that appears to be related to D3DRS_VIEWPORTENABLE on the Xbox360 version not having an equivalent on WinXP D3D9. This article had an interesting idea, but the only way to construct an identity matrix is to supply negative numbers to D3DVIEWPORT9::X and D3DVIEWPORT9::Height, but they are unsigned numbers. (I tried to put in negative numbers anyway, but nothing interesting happened.)

So, how does one emulate the behavior of D3DRS_VIEWPORTENABLE under WinXP/D3D9?

(For clarity, the result I'm seeing is that a 2d screen-aligned quad works fine on Xbox360 but is offset/stretched on WinXP. In fact, the (0, 0) starts in the center of the screen on WinXP instead of in the lower-left corner like on the Xbox360 as a result of applying the viewport transform.)

Update: I didn't have an Xbox360 devkit at the time I wrote up this question, but I've since gotten one. I commented out the disabling of the D3DRS_VIEWPORTENABLE state, and the exact same behavior resulted on the Xbox360 as on the WinXP build. So, there must be some DirectX magic to bridge the gap here for emulating D3DRS_VIEWPORTENABLE being turned off on WinXP.

解决方案

Instead of thinking about how you could put negatives into the viewport matrix think about it from the projection matrix.

The viewport matrix is applied directly after the projection matrix. So if you imagine setting the viewport to identity and the multiply it with the wvp (world-view-projection) matrix. ie

world * view * projection * viewport

You can now set the viewport to anything you want.

Of course this isn't actually the best way to attack the problem either. Some drivers will probably make optimisations based upon entries in t e viewport (they may not actually do a matrix multiply, for one). I wouldn't personally use the above system I can foresee too many issues coming from it.

So where does that leave you?

Well actually its still pretty simple. If you multiply the projection matrix by a matrix that is the inverse of the viewport matrix then you will find that when the viewport "matrix" is applied they cancel each other out and you are left with the direct output of the projection. The viewport has now been, effectively, "disabled".

这篇关于WinXP D3D9上的Xbox360的D3DRS_VIEWPORTENABLE等效功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆