Merge branch 'wip/otte/for-main' into 'main'
vulkan: Handle generating mipmaps for 1x1 images Closes #6553 See merge request GNOME/gtk!7073
This commit is contained in:
@@ -456,43 +456,33 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
|
||||
{
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GdkFrameClock *frame_clock;
|
||||
GdkFrameTimings *start, *end;
|
||||
gint64 start_counter, end_counter;
|
||||
gint64 n_frames, expected_frames;
|
||||
gint64 start_timestamp, end_timestamp;
|
||||
GdkFrameTimings *end;
|
||||
gint64 end_counter;
|
||||
double fps, expected_fps;
|
||||
gint64 interval;
|
||||
|
||||
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (fishbowl));
|
||||
if (frame_clock == NULL)
|
||||
return;
|
||||
|
||||
start_counter = gdk_frame_clock_get_history_start (frame_clock);
|
||||
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
|
||||
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
|
||||
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
|
||||
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
|
||||
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
|
||||
end_counter--;
|
||||
if (end_counter - start_counter < 4)
|
||||
fps = gdk_frame_clock_get_fps (frame_clock);
|
||||
if (fps <= 0.0)
|
||||
return;
|
||||
|
||||
start_timestamp = gdk_frame_timings_get_presentation_time (start);
|
||||
end_timestamp = gdk_frame_timings_get_presentation_time (end);
|
||||
if (start_timestamp == 0 || end_timestamp == 0)
|
||||
{
|
||||
start_timestamp = gdk_frame_timings_get_frame_time (start);
|
||||
end_timestamp = gdk_frame_timings_get_frame_time (end);
|
||||
}
|
||||
|
||||
n_frames = end_counter - start_counter;
|
||||
priv->framerate = ((double) n_frames) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
|
||||
priv->framerate = ((int)(priv->framerate * 100))/100.0;
|
||||
|
||||
priv->framerate = fps;
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
|
||||
|
||||
if (!priv->benchmark)
|
||||
return;
|
||||
|
||||
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
|
||||
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
|
||||
end != NULL && !gdk_frame_timings_get_complete (end);
|
||||
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
|
||||
end_counter--;
|
||||
if (end == NULL)
|
||||
return;
|
||||
|
||||
interval = gdk_frame_timings_get_refresh_interval (end);
|
||||
if (interval == 0)
|
||||
{
|
||||
@@ -500,16 +490,16 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
|
||||
if (interval == 0)
|
||||
return;
|
||||
}
|
||||
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
|
||||
expected_fps = (double) G_USEC_PER_SEC / interval;
|
||||
|
||||
if (n_frames >= expected_frames)
|
||||
if (fps > (expected_fps - 1))
|
||||
{
|
||||
if (priv->last_benchmark_change > 0)
|
||||
priv->last_benchmark_change *= 2;
|
||||
else
|
||||
priv->last_benchmark_change = 1;
|
||||
}
|
||||
else if (n_frames + 1 < expected_frames)
|
||||
else if (0.95 * fps < expected_fps)
|
||||
{
|
||||
if (priv->last_benchmark_change < 0)
|
||||
priv->last_benchmark_change--;
|
||||
|
||||
@@ -2077,6 +2077,8 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
/* now intersect with actual node bounds */
|
||||
if (!gsk_rect_intersection (&clip_bounds, &node->bounds, &clip_bounds))
|
||||
return;
|
||||
clip_bounds.size.width = ceilf (clip_bounds.size.width);
|
||||
clip_bounds.size.height = ceilf (clip_bounds.size.height);
|
||||
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
|
||||
graphene_vec2_one (),
|
||||
&clip_bounds,
|
||||
|
||||
@@ -245,7 +245,9 @@ gsk_gpu_render_pass_end_op_vk_command (GskGpuOp *op,
|
||||
|
||||
vkCmdEndRenderPass (state->vk_command_buffer);
|
||||
|
||||
if (gsk_gpu_image_get_flags (self->target) & GSK_GPU_IMAGE_CAN_MIPMAP)
|
||||
if ((gsk_gpu_image_get_flags (self->target) & GSK_GPU_IMAGE_CAN_MIPMAP) &&
|
||||
(gsk_gpu_image_get_width (self->target) > 1 ||
|
||||
gsk_gpu_image_get_height (self->target) > 1))
|
||||
{
|
||||
vkCmdPipelineBarrier (state->vk_command_buffer,
|
||||
gsk_vulkan_image_get_vk_pipeline_stage (GSK_VULKAN_IMAGE (self->target)),
|
||||
|
||||
@@ -71,7 +71,7 @@ static inline guint
|
||||
gsk_vulkan_mipmap_levels (gsize width,
|
||||
gsize height)
|
||||
{
|
||||
return g_bit_nth_msf (MAX (width, height) - 1, -1) + 1;
|
||||
return g_bit_nth_msf (MAX (MAX (width, height) - 1, 1), -1) + 1;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
7
testsuite/gsk/compare/mipmap-with-1x1.node
Normal file
7
testsuite/gsk/compare/mipmap-with-1x1.node
Normal file
@@ -0,0 +1,7 @@
|
||||
texture-scale {
|
||||
bounds: 0 0 10 10;
|
||||
filter: trilinear;
|
||||
texture: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWP4z8DwHwAFAAH/q842\
|
||||
iQAAAABJRU5ErkJggg==\
|
||||
");
|
||||
}
|
||||
BIN
testsuite/gsk/compare/mipmap-with-1x1.png
Normal file
BIN
testsuite/gsk/compare/mipmap-with-1x1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 B |
@@ -0,0 +1,14 @@
|
||||
color {
|
||||
bounds: 0 0 3 2;
|
||||
color: rgb(0,0,0);
|
||||
}
|
||||
transform {
|
||||
transform: scale(2);
|
||||
child: texture-scale {
|
||||
bounds: 0 0 1.5 1;
|
||||
filter: nearest;
|
||||
texture: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQImWNoYGAAAAGEAIGs40g+\
|
||||
AAAAAElFTkSuQmCC\
|
||||
");
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 82 B |
@@ -104,6 +104,7 @@ compare_render_tests = [
|
||||
'mask-modes-with-alpha',
|
||||
'mask-texture-color-alpha',
|
||||
'mipmap-generation-later',
|
||||
'mipmap-with-1x1',
|
||||
'nested-rounded-clips',
|
||||
'offscreen-forced-downscale',
|
||||
'offscreen-fractional-translate-nogl',
|
||||
@@ -170,6 +171,7 @@ compare_render_tests = [
|
||||
'texture-scale-filters-nocairo',
|
||||
'texture-scale-magnify-10000x',
|
||||
'texture-scale-magnify-rotate',
|
||||
'texture-scale-nearest-noninteger-scaled-nogl',
|
||||
'texture-scale-nearest-vs-linear',
|
||||
'texture-scale-offset',
|
||||
'texture-scale-stripes',
|
||||
|
||||
Reference in New Issue
Block a user