Results 1 to 10 of 13

Thread: [delphi 7]code optimalisation, comparing 2d matrices of words [SSE?]

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    By the way, I've been thinking... You could also try some unorthodox approach using simple GPU tricks.

    Taking this code:
    for x := rect.Left to rect.Right do
    for y := rect.Top to rect.Bottom do
    dLW := dLW + abs( ((currentPixels[y + yo,x + xo] * multLW) shr 14) - referencePixels[y,x] ) shr 6;
    Use the following approach:
    1) Load image_1 and image_2 with A16B16G16R16.
    2) Draw image_1 on A16B16G16R16 render target.
    3) Draw image_2 on the same render target using subtract blending operation.
    4) Take render target and generate full set of mipmaps up to 1x1 on GPU.
    5) Smallest mipmap (1x1, one pixel) contains the resulting average difference, in 16-bit.

    You could even improve resolution to 32-bit, but generating mipmaps will be more complicated. You will have to make them sequentially by drawing 50% image on render target and repeat the same process until last render target is 1x1 pixel. This is most likely how GPU does it anyway though.

    Using above approach you take advantage of full GPU's parallel processing power and memory bandwidth, but without using complex GPGPU techniques.

    P.S. Using shaders, calculating differences and making mipmaps can be even combined into one single step to reduce number of iterations (e.g. reduce image by 4x, calculating differences for the reduced segment).
    Last edited by LP; 28-08-2012 at 02:12 AM. Reason: added more detailed explanation

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •