Fix BitonicSort constant buffer size error on Vulkan due to structure padding

This commit is contained in:
Wojtek Figat
2021-04-28 15:51:54 +02:00
parent f3be30a55e
commit cf799c2198
4 changed files with 31 additions and 39 deletions

View File

@@ -7,36 +7,15 @@
/// <summary>
/// Bitonic Sort implementation using GPU compute shaders.
/// It has a complexity of O(n*(log n)^2), which is inferior to most
/// traditional sorting algorithms, but because GPUs have so many threads,
/// and because each thread can be utilized, the algorithm can fully load
/// the GPU, taking advantage of its high ALU and bandwidth capabilities.
/// It has a complexity of O(n*(log n)^2), which is inferior to most traditional sorting algorithms, but because GPUs have so many threads,
/// and because each thread can be utilized, the algorithm can fully load the GPU, taking advantage of its high ALU and bandwidth capabilities.
/// </summary>
class BitonicSort : public RendererPass<BitonicSort>
{
public:
// The sorting keys buffer item structure template. Matches the shader type.
struct Item
{
float Key;
uint32 Value;
};
private:
PACK_STRUCT(struct Data {
Item NullItem;
uint32 CounterOffset;
uint32 MaxIterations;
uint32 LoopK;
float KeySign;
uint32 LoopJ;
float Dummy0;
});
AssetReference<Shader> _shader;
GPUBuffer* _dispatchArgsBuffer;
GPUBuffer* _dispatchArgsBuffer = nullptr;
GPUConstantBuffer* _cb;
GPUShaderProgramCS* _indirectArgsCS;
GPUShaderProgramCS* _preSortCS;
@@ -44,13 +23,6 @@ private:
GPUShaderProgramCS* _outerSortCS;
GPUShaderProgramCS* _copyIndicesCS;
public:
/// <summary>
/// Initializes a new instance of the <see cref="BitonicSort"/> class.
/// </summary>
BitonicSort();
public:
/// <summary>