Dxt1 textures no mip levels

Started by
2 comments, last by 21st Century Moose 11 years, 7 months ago
Hello everbody!

Im trying to create a texture that has Dxt1 compressed data. So basically the format Format.Dxt1 from SlimDX.Direct3D9.Format enumeration. In order to do this im using BC1_UNorm in D3D11 as a format as thats what i could read is the correct format in D3D11. Well, there is a problem with that format:
My texture has several mip levels already defined but when i set a mip level other to 1 the texture creation fails with D3DERR_INVALID_ARG, including 0 which is supposed by the MSDN for a full set of mip maps.
[source lang="csharp"] Texture2DDescription desc = new Texture2DDescription()
{
Usage = ResourceUsage.Dynamic,
SampleDescription = new SampleDescription(1, 0),
OptionFlags = ResourceOptionFlags.None,
MipLevels = levelCount,
Width = width,
Height = height,
Format = texFmt,
CpuAccessFlags = CpuAccessFlags.Write,
BindFlags = BindFlags.ShaderResource,
ArraySize = 1
};[/source]

Where:
levelCount in a particular case is 9, width and height are 256, texFmt is BC1_UNorm.

How do i create a texture with S3TC and several mip levels?

Greetings and thanks in advance
Plerion
Advertisement
You're trying to make it a dynamic texture, and dynamic textures don't support mip maps. Do you actually need it to be dynamic?

FYI if you create the device with the DEBUG flag it will output messages about errors like this. It will output them to the native debugging stream, so you need to have native debugging enabled or use a program like DebugView to see the messages in a managed app.
Well it seems ive misunderstood some of the concepts with the CpuAccessFlags and/or ResourceUsages. After ive read the section about resources in my book i assumed that for UpdateSubresource i need to specify CpuAccessFlags.Write and thus i need to use Dynamic as usage. But obviously this is not needed. Changed it to Default and CpuAccessFlags.None, now it works and also UpdateSubresource works which i dont understand to be honest...
View the CPU Access Flags member as being relevant to a Map call - you need a CPU access that will allow for the map type you're using. This is specifically called out by the documentation for D3D11_CPU_ACCESS_FLAG (see http://msdn.microsof...6(v=vs.85).aspx) where each flag is defined in terms of the resource being mappable.

You can still use UpdateSubresource on USAGE_DEFAULT resources. Here you're not actually accessing the resource data directly yourself, instead you're shoving a chunk of data to the driver and telling the driver to use it to update the resource. So the general rule is - if D3D gives you a pointer via a Map operation then you need CPU access, if you provide the pointer yourself and send data to D3D then you don't.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement