32 votes
Accepted

When is a compute shader more efficient than a pixel shader for image filtering?

An architectural advantage of compute shaders for image processing is that they skip the ROP step. It's very likely that writes from pixel shaders go through all the regular blending hardware even if ...
user avatar
21 votes
Accepted

Why is work-efficiency desired in GPU programming?

First of all, re: "GPUs are simply giant SIMD processors and should operate in lock-step", it's a bit more complicated than that. The entire GPU does not run in lockstep. Shader threads are organized ...
user avatar
  • 23.6k
18 votes

When is a compute shader more efficient than a pixel shader for image filtering?

John has already written a great answer so consider this answer an extension of his. I'm currently working a lot with compute shaders for different algorithms. In general, I've found that compute ...
user avatar
  • 800
14 votes
Accepted

Synchronizing successive OpenGL Compute Shader invocations

No it is not guaranteed, since the OpenGL specification allows that two Compute Shader run concurrently or even in different order. You need to call ...
user avatar
  • 813
10 votes
Accepted

Performance of Compute Shaders vs. Fragment Shaders for Deferred Rendering

After more analysis, the TL;DR here is that, yes, the slowdown is due to memory locality, and yes the pixel order is to blame. More interestingly, by writing the shader differently, we can greatly ...
user avatar
  • 1,790
7 votes
Accepted

OpenGL Compute Shader generating triangle indices: How to get correct element count for glDrawElementsIndirect?

If you have access to glsl 4.3+ (or glsl ES 3.1) you can use atomicAdd The next option is to use a barrier() after all vertices are generated in the compute and ...
user avatar
7 votes

Compute Shader vs CUDA/OpenCL

It's not quite correct, today, to think of compute shaders as being "in the shader pipeline" in the same sense that your vertex and fragment shaders are literally hooked up into a pipeline. Compute ...
user avatar
7 votes

What's the point of "work groups" for OpenGL compute shaders?

I won't be discussing the usefulness of workgroups here as you can find it pretty much anywhere. However I am going to touch up on GPU architecture to understand why do we have workgroups in the first ...
user avatar
6 votes

Creating shared vertex normals on GPU

For an nVidia only solution you can use floating point atomic add intrinsics (like NvInterlockedAddFp32) Unlocking GPU Intrinsics in HLSL | NVIDIA Developer I tried this on 80.000 vertex mesh and it'...
user avatar
6 votes
Accepted

How to convert a thread ID into Screen Space Coord in an OpenGL Compute Shader?

The problem is actually in your fragment shader: color_out = texture(source_image, gl_FragCoord.xy); The texture() function accepts normalized coordinates which ...
user avatar
5 votes
Accepted

Threads per compute shader group

There shouldn't be any performance penalty inherent in using a 3D group over a 2D one, the dimensions are just an aid for programmers to map invocations on to memory locations (since you can read or ...
user avatar
  • 2,302
5 votes

Compute shaders: one-time-only versus persistent buffers

Yes, it's totally possible, and in fact it's preferable to keep buffers in memory if you will be accessing them over the life of your program, rather than deallocating and reallocating them again. I ...
user avatar
  • 2,302
5 votes
Accepted

Threads lockstep and conditions in compute shader

Not all threads will execute in lockstep but they are split into groups whose threads are locked to each other. This means that if only 1 thread out of all threads enters a branch then only 1 group ...
user avatar
5 votes

What's the point of "work groups" for OpenGL compute shaders?

Work groups share resources. The most notable resources they share are barriers and LDS (Local Data Storage aka shared memory in GL lingo, aka Thread Group Shared Memory). See Efficient Compute Shader ...
user avatar
4 votes

Estimating the area of a triangle-circle intersection

Working Towards an Exact solution Just some quick thought before I must run! Ok, let us turn the problem on its head. What if one does not calculate the area of the triangle cut by the circle. ...
user avatar
  • 8,169
4 votes
Accepted

Register pressure in Compute Shader

