Skip to content

Commit

Permalink
Fix crash with Tracy enabled
Browse files Browse the repository at this point in the history
Renderer libraries are unloaded, so the zones are transient here.
  • Loading branch information
Xottab-DUTY committed Jan 19, 2025
1 parent 8ffad26 commit 8c5d692
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/Layers/xrRenderDX11/dx11HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CHW::OnAppDeactivate()
//////////////////////////////////////////////////////////////////////
void CHW::CreateD3D()
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

hDXGI = XRay::LoadModule("dxgi");
hD3D = XRay::LoadModule("d3d11");
Expand Down Expand Up @@ -92,7 +92,7 @@ void CHW::DestroyD3D()

void CHW::CreateDevice(SDL_Window* sdlWnd)
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

CreateD3D();
if (!Valid)
Expand Down Expand Up @@ -148,7 +148,7 @@ void CHW::CreateDevice(SDL_Window* sdlWnd)

const auto createDevice = [&](const D3D_FEATURE_LEVEL* level, const u32 levels)
{
ZoneScopedN("Create device");
ZoneTransientN(tracy_scoped_zone_2, "CreateDevice", true);

static const auto d3d11CreateDevice = static_cast<PFN_D3D11_CREATE_DEVICE>(hD3D->GetProcAddress("D3D11CreateDevice"));
return d3d11CreateDevice(m_pAdapter, D3D_DRIVER_TYPE_UNKNOWN,
Expand Down Expand Up @@ -223,15 +223,15 @@ void CHW::CreateDevice(SDL_Window* sdlWnd)
{
TaskScheduler->AddTask([this]
{
ZoneScopedN("TracyD3D11Context");
ZoneTransientN(tracy_scoped_zone_2, "TracyD3D11Context", true);
profiler_ctx = TracyD3D11Context(pDevice, get_context(CHW::IMM_CTX_ID));
});
}

// Create deferred contexts
if (ThisInstanceIsGlobal())
{
ZoneScopedN("Create deferred contexts");
ZoneTransientN(tracy_scoped_zone_2, "Create deferred contexts", true);
for (int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id)
{
R = pDevice->CreateDeferredContext(0, &d3d_contexts_pool[id]);
Expand Down Expand Up @@ -282,7 +282,7 @@ void CHW::CreateDevice(SDL_Window* sdlWnd)

bool CHW::CreateSwapChain(HWND hwnd)
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

// Set up the presentation parameters
DXGI_SWAP_CHAIN_DESC& sd = m_ChainDesc;
Expand Down Expand Up @@ -338,7 +338,7 @@ bool CHW::CreateSwapChain2(HWND hwnd)
if (strstr(Core.Params, "-no_dx11_2"))
return false;

ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

#ifdef HAS_DX11_2
IDXGIFactory2* pFactory2{};
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderGL/glHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void CHW::OnAppDeactivate()
//////////////////////////////////////////////////////////////////////
void CHW::CreateDevice(SDL_Window* hWnd)
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

m_window = hWnd;

Expand Down Expand Up @@ -104,7 +104,7 @@ void CHW::CreateDevice(SDL_Window* hWnd)

int version;
{
ZoneScopedN("gladLoadGL");
ZoneTransientN(tracy_scoped_zone_2, "gladLoadGL", true);
version = gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress));
}
if (version == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/r2_test_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class sdl_window_test_helper

BOOL xrRender_test_hw()
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

// Check if minimal required OpenGL features are available
const sdl_window_test_helper windowTest;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/xrRender_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RGLRendererModule final : public RendererModule

const xr_vector<std::pair<pcstr, int>>& ObtainSupportedModes() override
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

if (CheckCanAddMode())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r2_test_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DX11TestHelper

BOOL xrRender_test_hw()
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

const DX11TestHelper helper;
if (!helper.Successful())
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/xrRender_R4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class R4RendererModule final : public RendererModule

const xr_vector<std::pair<pcstr, int>>& ObtainSupportedModes() override
{
ZoneScoped;
ZoneTransient(tracy_scoped_zone, true);

const BOOL result = CheckCanAddMode();
if (result != FALSE)
Expand Down

0 comments on commit 8c5d692

Please sign in to comment.