Original Post
🔒 Locked
D3D10: ConstantBuffer vs. EffectVariable
Advertisement
Actually, the effect-framework uses ConstantBuffers internally.
(As you can easily see if you monitor your program with PIX for example.)
To get the maximum of speed, group your EffectVariables according to frequency of updates via
and DirectX automatically creates and manages the corresponding ConstantBuffers for you.
(As you can easily see if you monitor your program with PIX for example.)
To get the maximum of speed, group your EffectVariables according to frequency of updates via
cbuffer OncePerFrame{ //some variables herre};cbuffer OncePerObject{ //you get the idea};//etcand DirectX automatically creates and manages the corresponding ConstantBuffers for you.
Yup, you've pretty much clocked it - no requirement to use CB's but there could be a definite performance gain by grouping constants.
It's a simple case of the developer adding meta data to the code - that little extra hint that allows the runtime/compiler to better interpret the raw code we push in.
hth
Jack
It's a simple case of the developer adding meta data to the code - that little extra hint that allows the runtime/compiler to better interpret the raw code we push in.
hth
Jack
I experienced a strange thing.
I grouped together 2 variables that only really need to be changed per material. (For me a material is an effect, some textures and specular-coef/pow variables).
Performance went *down* after grouping if while I was still uploading the 2 variables for every mesh.
After making a test whether the previously drawn mesh has used the same material and not re-uploading those to 2 variables again in that case, the performance went up again, even surpassing the initial result.
Checking for the previously drawn material made no performance difference without constant buffers.
At first I was under the impression, that I couldn't possibly lose by declaring some cbuffers in my shader. But now it seems that I have to be careful. If it weren't for the "materialtest" I would have gotten the impression that cbuffers slow rendering down, if you know what I mean.
[Edited by - B_old on April 16, 2009 5:29:09 AM]
I grouped together 2 variables that only really need to be changed per material. (For me a material is an effect, some textures and specular-coef/pow variables).
Performance went *down* after grouping if while I was still uploading the 2 variables for every mesh.
After making a test whether the previously drawn mesh has used the same material and not re-uploading those to 2 variables again in that case, the performance went up again, even surpassing the initial result.
Checking for the previously drawn material made no performance difference without constant buffers.
At first I was under the impression, that I couldn't possibly lose by declaring some cbuffers in my shader. But now it seems that I have to be careful. If it weren't for the "materialtest" I would have gotten the impression that cbuffers slow rendering down, if you know what I mean.
[Edited by - B_old on April 16, 2009 5:29:09 AM]
Interesting findings, but not hugely surprising - for relatively small shaders I'd imagine the overhead might be dominant. The case where its likely to be a real win is bigger shaders where you might have 10's or 100's of constants - a vertex skinning shader for example or a deferred renderer etc..etc..
As with all these things, performance testing is indeed an important tool [smile]
Cheers,
Jack
As with all these things, performance testing is indeed an important tool [smile]
Cheers,
Jack
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement