添加插件

This commit is contained in:
2025-11-10 00:08:26 +08:00
parent 4059c207c0
commit 76f80db694
2814 changed files with 436400 additions and 178 deletions

View File

@@ -0,0 +1,39 @@
#pragma kernel BitonicSort
const uint numEntries;
const uint groupWidth;
const uint groupHeight;
const uint stepIndex;
RWStructuredBuffer<float> Keys;
RWStructuredBuffer<float> Values;
[numthreads(128,1,1)]
void BitonicSort(uint3 id : SV_DispatchThreadID)
{
uint i = id.x;
uint hIndex = i & (groupWidth - 1);
uint indexLeft = hIndex + (groupHeight + 1) * (i / groupWidth);
uint rightStepSize = stepIndex == 0 ? groupHeight - 2 * hIndex : (groupHeight + 1) / 2;
uint indexRight = indexLeft + rightStepSize;
// Exit if out of bounds (for non-power of 2 input sizes)
if (indexRight >= numEntries) return;
float keyLeft = Keys[indexLeft];
float keyRight = Keys[indexRight];
float valueLeft = Values[indexLeft];
float valueRight = Values[indexRight];
// Swap entries if value is descending
if (valueLeft > valueRight)
{
Keys[indexLeft] = keyRight;
Keys[indexRight] = keyLeft;
Values[indexLeft] = valueRight;
Values[indexRight] = valueLeft;
}
}