[gtk+/wip/otte/shader: 161/200] gskspv: Variables can go different places
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 161/200] gskspv: Variables can go different places
- Date: Mon, 16 Oct 2017 23:13:29 +0000 (UTC)
commit 509e8977b8c678f4ec316d21fbe08f47232180d0
Author: Benjamin Otte <otte redhat com>
Date: Sat Oct 7 23:22:09 2017 +0200
gskspv: Variables can go different places
Global variables are declared in the type definition section while local
variables are part of the function body.
gsk/gskslvariable.c | 6 +++++-
gsk/gskspvwritergeneratedprivate.h | 3 ++-
gsk/spirv.js | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskslvariable.c b/gsk/gskslvariable.c
index 356f9eb..bf5bd52 100644
--- a/gsk/gskslvariable.c
+++ b/gsk/gskslvariable.c
@@ -152,8 +152,11 @@ gsk_sl_variable_write_spv (const GskSlVariable *variable,
GskSpvWriter *writer)
{
guint32 result_id;
+ GskSlQualifierLocation location;
+
+ location = gsk_sl_qualifier_get_location (gsk_sl_pointer_type_get_qualifier (variable->type));
- if (gsk_sl_qualifier_get_location (gsk_sl_pointer_type_get_qualifier (variable->type)) ==
GSK_SL_QUALIFIER_PARAMETER)
+ if (location == GSK_SL_QUALIFIER_PARAMETER)
{
result_id = gsk_spv_writer_function_parameter (writer,
gsk_sl_pointer_type_get_type (variable->type));
@@ -168,6 +171,7 @@ gsk_sl_variable_write_spv (const GskSlVariable *variable,
value_id = 0;
result_id = gsk_spv_writer_variable (writer,
+ location == GSK_SL_QUALIFIER_GLOBAL ?
GSK_SPV_WRITER_SECTION_DEFINE : GSK_SPV_WRITER_SECTION_DECLARE,
variable->type,
gsk_sl_qualifier_get_storage_class
(gsk_sl_pointer_type_get_qualifier (variable->type)),
value_id);
diff --git a/gsk/gskspvwritergeneratedprivate.h b/gsk/gskspvwritergeneratedprivate.h
index 17ebd42..3b7262e 100644
--- a/gsk/gskspvwritergeneratedprivate.h
+++ b/gsk/gskspvwritergeneratedprivate.h
@@ -914,11 +914,12 @@ gsk_spv_writer_function_call (GskSpvWriter *writer,
static inline guint32
gsk_spv_writer_variable (GskSpvWriter *writer,
+ GskSpvWriterSection section,
GskSlPointerType * result_type,
GskSpvStorageClass storage_class,
guint32 opt_initializer)
{
- GArray *bytes = gsk_spv_writer_get_bytes (writer, GSK_SPV_WRITER_SECTION_DECLARE);
+ GArray *bytes = gsk_spv_writer_get_bytes (writer, section);
guint32 result_type_id = gsk_spv_writer_get_id_for_pointer_type (writer, result_type);
guint32 result_id = gsk_spv_writer_make_id (writer);
guint start_index = bytes->len;
diff --git a/gsk/spirv.js b/gsk/spirv.js
index 1354053..bd5e588 100644
--- a/gsk/spirv.js
+++ b/gsk/spirv.js
@@ -139,7 +139,7 @@ var Sections = {
"OpFunctionParameter": "declare",
"OpFunctionEnd": "code",
"OpFunctionCall": "code",
- "OpVariable": "declare",
+ "OpVariable": "",
"OpImageTexelPointer": "code",
"OpLoad": "code",
"OpStore": "code",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]