-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renderdiff: Use single lib for osmesa (#8255)
Previously, we linked against libOSMesa through the linker and then used dlopen to link against libGL. This is not how libOSMesa is intended to be used. Instead, we use dlopen on libOSMesa (via bluegl), which then will map the correct GL methods for us, and for the OSMesa functions, we also map those functions from libOSMesa (instead of relying on compile-time linker).
- Loading branch information
Showing
5 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <GL/gl.h> | ||
#include <dlfcn.h> | ||
#include <string.h> | ||
|
||
namespace bluegl { | ||
|
||
namespace { | ||
using ProcAddressFunc = void*(*)(char const* funcName); | ||
} | ||
|
||
struct Driver { | ||
ProcAddressFunc OSMesaGetProcAddress; | ||
void* library; | ||
} g_driver = {nullptr, nullptr}; | ||
|
||
bool initBinder() { | ||
constexpr char const* libraryNames[] = {"libOSMesa.so", "libosmesa.so"}; | ||
for (char const* name : libraryNames) { | ||
g_driver.library = dlopen(name, RTLD_GLOBAL | RTLD_NOW); | ||
if (g_driver.library) { | ||
break; | ||
} | ||
} | ||
if (!g_driver.library) { | ||
return false; | ||
} | ||
|
||
g_driver.OSMesaGetProcAddress = (ProcAddressFunc) | ||
dlsym(g_driver.library, "OSMesaGetProcAddress"); | ||
|
||
return g_driver.OSMesaGetProcAddress; | ||
} | ||
|
||
void* loadFunction(const char* name) { | ||
return (void*) g_driver.OSMesaGetProcAddress(name); | ||
} | ||
|
||
void shutdownBinder() { | ||
dlclose(g_driver.library); | ||
memset(&g_driver, 0, sizeof(g_driver)); | ||
} | ||
|
||
} // namespace bluegl |