• 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
  • entries
    83
  • comments
    0
  • views
    65128

About this blog

Game programming with the XNA Framework

Entries in this blog

shawnhar

Stuart is a contrivedly acronymed Windows 10 photo editing app which I wrote during a recent Win2D app building exercise.  I’m posting it here because I’m pleased with how it turned out.  XAML + Win2D makes it really easy to do this sort of thing!


 


Where to get it



                                   


Features



  • Use a rich set of image effects to tweak your photos

  • Apply effects to the whole image or just selected parts of it

  • Feather selected regions for smooth transitions

  • Runs on Windows 10 PCs and phones


 


Screenshots


Starting with this photo from a dawn hike on Mount Rainier:


 


 


Stuart can make the colors more intense:


 


 


Or brighten the foreground rocks and trees without changing the sky:


 


 


Or we can go retro:


 


 


Or completely stylized:


 



Source
shawnhar

Stuart: Shawn

Stuart is a contrivedly acronymed Windows 10 photo editing app which I wrote during a recent Win2D app building exercise.  I’m posting it here because I’m pleased with how it turned out.  XAML + Win2D makes it really easy to do this sort of thing!

 


Where to get it



                                   


Features



  • Use a rich set of image effects to tweak your photos

  • Apply effects to the whole image or just selected parts of it

  • Feather selected regions for smooth transitions

  • Runs on Windows 10 PCs and phones


 


Screenshots


Starting with this photo from a dawn hike on Mount Rainier:


src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/5428.original.jpg" alt="" border="0"> 


 


Stuart can make the colors more intense:


 src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/8875.adjusted.jpg" alt="" border="0">


 


Or brighten the foreground rocks and trees without changing the sky:


 src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/0245.regionEdit.jpg" alt="" border="0">


 


Or we can go retro:


 src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/6266.retro.jpg" alt="" border="0">


 


Or completely stylized:


 src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/3771.stylize.jpg" alt="" border="0">



Source

shawnhar

Today the Visual Studio team shipped a project template for cross-platform graphics development.  This uses the Visual Studio shared project mechanism to target the Windows Universal Platform, Android, and iOS, with identical OpenGL ES 2.0 rendering code shared across all three platforms.


I'm posting this here partly because I think it is cool, but more importantly because I had a hand in making it happen.  In order to run portable GL rendering code on Windows, this template uses a version of ANGLE that is maintained by my team.  When you compile it for Windows, Visual Studio will automatically pull down our ANGLE binaries from NuGet.


 


The Visual Studio project looks like so:


 


 


Let's be honest, this is not the most visually exciting graphics demo ever :-)  But hey, just insert some different draw calls, different GLSL shaders, different vertices, maybe a few textures, and you could make it draw something far more interesting!




Source
shawnhar

Today the Visual Studio team shipped a project template for cross-platform graphics development.  This uses the Visual Studio shared project mechanism to target the Windows Universal Platform, Android, and iOS, with identical OpenGL ES 2.0 rendering code shared across all three platforms.


I'm posting this here partly because I think it is cool, but more importantly because I had a hand in making it happen.  In order to run portable GL rendering code on Windows, this template uses a version of ANGLE that is maintained by my team.  When you compile it for Windows, Visual Studio will automatically pull down our href="https://www.nuget.org/packages/ANGLE.WindowsStore">ANGLE binaries from NuGet.


 


The Visual Studio project looks like so:


 original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/7356.SimpleRenderer_2D00_ClassView_5B00_1_5D00_.png"> src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/7356.SimpleRenderer-ClassView[1].png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/7356.SimpleRenderer_2D00_ClassView_5B00_1_5D00_.png" alt="" width="352" height="275">


 


Let's be honest, this is not the most visually exciting graphics demo ever :-)  But hey, just insert some different draw calls, different GLSL shaders, different vertices, maybe a few textures, and you could make it draw something far more interesting!


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/7457.Cube_2D00_Windows_5B00_1_5D00_.png"> src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/7457.Cube-Windows[1].png" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20/7457.Cube_2D00_Windows_5B00_1_5D00_.png" alt="" width="515" height="885">



Source

shawnhar

tl; dr

If you are developing your own Windows Runtime component using WRL, you might be interested in borrowing these implementations of standard interfaces:

More detail:

Windows Runtime components can be implemented using .NET, C++/CX, or standard C++ with WRL. We chose WRL for the Win2D project, because it's the lowest level option and gives the most control over every detail of the implementation. Of course, this also means it is the hardest to work with and requires us to do the most work!

