Hi folks, The problem is that there is nothing like the "invariant" keyword in D3D9 HLSL (or even D3D10 HLSL for that matter) that I am aware of. In practise, there must be some form of invariance guaranteed by d3d9 (especially for position), since I know of many games which use multi-pass rendering algorithms which work just fine. The difficulty lies in figuring out exactly what is guaranteed by D3D9, since we've been unable to find any sort of public documentation or discussion of these issues. However, even if there is position invariance, this does not provide a mechanism to toggle invariance on and off on a per-variable basis as is required in GLSL. The closest thing we've been able to find is a SIGGRAPH article on D3D10 from Microsoft. (http://download.microsoft.com/download/f/2/d/f2d5ee2c-b7ba-4cd0-9686-b6508b5479a1/Direct3D10_web.pdf) They briefly allude to this problem in section 5.4:
My assumption is that D3D9 must have had similar requirements. The version of Cg that was open-sourced is quite archaic at this point. The ANGLE compiler is open-sourced (https://code.google.com/p/angleproject/) and is based off the 3DLabs GLSL compiler. It compiles GLSL ES to HLSL9 which is then compiled to D3D9 byte-code using D3DXCompileShader. A future extension to ANGLE could be to generate D3D9 byte-code directly. However, even D3D9 bytecode is still an IL and there is no guarantee that the hardware executes those instructions exactly (and I know there are implementations which do compile/optimize this further). The issue raised about ftransform in CG and GLSL and position invariance was primarily an issue when using fixed function and shaders together, and it was indeed a very common problem. This is also why the "position_invariant" option was added to the ARB_vertex_program assembly extension. Examples of this occurring in shader-only applications are much more difficult to come by. Ideally, an example program which does exhibit invariance issues in webgl (or GLSL or GLSL ES) would be available to demonstrate that this is actually a real problem for webgl. If that existed, we could verify whether or not ANGLE on D3D9 has such problems, or if it just works. Steve Baker: do you have any such examples, or would you be able to put one together which demonstrates this problem? We are continuing to investigate the guarantees provided by D3D in this area and a concrete test case showing such issues would be invaluable for this. Thanks, Daniel On 2010-07-10, at 1:35 PM, Steve Baker wrote:
On 2010-07-09, at 9:58 PM, Steve Baker wrote:
--- Daniel Koch -+- daniel@transgaming.com -+- 1 613.244.1111 x352 Senior Graphics Architect -+- TransGaming Inc. -+- www.transgaming.com 311 O'Connor St., Suite 300, Ottawa, Ontario, Canada, K2P 2G9 This message is a private communication. It also contains information that is privileged or confidential. If you are not the intended recipient, please do not read, copy or use it, and do not disclose it to others. Please notify the sender of the delivery error by replying to this message, and then delete it and any attachments from your system. Thank you. |