Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shumway and stage3d

127 views
Skip to first unread message

Carlos Ballesteros Velasco

unread,
Apr 10, 2015, 10:02:48 AM4/10/15
to mozilla-d...@lists.mozilla.org
I was evaluating shumway. And I have seen that it doesn't support stage3D yet.

https://github.com/mozilla/shumway/blob/master/src/flash/display/Stage.ts#L310

Is someone working on it? Are you accepting contributions?

Till Schneidereit

unread,
Apr 10, 2015, 10:10:30 AM4/10/15
to Carlos Ballesteros Velasco, mozilla-dev-sh.
Hey Carlos,
We've looked into it in the past and decided that it's absolutely doable,
but not something that fits with our current focus. So no, nobody's
currently working on it. However, we'd most definitely accept, emphatically
welcome, and be excited about contributions in this area, and gladly
support you however we can, yes.

If you want, please just dive right in. Be aware, however, that current
development happens in the "redux" branch, which will merge back to master
pretty soon. It has some changes to how the standard library works, so it'd
be best to start off of that. Feel free to join us in the #shumway channel
on irc.mozilla.org or send any questions you might have to this list.


thanks,
till

Carlos Ballesteros Velasco

unread,
Apr 13, 2015, 1:09:55 PM4/13/15
to mozilla-d...@lists.mozilla.org
Great, I will start forking redux branch asap. I'm glad you are using TypeScript for it. It will be a lot easier for me to work on it than if it were plain javascript. I will join the irc channel after feeling comfortable with the codebase.

Thanks for the support!

Till Schneidereit

unread,
Apr 13, 2015, 2:00:49 PM4/13/15
to Carlos Ballesteros Velasco, mozilla-dev-sh.
Great!

You might want to look into https://github.com/renaun/KontikiJS. It has
quite a bit of an implementation of the Stage3D stuff. It won't be a
drop-in thing for Shumway, of course, but the conversion to WebGL should be
in there, at least, and inspiration for how the internals work. The license
is the same, too, so you can freely copy code as long as you include the
proper attribution in the affected files.

And thanks for digging in, very exciting!

On Fri, Apr 10, 2015 at 5:39 PM, Carlos Ballesteros Velasco <
soy...@gmail.com> wrote:

> Great, I will start forking redux branch asap. I'm glad you are using
> TypeScript for it. It will be a lot easier for me to work on it than if it
> were plain javascript. I will join the irc channel after feeling
> comfortable with the codebase.
>
> Thanks for the support!
>
> On Friday, April 10, 2015 at 4:10:30 PM UTC+2, Till Schneidereit wrote:
> _______________________________________________
> dev-shumway mailing list
> dev-s...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-shumway
>

Till Schneidereit

unread,
Apr 14, 2015, 10:06:06 AM4/14/15
to soywiz, mozilla-dev-sh.
On Tue, Apr 14, 2015 at 9:59 AM, soywiz <soy...@gmail.com> wrote:

> Thanks for the info! I have experience creating graphics back ends with
> haxe and as3 for webgl and stage3d. I was already thinking how to pass
> registers to uniforms. But if someone did it already, I could use it.
>
> I have been diving into the code this weekend. I was able to get Stage3D
> classes referenced. I had to move TextureBase reference before Texture to
> get it working because one extends the another. Also the build script
> worked like a charm in a Mac, but failed on a windows machine. I had to
> change the tsc reference to call node instead for windows.
>
Can you give us some more details on what went wrong exactly? The build
setup should work on Windows, as far as we know. The test commands are
known not to work, because Windows doesn't have the `parallel` tool. We'll
eventually fix this, but if you need it sooner, you'll have to somehow work
around it, I'm afraid.

> Got stuck creating a typed vector for the 4 stage3d instances in the
> Stage.
>
You're working in TypeScript, not AS3, right? Assuming "yes", here's how to
do that, for now:
https://github.com/mozilla/shumway/blob/f3fc7252a4c035f247e55f17b544f9f5d7b7091f/src/flash/display/Stage.ts#L48-49

Note the array passed in as arguments to axConstruct. We want to have an
alternative version of the standard axConstruct for at least some important
functions that does away with the need for the array, but for now this is
what's needed.

