Slow texture content builds on Vista x64 (TextureImporter.Init3D)

Last post 04-27-2008, 10:11 PM by Shawn Hargreaves. 2 replies.
Sort Posts: Previous Next
  •  04-27-2008, 11:07 AM

    Slow texture content builds on Vista x64 (TextureImporter.Init3D)

    Hello all,

    I've just upgraded to a new PC and am now experiencing slow XNA project builds. The culprit seems to be content pipeline texture importing, which is taking approx. 4 seconds per imported texture.

    This ran blindingly fast on my old PC, which was a 32 bit XP install on an Intel P4 2.4GHz hyperthreaded CPU with a GeForce 6800 graphics card. The new PC is a 64 bit Vista install on an Intel Core 2 Duo 3.0 GHz CPU with a GeForce 8800 GT graphics card. Both machines are fully patched with Windows Update and running the latest NVidia ForceWare drivers. Both are running DirectX retail, both report no issues in dxdiag, and the CPU and hard drive are essentially idle other than performing the build (verified with Task Manager and SysInternals' Process Monitor.) Nor are there any unusual processes running, or processes which also make use of Direct3D.

    I managed to reproduce this in a very simple case. I put a test.png file (48 x 48 pixels, 557 bytes) into a new folder, and added the following msbuild script as test.xml:

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <XnaPlatform>Windows</XnaPlatform>
    <XnaFrameworkVersion>v2.0</XnaFrameworkVersion>
    </PropertyGroup>
    <ItemGroup>
    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
    <Private>False</Private>
    </Reference>
    </ItemGroup>
    <ItemGroup>
    <Compile Include="Test.png">
    <Name>Test</Name>
    <Importer>TextureImporter</Importer>
    <Processor>TextureProcessor</Processor>
    </Compile>
    </ItemGroup>
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v2.0\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
    </Project>

    I invoke msbuild and get the following output:

    > msbuild /target:Clean,Build test.xml
    Microsoft (R) Build Engine Version 2.0.50727.1434
    [Microsoft .NET Framework, Version 2.0.50727.1434]
    Copyright (C) Microsoft Corporation 2005. All rights reserved.

    Build started 27/04/2008 15:29:20.
    __________________________________________________
    Project "[...]\test.xml" (Clean;Build target(s)):

    Target XNAContentClean:
    Deleting content pipeline output files
    Target CoreClean:
    Deleting file "[...]\obj\Debug\ResolveAssemblyReference.cache".
    Target CoreCompile:
    Building Test.png -> bin\Debug\Content\Test.xnb
    Rebuilding because asset is new
    Importing Test.png with Microsoft.Xna.Framework.Content.Pipeline.TextureImporter
    Processing Test.png with Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessor
    Compiling bin\Debug\Content\Test.xnb

    Build succeeded.
    0 Warning(s)
    0 Error(s)

    Time Elapsed 00:00:11.51

    Which as you can see is quite a pitiful build time for a single texture. But even allowing that the MSBuild setup/teardown may account for a lot of this time, I've noticed that 4 seconds of that is taken up by the stage "Import Test.png with ...TextureImporter", and this is the bit which concerns me most.

    I ran a CLR profiler against msbuild, and tracked the main slowdown to inside TextureImporter itself. The biggest overhead is
    TextureImporter.Import which calls TextureImporter.InitD3D, which calls CommonHelperFunctions.InitD3D(), which takes 3.44 seconds to execute.

    Inside CommonHelperFunctions.InitD3D(), there are 3 function calls. CommonHelperFunctions.CreateDummyWindow() takes 0.93 seconds. <Module>.Direct3DCreate() takes 0.67 seconds. Direct3DBundle..ctor() takes 0.00 seconds. The rest of the method body takes up 1.84 seconds.

    My profiler couldn't pick it up, but running Reflector on CommonHelperFunctions.InitD3D() I can see there's a somewhat indirected function call to IDirect3D::CreateDevice() in there. Since the rest of the method, other than the aforementioned calls, is just doing some memory clearing and copying, I assume this call takes about 1.84 seconds.

    I think I've gone about as far as I can in investigating it. So my question is, does anyone have any ideas as to why this is so slow? For projects with lots of textures, my clean build times are getting a little crazy.
  •  04-27-2008, 1:16 PM

    Re: Slow texture content builds on Vista x64 (TextureImporter.Init3D)

    Belay that...this wasn't anything to do with XNA or even DirectX.

    Sheepishly I have to admit that I was using my motherboard vendor's drivers for the nForce chipset on the motherboard. These were nowhere near as current as NVidia's own nForce drivers.

    I just installed the latest nForce drivers for my system from nVidia, and not only does the above content build execute in 1.35 seconds - (a tenfold(!) speed increase) - but all sorts of other little peculiarities which I had assumed were just Vista being odd have now disappeared (a periodically slow Vista Start menu, slow rendering in web browsers, slow popups and pull out menus in various applications).

    That's certainly "learned" me. I'd never ascribed vast importance to the currency of my motherboard drivers. I now know different!

    Thanks for reading in any case.

  •  04-27-2008, 10:11 PM

    Re: Slow texture content builds on Vista x64 (TextureImporter.Init3D)

    Phew :-)

    Glad to hear you got this fixed!

    --
    XNA Framework Developer
    blog - homepage
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback