• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KaiRohmer

Approach to enable Shader Debugging for WPF Applications

1 post in this topic

Hi,
I was looking for quite some time find a way to debug my GPU code in WPF applications. WPF is quite nice because of scalable, transparent and easy to build user interfaces. At the moment there are a few drawbacks to make it a “perfect” solution (at least for me).
E.g. the XAML Syntax of Windows WPFs and Windows8 (formerly Metro-Apps) is slightly different (the control base classes differ and so the namespace but this is not the problem). My point is the different syntax for including namespaces! And the absence of preprocessor macros. So one needs to create two nearly the same XAML Files or completely define the UI in code if both targets should be addressed. (If you know something I missed please leave a notice ;)

The problem this thread is about is the missing debugging capability. The common graphics debuggers have problems to attach to WPF Applications because of the way you create your “backbuffer” for render panels. The only way I know is to create a texture that is shared between DirectX11 and 9. The DX9 texture is bound as ImageSource to an image that is then drawn by the window management (using Direct2D?). As you may notice this concept makes no use of a SwapChain and so there is now call to present this swap chain what I believe is the reason why PIX and other debuggers can’t capture a frame.
If you like to use WinForms instead of WPF there is no problem. You create your SwapChain with a handle of the window or of a panel and everything works fine.

After some time trying different approaches I found in the net or ideas of friends like these:
Embed the mentioned WinForms panel via Host into the WPF Application. Or the opposite direction to embed the WPF UI via Host into a WinForms Application. Both work but there is no way to get Transparency working so the UI is completely opaque. Because I would like to define complete pages for my UI there is no pixel left to see of the rendered scene [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] I’m not sure at the moment but I think the debugging problem was still there in both approaches.

Now to my solution that works (at the moment):
Starting from the standard WPF solution with a shared Texture bound as ImageSource.
Then create a hidden WinForms Form before starting the WPF application (this requires an own application entry point: static main). Use this form to initialize your graphics device and create a SwapChain. Then create and open you WPF Window and listen to CompositionTarget.Rendering. When this event is fired, draw all your content to your render panels and then present the SwapChain of the hidden window (this will allow the graphics debugger to capture the frame). Finally we need to start the main loop. This is not the one of the WPF application! Instead start the RenderLoop of SharpDX (or the message pump equivalent of SlimDX). The function you define as main loop then performs nothing. It just keeps our application running and all the render passes are initiated by the composition target.

I hope you could follow me. A Sample can be found in the attachments and here [url="http://sdrv.ms/Q6k8bE"]http://sdrv.ms/Q6k8bE[/url]. I worked this out on Windows 8 and Visual Studio 2012 and used the build in Graphics Debugger. I tested it with PIX, too. There the capturing works, but the scene isn’t visible while the application runs. I also tried the Intel GPA but unfortunately it crashes during startup. If you have ideas to fix this you are very welcome ;)

One point I left out in this Sample. One should use this approach not for release builds because the hidden window is very dirty [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
I would like you to give me some feedback and discuss about improvements.

Thanks!
Kai Edited by derKai
0

Share this post


Link to post
Share on other sites
PIX:
another test with some more draw calls failed [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] .. the debugger can be attached but there are lot of calls missing in the event history of the recorded frame
are there any ideas how else this could work?

VS 2012 Graphics Debugger:
With native code debugging in the projects properties it seems to work. =) Edited by derKai
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0