Re: AW: GPU Accelerated loading of fanart/images
Should do yes.
Does it also improve speed on ATI cards?
Should do yes.
Does it also improve speed on ATI cards?
nvcompress.exe -bc3 "\\source\test.jpg" c:\test.dds
private static void SaveAsDDS(Bitmap Image, string filename)
{
using (var iStream = ConvertImageToStream(Image))
{
Format fmt = Format.A8R8G8B8;
var info = new ImageInformation();
var texture = TextureLoader.FromStream(GUIGraphicsContext.DX9Device,
iStream, (int)iStream.Length,
0, 0, //width/height -> auto
1, //mipslevels
0,
fmt,
GUIGraphicsContext.GetTexturePoolType(),
Filter.None,
Filter.None,
0,
ref info);
TextureLoader.Save(filename, ImageFileFormat.Dds, texture);
texture.SafeDispose();
}
}
private static MemoryStream ConvertImageToStream(Bitmap imageToConvert)
{
var ms = new MemoryStream(imageToConvert.Width * imageToConvert.Size.Height * 4);
imageToConvert.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
return ms;
}
I have experimented with this before, as said above, no code changes are required (strickly speaking).
I have a patch laying around that hcanges the texturepacker to pack things as dds instead of png. But I decided not to pursue it because while packed skin files are loaded faster (about 150ms before to about 35ms after per packed texture) it doesnt really matter because they are loaded once per application start only anyways.
The other graphics, are things like fanart. Those get loaded/unloaded on the fly, so the should benefit. Nothing is stopping skinners that use alot of such large images to supply them as dds, or convert them to dds in their installer. So MePo shouldn't interfere here.
The last thing, are dynamically downloaded/created images, like movie-specific fanart etc. Here we have to question filesize/time to convert these images. DDS files are vastly larger than most jepgs, so for users with 100s of movies, and a few fanart per movie, maybe large poster files, we could be taking gbs of data. And to convert them, is MePo responsible to do that, or the plugins? Should it be handled in the background? I think this should be up to plugin-devs to decide, as they know best. If they are converted on first load, this will slow things down alot for the first time.
To sum up, IMO:
- packed graphics doesnt benefit noticably at all
- static images of skins should be handled by the skinners
- plugin-devs are the only ones that can know for what images their plugin may benefit. It should be up to them to save them as such (its simple to write a file as dds) as they may also reference them in their database or handle cleaning up. So they have to know whats going on.
- In the end, Mediaportal is fully ready to support dds images. It's more a matter of educating skin/plugin-devs.
Edit: heres some quick code to convert an image to DDS and save it to the disk for consequent loading. I'm sure Nvidia texture tools etc. are faster/higher quality, but this is to get an idea if someone wants to write code.
Code:private static void SaveAsDDS(Bitmap Image, string filename) { using (var iStream = ConvertImageToStream(Image)) { Format fmt = Format.A8R8G8B8; var info = new ImageInformation(); var texture = TextureLoader.FromStream(GUIGraphicsContext.DX9Device, iStream, (int)iStream.Length, 0, 0, //width/height -> auto 1, //mipslevels 0, fmt, GUIGraphicsContext.GetTexturePoolType(), Filter.None, Filter.None, 0, ref info); TextureLoader.Save(filename, ImageFileFormat.Dds, texture); texture.SafeDispose(); } } private static MemoryStream ConvertImageToStream(Bitmap imageToConvert) { var ms = new MemoryStream(imageToConvert.Width * imageToConvert.Size.Height * 4); imageToConvert.Save(ms, ImageFormat.Bmp); ms.Seek(0, SeekOrigin.Begin); return ms; }
The last thing, are dynamically downloaded/created images, like movie-specific fanart etc. Here we have to question filesize/time to convert these images. DDS files are vastly larger than most jepgs, so for users with 100s of movies, and a few fanart per movie, maybe large poster files, we could be taking gbs of data. And to convert them, is MePo responsible to do that, or the plugins? Should it be handled in the background? I think this should be up to plugin-devs to decide, as they know best. If they are converted on first load, this will slow things down alot for the first time.