+// Helper function to resolve the backend filename based on architecture
+static bool
+swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
+{
+#ifdef HAVE_SWR_BUILTIN
+ screen->pLibrary = NULL;
+ screen->pfnSwrGetInterface = SwrGetInterface;
+ screen->pfnSwrGetInterface = SwrGetTileInterface;
+ InitTilesTable();
+ fprintf(stderr, "(using: builtin).\n");
+#else
+ char filename[256] = { 0 };
+ sprintf(filename, "%sswr%s%s", UTIL_DL_PREFIX, arch, UTIL_DL_EXT);
+
+ screen->pLibrary = util_dl_open(filename);
+ if (!screen->pLibrary) {
+ fprintf(stderr, "(skipping: %s).\n", util_dl_error());
+ return false;
+ }
+
+ util_dl_proc pApiProc = util_dl_get_proc_address(screen->pLibrary,
+ "SwrGetInterface");
+ util_dl_proc pTileApiProc = util_dl_get_proc_address(screen->pLibrary,
+ "SwrGetTileIterface");
+ util_dl_proc pInitFunc = util_dl_get_proc_address(screen->pLibrary,
+ "InitTilesTable");
+ if (!pApiProc || !pInitFunc || !pTileApiProc) {
+ fprintf(stderr, "(skipping: %s).\n", util_dl_error());
+ util_dl_close(screen->pLibrary);
+ screen->pLibrary = NULL;
+ return false;
+ }
+
+ screen->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
+ screen->pfnSwrGetTileInterface = (PFNSwrGetTileInterface)pTileApiProc;
+
+ SWR_ASSERT(screen->pfnSwrGetInterface != nullptr);
+ SWR_ASSERT(screen->pfnSwrGetTileInterface != nullptr);
+ SWR_ASSERT(pInitFunc != nullptr);
+
+ pInitFunc();
+
+ fprintf(stderr, "(using: %s).\n", filename);
+#endif
+ return true;
+}
+
+