Why so many big structures in managed directx?

I was told to ask this question here to get an answer:
struct Caps 304 bytes struct Material 68 bytes ... These big structures are used as properties and passed here and there. Isn't this a big performance penalty? I checked the generated asm code, and it seems these's no optimization to remove the overhead. So anyone knows why?

[387 byte] By [qrli] at [2008-2-14]
# 1
Why would it be a performance penalty? You read the caps bits once - at load time. It wouldn't matter if it was megabytes in size. You're assuming too much about what takes the time in a program. I advise spending some time looking at VTune traces - the results may surprise you.
TomForsyth at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2

Well, I admit they do not executes every frame so their drawback can be ignored. But still I wonder the reason to use struct instead of class. Following the design guideline from MSDN (small, value symantic), it should be class, and it would be more efficient also. There should be some reason other than "it's not a performance hit".

E.g. for the Matrix struct, it's way slow for the lack of "const T&" in C#. But I can understand that it will be more slow if it's class because of the allocation stuff.

qrli at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3
This is a trivial speed matter, given that you're using C# in the first place. There's a bazillion other things to worry about first.
TomForsyth at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4
Just to add to what Tom has said...

You really need to look at some instrumentation before you can decide whether the size (in this case) is actually posing a problem.

If you're really stuck for memory space and your tools are telling you that such-and-such a struct/class is taking up unnecessary space then you should start looking for ways to get rid of it (or reduce it's size). Going the other way around (hunting for problems) rarely provides much reward Smile

hth
Jack

JackHoxley at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 5

There is no difference between a struct and a class except for the fact that a struct has public members and a class has private. The old C style structs were different and needed typedef. But with C++ and now C# the struct and class are the same creature.

GrkEngineer at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...