Game Development Community

Anyone Playing with Server-Side XNA Rendering?

by John Kanalakis · in Torque X 2D · 05/19/2009 (11:42 pm) · 15 replies

Has anyone played around with a server-side implementation of an XNA game? I'm not referring to any sort of multiplayer gaming. Rather, I would like to get an XNA game running on a hosted Windows server, possibly as a Windows Service, and have it render its scene state directly to a memory buffer instead of the GPU. This rendered scene, would then be pushed down to connected Windows (not Xbox360) clients as a thumbnail image. It's all very experimental, but I was wondering if someone has tried something similar before I start marching off into the great unknown.

John K.
www.envygames.com

About the author

John Kanalakis is the owner of EnvyGames, an independent game development studio in Silicon Valley that produces games and tools for Xbox 360, Windows, and the Web.


#1
05/20/2009 (11:17 am)
Sounds like a Remote Desktop/Citrix/VMWare type of thing to do. Are you thinking about trying to create some type of browser turn-based game? I have messed with osakit but it won't let me embed an TorqueX game in the browser (actually it does, but the application freezes). It will launch it out of a browser though much like a Java WebStart application.

Brian

Edit: The OSAKit stuff was done using TX 2.0 and XNA 2.0 so this may not be the case any longer. Will try it again when I get the chance.
#2
05/20/2009 (2:03 pm)
I'll have to try that, I haven't heard of OSAKit. I'm trying to create a server-side wrapper for my SpriteWorks software to support requests for a MacOS version. I'm currently experimenting by creating a Windows service that creates an instance of the XNA Game object - which is not so easy since Windows services are meant to have no visual components and XNA is all about the visuals.

If this experiment works, then I can have this XNA-based windows service dynamically generate an XNA scene to a memory buffer and write that buffer out as an image, which can be pushed down to a Silverlight client. Since Silverlight runs in Firefox, Safari, and Internet Explorer, I can meet my growing multiplayer needs.

I tried XenoCode's Web deploy, but need to get a price quote from the sales team - (aka very expensive). I'll take a look at OSAKit next. Thank you for the ideas!

John K.
www.envygames.com
#3
05/20/2009 (2:31 pm)
Nice! I don't think OSAKit is going to help then. It just packages your game up into a compressed file the plugin can read in. I'm pretty sure it just runs it sort of like running other stuff from a zip file so it probably isn't going to make it run on platforms that can't run .net and XNA. Sorry about that. I'm surprised Microsoft hasn't really considered making a browser plugin for XNA sort of like the way Java Applets are deployed. Probably wouldn't help out on the Mac though...

Brian
#4
05/20/2009 (2:40 pm)
Yeah, I've just finished up with OSAKit. I like it and it's interesting, but I still have the same problems. Not only will XNA not work on platforms like MacOS, but I'm also trying to spare Windows game designers the requirement of downloading Visual C# Express and the XNA Framework. I've just finished compiling a Windows service that starts an XNA game instance - there's a setting in the Services properties, "Allow service to interact with desktop", that seems to make a big difference. I'll post more details as I continue to uncover them.

John K.
www.envygames.com
#5
05/20/2009 (2:57 pm)
Awesome! Let us know!

Brian
#6
05/20/2009 (9:53 pm)
Making some progress but hit another roadblock...

I created a Windows service that will run on my Vista with UAC. It took a long time to jump through security hoops and create the service installer. When it runs, the service creates an XNA game object asynchronously and calls it's run method. The game class constructor is being reached, but BeginRun() is never called by the XNA Framework. I'm debugging by writing messages to the EventLog, so it takes a while to register the service, perform the test, review the event logs, uninstal the service, make code changes, and repeat. I'll keep researching for a little longer and I'm wide open to ideas.

