RE: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
Actually, one more idea: It will be extra-slow, but we could implement a general all-to-all format by converting the source format to A32R32G32B32F(float values), and then write code to convert this format to all possible destination formats. The from-to table lookup could be replaced by code that can combine multiple conversions to find a conversion strategy(e.g. R5G6B5-ARGB32F-R8G8B8). I am not sure if it is a good idea, but it is worth a consideration
RE: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
The patch looks reasonably, just one small thing: There is a count_bits function implemented in utils.c, which as far as I can see does the same as getMaskSize. Can you check if you can reuse it? -Original Message- From: [EMAIL PROTECTED] [mailto:wine-patches- [EMAIL PROTECTED] On Behalf Of Victor Eremin Sent: Wednesday, July 23, 2008 10:25 AM To: [EMAIL PROTECTED] Subject: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt) Supports conversion between most of unsigned color argb/xrgb surface formats (D3DFMT_A8R8G8B8, D3DFMT_A8R3G3B2, etc), and luminosity color formats (D3DFMT_L8, etc), excluding D3DFMT_A16R16G16B16, D3DFMT_A8P8, D3DFMT_P8 and D3DFMT_A1. luminosity to argb/xrgb (and vice versa) conversions are not supported Removes Cannot find coverter FIXMEs from Ancient Evil and Stranded 2 games. Fixes water glitches in Stranded 2 game. --- dlls/wined3d/surface_base.c| 202 ++- dlls/wined3d/utils.c | 126 +- dlls/wined3d/wined3d_private.h |2 +- 3 files changed, 260 insertions(+), 70 deletions(-)
Re: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
On Wednesday 23 July 2008 20:10:02 Stefan Dösinger wrote: Actually, one more idea: It will be extra-slow, but we could implement a general all-to-all format by converting the source format to A32R32G32B32F(float values), and then write code to convert this format to all possible destination formats. The from-to table lookup could be replaced by code that can combine multiple conversions to find a conversion strategy(e.g. R5G6B5-ARGB32F-R8G8B8). I am not sure if it is a good idea, but it is worth a consideration I thought about that, but decided that it'll be too slow (conversion to float and back), and there are more than 4 possible channels (luminance, palette, depth, stencil, channels for formats like D3DFMT_V8U8), there are compressed formats like DXT, and two palette formats that would need additional data for conversion. I think it makes sense (later) to implement several different generic converters, several special conversion functions (like A8R8G8B8-P8) and then use this strategy to combine all these converters into one chain. It makes sense to consider which conversions are really used. Stuff like R5G6B5-X8R8G8B8 is common, but I don't think anyone would ever need D24S8-ARGB32F. Even ARGB32F-P8 is unlikely (although X8R8G8B8-P8 is required by some games). On Wednesday 23 July 2008 20:10:02 Stefan Dösinger wrote: The patch looks reasonably, just one small thing: There is a count_bits function implemented in utils.c, which as far as I can see does the same as getMaskSize. Can you check if you can reuse it? Done and resubmitted (count_bits was more elegant, by the way). But I hope that there is a warranty that unsigned int isn't less than 32 bit on all systems where WINE is used (maybe I'm just paranoid). -- Victor Eremin ([EMAIL PROTECTED]) signature.asc Description: This is a digitally signed message part.
Re: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
On Wednesday 23 July 2008 09:10:02 am Stefan Dösinger wrote: The patch looks reasonably, just one small thing: There is a count_bits function implemented in utils.c, which as far as I can see does the same as getMaskSize. Can you check if you can reuse it? Maybe it would be better if the table was changed to have a bit offset and a mask size, instead of the actual mask. All the bits for any given component are always continuous, and things would be easier to handle with the offset and size (eg. the float formats could get a proper mask; not that they could be converted in this way, though). So for a generic converter, you can basically get: outcolor = (((incolorinfmt-r_offset)((1infmt-r_size)-1)) * outfmt-r_size / infmt-r_size) outfmt-r_offset; outcolor |= (((incolorinfmt-g_offset)((1infmt-g_size)-1)) * outfmt-g_size / infmt-g_size) outfmt-g_offset; outcolor |= (((incolorinfmt-b_offset)((1infmt-b_size)-1)) * outfmt-b_size / infmt-b_size) outfmt-b_offset; outcolor |= (((incolorinfmt-a_offset)((1infmt-a_size)-1)) * outfmt-a_size / infmt-a_size) outfmt-a_offset; For any non-mixed unsigned integer type.
Re: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
On Wednesday 23 July 2008 21:18:57 Chris Robinson wrote: Maybe it would be better if the table was changed to have a bit offset and a mask size, instead of the actual mask. 0) initial patch used mask size + mask offset, but was rewritten to use mask value when Stefan Dösinger requested that. I don't want to rewrite it back to use mask size + mask offset. 1) mask size and offset can be extracted from mask value. 2) using mask instead of mask size + mask offset requires less function arguments and smaller format table, although, yes there is a higher chance of producing errors. -- Victor Eremin ([EMAIL PROTECTED]) signature.asc Description: This is a digitally signed message part.
Re: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
On Wednesday 23 July 2008 10:29:37 am Victor wrote: 0) initial patch used mask size + mask offset, but was rewritten to use mask value when Stefan Dösinger requested that. I don't want to rewrite it back to use mask size + mask offset. 1) mask size and offset can be extracted from mask value. 2) using mask instead of mask size + mask offset requires less function arguments and smaller format table, although, yes there is a higher chance of producing errors. But extracting the mask offset and size from the actual mask takes a bit of time, and as it is, the table can't currently set a proper mask for anything over 32 bits (including the 16-bit-per-component unsigned integer types).
Re: wined3d: universal surface convertor function for unsigned integer color formats(3rd attempt)
On Wednesday 23 July 2008 21:48:59 Chris Robinson wrote: But extracting the mask offset and size from the actual mask takes a bit of time, Extracting mask is called once or twice per channel conversion. I.e. in case of converting a8r8g8b8-a1r5g5b5 mask should be calculated only 8 times, no matter how big surface is. check mask_copy() routine for details. Optimizing this is pointless - converter performs much more per pixel operations - shifts, bitwise operations, etc, so you won't notice any difference. and as it is, the table can't currently set a proper mask for anything over 32 bits (including the 16-bit-per-component unsigned integer types). Yes, this isn't supported. But with current scheme of conversion, adding support for 16-bit-per-component surfaces would require operating on 64bit numbers or increasing number of per-pixel operations. I think per-pixel 64bit shifts on 32bit CPUs will be slower. replacing masks with number of bits and shift will need additional work, since masks are probably used in other places. There will be also high chance of breaking entire table accidentally because of misprint. If you don't like current functionality, to my opinion the best approach would be to modify it once my patch made it in repository. -- Victor Eremin ([EMAIL PROTECTED]) signature.asc Description: This is a digitally signed message part.