aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-01-12 18:30:59 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-15 15:50:19 +0000
commit23540b557931bddc5053f363fa38d87e3254a78d (patch)
treecb6e8e53e72e49432b53254cb1045b42763c0a7b /render
parent4a70172e267b52c20b8bb25b74347b25407c7247 (diff)
render: allow wlr_renderer_impl.begin to fail
Make it return a bool to indicate success/failure. Adapt the various implementations to check errors.
Diffstat (limited to 'render')
-rw-r--r--render/gles2/renderer.c4
-rw-r--r--render/pixman/renderer.c22
-rw-r--r--render/vulkan/renderer.c12
3 files changed, 28 insertions, 10 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 8d060150..ee4f60e8 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -198,7 +198,7 @@ static bool gles2_bind_buffer(struct wlr_renderer *wlr_renderer,
return true;
}
-static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
+static bool gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
uint32_t height) {
struct wlr_gles2_renderer *renderer =
gles2_get_renderer_in_context(wlr_renderer);
@@ -219,6 +219,8 @@ static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
// for users to sling matricies themselves
pop_gles2_debug(renderer);
+
+ return true;
}
static void gles2_end(struct wlr_renderer *wlr_renderer) {
diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c
index d7ed3eae..b58ee1b4 100644
--- a/render/pixman/renderer.c
+++ b/render/pixman/renderer.c
@@ -127,7 +127,7 @@ error_buffer:
return NULL;
}
-static void pixman_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
+static bool pixman_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
uint32_t height) {
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
renderer->width = width;
@@ -139,9 +139,11 @@ static void pixman_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
void *data = NULL;
uint32_t drm_format;
size_t stride;
- wlr_buffer_begin_data_ptr_access(buffer->buffer,
- WLR_BUFFER_DATA_PTR_ACCESS_READ | WLR_BUFFER_DATA_PTR_ACCESS_WRITE,
- &data, &drm_format, &stride);
+ if (!wlr_buffer_begin_data_ptr_access(buffer->buffer,
+ WLR_BUFFER_DATA_PTR_ACCESS_READ | WLR_BUFFER_DATA_PTR_ACCESS_WRITE,
+ &data, &drm_format, &stride)) {
+ return false;
+ }
// If the data pointer has changed, re-create the Pixman image. This can
// happen if it's a client buffer and the wl_shm_pool has been resized.
@@ -149,10 +151,18 @@ static void pixman_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
pixman_format_code_t format = get_pixman_format_from_drm(drm_format);
assert(format != 0);
- pixman_image_unref(buffer->image);
- buffer->image = pixman_image_create_bits_no_clear(format,
+ pixman_image_t *image = pixman_image_create_bits_no_clear(format,
buffer->buffer->width, buffer->buffer->height, data, stride);
+ if (image == NULL) {
+ wlr_buffer_end_data_ptr_access(buffer->buffer);
+ return false;
+ }
+
+ pixman_image_unref(buffer->image);
+ buffer->image = image;
}
+
+ return true;
}
static void pixman_end(struct wlr_renderer *wlr_renderer) {
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c
index ff208abc..e35d4707 100644
--- a/render/vulkan/renderer.c
+++ b/render/vulkan/renderer.c
@@ -691,14 +691,14 @@ static bool vulkan_bind_buffer(struct wlr_renderer *wlr_renderer,
return true;
}
-static void vulkan_begin(struct wlr_renderer *wlr_renderer,
+static bool vulkan_begin(struct wlr_renderer *wlr_renderer,
uint32_t width, uint32_t height) {
struct wlr_vk_renderer *renderer = vulkan_get_renderer(wlr_renderer);
assert(renderer->current_render_buffer);
struct wlr_vk_command_buffer *cb = acquire_command_buffer(renderer);
if (cb == NULL) {
- return;
+ return false;
}
assert(renderer->current_command_buffer == NULL);
@@ -707,7 +707,11 @@ static void vulkan_begin(struct wlr_renderer *wlr_renderer,
VkCommandBufferBeginInfo begin_info = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
};
- vkBeginCommandBuffer(cb->vk, &begin_info);
+ VkResult res = vkBeginCommandBuffer(cb->vk, &begin_info);
+ if (res != VK_SUCCESS) {
+ wlr_vk_error("vkBeginCommandBuffer", res);
+ return false;
+ }
// begin render pass
VkFramebuffer fb = renderer->current_render_buffer->framebuffer;
@@ -737,6 +741,8 @@ static void vulkan_begin(struct wlr_renderer *wlr_renderer,
renderer->render_width = width;
renderer->render_height = height;
renderer->bound_pipe = VK_NULL_HANDLE;
+
+ return true;
}
static void vulkan_end(struct wlr_renderer *wlr_renderer) {