Lowering register pressure doesn't necessarily give you any performance boost though. I recently went through this exercise myself on GCN architectures (for a simple ray tracer) and reduced register ...
user avatar
  • 3,556
4 votes

When is a compute shader more efficient than a pixel shader for image filtering?

I stumbled on this blog: Compute Shader Optimizations for AMD Given what tricks can be done in compute shader (that are specific only to compute shaders) I was curious if parallel reduction on ...
user avatar
  • 56
4 votes
Accepted

CUDA/OpenCL vs OpenGL compute shader for Path tracer

To first clear your confusion around the terms: GPGPU stands for General Purpose computing on GPUs CUDA is the specific NVIDIA API to perform GPGPU only on their hardware OpenGL is a graphics ...
user avatar
4 votes
Accepted

Can gl_WorkGroupSize be set outside the compute shader?

Core OpenGL has no mechanism for this. The ARB_compute_variable_group_size extension provides such a feature. It doesn't allow for indirect compute operations though. It doesn't seem to have much AMD ...
user avatar
  • 8,101
4 votes
Accepted

Performance difference in OpenGL compute shader vs Vulkan Compute Shader vs Cuda/OpenCL and others

In general, you should not see significant performance differences running identical compute shaders via one API vs. another; in the end they’re running the same instructions on the same hardware. It’...
user avatar
4 votes
Accepted

Compute Shader shared average value

First of all, I don't think you need volatile or memory barriers if you're just using atomic operations. Atomic operations are always supposed to be atomic ...
user avatar
  • 23.6k
3 votes
Accepted

Controling order of execution of a (compute) shader on an array of vertices (data) in Vulkan

Vulkan is not really suited to at least some of the task you're trying to accomplish. It has no mechanism to declare from within a shader that some additional work should be invoked. Or at least, not ...
user avatar
  • 8,101
3 votes
Accepted

Process of compute shader in OpenGL

The Opengl deals this problem automatically? How could it? At no point do you inform OpenGL that you only want 900 invocations. You have exactly 2 mechanisms to control the number of invocations: ...
user avatar
  • 8,101
3 votes
Accepted

Buffer of arrays in HLSL compute shader

It looks to me like you want a buffer containing a single array of integers (not a buffer containing multiple arrays, whatever that would mean). So, you should be able to just do this: ...
user avatar
  • 23.6k
3 votes

Writing to a compressed texture using a compute shader, with no extra copies

After looking into this for a while, I found out a couple of things: You cannot avoid a memcpy: You cannot write directly into texture storage allocated for a compressed texture using only OpenGL API ...
user avatar
  • 1,074
3 votes
Accepted

Procedural terrain: What's the best approach to calculate noise in the GPU?

r a similar problem (a tree of combined noise functions, evaluated on the GPU), I found a good method is to generate a shader from the expression tree. Each predefined node corresponds to a single ...
user avatar
  • 811
3 votes
Accepted

GLSL Compute Shader doesn't run for large inputs

Operating systems cancel GPU program executions if they take too long. On Windows it is generally two seconds and on Linux it is five seconds most of the time, but it can vary. This is to detect GPU ...
user avatar
  • 179
3 votes
Accepted

Sharing memory between compute shader and pixel shader

well, if anyone is stumbling across this and needs to know what solved it for me: We can bind a compute buffer to global shader memory if we just know what exactly we need to do within the Compute ...
user avatar
3 votes
Accepted

GLSL Compute Shader Setting "shared" memory buffer size

GLSL has no mechanism to change the "size" of shared memory. Indeed, GLSL is structurally incapable of such a thing. You can't get a pointer to shared memory. Indeed, "shared memory&...
user avatar
  • 8,101
2 votes
Accepted

Raytracing in OpenGL using Compute Shaders

So i searched a lot after this and I think it was my confusion on FrameBuffer Objects. I thought you could use FBO's just like a default FrameBuffer and display the texture image attached to it but ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible