[gtk+/wip/otte/shader: 92/101] gskslvariable: Make creating the access chain a vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 92/101] gskslvariable: Make creating the access chain a vfunc
- Date: Fri, 27 Oct 2017 12:29:55 +0000 (UTC)
commit 6d84cbc264f591e43d63ac0732448b1fcff1b485
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 24 22:11:35 2017 +0200
gskslvariable: Make creating the access chain a vfunc
This just shuffles code around (so the vfunc can either return NULL or
create an access chain), but will be useful later.
gsk/gskslvariable.c | 123 +++++++++++++++++++--------------------------------
1 files changed, 45 insertions(+), 78 deletions(-)
---
diff --git a/gsk/gskslvariable.c b/gsk/gskslvariable.c
index dbd13c4..3a91757 100644
--- a/gsk/gskslvariable.c
+++ b/gsk/gskslvariable.c
@@ -46,7 +46,8 @@ struct _GskSlVariableClass
void (* free) (GskSlVariable *variable);
GskSlValue * (* get_initial_value) (const GskSlVariable *variable);
- gboolean (* is_direct_access_spv) (const GskSlVariable *variable);
+ GskSpvAccessChain * (* get_access_chain) (GskSlVariable *variable,
+ GskSpvWriter *writer);
guint32 (* write_spv) (const GskSlVariable *variable,
GskSpvWriter *writer);
guint32 (* load_spv) (GskSlVariable *variable,
@@ -88,6 +89,34 @@ gsk_sl_variable_default_get_initial_value (const GskSlVariable *variable)
return NULL;
}
+static GskSpvAccessChain *
+gsk_spv_access_chain_new (GskSlVariable *variable,
+ GskSpvWriter *writer);
+
+static GskSpvAccessChain *
+gsk_sl_variable_default_get_access_chain (GskSlVariable *variable,
+ GskSpvWriter *writer)
+{
+ return gsk_spv_access_chain_new (variable, writer);
+}
+
+static GskSpvAccessChain *
+gsk_sl_variable_default_get_no_access_chain (GskSlVariable *variable,
+ GskSpvWriter *writer)
+{
+ return NULL;
+}
+
+static guint32
+gsk_sl_variable_default_load_spv (GskSlVariable *variable,
+ GskSpvWriter *writer)
+{
+ return gsk_spv_writer_load (writer,
+ variable->type,
+ gsk_spv_writer_get_id_for_variable (writer, variable),
+ 0);
+}
+
/* STANDARD */
typedef struct _GskSlVariableStandard GskSlVariableStandard;
@@ -117,12 +146,6 @@ gsk_sl_variable_standard_get_initial_value (const GskSlVariable *variable)
return standard->initial_value;
}
-static gboolean
-gsk_sl_variable_standard_is_direct_access_spv (const GskSlVariable *variable)
-{
- return TRUE;
-}
-
static guint32
gsk_sl_variable_standard_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
@@ -155,23 +178,13 @@ gsk_sl_variable_standard_write_spv (const GskSlVariable *variable,
return result_id;
}
-static guint32
-gsk_sl_variable_standard_load_spv (GskSlVariable *variable,
- GskSpvWriter *writer)
-{
- return gsk_spv_writer_load (writer,
- gsk_sl_variable_get_type (variable),
- gsk_spv_writer_get_id_for_variable (writer, variable),
- 0);
-}
-
static const GskSlVariableClass GSK_SL_VARIABLE_STANDARD = {
sizeof (GskSlVariableStandard),
gsk_sl_variable_standard_free,
gsk_sl_variable_standard_get_initial_value,
- gsk_sl_variable_standard_is_direct_access_spv,
+ gsk_sl_variable_default_get_access_chain,
gsk_sl_variable_standard_write_spv,
- gsk_sl_variable_standard_load_spv
+ gsk_sl_variable_default_load_spv
};
/* BUILTIN */
@@ -184,12 +197,6 @@ struct _GskSlVariableBuiltin {
GskSpvBuiltIn builtin;
};
-static gboolean
-gsk_sl_variable_builtin_is_direct_access_spv (const GskSlVariable *variable)
-{
- return TRUE;
-}
-
static guint32
gsk_sl_variable_builtin_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
@@ -216,23 +223,13 @@ gsk_sl_variable_builtin_write_spv (const GskSlVariable *variable,
return result_id;
}
-static guint32
-gsk_sl_variable_builtin_load_spv (GskSlVariable *variable,
- GskSpvWriter *writer)
-{
- return gsk_spv_writer_load (writer,
- gsk_sl_variable_get_type (variable),
- gsk_spv_writer_get_id_for_variable (writer, variable),
- 0);
-}
-
static const GskSlVariableClass GSK_SL_VARIABLE_BUILTIN = {
sizeof (GskSlVariableBuiltin),
gsk_sl_variable_free,
gsk_sl_variable_default_get_initial_value,
- gsk_sl_variable_builtin_is_direct_access_spv,
+ gsk_sl_variable_default_get_access_chain,
gsk_sl_variable_builtin_write_spv,
- gsk_sl_variable_builtin_load_spv
+ gsk_sl_variable_default_load_spv
};
/* CONSTANT */
@@ -263,12 +260,6 @@ gsk_sl_variable_constant_get_initial_value (const GskSlVariable *variable)
return constant->value;
}
-static gboolean
-gsk_sl_variable_constant_is_direct_access_spv (const GskSlVariable *variable)
-{
- return FALSE;
-}
-
static guint32
gsk_sl_variable_constant_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
@@ -289,19 +280,13 @@ static const GskSlVariableClass GSK_SL_VARIABLE_CONSTANT = {
sizeof (GskSlVariableConstant),
gsk_sl_variable_constant_free,
gsk_sl_variable_constant_get_initial_value,
- gsk_sl_variable_constant_is_direct_access_spv,
+ gsk_sl_variable_default_get_no_access_chain,
gsk_sl_variable_constant_write_spv,
gsk_sl_variable_constant_load_spv
};
/* PARAMETER */
-static gboolean
-gsk_sl_variable_parameter_is_direct_access_spv (const GskSlVariable *variable)
-{
- return TRUE;
-}
-
static guint32
gsk_sl_variable_parameter_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
@@ -318,33 +303,17 @@ gsk_sl_variable_parameter_write_spv (const GskSlVariable *variable,
return result_id;
}
-static guint32
-gsk_sl_variable_parameter_load_spv (GskSlVariable *variable,
- GskSpvWriter *writer)
-{
- return gsk_spv_writer_load (writer,
- gsk_sl_variable_get_type (variable),
- gsk_spv_writer_get_id_for_variable (writer, variable),
- 0);
-}
-
static const GskSlVariableClass GSK_SL_VARIABLE_PARAMETER = {
sizeof (GskSlVariable),
gsk_sl_variable_free,
gsk_sl_variable_default_get_initial_value,
- gsk_sl_variable_parameter_is_direct_access_spv,
+ gsk_sl_variable_default_get_access_chain,
gsk_sl_variable_parameter_write_spv,
- gsk_sl_variable_parameter_load_spv
+ gsk_sl_variable_default_load_spv
};
/* CONST_PARAMETER */
-static gboolean
-gsk_sl_variable_const_parameter_is_direct_access_spv (const GskSlVariable *variable)
-{
- return FALSE;
-}
-
static guint32
gsk_sl_variable_const_parameter_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
@@ -370,7 +339,7 @@ static const GskSlVariableClass GSK_SL_VARIABLE_CONST_PARAMETER = {
sizeof (GskSlVariable),
gsk_sl_variable_free,
gsk_sl_variable_default_get_initial_value,
- gsk_sl_variable_const_parameter_is_direct_access_spv,
+ gsk_sl_variable_default_get_no_access_chain,
gsk_sl_variable_const_parameter_write_spv,
gsk_sl_variable_const_parameter_load_spv
};
@@ -525,10 +494,11 @@ gsk_sl_variable_is_constant (const GskSlVariable *variable)
return gsk_sl_qualifier_is_constant (&variable->qualifier);
}
-static gboolean
-gsk_sl_variable_is_direct_access_spv (const GskSlVariable *variable)
+GskSpvAccessChain *
+gsk_sl_variable_get_access_chain (GskSlVariable *variable,
+ GskSpvWriter *writer)
{
- return variable->class->is_direct_access_spv (variable);
+ return variable->class->get_access_chain (variable, writer);
}
guint32
@@ -558,15 +528,12 @@ struct _GskSpvAccessChain
guint swizzle_length;
};
-GskSpvAccessChain *
-gsk_sl_variable_get_access_chain (GskSlVariable *variable,
- GskSpvWriter *writer)
+static GskSpvAccessChain *
+gsk_spv_access_chain_new (GskSlVariable *variable,
+ GskSpvWriter *writer)
{
GskSpvAccessChain *chain;
- if (!gsk_sl_variable_is_direct_access_spv (variable))
- return NULL;
-
chain = g_slice_new0 (GskSpvAccessChain);
chain->writer = gsk_spv_writer_ref (writer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]