> Tried to check recompiled code, to check how to create and populate right
> a vector but noticed that at least in redux the method was interpreted.
>
Right now, the redux branch doesn't have support for a JIT compiler. We'll
port the baseline compiler over once everything else works, but the
optimizing JIT that's used on master won't make it over. We do however
think that we'll be able to get the baseline compiler optimized to a point
where script execution speed isn't the bottleneck for almost all or all
applications.

> Is it possible to do a full-aot and generate JavaScript versions all the
> methods of a swf offline? For what I have seen you are creating an
> intermediate ast and then using relooper to create functions with jumps per
> trait. So while no dynamic code loading is involved it should be possible.
>
The Relooper is what's used in the baseline compiler, yes. The intermediate
AST isn't really used though: that's part of the optimizing JIT.

Doing AOT compilation is something we're definitely interested in, and it
shouldn't be all that hard to implement. You're right about there not being
any real issues with doing that. We've talked about building a tool that'd
take a SWF and preprocess it into something that can be run without needing
an interpreter or JIT, and that has better startup performance. It's not
something we need for our initial use case, so it hasn't been a priority,
though.

soywiz

unread,
Apr 14, 2015, 12:20:57 PM4/14/15
to Till Schneidereit, mozilla-d...@lists.mozilla.org
Thanks for the info! I have experience creating graphics back ends with
haxe and as3 for webgl and stage3d. I was already thinking how to pass
registers to uniforms. But if someone did it already, I could use it.

I have been diving into the code this weekend. I was able to get Stage3D
classes referenced. I had to move TextureBase reference before Texture to
get it working because one extends the another. Also the build script
worked like a charm in a Mac, but failed on a windows machine. I had to
change the tsc reference to call node instead for windows. Got stuck
creating a typed vector for the 4 stage3d instances in the Stage. Tried to
check recompiled code, to check how to create and populate right a vector
but noticed that at least in redux the method was interpreted. Is it
possible to do a full-aot and generate JavaScript versions all the methods
of a swf offline? For what I have seen you are creating an intermediate ast
and then using relooper to create functions with jumps per trait. So while
no dynamic code loading is involved it should be possible.
El 13/4/2015 20:00, "Till Schneidereit" <ti...@tillschneidereit.net>
escribió:

> Great!
>
> You might want to look into https://github.com/renaun/KontikiJS. It has
> quite a bit of an implementation of the Stage3D stuff. It won't be a
> drop-in thing for Shumway, of course, but the conversion to WebGL should be
> in there, at least, and inspiration for how the internals work. The license
> is the same, too, so you can freely copy code as long as you include the
> proper attribution in the affected files.
>
> And thanks for digging in, very exciting!
>
> On Fri, Apr 10, 2015 at 5:39 PM, Carlos Ballesteros Velasco <
> soy...@gmail.com> wrote:
>
>> Great, I will start forking redux branch asap. I'm glad you are using
>> TypeScript for it. It will be a lot easier for me to work on it than if it
>> were plain javascript. I will join the irc channel after feeling
>> comfortable with the codebase.
>>
>> Thanks for the support!
>>
>> On Friday, April 10, 2015 at 4:10:30 PM UTC+2, Till Schneidereit wrote:

soywiz

unread,
Apr 15, 2015, 9:42:35 AM4/15/15
to Till Schneidereit, mozilla-dev-sh.
On Tue, Apr 14, 2015 at 4:05 PM Till Schneidereit <ti...@tillschneidereit.net>
wrote:

> On Tue, Apr 14, 2015 at 9:59 AM, soywiz <soy...@gmail.com> wrote:
>
>> Thanks for the info! I have experience creating graphics back ends with
>> haxe and as3 for webgl and stage3d. I was already thinking how to pass
>> registers to uniforms. But if someone did it already, I could use it.
>>
>> I have been diving into the code this weekend. I was able to get Stage3D
>> classes referenced. I had to move TextureBase reference before Texture to
>> get it working because one extends the another. Also the build script
>> worked like a charm in a Mac, but failed on a windows machine. I had to
>> change the tsc reference to call node instead for windows.
>>
> Can you give us some more details on what went wrong exactly? The build
> setup should work on Windows, as far as we know. The test commands are
> known not to work, because Windows doesn't have the `parallel` tool. We'll
> eventually fix this, but if you need it sooner, you'll have to somehow work
> around it, I'm afraid.
>

It seems that I triggered this problem:
https://github.com/npm/npm/issues/2576

C:\projects\shumway-redux>grunt exec:build_avm2_ts
Running "exec:build_avm2_ts" (exec) task
*>> "node_modules" no se reconoce como un comando interno o externo,*
>> programa o archivo por lotes ejecutable.
>> Exited with code: 1.
Warning: Task "exec:build_avm2_ts" failed. Use --force to continue.

Aborted due to warnings.


Execution Time (2015-04-14 18:12:01 UTC)
loading tasks 339ms ████████████████████████████████████████ 95%
exec:build_avm2_ts 17ms ██ 5%
Total 357ms

I managed to sovle the problem editing Gruntfile.js

var tscCommand = 'node node_modules/typescript/bin/tsc.js';
//var tscCommand = 'node_modules/typescript/bin/tsc';

Got stuck creating a typed vector for the 4 stage3d instances in the Stage.
>>
> You're working in TypeScript, not AS3, right? Assuming "yes", here's how
> to do that, for now:
>
> https://github.com/mozilla/shumway/blob/f3fc7252a4c035f247e55f17b544f9f5d7b7091f/src/flash/display/Stage.ts#L48-49
>

I was editing typescript files, yes. And I found that reference. The
problem was not creating the object, but populating it.

I managed to write something like this:

this._stage3Ds = <any>objectVectorClass.axConstruct([4, true]);
[0, 1, 2, 3].forEach(n => {
this._stage3Ds.axSetNumericProperty(n, new
Shumway.AVMX.AS.flash.display.Stage3D());
});

But it failed in the interpreted code, but because it was interpreted and
not a real function it was a bit hard to debug so I switched to master that
still had JIT to try to determine what was failing or how to create a
vector properly.


> Note the array passed in as arguments to axConstruct. We want to have an
> alternative version of the standard axConstruct for at least some important
> functions that does away with the need for the array, but for now this is
> what's needed.
>
>> Tried to check recompiled code, to check how to create and populate right
>> a vector but noticed that at least in redux the method was interpreted.
>>
> Right now, the redux branch doesn't have support for a JIT compiler. We'll
> port the baseline compiler over once everything else works, but the
> optimizing JIT that's used on master won't make it over. We do however
> think that we'll be able to get the baseline compiler optimized to a point
> where script execution speed isn't the bottleneck for almost all or all
> applications.
>
>> Is it possible to do a full-aot and generate JavaScript versions all the
>> methods of a swf offline? For what I have seen you are creating an
>> intermediate ast and then using relooper to create functions with jumps per
>> trait. So while no dynamic code loading is involved it should be possible.
>>
> The Relooper is what's used in the baseline compiler, yes. The
> intermediate AST isn't really used though: that's part of the optimizing
> JIT.
>
> Doing AOT compilation is something we're definitely interested in, and it
> shouldn't be all that hard to implement. You're right about there not being
> any real issues with doing that. We've talked about building a tool that'd
> take a SWF and preprocess it into something that can be run without needing
> an interpreter or JIT, and that has better startup performance. It's not
> something we need for our initial use case, so it hasn't been a priority,
> though.
>

Great to see that.

I will continue diving into the code along this week.

Regards! And thank you very much for the support!

Michael Bebenita

unread,
Apr 15, 2015, 11:52:26 AM4/15/15
to soywiz, Till Schneidereit, mozilla-dev-sh.
One issue could be that the Stage3D objects are not constructed correctly.
The code below should read:

this._stage3Ds.axSetNumericProperty(n, new
this.sec.flash.display.Stage3D());

For security reasons, in the redux branch we must allocate all objects in
the correct security domain. In most contexts, a reference to the current
security domain is usually gained through |this.sec|.

I can help you write all the integration code, if you want to focus more on
the interesting bits like getting the Stage3D -> WebGL translation in
place. Most of this code will probably live in the GFX backend, so it will
be somewhat isolated.

Thanks for looking into this, we had an attempt at WebGL rendering but it
wasn't our area of expertise.

Cheers,
Michael
0 new messages