Sign in to follow this  

Direct2D slow for general apps?

This topic is 2793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been mucking around with Direct2D and made a simple circle that's set to the mouse's position. What surprises me is that it's slower than gdi/+. The circle lags less behind the mouse if I switch over to software rendering but of course the lag increases with the more objects I add, while hardware mode consistently lags the same as more are added. Btw, it's still rendering at 60fps. Why is this? I also checked one of the Direct2D samples in the SDK that has a square set to the mouses position and it lags behind as well but at 60fps. Should I stick to GDI/+ for general apps?

Share this post


Link to post
Share on other sites
This is because VSync. To turn it off, just do that when you create the rendertarget:

V_RETURN(MyVars.D2DFactory->CreateHwndRenderTarget( RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,PixelFormat(DXGI_FORMAT_UNKNOWN ,D2D1_ALPHA_MODE_PREMULTIPLIED )), HwndRenderTargetProperties( hw, SizeU( WindowSize.right - WindowSize.left, WindowSize.bottom - WindowSize.top),D2D1_PRESENT_OPTIONS_IMMEDIATELY ), &MyVars.RT));

This will unlock your FPS.

EDIT: Oh, didn't read you post carefully. :( But try setting off vsync, and please show how you set up Direct2D. In my engine, it renders just very fast...

Share this post


Link to post
Share on other sites
Another potential cause is that Direct2D was written by people who don't understand how an API is used or how to write one.

Please post the entire source code for "made a simple circle that's set to the mouse's position" because I want to laugh at how many hoops you have to jump through to do something like that.

Share this post


Link to post
Share on other sites
Quote:
Original post by CadetUmfer
Another potential cause is that Direct2D was written by people who don't understand how an API is used or how to write one.

Please post the entire source code for "made a simple circle that's set to the mouse's position" because I want to laugh at how many hoops you have to jump through to do something like that.


It's meant to be a high-performance graphics API that allows you to use GPU hardware acceleration. The description on MSDN seems to make this quite clear. Such an API obviously requires a lower level of abstraction, requiring you to deal with some specifics of the driver structure and graphics hardware. You can't have your cake and eat it too when it comes to these things...you either work at a low-level or you work with a framework that trades simplicity for flexibility.

Share this post


Link to post
Share on other sites
Yeah, but when the API is more complex than just using ID3DXSprite...something is wrong.

https://mollyrocket.com/9115

Quote:
Original post by MJP
you either work at a low-level or you work with a framework that trades simplicity for flexibility


I think that exact tradeoff is what most potential users of Direct2D would've wanted.

Share this post


Link to post
Share on other sites
Quote:
Original post by CadetUmfer
Yeah, but when the API is more complex than just using ID3DXSprite...something is wrong.

https://mollyrocket.com/9115

Quote:
Original post by MJP
you either work at a low-level or you work with a framework that trades simplicity for flexibility


I think that exact tradeoff is what most potential users of Direct2D would've wanted.


The D3DX library is a utility library that sits on top of Direct3D, not a part of the Direct3D specific API. You are comparing apples to oranges.

People who want something higher level should stick to GDI/GDI+.

Share this post


Link to post
Share on other sites
No I'm not. I'm comparing 2 APIs that can accomplish similar things: tell the GPU to draw a textured quad. In addition, Direct2D is also built on top of Direct3D.

Maybe I'm wrong, and there is a large market of users who want to write high-performance 2D graphics, and want to learn a complex API, but don't want those skills to transfer over to a existing popular 3D API.

Share this post


Link to post
Share on other sites
Quote:
Original post by CadetUmfer
No I'm not. I'm comparing 2 APIs that can accomplish similar things: tell the GPU to draw a textured quad. In addition, Direct2D is also built on top of Direct3D.


You're comparing a single class with an extremely narrow use-case (drawing textured quads) with an entire API that has an extremely broad use-case (drawing 2D graphics and text). If you wanted you could make your own ID3DXSprite-esque class for Direct2D that makes it easy to throw sprites at the screen, since that's the whole point of Direct2D: it'd flexible and low-level enough for you to build higher-level frameworks abstractions on top of it without getting in your way.

If you think that there isn't a need for such an API then you're welcome to feel that way, but I think it was more than a little misguided on your part to claim that the API writers are bad at what they do just because you misunderstood Direct2D's purpose.

Share this post


Link to post
Share on other sites
Plus ID3DXSprite draws simple raster images, whereas Direct2D is a complete high-performance vector graphics API. They're not even close to the same thing, at all.

Share this post


Link to post
Share on other sites
Fair enough. But for the subset of functionality that most 2D game developers use, another API is probably better suited.

Then again, it says that in the first paragraph of the docs.

Edit: here's another discussion http://braid-game.com/news/?p=466

Share this post


Link to post
Share on other sites

This topic is 2793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this