Skip to content

Commit 534054b

Browse files
author
hartsantler
committed
webCLgl backend: fixed dynamic attributes, js-mode needs glsljit code outside of wrapper function so that this can be bound properly.
1 parent e5c0b39 commit 534054b

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

pythonjs/pythonjs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def _visit_function(self, node):
317317
lines.append(';')
318318

319319
if is_main:
320-
insert = lines
321-
lines = []
320+
#insert = lines
321+
#lines = []
322322

323323
if not glsl_wrapper_name:
324324
glsl_wrapper_name = node.name
@@ -328,9 +328,9 @@ def _visit_function(self, node):
328328
else:
329329
lines.append('function %s( __offset ) {' %glsl_wrapper_name )
330330

331-
lines.append(' __offset = __offset || 0') ## note by default: 0 allows 0-1.0 ## TODO this needs to be set per-buffer
331+
lines.append(' __offset = __offset || 1024*512') ## note by default: 0 allows 0-1.0 ## TODO this needs to be set per-buffer
332332

333-
lines.extend( insert )
333+
#lines.extend( insert )
334334

335335
lines.append(' var __webclgl = new WebCLGL()')
336336
lines.append(' var header = "\\n".join(__shader_header__)')
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class myclass:
2+
def __init__(self):
3+
self.width = 100
4+
self.height = 64
5+
self.step = 0.01
6+
7+
def run(self, w, h, s):
8+
self.width = w
9+
self.height = h
10+
self.step = s
11+
12+
@returns( array=[8,8] )
13+
@gpu.main
14+
def gpufunc():
15+
float b = 0.0
16+
for x in range( self.width ):
17+
for y in range( self.height ):
18+
b += self.step
19+
return b
20+
21+
return gpufunc()
22+
23+
def main():
24+
A = myclass()
25+
r = A.run(4,4, 0.8)
26+
print(r)
27+
r = A.run(16,16, 0.5)
28+
print(r)

0 commit comments

Comments
 (0)