From 2565588d8101ebe7344ce8f13a7db6089984ecbe Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sun, 16 Nov 2025 22:02:21 -0600 Subject: [PATCH] feat(gx): add AdapterFormatSort --- src/gx/CGxFormat.cpp | 21 +++++++++++++++++++++ src/gx/CGxFormat.hpp | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/gx/CGxFormat.cpp b/src/gx/CGxFormat.cpp index e23ea93..c09d63a 100644 --- a/src/gx/CGxFormat.cpp +++ b/src/gx/CGxFormat.cpp @@ -21,3 +21,24 @@ int32_t CGxFormat::formatToBitsUint[] = { 24, // Fmt_Ds248 32, // Fmt_Ds320 }; + +int32_t AdapterFormatSort(const void* a, const void* b) { + auto formatA = static_cast(a); + auto formatB = static_cast(b); + + auto sizeSort = (formatA->size.x * formatA->size.y) - (formatB->size.x * formatB->size.y); + + if (sizeSort != 0) { + return sizeSort; + } + + auto colorSort = formatA->colorFormat - formatB->colorFormat; + + if (colorSort != 0) { + return colorSort; + } + + auto multisampleSort = formatA->multisampleCount - formatB->multisampleCount; + + return multisampleSort; +} diff --git a/src/gx/CGxFormat.hpp b/src/gx/CGxFormat.hpp index 9c8c6cf..4849e75 100644 --- a/src/gx/CGxFormat.hpp +++ b/src/gx/CGxFormat.hpp @@ -36,4 +36,6 @@ class CGxFormat { C2iVector pos; }; +int32_t AdapterFormatSort(const void* a, const void* b); + #endif