Merge branch 'wip/otte/for-main' into 'main'

gpu: Don't crash when there's no ops

Closes #6992

See merge request GNOME/gtk!7710
This commit is contained in:
Matthias Clasen 2024-09-12 00:27:29 +00:00
commit bdee95c32c
9 changed files with 42 additions and 18 deletions

View File

@ -473,9 +473,8 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
res = GDK_VK_CHECK (vkCreateSwapchainKHR, device,
&(VkSwapchainCreateInfoKHR) {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.flags =
(gdk_vulkan_context_has_feature (context, GDK_VULKAN_FEATURE_SWAPCHAIN_MAINTENANCE) ?
VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT : 0),
.pNext = NULL,
.flags = 0,
.surface = priv->surface,
.minImageCount = CLAMP (4,
capabilities.minImageCount,

View File

@ -309,13 +309,27 @@ gsk_gpu_clip_get_shader_clip (const GskGpuClip *self,
const graphene_point_t *offset,
const graphene_rect_t *rect)
{
if (self->type == GSK_GPU_CLIP_NONE ||
self->type == GSK_GPU_CLIP_CONTAINED ||
gsk_gpu_clip_contains_rect (self, offset, rect))
return GSK_GPU_SHADER_CLIP_NONE;
else if (self->type == GSK_GPU_CLIP_RECT)
return GSK_GPU_SHADER_CLIP_RECT;
else
return GSK_GPU_SHADER_CLIP_ROUNDED;
switch (self->type)
{
case GSK_GPU_CLIP_NONE:
case GSK_GPU_CLIP_CONTAINED:
return GSK_GPU_SHADER_CLIP_NONE;
case GSK_GPU_CLIP_RECT:
if (gsk_gpu_clip_contains_rect (self, offset, rect))
return GSK_GPU_SHADER_CLIP_NONE;
else
return GSK_GPU_SHADER_CLIP_RECT;
case GSK_GPU_CLIP_ROUNDED:
if (gsk_gpu_clip_contains_rect (self, offset, rect))
return GSK_GPU_SHADER_CLIP_NONE;
else
return GSK_GPU_SHADER_CLIP_ROUNDED;
case GSK_GPU_CLIP_ALL_CLIPPED:
default:
g_return_val_if_reached (GSK_GPU_SHADER_CLIP_NONE);
}
}

View File

@ -30,8 +30,6 @@ typedef enum {
GSK_GPU_CLIP_ROUNDED
} GskGpuClipComplexity;
typedef struct _GskGpuClip GskGpuClip;
struct _GskGpuClip
{
GskGpuClipComplexity type;

View File

@ -74,6 +74,7 @@ gsk_gpu_frame_default_cleanup (GskGpuFrame *self)
}
gsk_gpu_ops_set_size (&priv->ops, 0);
priv->first_op = NULL;
priv->last_op = NULL;
}
@ -283,6 +284,9 @@ gsk_gpu_frame_seal_ops (GskGpuFrame *self)
GskGpuOp *last, *op;
gsize i;
if (gsk_gpu_ops_get_size (&priv->ops) == 0)
return;
priv->first_op = (GskGpuOp *) gsk_gpu_ops_index (&priv->ops, 0);
last = priv->first_op;

View File

@ -15,14 +15,21 @@ gsk_gpu_print_indent (GString *string,
void
gsk_gpu_print_shader_flags (GString *string,
GskGpuShaderFlags flags)
GskGpuShaderFlags flags,
gboolean first)
{
GskGpuShaderClip clip = gsk_gpu_shader_flags_get_clip (flags);
g_string_append (string, first ? "+ " : "| ");
#if 0
g_string_append (string, first ? (last ? "" : "")
: (last ? "" : ""));
#endif
switch (clip)
{
case GSK_GPU_SHADER_CLIP_NONE:
g_string_append (string, "🞨 ");
g_string_append (string, " ");
break;
case GSK_GPU_SHADER_CLIP_RECT:
g_string_append (string, "");

View File

@ -18,7 +18,8 @@ void gsk_gpu_print_newline (GString
void gsk_gpu_print_string (GString *string,
const char *s);
void gsk_gpu_print_shader_flags (GString *string,
GskGpuShaderFlags flags);
GskGpuShaderFlags flags,
gboolean first);
void gsk_gpu_print_color_states (GString *string,
GskGpuColorStates color_states);
void gsk_gpu_print_enum (GString *string,

View File

@ -52,7 +52,7 @@ gsk_gpu_shader_op_print (GskGpuOp *op,
for (i = 0; i < self->n_ops; i++)
{
gsk_gpu_print_op (string, indent, shader_name);
gsk_gpu_print_shader_flags (string, self->flags);
gsk_gpu_print_shader_flags (string, self->flags, i == 0);
gsk_gpu_print_color_states (string, self->color_states);
shader_class->print_instance (self,
instance + i * shader_class->vertex_size,

View File

@ -7,6 +7,7 @@
typedef struct _GskGpuBuffer GskGpuBuffer;
typedef struct _GskGpuCache GskGpuCache;
typedef struct _GskGpuClip GskGpuClip;
typedef guint32 GskGpuColorStates;
typedef struct _GskGpuDevice GskGpuDevice;
typedef struct _GskGpuFrame GskGpuFrame;

View File

@ -792,7 +792,7 @@ gtk_single_selection_get_can_unselect (GtkSingleSelection *self)
*
* Note that setting [property@Gtk.SingleSelection:autoselect] will
* cause unselecting to not work, so it practically makes no sense
* to set both at the same time the same time.
* to set both at the same time.
*/
void
gtk_single_selection_set_can_unselect (GtkSingleSelection *self,