From 676cd1e673e906858a724258f8b37467a7705cea Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 21:21:39 -0400 Subject: [PATCH 1/6] tests: Stop copying the tool tests No point in doing that, and the meson feature we are using here is deprecated. --- testsuite/tools/meson.build | 8 ++------ testsuite/tools/{settings.in => settings} | 0 testsuite/tools/{simplify.in => simplify} | 0 testsuite/tools/{simplify-3to4.in => simplify-3to4} | 0 testsuite/tools/{validate.in => validate} | 0 5 files changed, 2 insertions(+), 6 deletions(-) rename testsuite/tools/{settings.in => settings} (100%) rename testsuite/tools/{simplify.in => simplify} (100%) rename testsuite/tools/{simplify-3to4.in => simplify-3to4} (100%) rename testsuite/tools/{validate.in => validate} (100%) diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build index 986c2d6dcc..96ac7fda06 100644 --- a/testsuite/tools/meson.build +++ b/testsuite/tools/meson.build @@ -3,12 +3,8 @@ if bash.found() test_env = environment() foreach t : ['simplify', 'simplify-3to4', 'validate', 'settings'] - configure_file(output: t, - input: '@0@.in'.format(t), - copy: true, - ) - test(t, bash, - args: t, + test(t, + find_program(t, dirs: meson.current_source_dir()), workdir: meson.current_build_dir(), protocol: 'tap', env: [ diff --git a/testsuite/tools/settings.in b/testsuite/tools/settings similarity index 100% rename from testsuite/tools/settings.in rename to testsuite/tools/settings diff --git a/testsuite/tools/simplify.in b/testsuite/tools/simplify similarity index 100% rename from testsuite/tools/simplify.in rename to testsuite/tools/simplify diff --git a/testsuite/tools/simplify-3to4.in b/testsuite/tools/simplify-3to4 similarity index 100% rename from testsuite/tools/simplify-3to4.in rename to testsuite/tools/simplify-3to4 diff --git a/testsuite/tools/validate.in b/testsuite/tools/validate similarity index 100% rename from testsuite/tools/validate.in rename to testsuite/tools/validate From 27368a418ad4ac8ecafbaa51db18531a5e5c160a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 21:33:21 -0400 Subject: [PATCH 2/6] build: Require meson 0.63 This is needed for option deprecation. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 825b9c629d..a7db954f7f 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,7 @@ project('gtk', 'c', # https://github.com/mesonbuild/meson/issues/2289 'c_std=gnu99', ], - meson_version : '>= 0.60.0', + meson_version : '>= 0.63.0', license: 'LGPL-2.1-or-later') # keep these numbers in sync with wrap files where there exist From 5fbeea38708f13bd8e02a81f3c4dde64fd5d5c24 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 21:28:52 -0400 Subject: [PATCH 3/6] build: Deprecate an option Rename the demos option to build-demos, to match the other options for building optional parts. --- meson.build | 6 +++--- meson_options.txt | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index a7db954f7f..a46257faa6 100644 --- a/meson.build +++ b/meson.build @@ -753,7 +753,7 @@ subdir('gdk') subdir('gsk') subdir('gtk') subdir('modules') -if get_option('demos') +if get_option('build-demos') subdir('demos') endif subdir('tools') @@ -860,7 +860,7 @@ if not meson.is_cross_build() gnome.post_install( glib_compile_schemas: true, gio_querymodules: gio_module_dirs, - gtk_update_icon_cache: get_option('demos'), + gtk_update_icon_cache: get_option('build-demos'), ) else message('Not executing post-install steps automatically when cross compiling') @@ -901,7 +901,7 @@ summary('Documentation', get_option('gtk_doc'), section: 'Build') summary('Man pages', get_option('man-pages'), section: 'Build') summary('Testsuite', get_option('build-testsuite'), section: 'Build') summary('Tests', get_option('build-tests'), section: 'Build') -summary('Demos', get_option('demos'), section: 'Build') +summary('Demos', get_option('build-demos'), section: 'Build') summary('Examples', get_option('build-examples'), section: 'Build') # Directories diff --git a/meson_options.txt b/meson_options.txt index 9f608e9e35..1526a351bc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -108,17 +108,22 @@ option('introspection', # Demos, examples and tests -option('demos', - type: 'boolean', - value: true, - description : 'Build demo programs') - option('profile', type: 'combo', choices: [ 'default', 'devel' ], value: 'default', description : 'Profile to use for demos') +option('build-demos', + type: 'boolean', + value: true, + description : 'Build demo programs') + +option('demos', + type: 'boolean', + value: true, + deprecated: 'build-demos') + option('build-testsuite', type: 'boolean', value: true, From ba6a618d44720cfaca7d80cad77431ac756a8b2f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 21:39:20 -0400 Subject: [PATCH 4/6] build: Rename another option --- build-aux/flatpak/org.gtk.Demo4.json | 2 +- build-aux/flatpak/org.gtk.IconBrowser4.json | 2 +- build-aux/flatpak/org.gtk.WidgetFactory4.json | 2 +- build-aux/flatpak/org.gtk.gtk4.NodeEditor.json | 2 +- demos/meson.build | 2 +- meson_options.txt | 8 +++++++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build-aux/flatpak/org.gtk.Demo4.json b/build-aux/flatpak/org.gtk.Demo4.json index 457dfd64b8..5c75ece589 100644 --- a/build-aux/flatpak/org.gtk.Demo4.json +++ b/build-aux/flatpak/org.gtk.Demo4.json @@ -187,7 +187,7 @@ "--libdir=/app/lib", "-Dvulkan=disabled", "-Dbuildtype=debugoptimized", - "-Dprofile=devel" + "-Ddemo-profile=devel" ], "sources" : [ { diff --git a/build-aux/flatpak/org.gtk.IconBrowser4.json b/build-aux/flatpak/org.gtk.IconBrowser4.json index 00cdf9f110..b563dbb285 100644 --- a/build-aux/flatpak/org.gtk.IconBrowser4.json +++ b/build-aux/flatpak/org.gtk.IconBrowser4.json @@ -116,7 +116,7 @@ "--libdir=/app/lib", "-Dvulkan=disabled", "-Dbuildtype=debugoptimized", - "-Dprofile=devel" + "-Ddemo-profile=devel" ], "sources" : [ { diff --git a/build-aux/flatpak/org.gtk.WidgetFactory4.json b/build-aux/flatpak/org.gtk.WidgetFactory4.json index cdca2010ee..390da50cac 100644 --- a/build-aux/flatpak/org.gtk.WidgetFactory4.json +++ b/build-aux/flatpak/org.gtk.WidgetFactory4.json @@ -116,7 +116,7 @@ "--libdir=/app/lib", "-Dvulkan=disabled", "-Dbuildtype=debugoptimized", - "-Dprofile=devel" + "-Ddemo-profile=devel" ], "sources" : [ { diff --git a/build-aux/flatpak/org.gtk.gtk4.NodeEditor.json b/build-aux/flatpak/org.gtk.gtk4.NodeEditor.json index bff6b20be3..ef60c66084 100644 --- a/build-aux/flatpak/org.gtk.gtk4.NodeEditor.json +++ b/build-aux/flatpak/org.gtk.gtk4.NodeEditor.json @@ -116,7 +116,7 @@ "--libdir=/app/lib", "-Dvulkan=disabled", "-Dbuildtype=debugoptimized", - "-Dprofile=devel" + "-Ddemo-profile=devel" ], "sources" : [ { diff --git a/demos/meson.build b/demos/meson.build index 91eb3c465c..d4c04d2b8b 100644 --- a/demos/meson.build +++ b/demos/meson.build @@ -1,5 +1,5 @@ gen_demo_header = find_program('../build-aux/meson/gen-demo-header.py') -demo_profile = get_option('profile') +demo_profile = get_option('demo-profile') demo_conf_h = declare_dependency( sources: custom_target('demo-header', diff --git a/meson_options.txt b/meson_options.txt index 1526a351bc..f4399d39df 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -108,7 +108,7 @@ option('introspection', # Demos, examples and tests -option('profile', +option('demo-profile', type: 'combo', choices: [ 'default', 'devel' ], value: 'default', @@ -119,6 +119,12 @@ option('build-demos', value: true, description : 'Build demo programs') +option('profile', + type: 'combo', + choices: [ 'default', 'devel' ], + value: 'default', + deprecated: 'demo-profile') + option('demos', type: 'boolean', value: true, From 5c10f2b4cda25d3c6897216856298cdeca66eb6a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 23:02:30 -0400 Subject: [PATCH 5/6] Improve coverage for half-float fallbacks --- testsuite/gsk/half-float.c | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/testsuite/gsk/half-float.c b/testsuite/gsk/half-float.c index 5f74072a84..3b06d7df22 100644 --- a/testsuite/gsk/half-float.c +++ b/testsuite/gsk/half-float.c @@ -32,6 +32,36 @@ test_constants (void) } } +static void +test_constants_c (void) +{ + struct { + float f; + guint16 h; + } tests[] = { + { 0.0, FP16_ZERO }, + { 1.0, FP16_ONE }, + { -1.0, FP16_MINUS_ONE }, + }; + + for (int i = 0; i < G_N_ELEMENTS (tests); i++) + { + float f[4]; + guint16 h[4]; + + memset (f, 0, sizeof (f)); + f[0] = tests[i].f; + float_to_half4_c (f, h); + g_assert_cmpuint (h[0], ==, tests[i].h); + + + memset (h, 0, sizeof (h)); + h[0] = tests[i].h; + half_to_float4_c (h, f); + g_assert_cmpfloat (f[0], ==, tests[i].f); + } +} + static float random_representable_float (void) { @@ -69,6 +99,26 @@ test_roundtrip (void) } } +static void +test_roundtrip_c (void) +{ + for (int i = 0; i < 100; i++) + { + float f[4]; + float f2[4]; + guint16 h[4]; + + f2[0] = random_representable_float (); + memset (f, 0, sizeof (f)); + f[0] = f2[0]; + + float_to_half4_c (f, h); + half_to_float4_c (h, f2); + + g_assert_cmpfloat (f[0], ==, f2[0]); + } +} + /* Test that the array version work as expected, * in particular with unaligned boundaries. */ @@ -95,6 +145,29 @@ test_many (void) } } +static void +test_many_c (void) +{ + for (int i = 0; i < 100; i++) + { + int size = g_random_int_range (100, 200); + int offset = g_random_int_range (0, 20); + + guint16 *h = g_new0 (guint16, size); + float *f = g_new0 (float, size); + float *f2 = g_new0 (float, size); + + for (int j = offset; j < size; j++) + f[j] = random_representable_float (); + + float_to_half_c (f + offset, h + offset, size - offset); + half_to_float_c (h + offset, f2 + offset, size - offset); + + for (int j = offset; j < size; j++) + g_assert_cmpfloat (f[j], ==, f2[j]); + } +} + int main (int argc, char *argv[]) { @@ -103,6 +176,9 @@ main (int argc, char *argv[]) g_test_add_func ("/half-float/constants", test_constants); g_test_add_func ("/half-float/roundtrip", test_roundtrip); g_test_add_func ("/half-float/many", test_many); + g_test_add_func ("/half-float/constants/c", test_constants_c); + g_test_add_func ("/half-float/roundtrip/c", test_roundtrip_c); + g_test_add_func ("/half-float/many/c", test_many_c); return g_test_run (); } From 9a9257d7be38e7378ecb1766437d1a47acbb8d18 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 9 May 2023 23:02:48 -0400 Subject: [PATCH 6/6] tests: Don't disable vertex arrays It doesn't work, and that makes tests fail. --- testsuite/meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/meson.build b/testsuite/meson.build index b300823339..8650e918e7 100644 --- a/testsuite/meson.build +++ b/testsuite/meson.build @@ -19,7 +19,6 @@ setups = [ 'backend': 'wayland', 'if': wayland_enabled, 'env': ['GDK_DEBUG=gl-gles,default-settings', 'MESA_GLES_VERSION_OVERRIDE=2.0', - 'MESA_EXTENSION_OVERRIDE=-GL_OES_vertex_array_object', 'GSK_MAX_TEXTURE_SIZE=1024', ], }, { 'backend': 'win32', 'if': os_win32 },