The Windows Runtime defines standard interfaces representing collections (IVector) and asynchronous computations (IAsyncOperation). Both .NET and C++/CX provide rich language projections on top of these interfaces, mapping them to specialized APIs that make it easy to create and consume them. WRL, not so much :-)

We looked around for existing WRL vector and async implementations that we could use in Win2D, but could not find anything that met all our requirements (complete, robust, well tested, under a suitable open source license, and not too badly tangled up with other code). So we rolled our own. Each interface is implemented in a single header with no dependencies on the rest of Win2D, so we hope these will prove suitable for anyone else who finds themselves needing the same thing in future.

Vector.h

This header provides the class Vector<T>, which implements the Windows Runtime interfaces IVector<T>, IVectorView<T>, IIterable<T>, and IIterator<T>. The vector can be fixed size or dynamically resizable, and tracks a dirty flag so you can efficiently check if its contents have changed. T may be any value type, interface, or runtime class, but strings are not currently supported.

Usage example (error handling skipped for brevity):

    IFACEMETHODIMP CreateVectorOfInts(IVector<int>** returnValue)
{
ComPtr<Vector<int>> v = Make<Vector<int>>(initialSize, isFixedSize);

// Access the vector using Windows Runtime interface methods.
v->Append(42);
v->InsertAt(0, 23);

// Internally to your implementation module, it is also possible
// to get direct access to the underlying STL collection.
std::vector<int>& raw = v->InternalVector();
std::sort(raw.begin(), raw.end());

v.CopyTo(returnValue);
return S_OK;
}





AsyncOperation.h



This header provides the classes AsyncOperation<T> and AsyncAction, which implement the Windows Runtime interfaces IAsyncOperation<T*> and IAsyncAction respectively. It runs arbitrary code on the system threadpool, and reports the result or error status through standard async interfaces. It is also possible to register one async operation to run as the continuation of another.



Example (error handling skipped for brevity) which uses an asynchronous thread pool task to add two integers:



    IFACEMETHODIMP AddAsync(int a, int b, IAsyncOperation<int>** returnValue)
{
auto asyncOperation = Make<AsyncOperation<int>>([=]
{
return a + b;
});

asyncOperation.CopyTo(returnValue);
return S_OK;
}


Even sillier example, which runs an asynchronous multiply task as the continuation of an asynchronous addition:



    IFACEMETHODIMP AddAndThenMultiplyAsync(int a, int b, int c, IAsyncOperation<int>** returnValue)
{
// Start the first asynchronous computation.
// This computes a + b.

ComPtr<IAsyncOperation<int>> addOperation;
AddAsync(a, b, &addOperation);

// Register a second asynchronous computation to run as the continuation of the first.
// This computes <previous async result> * c.

auto multiplyOperation = Make<AsyncOperation<int>>(addOperation, [=]
{
int addResult;
addOperation->GetResults(&addResult);
return addResult * c;
});

multiplyOperation.CopyTo(returnValue);
return S_OK;
}



Source
shawnhar

tl; dr

If you are developing your own Windows Runtime component using WRL, you might be interested in borrowing these implementations of standard interfaces:




More detail:


Windows Runtime components can be implemented using .NET, C++/CX, or standard C++ with WRL.  We chose WRL for the href="https://github.com/Microsoft/Win2D" target="_blank">Win2D project, because it’s the lowest level option and gives the most control over every detail of the implementation.  Of course, this also means it is the hardest to work with and requires us to do the most work!


The Windows Runtime defines standard interfaces representing collections (IVector) and asynchronous computations (href="http://msdn.microsoft.com/en-us/library/windows/apps/br206598.aspx" target="_blank">IAsyncOperation).  Both .NET and C++/CX provide rich language projections on top of these interfaces, mapping them to specialized APIs that make it easy to create and consume them.  WRL, not so much src="https://blogs.msdn.microsoft.com/shawnhar/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" />


We looked around for existing WRL vector and async implementations that we could use in Win2D, but could not find anything that met all our requirements  (complete, robust, well tested, under a suitable open source license, and not too badly tangled up with other code).  So we rolled our own.  Each interface is implemented in a single header with no dependencies on the rest of Win2D, so we hope these will prove suitable for anyone else who finds themselves needing the same thing in future.


 


Vector.h


