Skip to content

Commit 273ded5

Browse files
committed
xapp-gpu-offload-helper: Remove XAppGpuInfo.is_discrete member.
This is only used when getting a list of gpus, and isn't useful to the end user. This also would require package updates and rebuilds everywhere as the GpuInfo size had changed in the header file.
1 parent 10b4a7c commit 273ded5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

libxapp/xapp-gpu-offload-helper.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct _XAppGpuOffloadHelper
114114

115115
GMutex gpu_infos_mutex;
116116
GList *gpu_infos; // XAppGpuInfos
117+
GHashTable *discrete_infos;
117118

118119
gboolean ready;
119120

@@ -136,6 +137,7 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
136137
{
137138
GVariant *gpus;
138139
GList *infos = NULL;
140+
GHashTable *discrete_infos = g_hash_table_new (g_direct_hash, g_direct_equal);
139141
gint num_children, i;
140142
gboolean default_found = FALSE;
141143

@@ -195,9 +197,12 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
195197
info->display_name = g_strdup (name);
196198
info->env_strv = g_strdupv ((gchar **) env_strv);
197199
info->is_default = is_default;
198-
info->is_discrete = is_discrete;
199200

200201
infos = g_list_append (infos, info);
202+
if (is_discrete)
203+
{
204+
g_hash_table_add (discrete_infos, info);
205+
}
201206
}
202207

203208
if (infos == NULL)
@@ -221,6 +226,7 @@ process_gpus_property (XAppGpuOffloadHelper *helper,
221226
g_list_free_full (helper->gpu_infos, (GDestroyNotify) xapp_gpu_info_free);
222227
helper->gpu_infos = infos;
223228
helper->num_gpus = g_list_length (helper->gpu_infos);
229+
helper->discrete_infos = discrete_infos;
224230

225231
g_mutex_unlock (&helper->gpu_infos_mutex);
226232
}
@@ -440,6 +446,7 @@ xapp_gpu_offload_helper_dispose (GObject *object)
440446
helper->gpu_infos = NULL;
441447
}
442448

449+
g_clear_pointer (&helper->discrete_infos, g_hash_table_unref);
443450
g_clear_object (&helper->cancellable);
444451
g_clear_object (&helper->control);
445452

@@ -639,7 +646,7 @@ xapp_gpu_offload_helper_get_offload_infos (XAppGpuOffloadHelper *helper)
639646
if (!info->is_default)
640647
continue;
641648

642-
if (info->is_discrete)
649+
if (g_hash_table_contains (helper->discrete_infos, info))
643650
retval = g_list_append (retval, info);
644651
break;
645652
}
@@ -649,7 +656,7 @@ xapp_gpu_offload_helper_get_offload_infos (XAppGpuOffloadHelper *helper)
649656
{
650657
XAppGpuInfo *info = l->data;
651658

652-
if (!info->is_discrete)
659+
if (!g_hash_table_contains (helper->discrete_infos, info))
653660
continue;
654661

655662
retval = g_list_append (retval, info);

libxapp/xapp-gpu-offload-helper.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ GType xapp_gpu_info_get_type (void) G_GNUC_CONST;
1919
* @is_default: Whether this GPU is used by default.
2020
* @display_name: User-visible name of the GPU.
2121
* @env_strv: (array zero-terminated=1): A string array containing alternating environment variables names and values to use to enable the gpu.
22-
* @is_discrete: Whether this GPU is a discrete GPU.
2322
*
2423
* Information about a single GPU used for offloading. The length of @env_strv will always be an even number.
2524
*/
@@ -29,7 +28,6 @@ struct _XAppGpuInfo
2928
gboolean is_default;
3029
gchar *display_name;
3130
gchar **env_strv;
32-
gboolean is_discrete;
3331
};
3432

3533
XAppGpuOffloadHelper *xapp_gpu_offload_helper_get (void);

0 commit comments

Comments
 (0)