[Optimization] (multidraw: compute): why bisect still not working???

This commit is contained in:
Swung0x48 2025-04-24 10:03:39 +08:00
parent a0bcd91257
commit e3c7bab0af
2 changed files with 17 additions and 15 deletions

View File

@ -280,11 +280,11 @@ void main() {
int high = draws.length();
while (low < high) {
int mid = low + (high - low) / 2;
if (prefixSums[mid] <= outIdx) {
low = mid + 1; // next [mid + 1, high)
if (prefixSums[mid] > outIdx) {
high = mid; // next [low, mid)
}
else {
high = mid; // next [low, mid)
low = mid + 1; // next [mid + 1, high)
}
}
@ -294,7 +294,8 @@ void main() {
uint inIndex = localIdx + cmd.firstIndex;
// Write out
out_indices[outIdx] = uint(int(in_indices[inIndex]) + cmd.baseVertex);
out_indices[outIdx] = uint(in_indices[inIndex] + uint(cmd.baseVertex));
// out_indices[outIdx] = uint(cmd.baseVertex);
}
)";

View File

@ -21,23 +21,23 @@ void main() {
return;
// Find out draw call #
// int low = 0;
// int high = draws.length();
// for (low = 0; low < high; ++low) {
// if (prefixSums[low] > outIdx) {
// break;
// }
// }
// int low = 0;
// int high = draws.length();
// for (low = 0; low < high; ++low) {
// if (prefixSums[low] > outIdx) {
// break;
// }
// }
int low = 0;
int high = draws.length();
while (low < high) {
int mid = low + (high - low) / 2;
if (prefixSums[mid] <= outIdx) {
low = mid + 1; // next [mid + 1, high)
if (prefixSums[mid] > outIdx) {
high = mid; // next [low, mid)
}
else {
high = mid; // next [low, mid)
low = mid + 1; // next [mid + 1, high)
}
}
@ -47,5 +47,6 @@ void main() {
uint inIndex = localIdx + cmd.firstIndex;
// Write out
out_indices[outIdx] = uint(int(in_indices[inIndex]) + cmd.baseVertex);
out_indices[outIdx] = uint(in_indices[inIndex] + uint(cmd.baseVertex));
// out_indices[outIdx] = uint(cmd.baseVertex);
}