Skip to content

Commit bdb473c

Browse files
author
hartsantler
committed
webCLgl backend: fixed return array of vec4
1 parent fff9f60 commit bdb473c

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

pythonjs/python_to_pythonjs.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(self, source=None, module=None, module_path=None, dart=False, coffe
156156

157157
self._with_glsl = False
158158
self._in_gpu_main = False
159-
self._gpu_return_type = 'array' ## 'array' or float32 or array of 'vec4' float32's.
159+
self._gpu_return_types = set() ## 'array' or float32, or array of 'vec4' float32's.
160160

161161
self._source = source.splitlines()
162162
self._classes = dict() ## class name : [method names]
@@ -1137,13 +1137,10 @@ def visit_Return(self, node):
11371137

11381138
if self._with_glsl and self._in_gpu_main:
11391139
## _id_ is inserted into all function headers by pythonjs.py for glsl functions.
1140-
if self._gpu_return_type == 'array':
1140+
if 'array' in self._gpu_return_types:
11411141
writer.write('out_float = %s' %self.visit(node.value))
1142-
elif self._gpu_return_type == 'vec4':
1142+
if 'vec4' in self._gpu_return_types:
11431143
writer.write('out_float4 = %s' %self.visit(node.value))
1144-
else:
1145-
raise NotImplementedError(node)
1146-
11471144

11481145
elif self._inline:
11491146
writer.write('__returns__%s = %s' %(self._inline[-1], self.visit(node.value)) )
@@ -2407,6 +2404,7 @@ def visit_FunctionDef(self, node):
24072404
threaded = self._with_webworker
24082405
jsfile = None
24092406

2407+
self._gpu_return_types = set()
24102408
gpu = False
24112409
gpu_main = False
24122410
gpu_vectorize = False
@@ -2449,6 +2447,7 @@ def visit_FunctionDef(self, node):
24492447
for k in decorator.keywords:
24502448
key = k.arg
24512449
assert key == 'array' or key == 'vec4'
2450+
self._gpu_return_types.add(key) ## used in visit_Return ##
24522451
return_type_keywords[ key ] = self.visit(k.value)
24532452

24542453
else:

0 commit comments

Comments
 (0)