• entries
    422
  • comments
    1540
  • views
    488859

PIXfW

Sign in to follow this  

211 views

When using PIX....

I've pretty much finished off my HDRI application now, hopefully release it to the wider world sometime in the next couple of days.

Having spent so much time on the code over the last week, I decided to spend a bit of time putting PIX for Windows (Video) through it's paces. I love PIX. [smile]

The HDRI demo is a pretty much perfect application to throw at PIX - as the actual demo is pretty much entirely GPU/Direct3D related work - there is very little "application logic" as such.

This provided it's own problem - there was almost too much information to make sense of. Or, more significantly, it proved very difficult to reason and make assertions about how the program actually runs. The saved call-stream for about 75 frames was a whopping 660mb [oh]


(Click To Enlarge)


The above screenshot shows a small section (from around 100-200) of calls made during a single frame.

Enter a couple of useful API calls [grin]

I have no idea if it was my "fault" that they appeared in PIX, but a while back I did ask for their inclusion - at the time my own profiling software had a mechanism for grouping function calls and annotating them in the resultant stream. PIX didn't offer this at that time.

int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName );

and

int WINAPI D3DPERF_EndEvent( VOID );

Place a pair of these around related blocks of code and PIX will automagically group all of their calls together when displaying the 'call stream'.

So, in the HDRI demo, the core OnFrameRender() function looks like this:

// HDRScene creates an unprocessed, raw, image to work with.
D3DPERF_BeginEvent( D3DCOLOR_XRGB( 255, 0, 0 ), L"HDRScene Rendering" );
{
HDRScene::RenderScene( pd3dDevice );
}
D3DPERF_EndEvent( );

// Luminance attempts to calculate what sort of tone/mapping should
// be done as part of the post-processing step.
D3DPERF_BeginEvent( D3DCOLOR_XRGB( 0, 0, 255 ), L"Luminance Rendering" );
{
Luminance::MeasureLuminance( pd3dDevice );
}
D3DPERF_EndEvent( );

// The post-processing adds the blur to the bright (over-exposed) areas
// of the image.
D3DPERF_BeginEvent( D3DCOLOR_XRGB( 255, 0, 0 ), L"Post-Processing Rendering" );
{
PostProcess::PerformPostProcessing( pd3dDevice );
}
D3DPERF_EndEvent( );


So, when using PIX I can straight away narrow down the main rendering code as being part of a functional unit. It looks something like this:


(Click To Enlarge)


Much better than the previous display. Clicking on the "+" next to a particular event expands the listing of calls that occured within the specified D3DPERF_BeginEvent() and D3DPERF_EndEvent() block.

Another neat feature it's provided is a duration summary for the event. Straight off I can begin to draw some conclusions as to which part of my frame is hurting the performance the most.

From the above screenshot it seems that the following is true:

[ Percentages are of the total frame time ]
HDRScene Rendering : 0.15%
Luminance Rendering : 0.46%
Post-Processing Rendering : 0.21%
Final Image Composition : 0.05%
GUI Rendering : 47.22%

Guess I should be looking at the GUI rendering code first [wink]
Sign in to follow this  


1 Comment


Recommended Comments

I thought it would be worth to say that you can also do this in Managed DirectX. All of the PIX related functions seem to be grouped together in the performence class:

Microsoft.DirectX.Direct3D.Performence

You use them in a similar way. Just call BeginEvent and then EndEvent when your done. I haven't tried it myself, but looks like it works like that anyway.

Share this comment


Link to comment

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