[gtk+/wip/otte/shader: 17/23] gskslvariable: Add load()/store() functions
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 17/23] gskslvariable: Add load()/store() functions
- Date: Tue, 10 Oct 2017 02:12:20 +0000 (UTC)
commit 9b795bb30e10be7e48674a4902154207126de403
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 10 01:18:44 2017 +0200
gskslvariable: Add load()/store() functions
This allows transitioning variables to different types. Which in the end
makes it possible to write different load/store code for parameters,
global variables or potentially GL builtins.
gsk/gskslexpression.c | 5 +----
gsk/gskslstatement.c | 7 +++----
gsk/gskslvariable.c | 23 +++++++++++++++++++++++
gsk/gskslvariableprivate.h | 5 +++++
4 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index db7b4a2..e014e1e 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -363,10 +363,7 @@ gsk_sl_expression_reference_write_spv (const GskSlExpression *expression,
{
GskSlExpressionReference *reference = (GskSlExpressionReference *) expression;
- return gsk_spv_writer_load (writer,
- gsk_sl_variable_get_type (reference->variable),
- gsk_spv_writer_get_id_for_variable (writer, reference->variable),
- 0);
+ return gsk_sl_variable_load_spv (reference->variable, writer);
}
static GskSpvAccessChain *
diff --git a/gsk/gskslstatement.c b/gsk/gskslstatement.c
index 9119592..b9d5814 100644
--- a/gsk/gskslstatement.c
+++ b/gsk/gskslstatement.c
@@ -239,10 +239,9 @@ gsk_sl_statement_declaration_write_spv (const GskSlStatement *statement,
if (declaration->initial && ! gsk_sl_variable_get_initial_value (declaration->variable))
{
- gsk_spv_writer_store (writer,
- gsk_spv_writer_get_id_for_variable (writer, declaration->variable),
- gsk_sl_expression_write_spv (declaration->initial, writer),
- 0);
+ gsk_sl_variable_store_spv (declaration->variable,
+ writer,
+ gsk_sl_expression_write_spv (declaration->initial, writer));
}
}
diff --git a/gsk/gskslvariable.c b/gsk/gskslvariable.c
index ee81141..f053a3e 100644
--- a/gsk/gskslvariable.c
+++ b/gsk/gskslvariable.c
@@ -182,3 +182,26 @@ gsk_sl_variable_write_spv (const GskSlVariable *variable,
return result_id;
}
+
+guint32
+gsk_sl_variable_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);
+}
+
+void
+gsk_sl_variable_store_spv (GskSlVariable *variable,
+ GskSpvWriter *writer,
+ guint32 value)
+{
+ gsk_spv_writer_store (writer,
+ gsk_spv_writer_get_id_for_variable (writer, variable),
+ value,
+ 0);
+
+}
+
diff --git a/gsk/gskslvariableprivate.h b/gsk/gskslvariableprivate.h
index f60b3c5..d414ad6 100644
--- a/gsk/gskslvariableprivate.h
+++ b/gsk/gskslvariableprivate.h
@@ -44,6 +44,11 @@ gboolean gsk_sl_variable_is_constant (const GskSlVari
guint32 gsk_sl_variable_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer);
+guint32 gsk_sl_variable_load_spv (GskSlVariable *variable,
+ GskSpvWriter *writer);
+void gsk_sl_variable_store_spv (GskSlVariable *variable,
+ GskSpvWriter *writer,
+ guint32 value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]