Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

double precision version of D3DXMATRIX

614 views
Skip to first unread message

pwm

unread,
Jan 24, 2008, 2:20:40 PM1/24/08
to
Is there a double precision version of D3DXMATRIX? I would like to use
the same data structures when implementing my back-end data model as I
do in providing data to the graphics pipeline, but I need double
precision matrix/vector/quaternion operations. The DirectX extension
provided D3DXMATRIX matrix uses FLOAT. Is there another version that
uses double? Even better (for C++) would be a generic templated version
that would allow both? My primary interest is C++, but C# would be nice
as well.

Thanks,
Phil

Richard [Microsoft Direct3D MVP]

unread,
Jan 24, 2008, 4:44:26 PM1/24/08
to
[Please do not mail me a copy of your followup]

pwm <pwm...@newsgroups.nospam> spake the secret code
<OBNp24rX...@TK2MSFTNGP02.phx.gbl> thusly:

>Is there a double precision version of D3DXMATRIX?

No. The entire D3D pipeline uses single precision floats throughout,
so there's no benefit to providing D3DXMATRIX as a double.

They don't use any templates in D3DX, but there's nothing in D3DX that
you can't do yourself. There are some template-based numeric vector
libraries out there, however. Google for Blitz++.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>

WenJun Zhang[msft]

unread,
Jan 31, 2008, 3:27:57 AM1/31/08
to
Hi Phil,

As Richard mentioned, there will not be any benefit to use any double
precision objects in D3D. I just wonder if you still have any questions
around this? The following information explains the similar reason of why
setting D3DCREATE_FPU_PRESERVE flag for CreateDevice call actually
decreases performance.

Direct3D's pipeline operates entirely on 'float' single-precision values.
Left in it's default state by the CRT, the FPU will compute everything in
double-precision mode. Since the majority of users of Direct3D are
performance-sensitive applications rather than scientific ones, Direct3D's
CreateDevice routine overrides the CRT setting and puts the FPU into
single-precision mode globally. The D3DCREATE_FPU_PRESERVE flag prevents
this from taking place so that applications that wish to have either the
default 'double-precision' mode or some other settings can do so.

If you are using "double", then your structures will be larger and the
compiler will have limited options. Even if you are using "float" types,
however, if the FPU is in double-precision mode they are extended
internally to doubles and computed with the extra precision before being
truncated back to single-precision "floats".

Please update here if you have any further question or concern.

Have a great day.

Sincerely,

WenJun Zhang

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at:

http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


pwm

unread,
Feb 1, 2008, 5:41:46 PM2/1/08
to WenJun Zhang[msft]
WenJun Zhang[msft] wrote:
> Hi Phil,
>
> As Richard mentioned, there will not be any benefit to use any double
> precision objects in D3D. I just wonder if you still have any questions
> around this? The following information explains the similar reason of why
> setting D3DCREATE_FPU_PRESERVE flag for CreateDevice call actually
> decreases performance.
>
> Direct3D's pipeline operates entirely on 'float' single-precision values.
> Left in it's default state by the CRT, the FPU will compute everything in
> double-precision mode. Since the majority of users of Direct3D are
> performance-sensitive applications rather than scientific ones, Direct3D's
> CreateDevice routine overrides the CRT setting and puts the FPU into
> single-precision mode globally. The D3DCREATE_FPU_PRESERVE flag prevents
> this from taking place so that applications that wish to have either the
> default 'double-precision' mode or some other settings can do so.
>
> If you are using "double", then your structures will be larger and the
> compiler will have limited options. Even if you are using "float" types,
> however, if the FPU is in double-precision mode they are extended
> internally to doubles and computed with the extra precision before being
> truncated back to single-precision "floats".

Hi WenJun,
Thanks for your reply. I do not, unfortunately, fully understand it.
My question is really more from the perspective of developing a
scientific application than a specific D3D pipleline question. And, it
is rather simply "Is there a double precision version of D3DXMATRIX?" I
am asking because I would like to use the same C++ classes in my
scientific development that I am already using in my D3D development.
My scientific algorithms require double precision accuracy, but I do not
want to use yet another set of C++ classes to represent and perform 3-D
geometry operations.

I am particularly confused about your statement "Even if you are using
'float' types, however, if the FPU is in double-precision mode ...".
What do you mean by the FPU being in double-precision mode? Isn't
D3DXMATRIX using the FLOAT (typedef to a float) and won't I be limited
to single precision?

Thanks for your help and sorry to follow-up your clarification with yet
another question! :-)

Phil

Chuck Walbourn [MSFT]

unread,
Feb 1, 2008, 7:36:36 PM2/1/08
to
There is no double version D3DXMATRIX nor is there any double precision
support in D3DX math generally.

The use of 'float' vs. 'double' data type in C/C++ determines the amount of
memory used (4 bytes vs. 8 bytes), but the actual computational precision of
the floating-point unit is controlled by a control-word setting. By default
the C Runtime (and the .NET CLR) sets it to "double-precision, no
exceptions".

To increase performance for games, Direct3D's CreateDevice sets the control
word to "single-precision, no exceptions". Even 'double' types will
therefore only have single-precision computation performed. To leave the FPU
control word alone, use pass the D3DCREATE_FPU_PRESERVE flag.

--
Chuck Walbourn
SDE, XNA Developer Connection

Message has been deleted

aesk...@gmail.com

unread,
Sep 12, 2013, 12:58:39 PM9/12/13
to
On Thursday, January 24, 2008 4:44:26 PM UTC-5, Richard [Microsoft Direct3D MVP] wrote:
> No. The entire D3D pipeline uses single precision floats throughout,
> so there's no benefit to providing D3DXMATRIX as a double.

I know this post is old but it showed up on Google as a top result so I feel the need to reply to this comment. Of course there is a benefit to double precision matrices! My application works with a very large world, and as a result, I must do all my calculations in double precision, or else my world will have lots of tearing between world tiles. So even though the actual graphics card uses single precision, there is a great benefit to being able to do calculations in double precision.

For those looking to do matrix math in a higher precision library, I highly recommend GLM (http://glm.g-truc.net/0.9.4/index.html). It is also easy to convert from a D3DXMATRIX to a glm::mat4. You do not even need to do the conversion yourself, the C++ operator= takes care of everything.
0 new messages