This header provides the class Vector<T>, which implements the Windows Runtime interfaces IVector<T>, href="http://msdn.microsoft.com/en-us/library/windows/apps/br226058.aspx" target="_blank">IVectorView<T>, href="http://msdn.microsoft.com/en-us/library/windows/apps/br226024.aspx" target="_blank">IIterable<T>, and href="http://msdn.microsoft.com/en-us/library/windows/apps/br226026.aspx" target="_blank">IIterator<T>.  The vector can be fixed size or dynamically resizable, and tracks a dirty flag so you can efficiently check if its contents have changed.  T may be any value type, interface, or runtime class, but strings are not currently supported.


Usage example (error handling skipped for brevity):


    IFACEMETHODIMP CreateVectorOfInts(IVector<int>** returnValue)
{
ComPtr<Vector<int>> v = Make<Vector<int>>(initialSize, isFixedSize);

// Access the vector using Windows Runtime interface methods.
v->Append(42);
v->InsertAt(0, 23);

// Internally to your implementation module, it is also possible
// to get direct access to the underlying STL collection.
std::vector<int>& raw = v->InternalVector();
std::sort(raw.begin(), raw.end());

v.CopyTo(returnValue);
return S_OK;
}


 


AsyncOperation.h


This header provides the classes AsyncOperation<T> and AsyncAction, which implement the Windows Runtime interfaces IAsyncOperation<T*> and href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.iasyncaction.aspx" target="_blank">IAsyncAction respectively.  It runs arbitrary code on the system threadpool, and reports the result or error status through standard async interfaces.  It is also possible to register one async operation to run as the continuation of another.


Example (error handling skipped for brevity) which uses an asynchronous thread pool task to add two integers:


    IFACEMETHODIMP AddAsync(int a, int b, IAsyncOperation<int>** returnValue)
{
auto asyncOperation = Make<AsyncOperation<int>>([=]
{
return a + b;
});

asyncOperation.CopyTo(returnValue);
return S_OK;
}


Even sillier example, which runs an asynchronous multiply task as the continuation of an asynchronous addition:


    IFACEMETHODIMP AddAndThenMultiplyAsync(int a, int b, int c, IAsyncOperation<int>** returnValue)
{
// Start the first asynchronous computation.
// This computes a + b.

ComPtr<IAsyncOperation<int>> addOperation;
AddAsync(a, b, &addOperation);

// Register a second asynchronous computation to run as the continuation of the first.
// This computes <previous async result> * c.

auto multiplyOperation = Make<AsyncOperation<int>>(addOperation, [=]
{
int addResult;
addOperation->GetResults(&addResult);
return addResult * c;
});

multiplyOperation.CopyTo(returnValue);
return S_OK;
}



Source

shawnhar

Win2D

If you had asked me a couple of years ago the probability that I would find myself in 2014 paid by Microsoft to work full time on open source code, I would have said near zero. And yet here we are!
Win2D is not my first open source project. I ran what grew to be a substantial one while in college, and more recently a smaller side project that sat alongside my regular day job. But this is my first time trying to combine the worlds of open source and software development at a large corporation.
I have seen companies approach open source in many different ways. Sometimes they just throw code over the wall without any support when a product reaches what would otherwise be the end of its lifespan. Other times they release periodic snapshots of code that is developed internally, with no path for others to contribute to it. Or they ship code without its tests[sup](1)[/sup], or code that requires tools not available to outsiders to build it. [quote]
[sup](1) [/sup]Yup, I'm guilty as charged of this with DirectXTK :-([/quote]
Plus of course, companies often do open source enthusiastically and whole-heartedly, which is what I hope to achieve with Win2D. For me this includes:

  1. Share everything. Not just the product code but also tests, source materials used to generate the documentation, scripts needed to build and validate the product, etc.
  2. Don't depend on anything proprietary or hard to get hold of (building and testing Win2D currently requires nothing more than Visual Studio, plus the open source Sandcastle Help File Builder if you want to rebuild the documentation).
  3. Ship early, update often, and share a roadmap.
  4. Accept contributions from others, as long as they are of sufficiently high quality and fit the goals of the project.
  5. Use a standard license that people are already familiar with.
My last few months have involved many round-peg square-hole problems as we worked out how to apply existing Microsoft processes that were designed for very different goals (such as building and shipping Windows) to this new way of working. I'm feeling good about how things have turned out so far...http://blogs.msdn.com/aggbug.aspx?PostID=10560585

Source
shawnhar

Win2D

