[gtk+/wip/otte/shader: 91/101] gskslvariable: Remove gsk_sl_variable_store_spv()



commit 39e815917384b12c526fef5e355005a596d2364e
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 24 18:56:17 2017 +0200

    gskslvariable: Remove gsk_sl_variable_store_spv()
    
    A bunch of variables can't be written to. Instead of assuming code just
    knows that and doesn't call store() on those, force storing to use
    access chains. In that case, a NULL access chain should make it kinda
    obvious that storing won't work.

 gsk/gsksldeclaration.c     |   13 ++++---
 gsk/gskslstatement.c       |   13 ++++---
 gsk/gskslvariable.c        |   78 +++-----------------------------------------
 gsk/gskslvariableprivate.h |    3 --
 4 files changed, 21 insertions(+), 86 deletions(-)
---
diff --git a/gsk/gsksldeclaration.c b/gsk/gsksldeclaration.c
index 0e80659..a8f785a 100644
--- a/gsk/gsksldeclaration.c
+++ b/gsk/gsksldeclaration.c
@@ -112,11 +112,14 @@ gsk_sl_declaration_variable_write_initializer_spv (const GskSlDeclaration *decla
 
   if (variable->initial && ! gsk_sl_variable_get_initial_value (variable->variable))
     {
-      gsk_sl_variable_store_spv (variable->variable,
-                                 writer,
-                                 gsk_sl_expression_write_spv (variable->initial,
-                                                              writer,
-                                                              gsk_sl_variable_get_type 
(variable->variable)));
+      GskSpvAccessChain *chain = gsk_sl_variable_get_access_chain (variable->variable, writer);
+
+      g_assert (chain); /* code further up should make sure this never happens */
+      gsk_spv_access_chain_store (chain, 
+                                  gsk_sl_expression_write_spv (variable->initial,
+                                                               writer,
+                                                               gsk_sl_variable_get_type 
(variable->variable)));
+      gsk_spv_access_chain_free (chain);
     }
 }
 
diff --git a/gsk/gskslstatement.c b/gsk/gskslstatement.c
index cdb1b5d..1b2547b 100644
--- a/gsk/gskslstatement.c
+++ b/gsk/gskslstatement.c
@@ -247,11 +247,14 @@ gsk_sl_statement_declaration_write_spv (const GskSlStatement *statement,
 
   if (declaration->initial && ! gsk_sl_variable_get_initial_value (declaration->variable))
     {
-      gsk_sl_variable_store_spv (declaration->variable,
-                                 writer,
-                                 gsk_sl_expression_write_spv (declaration->initial,
-                                                              writer,
-                                                              gsk_sl_variable_get_type 
(declaration->variable)));
+      GskSpvAccessChain *chain = gsk_sl_variable_get_access_chain (declaration->variable, writer);
+
+      g_assert (chain); /* code further up should make sure this never happens */
+      gsk_spv_access_chain_store (chain, 
+                                  gsk_sl_expression_write_spv (declaration->initial,
+                                                               writer,
+                                                               gsk_sl_variable_get_type 
(declaration->variable)));
+      gsk_spv_access_chain_free (chain);
     }
 
   return FALSE;
diff --git a/gsk/gskslvariable.c b/gsk/gskslvariable.c
index 6349f98..dbd13c4 100644
--- a/gsk/gskslvariable.c
+++ b/gsk/gskslvariable.c
@@ -51,9 +51,6 @@ struct _GskSlVariableClass
                                                                  GskSpvWriter           *writer);
   guint32               (* load_spv)                            (GskSlVariable          *variable,
                                                                  GskSpvWriter           *writer);
-  void                  (* store_spv)                           (GskSlVariable          *variable,
-                                                                 GskSpvWriter           *writer,
-                                                                 guint32                 value);
 };
 
 static gpointer
@@ -168,26 +165,13 @@ gsk_sl_variable_standard_load_spv (GskSlVariable *variable,
                               0);
 }
 
