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