If you had asked me a couple of years ago the probability that I would find myself in 2014 paid by Microsoft to work full time on open source code, I would have said near zero. And yet here we are!
Win2D is not my first open source project. I ran what grew to be a substantial one while in college, and more recently a smaller side project that sat alongside my regular day job. But this is my first time trying to combine the worlds of open source and software development at a large corporation.
I have seen companies approach open source in many different ways. Sometimes they just throw code over the wall without any support when a product reaches what would otherwise be the end of its lifespan. Other times they release periodic snapshots of code that is developed internally, with no path for others to contribute to it. Or they ship code without its tests[sup](1)[/sup], or code that requires tools not available to outsiders to build it.[quote]
[sup](1) [/sup]Yup, I’m guilty as charged of this with DirectXTK icon_sad.gif[/quote]Plus of course, companies often do open source enthusiastically and whole-heartedly, which is what I hope to achieve with Win2D. For me this includes:


  1. Share everything. Not just the product code but also tests, source materials used to generate the documentation, scripts needed to build and validate the product, etc.
  2. Don’t depend on anything proprietary or hard to get hold of (building and testing Win2D currently requires nothing more than Visual Studio, plus the open source Sandcastle Help File Builder if you want to rebuild the documentation).
  3. Ship early, update often, and share a roadmap.
  4. Accept contributions from others, as long as they are of sufficiently high quality and fit the goals of the project.
  5. Use a standard license that people are already familiar with.
My last few months have involved many round-peg square-hole problems as we worked out how to apply existing Microsoft processes that were designed for very different goals (such as building and shipping Windows) to this new way of working. I’m feeling good about how things have turned out so far…



Source

shawnhar

DirectXMesh

Chuck Walbourn has been hard at work on a new project which is now available on CodePlex: [quote]
directxmesh.codeplex.com[/quote]
This is a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, and vertex cache optimization. Basically it does for geometry processing what DirectXTex did for textures. It's mostly intended for offline tool usage, and finally replaces the need for content pipelines to depend on the legacy D3DX library.http://blogs.msdn.com/aggbug.aspx?PostID=10538141

Source
shawnhar

DirectXMesh

Chuck Walbourn has been hard at work on a new project which is now available on CodePlex:
[quote]
directxmesh.codeplex.com[/quote]This is a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, and vertex cache optimization. Basically it does for geometry processing what DirectXTex did for textures. It’s mostly intended for offline tool usage, and finally replaces the need for content pipelines to depend on the legacy D3DX library.



Source

