Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of rendering startup errors #93706

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion platform/android/display_server_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}

Expand All @@ -627,6 +628,7 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
ERR_PRINT(vformat("Failed to create %s window.", rendering_driver));
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}

Expand All @@ -635,7 +637,13 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
rendering_context->window_set_vsync_mode(MAIN_WINDOW_ID, p_vsync_mode);

rendering_device = memnew(RenderingDevice);
rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
if (rendering_device->initialize(rendering_context, MAIN_WINDOW_ID) != OK) {
rendering_device = nullptr;
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
rendering_device->screen_create(MAIN_WINDOW_ID);

RendererCompositorRD::make_current();
Expand Down
9 changes: 8 additions & 1 deletion platform/ios/display_server_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}

Expand All @@ -107,7 +108,13 @@
rendering_context->window_set_vsync_mode(MAIN_WINDOW_ID, p_vsync_mode);

rendering_device = memnew(RenderingDevice);
rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
if (rendering_device->initialize(rendering_context, MAIN_WINDOW_ID) != OK) {
rendering_device = nullptr;
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
rendering_device->screen_create(MAIN_WINDOW_ID);

RendererCompositorRD::make_current();
Expand Down
9 changes: 8 additions & 1 deletion platform/linuxbsd/wayland/display_server_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,14 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
#ifdef RD_ENABLED
if (rendering_context) {
rendering_device = memnew(RenderingDevice);
rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
if (rendering_device->initialize(rendering_context, MAIN_WINDOW_ID) != OK) {
memdelete(rendering_device);
rendering_device = nullptr;
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
rendering_device->screen_create(MAIN_WINDOW_ID);

RendererCompositorRD::make_current();
Expand Down
10 changes: 8 additions & 2 deletions platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6261,8 +6261,14 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode

#if defined(RD_ENABLED)
if (rendering_context) {
rendering_device = memnew(RenderingDevice);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed one line too many here... not sure why CI didn't complain, but then it broke once merged: https://github.com/godotengine/godot/actions/runs/9723676850/job/26839084653

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed up with 25de53e.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why CI didn't complain

Seems like the CI never ran because GH was broken yesterday: https://www.githubstatus.com/incidents/9vwllhs2w1kj

I wish they'd make that more explicit before merging.

rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
if (rendering_device->initialize(rendering_context, MAIN_WINDOW_ID) != OK) {
memdelete(rendering_device);
rendering_device = nullptr;
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
rendering_device->screen_create(MAIN_WINDOW_ID);

RendererCompositorRD::make_current();
Expand Down
9 changes: 8 additions & 1 deletion platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5873,7 +5873,14 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
#if defined(RD_ENABLED)
if (rendering_context) {
rendering_device = memnew(RenderingDevice);
rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
if (rendering_device->initialize(rendering_context, MAIN_WINDOW_ID) != OK) {
memdelete(rendering_device);
rendering_device = nullptr;
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
}
rendering_device->screen_create(MAIN_WINDOW_ID);

RendererCompositorRD::make_current();
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/rendering_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5507,7 +5507,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ
for (uint32_t i = 0; i < frames.size(); i++) {
// Staging was never used, create a block.
err = _insert_staging_block();
ERR_CONTINUE(err != OK);
ERR_FAIL_COND_V(err, FAILED);
}

draw_list = nullptr;
Expand Down