mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-04 14:26:20 +12:00
GL: Add fallback for when driver doesn't provide glDrawRangeElementsBaseVertex
This commit is contained in:
parent
8c80099339
commit
7b1afc849e
3 changed files with 47 additions and 6 deletions
|
@ -250,4 +250,25 @@ namespace PICA::IndexBuffer {
|
|||
return analyzePortable<useShortIndices>(indexBuffer, vertexCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
// In some really unfortunate scenarios (eg Android Studio emulator), we don't have access to glDrawRangeElementsBaseVertex
|
||||
// So we need to subtract the base vertex index from every index in the index buffer ourselves
|
||||
// This is not really common, so we do it without SIMD for the moment, just to be able to run on Android Studio
|
||||
template <bool useShortIndices>
|
||||
void subtractBaseIndex(u8* indexBuffer, u32 vertexCount, u16 baseIndex) {
|
||||
// Calculate the minimum and maximum indices used in the index buffer, so we'll only upload them
|
||||
if constexpr (useShortIndices) {
|
||||
u16* indexBuffer16 = reinterpret_cast<u16*>(indexBuffer);
|
||||
|
||||
for (u32 i = 0; i < vertexCount; i++) {
|
||||
indexBuffer16[i] -= baseIndex;
|
||||
}
|
||||
} else {
|
||||
u8 baseIndex8 = u8(baseIndex);
|
||||
|
||||
for (u32 i = 0; i < vertexCount; i++) {
|
||||
indexBuffer[i] -= baseIndex8;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace PICA::IndexBuffer
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace OpenGL {
|
|||
struct Driver {
|
||||
bool supportsExtFbFetch = false;
|
||||
bool supportsArmFbFetch = false;
|
||||
// Does this driver support glDraw(Range)ElementsBaseVertex?
|
||||
bool supportsDrawElementsBaseVertex = false;
|
||||
|
||||
bool supportFbFetch() const { return supportsExtFbFetch || supportsArmFbFetch; }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue