Fix bug 368: Specify the Levels parameter of CreateCubeTexture and CreateTexture correctly.

This fixes ATS test cases 38840,38841 (while making sure that 44095, 44096, 44097, 44100, 44101, 44102 still work)

The Direct3D spec for the 'Levels' parameter of IDirect3DDevice9::CreateCubeTexture (and IDirect3DDevice9::CreateTexture) says: "If this is zero, Direct3D will generate all cube texture sublevels down to 1x1 pixels for each face for hardware that supports mipmapped cube textures."

The 'levels' parameter can be 0 (which means "generate all texture sublevels") or a non-zero value for the actual number of levels to create (often 1 if mapmapping is disabled).
But 1x1 and 2x2 mipmapped textures are not supported, so textures with these dimensions will actually create a 4x4 texture, and set mLodOffset to 2 or 1 respectively so that the level index can be offset as appropriate.
There is only one special case (for textures with dimensions smaller than 4): when levels=1 and the texture is 2x2, it is unnecessary to create all miplevels, since the 1x1 texture will never be used.  For all other cases, all miplevels must be generated even though the upper ones will be unused in order to generate the lower ones.  If 'levels' is zero all miplevels must always be generated.
It's important to preserve the special case, to ensure that attempting to access the non-existant level produces the correct error.
So if 'levels' is zero, the 'Levels' parameter should always be zero, otherwise it's the sum of 'levels + mLodOffset'

Also, the calls to 'creationLevels' from the TextureCubeMap methods were not quite right.  Passing a zero for the second parameter causes this API to always fail, since '0' is not a power of two.  There is already a version of 'creationLevels' that takes just one parameter and works correctly, so just deleting the extra parameter fixes this problem.

BUG=https://code.google.com/p/angleproject/issues/detail?id=368

TEST=Run test cases 38840, 38841, 44095, 44096, 44097, 44100, 44101, 44102 in http://ats.macromedia.com/Players/ATS/ATS10AS3/Staging/ATS.html?dynamicXML=false&wmode=direct&section=Manual&xmlSetURL=http://fpqa.macromedia.com/crospepperbuild/XMLSets/ATS10AS3ManualPepper.xml

Review URL: https://codereview.appspot.com/6492098

git-svn-id: http://angleproject.googlecode.com/svn/trunk@1279 736b8ea6-26fd-11df-bfd4-992fa37f6226
2 files changed