Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "renderdoc_api.hh"
|
|
|
|
#ifdef _WIN32
|
|
# define WIN32_LEAN_AND_MEAN
|
|
# include <Windows.h>
|
|
#else
|
|
# include <dlfcn.h>
|
|
#endif
|
|
#include <iostream>
|
|
|
|
namespace renderdoc::api {
|
|
bool Renderdoc::start_frame_capture(RENDERDOC_DevicePointer device_handle,
|
|
RENDERDOC_WindowHandle window_handle)
|
|
{
|
|
if (!check_loaded()) {
|
|
return false;
|
|
}
|
|
renderdoc_api_->StartFrameCapture(device_handle, window_handle);
|
|
return true;
|
|
}
|
|
|
|
void Renderdoc::end_frame_capture(RENDERDOC_DevicePointer device_handle,
|
|
RENDERDOC_WindowHandle window_handle)
|
|
|
|
{
|
|
if (!check_loaded()) {
|
|
return;
|
|
}
|
|
renderdoc_api_->EndFrameCapture(device_handle, window_handle);
|
|
}
|
|
|
|
bool Renderdoc::check_loaded()
|
|
{
|
|
switch (state_) {
|
|
case State::UNINITIALIZED:
|
|
load();
|
|
return renderdoc_api_ != nullptr;
|
|
break;
|
|
case State::NOT_FOUND:
|
|
return false;
|
|
case State::LOADED:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void Renderdoc::load()
|
|
{
|
|
#ifdef _WIN32
|
|
if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) {
|
|
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)GetProcAddress(mod,
|
|
"RENDERDOC_GetAPI");
|
|
RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_2, (void **)&renderdoc_api_);
|
|
}
|
|
#else
|
|
if (void *mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD)) {
|
|
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
|
|
RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_2, (void **)&renderdoc_api_);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
} // namespace renderdoc::api
|