John K.
www.envygames.com
#7
05/21/2009 (4:34 pm)
Unfortunate Setback :( According to Shawn Hargreaves, XNA Framework engineer, it looks like running XNA as a Windows service is not going to happen. His response...

Quote:The XNA Framework uses Direct3D for rendering. Direct3D requires a connection to a terminal session: it cannot be used from a service context.

Christian Rousslle mentioned something about a DirectX "reference device", so there's still some hope. Any DirectX experts out there?

Plan-B is to use a couple desktop computers with decent video cards and generous RAM as running-game servers. The problem I have with this is Web hosting as most hosting services don't offer hardware configurations with graphics cards.

I'll have to create the computers and self-host them. Then address scalability with a queue system, like Vimeo's/YouTube's video encoding process to queue requests.

John K.
www.envygames.com
#8
05/23/2009 (5:42 pm)
The Direct3D Reference device is a software rasterizing device implementation that comes with the DirectX SDK, which supports the full Direct3D specification. I'm not familiar enough with XNA to know if you have enough control over the devices to use the reference device from within XNA, but if you can that's going to be the way to go.

I'm also not sure how it may relate to running it in a service context, but I have used it in the past to do rendering on a Windows Server without a graphics card from a standard user-mode process. (This was a native C++ app, not .NET, but it should work the same.)

It's not terribly fast, but probably good enough for your purposes.

Edit: It will probably be best to setup your rendering to render-to-texture, and then just save out the texture or pipe it to another service or application that will push it through to Silverlight.
#9
05/23/2009 (6:38 pm)
Thank you for the advice, Gerald. Unfortunately, the situation is not looking good. When I'm running XNA as a Windows service, it fails to initialize the the following exception is thrown.

Quote:
EXCEPTION: Direct3D hardware acceleration is not available or has been disabled. Verify that a Direct3D enabled graphics device is installed and check the display properties to make sure hardware acceleration is set to Full.

I think the problem is with XNA, it may simply have code in there to block initialization if there is no GPU present, since it is so shader dependent. I just might have to do this all with straight Direct X. I'm fine with the slow performance of the DirectX reference platform. All this program does is take snapshots of renderings.

Thank you for the help.

John K.
www.envygames.com
#10
05/23/2009 (6:54 pm)
John,

There may still be some hope. I did some looking around, and found that you can in fact use the reference rasterizer with XNA. However, as you suspected, there is some code that checks for SM1.1 compatibility in the GraphicsDeviceManager that ships with XNA, so even if you use the reference rasterize you need a SM1.1 GPU.

I found a custom implementation of GDM that says it will work without SM1.1, here XNA ReferenceGraphicsDeviceManager. This says it's for version 1.0, so I don't know if it will work with the current version, but it may help you figure out what you need to do.

Also there are some other things you'll need to do. You'll need to have the DirectX SDK installed on the server, and you'll need to configure DX in the DirectX control panel to enumerate the reference device. More info on that can be found here:

Using the Reference Rasterizer in XNA

Cheers
#11
05/23/2009 (7:29 pm)
WOW! Thank you, Gerald! I'll dive right into this tonight and give that a try. I'm also shocked that endless Web searching never brought me to the nuclex.org site, I guess I was using wrong keywords. Thank you for the great pointers, you made my day!

John K.
www.envygames.com
#12
05/23/2009 (8:02 pm)
No problem. Hope it can help. I'm actually looking into upgrading my system for generating thumbnails on our asset management server, so let me know how it turns out. And if you can't get it going I may give it a try sometime next week and see if I can figure it out.
#13
05/24/2009 (8:53 am)
OK for two guys on opposite coasts you look like you could be on the same beach.
#14
05/25/2009 (9:21 pm)
lol yeah I noticed that too. I'm pretty sure I had my laptop on my lap when that picture was taken too.
#15
05/26/2009 (1:31 am)
Pretty funny, I didn't even see that. I'll need to take a new picture... I've just replaced that old XPS with a new XPS Studio 16. Looks like it's time to head out to the beach for pictures, though it's hard to beat Miami's awesome beaches.

John K.
www.envygames.com