On 23/09/2007, Stefan Dösinger stefandoesinger@gmx.at wrote:
/* DXTn textures are based on compressed blocks of 4x4 pixels, each
* 16 bytes large (8 bytes in case of DXT1). Because of that Pitch has
* slightly different meaning compared to regular textures. For DXTn
* textures Pitch is the size of a row of blocks, 4 high and "width"
* long. The x offset is calculated differently as well, since moving 4
* pixels to the right actually moves an entire 4x4 block to right, ie
* 16 bytes (8 in case of DXT1). */
if (This->resource.format == WINED3DFMT_DXT1) {
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 2);
} else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3
|| This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) {
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 4);
} else {
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
}
Where did that part go?
Am Sonntag, 23. September 2007 00:14:06 schrieb Stefan Dösinger: Ah, and the cleanup needs a cleanup itself too, e.g. RequestLocation should move most code into subfunctions.
Yes.
The patches don't aim at fixing any bugs themselves, and I hardly tested them, so there may be a truckload of regressions. I'm mainly showing them to show the general direction I'm heading into.
The general direction of the patches seems ok, although I'm not sure if RequestLocation / ModifyLocation is optimal from a naming point of view. (Ie, RequestLocation typically moves data rather than returning a location for the caller to read/write to, while ModifyLocation just flips a flag rather than modifying the location of the actual data)
OT(?): Wrt. regressions, I would like to mention that I think that in general more care should be taken to verify a patch is correct when *writing* the patch. I do sometimes get the feeling that the general approach taken is one of "Throw some patches at it, see what sticks" :-/