Is it better to use one large buffer with all related data or several smaller buffers in HLSL

I was interested in both the design of the code and the performance aspect, if it is better to have dedicated buffers when sending data to the GPU in HLSL or to another high-level shader language.

Here, a particular shader should have a lot of variable data that changes at runtime, and, as such, information should be passed in buffers.

I give a very simple example:

cbuffer SomeLargeBuffer : register(cb0)
{
    float3 data;
    float someData;
    float4 largeArray[2500];
    float moreData;
    ...
    ...
    ... 
    ...
    ...
}

or have

cbuffer SamllerBuffer: register(cb0)
{
    float3 data;
    float someRelatedData;

}

cbuffer SecondSmallerBuffer : register(cb1)
{

    float4 largeArray[2500];
    float moreData;

}

cbuffer ThirdBuffer: register(cb2)
{
    ...
    ...
    ...
}
+4
source share
1 answer

From an efficiency point of view, the documentation on shader constants in HLSL gives the following advice:

- . , . , : , ( ) , . , , , ( ).

, , , . , : a) , b) c) ( ). , .

, .

+5

Source: https://habr.com/ru/post/1671544/


All Articles