-static void
-gsk_sl_variable_standard_store_spv (GskSlVariable *variable,
-                                    GskSpvWriter  *writer,
-                                    guint32        value)
-{
-  gsk_spv_writer_store (writer,
-                        gsk_spv_writer_get_id_for_variable (writer, variable),
-                        value,
-                        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_standard_write_spv,
-  gsk_sl_variable_standard_load_spv,
-  gsk_sl_variable_standard_store_spv,
+  gsk_sl_variable_standard_load_spv
 };
 
 /* BUILTIN */
@@ -242,26 +226,13 @@ gsk_sl_variable_builtin_load_spv (GskSlVariable *variable,
                               0);
 }
 
-static void
-gsk_sl_variable_builtin_store_spv (GskSlVariable *variable,
-                                    GskSpvWriter  *writer,
-                                    guint32        value)
-{
-  gsk_spv_writer_store (writer,
-                        gsk_spv_writer_get_id_for_variable (writer, variable),
-                        value,
-                        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_builtin_write_spv,
-  gsk_sl_variable_builtin_load_spv,
-  gsk_sl_variable_builtin_store_spv,
+  gsk_sl_variable_builtin_load_spv
 };
 
 /* CONSTANT */
@@ -314,22 +285,13 @@ gsk_sl_variable_constant_load_spv (GskSlVariable *variable,
   return gsk_spv_writer_get_id_for_value (writer, constant->value);
 }
 
-static void
-gsk_sl_variable_constant_store_spv (GskSlVariable *variable,
-                                    GskSpvWriter  *writer,
-                                    guint32        value)
-{
-  g_assert_not_reached ();
-}
-
 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_constant_write_spv,
-  gsk_sl_variable_constant_load_spv,
-  gsk_sl_variable_constant_store_spv,
+  gsk_sl_variable_constant_load_spv
 };
 
 /* PARAMETER */
@@ -366,26 +328,13 @@ gsk_sl_variable_parameter_load_spv (GskSlVariable *variable,
                               0);
 }
 
-static void
-gsk_sl_variable_parameter_store_spv (GskSlVariable *variable,
-                                     GskSpvWriter  *writer,
-                                     guint32        value)
-{
-  gsk_spv_writer_store (writer,
-                        gsk_spv_writer_get_id_for_variable (writer, variable),
-                        value,
-                        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_parameter_write_spv,
-  gsk_sl_variable_parameter_load_spv,
-  gsk_sl_variable_parameter_store_spv,
+  gsk_sl_variable_parameter_load_spv
 };
 
 /* CONST_PARAMETER */
@@ -417,22 +366,13 @@ gsk_sl_variable_const_parameter_load_spv (GskSlVariable *variable,
   return gsk_spv_writer_get_id_for_variable (writer, variable);
 }
 
-static void
-gsk_sl_variable_const_parameter_store_spv (GskSlVariable *variable,
-                                           GskSpvWriter  *writer,
-                                           guint32        value)
-{
-  g_assert_not_reached ();
-}
-
 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_const_parameter_write_spv,
-  gsk_sl_variable_const_parameter_load_spv,
-  gsk_sl_variable_const_parameter_store_spv,
+  gsk_sl_variable_const_parameter_load_spv
 };
 
 /* API */
@@ -605,14 +545,6 @@ gsk_sl_variable_load_spv (GskSlVariable *variable,
   return variable->class->load_spv (variable, writer);
 }
 
-void
-gsk_sl_variable_store_spv (GskSlVariable *variable,
-                           GskSpvWriter  *writer,
-                           guint32        value)
-{
-  variable->class->store_spv (variable, writer, value);
-}
-
 /* ACCESS CHAIN */
 
 struct _GskSpvAccessChain
diff --git a/gsk/gskslvariableprivate.h b/gsk/gskslvariableprivate.h
index cf38c2b..da3592c 100644
--- a/gsk/gskslvariableprivate.h
+++ b/gsk/gskslvariableprivate.h
@@ -54,9 +54,6 @@ guint32                 gsk_sl_variable_write_spv               (const GskSlVari
                                                                  GskSpvWriter           *writer);
 guint32                 gsk_sl_variable_load_spv                (GskSlVariable          *variable,
                                                                  GskSpvWriter           *writer);
-void                    gsk_sl_variable_store_spv               (GskSlVariable          *variable,
-                                                                 GskSpvWriter           *writer,
-                                                                 guint32                 value);
 
 void                    gsk_spv_access_chain_free               (GskSpvAccessChain      *chain);
 void                    gsk_spv_access_chain_add_index          (GskSpvAccessChain      *chain,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]