Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
4aa31a28
Unverified
Commit
4aa31a28
authored
Feb 12, 2020
by
Yuri Roubinsky
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #36141 from Chaosus/shader_struct_member_arrays
Added support for arrays as shader struct members
parents
0f90ddbc
6b99bda1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
300 additions
and
16 deletions
+300
-16
shader_compiler_gles2.cpp
drivers/gles2/shader_compiler_gles2.cpp
+30
-0
shader_compiler_rd.cpp
servers/visual/rasterizer_rd/shader_compiler_rd.cpp
+30
-0
shader_language.cpp
servers/visual/shader_language.cpp
+223
-15
shader_language.h
servers/visual/shader_language.h
+17
-1
No files found.
drivers/gles2/shader_compiler_gles2.cpp
View file @
4aa31a28
...
...
@@ -332,6 +332,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
struct_code
+=
" "
;
struct_code
+=
m
->
name
;
if
(
m
->
array_size
>
0
)
{
struct_code
+=
"["
;
struct_code
+=
itos
(
m
->
array_size
);
struct_code
+=
"]"
;
}
struct_code
+=
";
\n
"
;
}
struct_code
+=
"}"
;
...
...
@@ -558,6 +563,26 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
}
}
break
;
case
SL
:
:
Node
::
TYPE_ARRAY_CONSTRUCT
:
{
SL
::
ArrayConstructNode
*
arr_con_node
=
(
SL
::
ArrayConstructNode
*
)
p_node
;
int
sz
=
arr_con_node
->
initializer
.
size
();
if
(
acnode
->
datatype
==
SL
::
TYPE_STRUCT
)
{
code
+=
_mkid
(
arr_con_node
->
struct_name
);
}
else
{
code
+=
_typestr
(
arr_con_node
->
datatype
);
}
code
+=
"["
;
code
+=
itos
(
arr_con_node
->
initializer
.
size
());
code
+=
"]"
;
code
+=
"("
;
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
code
+=
_dump_node_code
(
arr_con_node
->
initializer
[
i
],
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
);
if
(
i
!=
sz
-
1
)
{
code
+=
", "
;
}
}
code
+=
")"
;
}
break
;
case
SL
:
:
Node
::
TYPE_ARRAY_DECLARATION
:
{
SL
::
ArrayDeclarationNode
*
arr_dec_node
=
(
SL
::
ArrayDeclarationNode
*
)
p_node
;
...
...
@@ -898,6 +923,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code
+=
_dump_node_code
(
member_node
->
owner
,
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
);
code
+=
"."
;
code
+=
member_node
->
name
;
if
(
member_node
->
index_expression
!=
NULL
)
{
code
+=
"["
;
code
+=
_dump_node_code
(
member_node
->
index_expression
,
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
);
code
+=
"]"
;
}
}
break
;
}
...
...
servers/visual/rasterizer_rd/shader_compiler_rd.cpp
View file @
4aa31a28
...
...
@@ -390,6 +390,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
}
struct_code
+=
" "
;
struct_code
+=
m
->
name
;
if
(
m
->
array_size
>
0
)
{
struct_code
+=
"["
;
struct_code
+=
itos
(
m
->
array_size
);
struct_code
+=
"]"
;
}
struct_code
+=
";
\n
"
;
}
struct_code
+=
"}"
;
...
...
@@ -701,6 +706,26 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
}
}
break
;
case
SL
:
:
Node
::
TYPE_ARRAY_CONSTRUCT
:
{
SL
::
ArrayConstructNode
*
acnode
=
(
SL
::
ArrayConstructNode
*
)
p_node
;
int
sz
=
acnode
->
initializer
.
size
();
if
(
acnode
->
datatype
==
SL
::
TYPE_STRUCT
)
{
code
+=
_mkid
(
acnode
->
struct_name
);
}
else
{
code
+=
_typestr
(
acnode
->
datatype
);
}
code
+=
"["
;
code
+=
itos
(
acnode
->
initializer
.
size
());
code
+=
"]"
;
code
+=
"("
;
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
code
+=
_dump_node_code
(
acnode
->
initializer
[
i
],
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
);
if
(
i
!=
sz
-
1
)
{
code
+=
", "
;
}
}
code
+=
")"
;
}
break
;
case
SL
:
:
Node
::
TYPE_ARRAY_DECLARATION
:
{
SL
::
ArrayDeclarationNode
*
adnode
=
(
SL
::
ArrayDeclarationNode
*
)
p_node
;
...
...
@@ -1000,6 +1025,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
case
SL
:
:
Node
::
TYPE_MEMBER
:
{
SL
::
MemberNode
*
mnode
=
(
SL
::
MemberNode
*
)
p_node
;
code
=
_dump_node_code
(
mnode
->
owner
,
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
)
+
"."
+
mnode
->
name
;
if
(
mnode
->
index_expression
!=
NULL
)
{
code
+=
"["
;
code
+=
_dump_node_code
(
mnode
->
index_expression
,
p_level
,
r_gen_code
,
p_actions
,
p_default_actions
,
p_assigning
);
code
+=
"]"
;
}
}
break
;
}
...
...
servers/visual/shader_language.cpp
View file @
4aa31a28
This diff is collapsed.
Click to expand it.
servers/visual/shader_language.h
View file @
4aa31a28
...
...
@@ -332,6 +332,7 @@ public:
TYPE_MEMBER
,
TYPE_ARRAY
,
TYPE_ARRAY_DECLARATION
,
TYPE_ARRAY_CONSTRUCT
,
TYPE_STRUCT
,
};
...
...
@@ -427,6 +428,17 @@ public:
is_const
(
false
)
{}
};
struct
ArrayConstructNode
:
public
Node
{
DataType
datatype
;
String
struct_name
;
Vector
<
Node
*>
initializer
;
ArrayConstructNode
()
:
Node
(
TYPE_ARRAY_CONSTRUCT
),
datatype
(
TYPE_VOID
)
{
}
};
struct
ArrayDeclarationNode
:
public
Node
{
DataPrecision
precision
;
DataType
datatype
;
...
...
@@ -520,9 +532,11 @@ public:
StringName
base_struct_name
;
DataPrecision
precision
;
DataType
datatype
;
int
array_size
;
StringName
struct_name
;
StringName
name
;
Node
*
owner
;
Node
*
index_expression
;
virtual
DataType
get_datatype
()
const
{
return
datatype
;
}
virtual
String
get_datatype_name
()
const
{
return
String
(
struct_name
);
}
...
...
@@ -531,7 +545,9 @@ public:
Node
(
TYPE_MEMBER
),
basetype
(
TYPE_VOID
),
datatype
(
TYPE_VOID
),
owner
(
NULL
)
{}
array_size
(
0
),
owner
(
NULL
),
index_expression
(
NULL
)
{}
};
struct
StructNode
:
public
Node
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment