   [DX9] Checking whether 2 textures are the same or not. How?
  Hi all,Is there a way to check whether 2 textures are "exactly" the same?Now I'm thinking an approach like locking all the pixels and checking'em pixel by pixel. But I'm afraid of becoming it too expensive.Please help.Thx. in advance.-R   
  Well, that's pretty much your only choice if you want to know if the two textures are the same.   ;  You could (ab)use the GPU for this.You would have a render target the same size as the textures, and a bunch of targets that are progressively half the size.First render with a shader that emits a 0 if the textures are equal in the fragment, and a 1 if they are not equal.Then you can bind that resulting target as a source texture and the next smaller target as your target, then draw with linear interpolation with a shader that samples the source, testing if the interpolated 2x2 block is 0 or not (that is, if the block contains no 1 fragments (as if it does, the value will be 1/3, 2/3 or 3/3).Simply repeat the process until you get to 1x1 or terminate earlier and test CPU-side. You can cut down the number of steps by sampling more in each level, but this will eventually be log(side) in complexity.Another approach is to do the first render to the top level of a mip target and then compute mipmaps, but that will only work for up to a particular size, and most probably uses CPU-side resources.The former method has the benefit of allowing you to do multiple tests at once, as you don't need that many bits per level in the render target.   ;  You could also use LockRect of both textures, and memcmp the pixel data.   ;  You could make that GPU method quicker by using an occlusion query, and adjusting the shader to clip() away matching pixels.   ;  Why don't you just compare each texel of a smaller mipmap provided you create mipmaps?   ;  Mipmaps generated by standard methods would give false positives on equality, as a texel in a downlevel mipmap is sourced from (at least) four texels on the level above, possibly mangled via lowpass filtering as well.Additionally, mipmaps are typically generated on the CPU, resulting in a larger cost than the naive lock+memcmp method.The shader pingpong I outlined in effect generates the mips through a different reduction function, preserving the presence of differences.As my fellow posters mention above, a more efficient way would probably be to texkill and test via occlusion counters or similiar ways.As for locking and memcmping, I believe that was what the OP wanted to get away from in the first place.   