shawnhar
The GPU profiling feature discussed in my previous post includes a not-very-obvious customization mechanism:

  • Graphics / Start Diagnostics, use Print Screen to capture frames, then return to Visual Studio
  • Open up the folder that contains the resulting .vsglog capture file (eg. right-click on GraphicsExperiment1.vsglog and select Open Containing Folder)
  • In this folder you will see a file named something like GraphicsExperiment1.vsglog.GraphicsFrameAnalysisParameters.xml
  • Edit this XML to configure GPU performance analysis settings
  • Now when you select the Frame Analysis tab and click on the Click here label, these new settings will be used

    Yes yes, I know - we simply didn't have time to make a better UI for these options :-) Although most people will be fine with the defaults, we figured it was still worth exposing this XML file for more advanced users to tweak things to their preference.
    Interesting settings to adjust:
    (default 5). This controls how many times each measurement is repeated, which is done to measure standard deviation and be able to tell which measurements result from noise other than the actual thing we are trying to measure. Turn it down to 1, and analysis will run much faster but you will no longer be able to tell if some results are due to random noise. Increase it, and you will get more accurate results even if the underlying data is noisy, but you might have to wait a while (perhaps leave such an analysis running while you go to lunch).
    . These elements control which experiments (changing viewport size, MSAA, filtering, reduced texture dimensions, etc.) are carried out. Deleting ones you don't need will speed up the analysis. If you only care about the baseline time per draw call, delete all but variant #0 for the fastest possible analysis (#0 is the baseline, which cannot be turned off).
    . This controls whether we will collect and display any hardware-specific counter values reported by the D3D driver (as exposed via the ID3D11Device::CreateCounter API and D3D11_COUNTER_DEVICE_DEPENDENT_0). The resulting data can be valuable for understanding GPU performance, but unfortunately not all drivers properly support this functionality, so by default we collect counters only on specific devices where we recognize the driver and know it will do the right thing. Hardware counters will be collected automatically on new Windows Phone 8.1 devices, but not on desktop PCs where we have no way to be sure what the driver will do if we call that API! If you are feeling brave, change the "Default" setting to "ForceEnable" and see what happens. On my dev PC the result is:[quote]
    The analysis tool returned an error.
    Code
    0x8031801E
    [/quote]

    so I guess my driver does not properly support ID3D11Device::CreateCounter :-(http://blogs.msdn.com/aggbug.aspx?PostID=10517210

    Source
shawnhar

The GPU profiling feature discussed in my previous post includes a not-very-obvious customization mechanism:


  • Graphics / Start Diagnostics, use Print Screen to capture frames, then return to Visual Studio
  • Open up the folder that contains the resulting .vsglog capture file (eg. right-click on GraphicsExperiment1.vsglog and select Open Containing Folder)
  • In this folder you will see a file named something like GraphicsExperiment1.vsglog.GraphicsFrameAnalysisParameters.xml
  • Edit this XML to configure GPU performance analysis settings
  • Now when you select the Frame Analysis tab and click on the Click here label, these new settings will be used
    Yes yes, I know – we simply didn’t have time to make a better UI for these options icon_smile.gif Although most people will be fine with the defaults, we figured it was still worth exposing this XML file for more advanced users to tweak things to their preference.
    Interesting settings to adjust:
    <ExperimentRepeatCount> (default 5). This controls how many times each measurement is repeated, which is done to measure standard deviation and be able to tell which measurements result from noise other than the actual thing we are trying to measure. Turn it down to 1, and analysis will run much faster but you will no longer be able to tell if some results are due to random noise. Increase it, and you will get more accurate results even if the underlying data is noisy, but you might have to wait a while (perhaps leave such an analysis running while you go to lunch).
    <Variant ID=”X”>. These elements control which experiments (changing viewport size, MSAA, filtering, reduced texture dimensions, etc.) are carried out. Deleting ones you don’t need will speed up the analysis. If you only care about the baseline time per draw call, delete all but variant #0 for the fastest possible analysis (#0 is the baseline, which cannot be turned off).
    <Variants HardwareCounterMode=”Default”>. This controls whether we will collect and display any hardware-specific counter values reported by the D3D driver (as exposed via the ID3D11Device::CreateCounter API and D3D11_COUNTER_DEVICE_DEPENDENT_0). The resulting data can be valuable for understanding GPU performance, but unfortunately not all drivers properly support this functionality, so by default we collect counters only on specific devices where we recognize the driver and know it will do the right thing. Hardware counters will be collected automatically on new Windows Phone 8.1 devices, but not on desktop PCs where we have no way to be sure what the driver will do if we call that API! If you are feeling brave, change the “Default” setting to “ForceEnable” and see what happens. On my dev PC the result is:[quote]
    The analysis tool returned an error.
    Code
    0x8031801E
    [/quote]so I guess my driver does not properly support ID3D11Device::CreateCounter icon_sad.gif



    Source

shawnhar
The graphics debugging tool formerly known as PIX has been integrated into Visual Studio for a while now, and gets better in every release. But unlike Xbox PIX, the Windows incarnation of this technology has until now been only for debugging and not profiling. It provided lots of information about what happened, but none at all about how long things took.
For Windows Phone 8.1, my team (hi Adrian!) added the ability to measure and analyze GPU performance. I'm particularly proud of the fact that, thanks to our efforts to make the Windows and Phone graphics stacks as similar as possible, we were able to build this new feature focusing mostly on Phone, yet the resulting code works exactly the same on full Windows. Visual Studio is even able to reuse a single version of our GPU performance analysis DLL across both Windows 8.1 and Phone 8.1.
Rong's talk at the Build conference shows this in action, and you can download Visual Studio 2013 Update 2 RC to try it out for yourself.


Here's how it works. I opened the default D3D project template, which gives me an oh-so-exciting spinning cube plus a framerate counter in the bottom right corner:

5700.image_5F00_thumb_5F00_6C57FBA7.png
To use the graphics diagnostics feature, open the Debug menu, click Graphics, and then Start Diagnostics:

0272.image5_5F00_thumb_5F00_3AF59922.png
This will run the app with D3D tracing enabled. Press the Print Screen (PrtSc) key one or more times to capture the frames you want to analyze. When you quit the app, Visual Studio will open its graphics debugger. This will look familiar if you have used PIX before, but the UI is considerably improved in this release, plus it now supports Phone as well as Windows:

0184.image_5F00_thumb_5F00_569A2518.png
So far so good, but where is this new profiling feature? Select the Frame Analysis tab, and click where it says Click here:

3731.image_5F00_thumb_5F00_16640B9E.png

Our new analysis engine will whir and click for a while (the more complicated your rendering, the longer this will take). When everything has been measured it shows a report describing the GPU performance of every draw call in the frame:

7043.image_5F00_thumb_5F00_562DF223.png
This simple app only contains two draw calls. Event #117 (DrawIndexed) is the cube, while #137 (DrawIndexedInstanced) is the framerate counter. There would obviously be a lot more data if you analyzed something more complicated, in which case the ID3DUserDefinedAnnotation API can be used to organize and label different sections of your rendering.
The blue bars near the top (labeled Time) show how long each draw call took for the GPU to execute. Clearly our cube is much more expensive than the framerate text (although both are ridiculously quick -- this template isn't exactly stressing my GPU :-) The column titled Baseline shows the numeric duration of each draw, and the other columns show a series of experiments where we changed various things about the rendering and measured how much difference each one made to the GPU. For instance this data tells us that:

  1. Shrinking the output viewport to 1x1 reduced GPU time to just 2% of the original. This means we are heavily fill rate limited, so a possible optimization would be to reduce the backbuffer resolution.
  2. Turning on 2x or 4x MSAA slowed things down, but only by ~10% -- worth considering whether we can afford that slight perf hit in exchange for the quality improvement?
  3. Reducing the backbuffer from 32 to 16 bit format gave only a small improvement.
  4. Automatically adding mipmaps to all the textures, or shrinking all the textures to half size, did not significantly affect performance, so we know this app is not bottlenecked by texture fetch bandwidth.


There are a couple of different forms of color highlighting going on in this report:

  1. The background of the first draw call is light red to show it was one of the more expensive draws in the frame, and therefore the part worth concentrating on.
  2. The most statistically significant differences produced by the various rendering experiments are highlighted in green (for improvements) or red (for changes that hurt performance). Numbers that are not highlighted indicate that, although we did measure a change of performance, this may just be random measurement noise rather than a truly significant change.


Move the mouse over any of these numbers to a view a hover tip showing more data about that particular measurement.
"Sounds great! So what types of device can I use this stuff on?"

  1. The debugging part of this tool works on all Windows 8.1 and Phone 8.1 devices.
  2. Performance analysis requires the graphics driver to support timestamp queries, which was not part of Windows Phone 8. This will work on Windows, and on newer 8.1 phones once those are available, but it will not work on existing phones (even when they are upgraded to the 8.1 OS, their older drivers will be missing the necessary query ability)
  3. New 8.1 phones will also report GPU counter values directly from the driver, which gives much richer information about what is going on inside the GPU.


Source
shawnhar

The graphics debugging tool formerly known as PIX has been integrated into Visual Studio for a while now, and gets better in every release.  But unlike Xbox PIX, the Windows incarnation of this technology has until now been only for debugging and not profiling.  It provided lots of information about what happened, but none at all about how long things took.

For Windows Phone 8.1, my team (hi Adrian!) added the ability to measure and analyze GPU performance.  I’m particularly proud of the fact that, thanks to our efforts to make the Windows and Phone graphics stacks as similar as possible, we were able to build this new feature focusing mostly on Phone, yet the resulting code works exactly the same on full Windows.  Visual Studio is even able to reuse a single version of our GPU performance analysis DLL across both Windows 8.1 and Phone 8.1.


Rong’s talk at the Build conference shows this in action, and you can download href="http://blogs.msdn.com/b/somasegar/archive/2014/04/02/visual-studio-2013-update-2-rc-universal-projects-for-windows-and-windows-phone.aspx" target="_blank">Visual Studio 2013 Update 2 RC to try it out for yourself.


 


Here’s how it works.  I opened the default D3D project template, which gives me an oh-so-exciting spinning cube plus a framerate counter in the bottom right corner:


 


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/3005.image_5F00_5682C323.png"> style="border: 0px currentcolor; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/metablogapi/5700.image_thumb_6C57FBA7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/5700.image_5F00_thumb_5F00_6C57FBA7.png" alt="image" width="320" height="180" border="0">


 


To use the graphics diagnostics feature, open the Debug menu, click Graphics, and then Start Diagnostics:


 


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/2335.image5_5F00_34428F9F.png"> style="border: 0px currentcolor; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/metablogapi/0272.image5_thumb_3AF59922.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/0272.image5_5F00_thumb_5F00_3AF59922.png" alt="image" width="697" height="253" border="0">


 


This will run the app with D3D tracing enabled.  Press the Print Screen (PrtSc) key one or more times to capture the frames you want to analyze.  When you quit the app, Visual Studio will open its graphics debugger.  This will look familiar if you have used PIX before, but the UI is considerably improved in this release, plus it now supports Phone as well as Windows:


 


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/8524.image_5F00_1ADA8C65.png"> style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/metablogapi/0184.image_thumb_569A2518.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/0184.image_5F00_thumb_5F00_569A2518.png" alt="image" width="640" height="453" border="0">


 


So far so good, but where is this new profiling feature?   Select the Frame Analysis tab, and click where it says Click here:


 


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/7041.image_5F00_4F7AE8A0.png"> style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/metablogapi/3731.image_thumb_16640B9E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/3731.image_5F00_thumb_5F00_16640B9E.png" alt="image" width="514" height="345" border="0">


 


Our new analysis engine will whir and click for a while (the more complicated your rendering, the longer this will take).  When everything has been measured it shows a report describing the GPU performance of every draw call in the frame:


 


original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/0677.image_5F00_7648FEE0.png"> style="border: 0px currentcolor; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/20/metablogapi/7043.image_thumb_562DF223.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-20-metablogapi/7043.image_5F00_thumb_5F00_562DF223.png" alt="image" width="1169" height="611" border="0">


 


This simple app only contains two draw calls.  Event #117 (DrawIndexed) is the cube, while #137 (DrawIndexedInstanced) is the framerate counter.  There would obviously be a lot more data if you analyzed something more complicated, in which case the ID3DUserDefinedAnnotation API can be used to organize and label different sections of your rendering.


The blue bars near the top (labeled Time) show how long each draw call took for the GPU to execute.  Clearly our cube is much more expensive than the framerate text  (although both are ridiculously quick – this template isn’t exactly stressing my GPU :-)   The column titled Baseline shows the numeric duration of each draw, and the other columns show a series of experiments where we changed various things about the rendering and measured how much difference each one made to the GPU.  For instance this data tells us that:



  1. Shrinking the output viewport to 1x1 reduced GPU time to just 2% of the original.  This means we are heavily fill rate limited, so a possible optimization would be to reduce the backbuffer resolution.

  2. Turning on 2x or 4x MSAA slowed things down, but only by ~10% – worth considering whether we can afford that slight perf hit in exchange for the quality improvement?

  3. Reducing the backbuffer from 32 to 16 bit format gave only a small improvement.

  4. Automatically adding mipmaps to all the textures, or shrinking all the textures to half size, did not significantly affect performance, so we know this app is not bottlenecked by texture fetch bandwidth.


There are a couple of different forms of color highlighting going on in this report:



  1. The background of the first draw call is light red to show it was one of the more expensive draws in the frame, and therefore the part worth concentrating on.

  2. The most statistically significant differences produced by the various rendering experiments are highlighted in green (for improvements) or red (for changes that hurt performance).  Numbers that are not highlighted indicate that, although we did measure a change of performance, this may just be random measurement noise rather than a truly significant change.


Move the mouse over any of these numbers to a view a hover tip showing more data about that particular measurement.


 


“Sounds great!  So what types of device can I use this stuff on?”



  1. The debugging part of this tool works on all Windows 8.1 and Phone 8.1 devices.

  2. Performance analysis requires the graphics driver to support timestamp queries, which was not part of Windows Phone 8.  This will work on Windows, and on newer 8.1 phones once those are available, but it will not work on existing phones  (even when they are upgraded to the 8.1 OS, their older drivers will be missing the necessary query ability)

  3. New 8.1 phones will also report GPU counter values directly from the driver, which gives much richer information about what is going on inside the GPU.



Source

shawnhar

Windows Phone 8.1

Hey up, long time no blog...

At the Build conference this week we announced what I've been working on for the last while: Windows Phone 8.1. It's full of cool new stuff, but my contribution was deep in the entrails of the operating system, converging the graphics stack between Phone and desktop Windows and making sure this shared code runs well in limited memory on mobile GPU hardware. I haven't been blogging much because, while I found this kind of work to be important and a lot of fun, there just isn't much that's interesting to discuss in public along the lines of "yay, one more place where Phone used to differ from Windows is now the same" or "huzzah, one more driver bug fixed!" :-)

You can pretty much sum up the end result as graphics on Phone 8.1 now being the same as Windows. For instance:

  • Phone now supports D2D
  • Phone now supports DWrite
  • Phone now supports WIC (Windows Imaging Codec)
  • Phone now includes the HLSL shader compiler
  • Corner cases where Phone D3D did not support all the same features as Windows (for instance not all of the same swapchain options were available) are now much more similar
  • The Visual Studio Graphics Diagnostics feature (aka PIX) now works on Phone
  • You can now have a single Visual Studio project that targets both Windows and Phone


    The Phone 8.1 SDK and emulator is available for download, and see Dan's Build talk for more details and demos.

    We also updated DirectXTK to include Phone 8.1 projects, which makes WICTextureLoader and SaveWICTextureToFile available on Phone.
    Source
shawnhar

Windows Phone 8.1

Hey up, long time no blog…

At the Build conference this week we announced what I’ve been working on for the last while: Windows Phone 8.1.  It’s full of href="http://www.technologyreview.com/news/526101/say-hello-to-microsofts-answer-to-siri" target="_blank">cool new stuff, but my contribution was deep in the entrails of the operating system, converging the graphics stack between Phone and desktop Windows and making sure this shared code runs well in limited memory on mobile GPU hardware.  I haven’t been blogging much because, while I found this kind of work to be important and a lot of fun, there just isn’t much that’s interesting to discuss in public along the lines of “yay, one more place where Phone used to differ from Windows is now the same” or “huzzah, one more driver bug fixed!src="https://blogs.msdn.microsoft.com/shawnhar/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" />


You can pretty much sum up the end result as graphics on Phone 8.1 now being the same as Windows. For instance:



  • Phone now supports D2D

  • Phone now supports DWrite

  • Phone now supports WIC  (Windows Imaging Codec)

  • Phone now includes the HLSL shader compiler

  • Corner cases where Phone D3D did not support all the same features as Windows (for instance not all of the same swapchain options were available) are now much more similar

  • The Visual Studio Graphics Diagnostics feature (aka PIX) now works on Phone

  • You can now have a single Visual Studio project that targets both Windows and Phone


The Phone 8.1 SDK and emulator is available for download, and see href="http://channel9.msdn.com/Events/Build/2014/3-510" target="_blank">Dan’s Build talk for more details and demos.


We also updated DirectXTK to include Phone 8.1 projects, which makes WICTextureLoader and SaveWICTextureToFile available on Phone.



Source

shawnhar
While I've been distracted working on the next version of Windows Phone, Chuck has been busy adding features to the DirectX Tool Kit. New in the Dec 24th release:

  • DirectXTK for Audio
  • Xbox One platform support
  • MakeSpriteFont tool updated with more progress feedback when capturing large fonts
  • Minor updates for .SDKMESH Model loader
  • Fixed bug in .CMO Model loader when handling multiple textures
  • Improved debugging output


    The new audio functionality is implemented as a helper layer on top of XAudio2, and provides an easy-to-use API similar to the XNA SoundEffect class. XAudio2 is like Direct3D in that it is powerful and efficient but not exactly easy to get started with. DirectXTK aims to help with this by making the common, simple things as easy as possible, but without hiding the underlying API so you can always drop down to the lower level when you need more detailed control.

    The audio features are documented here.

    Enjoy, and thank you Chuck!

    Source
shawnhar

Chuck, awesome fellow that he is, has been slaving away on a 3D model loading solution for the DirectX Tool Kit.  Documentation here.  I won't bother to repeat all the details in this post, but as a quick summary:


This is an implementation of a mesh renderer similar to the XNA Game Studio Model, ModelMesh, ModelMeshPart design.  It can load data from two different model formats:



  • The .cmo format used by the Visual Studio 3D Starter Kit.  This is a basic format with an extremely simplistic material system, but can be handy because the ability to convert from .fbx to .cmo is built into Visual Studio 2012.



  • The .sdkmesh format used by the legacy DirectX SDK.  This is a more advanced format than .cmo, with a richer feature set.  You can get a .fbx to .sdkmesh converter here.


Note: Model currently only supports rigid models. Support for animation, skinning, and frame hierarchy is on our radar for the future, but not yet implemented.


Check it out, let us know what you think, and a big thank you to Chuck for filling what until today was the biggest hole in our little toolkit!



Source
Sign in to follow this  
Followers 0