Archived

This topic is now archived and is closed to further replies.

How slow is GetRenderstate/Material?

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

Recommended Posts

Hello again! I''ve been wondering about something for a while... Since setting renderstates and materials and such excessively is computationally rather expensive and can slow things down... How slow do excessive GetRenderState calls make your system? If it hardly takes any time at all, would it be worthwile to, for instance, check if a renderstate is already set to the value you want before actually setting it? So, for instance:

DWORD returnValue;

GetRenderState(D3DRS_FILLMODE, &returnValue);
if (returnValue != D3DFILL_SOLID)
SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

This would only set the fillmode to solid if it''s set to anything else. If it''s already set to fillmode, nothing happens. This could come in handy if, for instance, you don''t know the default render state of certain hardware. Of course, if Getting a render state is as expensive as Setting a render state, this would be pointless. Any ideas?

Share on other sites
I recall reading somewhere that the SetRenderState call IS extremely cheap. It is the SetRenderState -> DrawImage step that may cost a lot of time, and / but the driver tries to optimise this out.

So, during "repetitive" calls (like you do) you wont see a lot of impact (besides the work of a function call and the check), but changing render states often still kills your performance.

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share on other sites
I''ve found keeping track of the render states and all that myself to be the best method so far. That way, it also works with pure devices (see the many threads lately) and it''s fast as well. Of course, you do have a bit more administrative overhead to your code.

- JQ
Full Speed Games. Coming soon.

Share on other sites
I''ve been thinking about that myself. You mean, for instance, creating an array of dword values and then changing that value every time you change a render state? So that, when you needed to check if a render state is set, you''d only have to check that particular array entry?

If the GetRenderState method is indeed that slow, this may be an option. Although I don''t see many advantages if the GetRenderState method takes almost no time at all.

Share on other sites
quote:
Original post by Bas Paap
If the GetRenderState method is indeed that slow, this may be an option. Although I don''t see many advantages if the GetRenderState method takes almost no time at all.

As JonnyQuest mentions above you have to be careful *if* you are using a pure device (see the D3D CreateDevice function) as you cannot call GetRenderState on these devices. Hence the need for your own state management routines.

Regards,
Sharky

• Forum Statistics

• Total Topics
628710
• Total Posts
2984334

• 23
• 11
• 10
• 13
• 14