Results 1 to 2 of 2

Thread: Operations on parts of different arrays

Hybrid View

  1. #1
    Newbie
    Join Date
    Dec 2013
    Posts
    1

    Operations on parts of different arrays

    Hello.
    I am doing a raycasting engine and for performance reasons I thought it would be good to use the GPU for many for loop calculations.
    Tutorials I found are very scarce and only show manipulation of multiple arrays of same size. I need to convert something like this:

    Code :
    for(int y = drawBeginAux; y < drawEndAux; ++y)
    {
        int texY = static_cast<int>(((y - rdba) * (middleImageHeight * lhfr))) % middleImageHeight;
        int texIndex = (texX * middleImageHeight + (middleImageHeight - texY - 1));
     
        int index = ((m_ScreenHeight - y - 1) * m_ScreenWidth + x);
     
        m_ScreenBuffer[index] = middleImageData[texIndex];
        m_ColorBuffer[index] = lightLevel;
    }

    Into OpenCL code and I have no clue how. Any help? It does not have to be full ocl code, just point me in the right direction.

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    161
    With OpenCL you replace your inner loop (or loops, for 2D or 3D cases) with kernels that execute in parallel. So replace your "for" loop with the kernel declaration, and then add "int y = get_global_id(0)" above your code. Many of the fixed variables become kernel parameters, and the screen buffer, color buffer, and image data become OpenCL buffer objects (or perhaps OpenCL image objects.

    Check out these fine training videos: http://www.khronos.org/message_board...raining-Videos

Posting Permissions

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