Results 1 to 4 of 4

Thread: Some questions about compute shader

  1. #1

    Question Some questions about compute shader

    Hello, I have some questions about compute shader. My application contains function, in which invokes 2 compute shaders. First fills by some value 2D texture (RGBA32F) or SSBO (in function invoked for 2D texture and SSBO), second performs computations and uses prepaired by first shader texture and SSBO (contains loops, if statements (at this moment can't rewrite without them)). In another function I read values from SSBO and texture by glMapBuffer and glGetTextureSubImage. All worked, before I started calling these functions in for loop. App began crashing after delay with STATUS_STACK_BUFFER_OVERRUN(0xC0000409) at the first occurrence of glMapBuffer/glGetTextureSubImage. If comment buffer and texture access functions (such as glMapBuffer/glGetTextureSubImage/glUnmapBuffer) app working without problem. So, for continue work around, I want to know something else about compute shader.

    1) Have to I call something else before reading from SSBO/texture modified by compute shader? (now I call only glMemoryBarrier with appropriate bit and bind buffer/texture)
    2) Have to I call something else after reading from SSBO/texture? (now only glUnmapBuffer if reading from SSBO)
    3) How should I invoke compute shader in such situation? (maybe I do something wrong: use shader - bind uniforms - glDispatchCompute - glMemoryBarrier - unuse shader)

  2. #2
    Yesterday I maybe found the source of problem - my second shader very complex and unoptimized, so it takes even seconds sometimes to complete work and Windows thinks, that application is not responding (window marked as Not responding before crash), so after a few seconds terminates it.

  3. #3
    Senior Member Regular Contributor
    Join Date
    May 2016
    Posts
    477
    maybe a "glFinish();" at the end of the loop solves the problem
    https://www.khronos.org/registry/Ope...glFinish.xhtml


    Quote Originally Posted by Van der Deken View Post
    1) Have to I call something else before reading from SSBO/texture modified by compute shader? (now I call only glMemoryBarrier with appropriate bit and bind buffer/texture)
    if you want to read from a buffer / texture in which the previous invocation of the computeshader writes into, then yes, you have to call:
    Code :
    glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_TEXTURE_FETCH_BARRIER_BIT);
    https://www.khronos.org/opengl/wiki/...lMemoryBarrier

    Quote Originally Posted by Van der Deken View Post
    2) Have to I call something else after reading from SSBO/texture? (now only glUnmapBuffer if reading from SSBO)
    yes, glMemoryBarrier(...) BEFORE you map the buffer, and when finished reading, immediately glUnmapBuffer(...) BEFORE you use the buffer again

    Quote Originally Posted by Van der Deken View Post
    3) How should I invoke compute shader in such situation? (maybe I do something wrong: use shader - bind uniforms - glDispatchCompute - glMemoryBarrier - unuse shader)
    thats correct, but you need to call glMemoryBarrier(...) if you want the buffers / textures to ...
    Quote Originally Posted by OenGL wiki
    ... reflect data written by shaders prior to the barrier.

  4. #4
    Thank you for your reply, john_connor, it helped me understand, that I correctly use compute shaders. glFinish() helped a little bit (app crashes now with higher values), so I think the main problem is shader's complexity and I have already started refactoring.

Similar Threads

  1. Replies: 3
    Last Post: 05-03-2018, 03:52 PM
  2. Some questions about compute shader
    By Van der Deken in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-13-2017, 09:01 AM
  3. VBO and compute shader
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-09-2015, 09:00 AM
  4. Compute shader unresponsive
    By Mustard in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-04-2013, 12:38 AM
  5. How to compute LOD in pixel shader?
    By Nadine in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-04-2004, 01:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean