private void CreateVolumeTexture()
{
Debug.Assert( Width > 0 && Height > 0 && Depth > 0 );
if ( ( Usage & TextureUsage.RenderTarget ) != 0 )
{
throw new Exception( "SDX Volume texture can not be declared as render target!!, SDXTexture.CreateVolumeTexture" );
}
D3D.Format sdPF = ChooseD3DFormat();
D3D.Usage usage = 0;
int numMips = ( RequestedMipmapCount == 0x7FFFFFFF ) ? -1 : RequestedMipmapCount + 1;
if ( ( Usage & TextureUsage.Dynamic ) != 0 )
{
if ( CanUseDynamicTextures( usage, D3D.ResourceType.VolumeTexture, sdPF ) )
{
usage |= D3D.Usage.Dynamic;
_dynamicTextures = true;
}
else
{
_dynamicTextures = false;
}
}
// check if mip map volume textures are supported
MipmapsHardwareGenerated = false;
if ( ( _devCaps.TextureCaps & D3D.TextureCaps.MipVolumeMap ) != 0 )
{
if ( ( Usage & TextureUsage.AutoMipMap ) != 0 && RequestedMipmapCount != 0 )
{
MipmapsHardwareGenerated = CanAutoGenMipMaps( usage, D3D.ResourceType.VolumeTexture, sdPF );
if ( MipmapsHardwareGenerated )
{
Usage |= TextureUsage.AutoMipMap;
numMips = 0;
}
}
}
else
{
// no mip map support for this kind of textures :(
MipmapCount = 0;
numMips = 1;
}
// derive the pool to use
DeterminePool();
// create the texture
_volumeTexture = new D3D.VolumeTexture( _device,
Width,
Height,
Depth,
numMips,
usage,
sdPF,
_d3dPool );
// store base reference to the texture
_texture = _volumeTexture;
// set the final texture attributes
D3D.VolumeDescription desc = _volumeTexture.GetLevelDescription( 0 );
SetFinalAttributes( desc.Width, desc.Height, desc.Depth, D3DHelper.ConvertEnum( desc.Format ) );
if ( this.MipmapsHardwareGenerated )
_texture.AutoMipGenerationFilter = GetBestFilterMethod();
}