TheSonny

How to "enable" automatic mipmap generation in RenderTarget2D


Re: XNA Framework RenderTarget2D and MipMaps

Shawn Hargreaves - MSFT

Create a rendertarget with more than one mip level, and you're done. If there are mipmaps, the framework will automatically fill them for you during the Resolve call.





Re: XNA Framework RenderTarget2D and MipMaps

TheSonny

i don't know why but it don't work

m_DrawBufferColor = new RenderTarget2D(m_GraphicsDevice,
1024, 1024, 4, SurfaceFormat.Color, MultiSampleType.None, 0);

m_Game.GraphicsDevice.SetRenderTarget(0, m_DrawBufferColor);

//here i render

m_GraphicsDevice.ResolveRenderTarget(0);
m_GraphicsDevice.SetRenderTarget(0, null);

//now i use it

Texture2D Tex = m_DrawBufferColor.GetTexture();
m_HDREffect.Parameters["DiffuseTexture"].SetValue(Tex);

//part of fx file
Out = tex2Dbias(DiffuseSampler, float4(In.TexCoord.xy, 0, 3));

and i get some thing that looks like like random (texture on this mip level is some random memory)

//------------------------
it work when i do it that way but its slower:

Texture2D Tex = new Texture2D(m_Game.GraphicsDevice, 1024, 1024, 1,
ResourceUsage.AutoGenerateMipMap, SurfaceFormat.Color);

byte[] Data = new byte[1024*1024*4];
m_DrawBufferColor.GetTexture().GetData(Data);
Tex.SetData(Data);
m_HDREffect.Parameters["DiffuseTexture"].SetValue(Tex);

and now it work fine
//-------------------------

any sugestion what i do wrong




Re: XNA Framework RenderTarget2D and MipMaps

Shawn Hargreaves - MSFT

What platform is this on If Windows, what is your graphics card





Re: XNA Framework RenderTarget2D and MipMaps

TheSonny

Windows, (gf6200 128MB)
and first mip map looks like this: [old link]




Re: XNA Framework RenderTarget2D and MipMaps

Tom Miller - MS

Do you happen to remember which version of the driver you are using for your graphics card




Re: XNA Framework RenderTarget2D and MipMaps

TheSonny

i try it on 91.31 and 93.71 and dont work

i have link to exe : [old link]

if you see many earth on black it mean that my comp/system is broken:)
if you see some thing else - its something with code.




Re: XNA Framework RenderTarget2D and MipMaps

Shawn Hargreaves - MSFT

We're thinking this is actually a driver bug. Apparently there is a problem with some NVidia drivers where the StretchRect call that we use internally is failing, but reporting success so we have no way of detecting and working around the problem.