Coffeehouse Thread

15 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

How do the new Silverlight immediate mode / 3D graphics APIs relate to XNA?

Back to Forum: Coffeehouse
  • User profile image
    contextfree

    Has there been any word on this? Especially from a Windows Phone POV it seems weird to have two separate APIs for this, instead of integrating them.

  • User profile image
    ZippyV

    That would make Silverlight not cross platform anymore.

  • User profile image
    contextfree

    @ZippyV: Good point. XNA is only on Microsoft platforms, after all. However, maybe the SL APIs will be a subset of XNA?

  • User profile image
    rhm

    We don't have any information on SL5's 3D API yet so it's all guesswork. But in the keynote they said that it's an immediate mode API and that it supports custom shaders. Those are the key things in my view.

    XNA, OpenGL and WebGL are all immediate mode APIs so it could be like any of them. Making it like XNA would make sense so that if they ever bring it to WP7, it'll drop in easily for devs that already have XNA experience there. Likewise for XBox. On the other hand, making it like WebGL would be a plus from the point of view of web developers.

    FWIW, the cross-platform issue is a bit of a red herring. The different 3Ds are not so different that they cannot be implemented in terms of each other. As an example, check out the opensource project called XNATouch. That implements the XNA 3D API on iOS running under MonoTouch, translating XNA calls into OpenGL ES calls as it goes.

  • User profile image
    battlebottle

    I remember seeing a technology demo awhile back where someone on the WPF team was demonstrating an application that used both xna and wpf. that is to say the background of the window was an xna surface but wpf controls were being composited on top. I also recall Shawn Hargreaves hinting that they were looking into ways to be able to use silverlight and XNA in the same application on WP7.

    It would be super sweet if we got a XNASurfaceControl for silverlight. We could write games and use the same code to compile for desktop, web, xbox 360 and wp7. now that'd be sweet. Would see games in silverlight erupt online too i bet ;].

  • User profile image
    rhm

    , battlebottle wrote

    I remember seeing a technology demo awhile back where someone on the WPF team was demonstrating an application that used both xna and wpf. that is to say the background of the window was an xna surface but wpf controls were being composited on top. I also recall Shawn Hargreaves hinting that they were looking into ways to be able to use silverlight and XNA in the same application on WP7.

    Yes, that demo was at PDC09 (or maybe it was even PDC08). I was revealed more recently that it was basically hacked together using p/invokes and that the feature never actually made it to the development stage. Not sure why they decided to demo it in that case. Given how far off the SL5 release is, I wouldn't be surprised if the code in that keynote demo was just calling out to Managed DirectX or something like that.

  • User profile image
    sysrpl

    , rhm wrote

    XNA, OpenGL and WebGL are all immediate mode APIs so it could be like any of them. Making it like XNA would make sense so that if they ever bring it to WP7, it'll drop in easily for devs that already have XNA experience there. Likewise for XBox. On the other hand, making it like WebGL would be a plus from the point of view of web developers.

    I think this is one of the situations where a technology label applied in different context means different things to different people. When Silverlight people think about immediate mode, as oppossed to retained mode, they think of a rendering system where graphical objects and their related resource are created and cached/reused over each drawn frame and otherwise managed by the rendering engine. Unfortunately immediate mode may have a different meaning to OpenGL and Direct3D developers.

    In the OpenGL and Direct3D spheres, immediate mode can mean drawing without using batch draw commands, specifically drawing from vertex buffers. A vertex buffer is a memory location, typically in video memory, where vertex data and other data attributes are stored and then used from batch draw commands such as glDrawElements. Such immediate drawing code would look like this:

    glBegin(GL_QUADS); glVertex(...); glVertex(...); glVertex(...); glVertex(...); glEnd(); // creates a rectangle in 3D space

    Instead, what I believe the Silverlight team means by immediate mode is the opposite of what that term means to OpenGL and Direct3D programmers. That is to say Silverlight 5 will employ vertex buffers and batch drawing command on a per frame basis, much like using glDrawElements to render a complex 3D model from a bunch of vertex data in one function call.

     

     

     

  • User profile image
    rhm

    @sysrpl: I disagree. Although what we disagree about here is the confusion level rather than the definitions themselves so it's kindof a meta-disagreement Smiley

    Of course without surveying every Silverlight developer it's a bit hard to say what they would interpret 'immediate' and 'retained' to mean, but here's a simple definition that applies to any graphics API including OpenGL/DirectX and Silverlight/WPF and even Win32:-

    Immediate - Every time the screen (or part thereof) is to be redrawn, your program must call API functions to make that happen.

    Retained - Your program provides data to the API and then the system redraws the screen as necessary without further involvement of your program until you decide that you want something different to be displayed.

    Following these definitions OpenGL, DirectX and XNA are strictly immediate whether you use index buffers or individual primite draw calls (although DirectX did have a retained mode back in the DX3 days it was dropped a long time ago). Win32 is also an immediate mode API if you think about it - you get a WM_PAINT message, but it's still your code that's redrawing the screen.

    Silverlight is at the moment strictly a retained mode API. You have to create instances of objects that derive from the UIElement class and attach them to the visual tree in order to make anything happen on screen. Once you've done so your program has no more involvement in drawing the window regardless of how many times it needs to be repained by the windowing system. In fact Silverlight goes even further and takes animation out of your hands, making that a retained behaviour.

    WPF you could look at either way. It has the same retained visual tree objects as Silverlight, but you can also draw in an immediate style by overriding the OnRender method of the UIElement class. However, the functions you call on the DrawingContext don't actually result in something being drawn on-screen at that point in time, instead a datastructure is created behind the scenes which is used behind the scenes to paint the window when WPF decides it needs doing and that is retained until the next call to OnRender is forced. So WPF is also strictly a retained mode API, although it can be programmed in an immediate style.

  • User profile image
    Cream​Filling512

    @sysrpl:

    Vertex buffers/batching is still immediate mode, in fact I would argue that a pattern like glBegin()/glEnd() is more retained than immediate mode since it's a high-level abstraction where the runtime has to ultimately build up vertex streams internally at some point. Using vertex buffers is closer to how the hardware interface actually works, streams of geometry and drawing commands sent over DMA.

  • User profile image
    sysrpl

     

     

    So@CreamFilling512:

    @rhm:

    See, this is exactly what I meant. Both of you believe a term has one meaning, but in reality the meaning is different for developers using different tools.

    From wikipedia:

    immediate-mode

    And from apple:

    apple-immediate-mode

    And this little bit from the nvidia developer manual:

    http://imagebot.org/snapshops/nvidia-tutorial.jpg

    So, as you can see, developer's with different backgrounds use the terms you are using with completely different meanings. That's all I am sayin'.

  • User profile image
    Minh

    @CreamFilling512: you're grossly misunderstanding what retained mode means

  • User profile image
    androidi

    I don't see any technical reason for not being able to do GUI using "retained" (xaml) style while doing the engine in more "immediate" (xna) style. It should all be built into Silverlight/WPF and require no pinvokes from the API consumer. Of course it would be nice to have some way to add those guis to XNA apps as well and all this stuff should load real quick. Smiley I think it's doable.

  • User profile image
    rhm

    , sysrpl wrote

     So@CreamFilling512:

    @rhm:

    See, this is exactly what I meant. Both of you believe a term has one meaning, but in reality the meaning is different for developers using different tools.

    <snip>

    So, as you can see, developer's with different backgrounds use the terms you are using with completely different meanings. That's all I am sayin'.

    Well all those definitions agree with me, so I'm happy Smiley But maybe you're right that there is confusion, but that's why there is such a thing as education - as long as people are willing to stand up and say "no, you're using the wrong term there" instead of letting things slide, we'll get things straight eventually.

  • User profile image
    rhm

    , battlebottle wrote

    I remember seeing a technology demo awhile back where someone on the WPF team was demonstrating an application that used both xna and wpf. that is to say the background of the window was an xna surface but wpf controls were being composited on top.

    I came across an open-source project called SlimDX the other day. It seems to wrap the DirectX API nicely and unlike XNA, MDX or the Code Pack projects from Microsoft, it covers 9, 10.1 and 11 (as well as Direct2D). They were also good enough to include samples of WPF interfacing, so if you want to use an immediate mode 3D API within a WPF application, I'd suggest checking that out because sitting on our hands waiting for Microsoft to get their stuff together with WPF doesn't seem very productive.

    I also recall Shawn Hargreaves hinting that they were looking into ways to be able to use silverlight and XNA in the same application on WP7.

    People are going to want that - in fact it's something I've complained about a lot on this very forum - but the more I think about it, I don't see it happening at least with the current generation of phones. Silverlight is the most spectacularly inefficient way possible to display a user interface and it consumes so much of the phone's resources that I doubt it would be possible to do any XNA calls and still have things run at a reasonable speed.

  • User profile image
    battlebottle

    @rhm: Cool to hear about SlimDX. I remember reading about it back when in was inbeta. Nice to see it's a mature product now.

    I'm not so sure Silverlight is a as resource hungry on the phone as you might think (though i might be wrong on that). According to Scott Guthrie silverlight on the phone does automatic bitmap caching of UIElement. Such that when you scroll across in your panorama control, the text and images aren't being redrawn on each frame. Instead the fonts, images and other graphics are drawn once on start up and the gpu moves the bitmap cache around the screen. I understand Silverlight on wp7 has other proformance issues, such as when initialing UIElements but i don't think the rendering of the UI itself is a big bottleneck in most apps.

    I don't see making calls to xna being a big deal within Silverlight. If a developer is smart enough to design Silverlight control to overlay an xna game that can benefit from bitmap caching then the overhead will be extremely low. Also, if for some reason the Silverlight controls do cause performance issues, the will not cause the xna game to freeze since the controls are composited together on a separate thread.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.