Questions tagged [compute-shader]
The compute-shader tag has no usage guidance.
74
questions
59
votes
3
answers
35k
views
When is a compute shader more efficient than a pixel shader for image filtering?
Image filtering operations such as blurs, SSAO, bloom and so forth are usually done using pixel shaders and "gather" operations, where each pixel shader invocation issues a number of texture fetches ...
15
votes
1
answer
3k
views
Synchronizing successive OpenGL Compute Shader invocations
I have a couple of compute shaders that need to be executed in a certain order and whose outputs depend on previous inputs. Ideally, I'll never need to copy a buffer client-side and do all of my work ...
14
votes
1
answer
940
views
Why is work-efficiency desired in GPU programming?
I've been reading the following article on how to do a parallel scan in CUDA:
https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch39.html
In the article, there is an emphasis on making the scan ...
10
votes
1
answer
7k
views
Performance of Compute Shaders vs. Fragment Shaders for Deferred Rendering
I have written a deferred renderer that can use either a fragment shader or a compute shader to execute the shading pass. Unfortunately, the compute shader implementation runs slower. I'm trying to ...
10
votes
1
answer
601
views
Creating shared vertex normals on GPU
I've mostly succeeded at porting an implementation of Marching Cubes from CPU over to OpenGL compute shaders, but I haven't tackled normals yet and wondering the best way to go about it.
My ...
9
votes
1
answer
4k
views
Compute Shader vs CUDA/OpenCL
So I just recently learned about the Compute Shader and it looks from what I have picked up the same idea as parallel programming you would do with CUDA or OpenCL, but in the shader pipeline.
If I ...
9
votes
1
answer
2k
views
Writing to a compressed texture using a compute shader, with no extra copies
I'm trying to figure out what the best way is to generate an OpenGL texture using a compute shader. So far, I've read that pixel buffer objects are good for non-blocking CPU -> GPU transfers, and that ...
8
votes
1
answer
2k
views
OpenGL Compute Shader generating triangle indices: How to get correct element count for glDrawElementsIndirect?
I have a sequence of compute shaders that generates an indexed mesh.The last one of those writes the generated indices like this:
...
7
votes
1
answer
2k
views
How to convert a thread ID into Screen Space Coord in an OpenGL Compute Shader?
I've written an implementation of the sphere tracing algorithm in OpenGL 4+.
As an experiment/toy project, I'm re-implementing it using the OpenGL 4.3 compute shader, but I'm having trouble with the ...
7
votes
1
answer
750
views
Estimating the area of a triangle-circle intersection
I am trying to implement Ray Tracing with Cones (Amanatides 1984). Instead of rays, cones are shot into the scene and intersected with geometry. Since multiple triangles can occupy the cone's aperture,...
6
votes
1
answer
3k
views
UV Coordinate Interpolation in Compute Shader
I am trying to get the screen space position of each pixel in a texture on a mesh and write it into a texture. I was hoping to use a compute shader to do this:
...
6
votes
1
answer
1k
views
Can I reuse glBindBufferBase in compute shaders to keep data on GPU?
(Apologies: I am cross-posting from SO, where there is no answer. I figured it might be more appropriate to be on this site.)
I'm trying to build a compute shader in OpenGL to perform a ...
5
votes
2
answers
4k
views
What's the point of "work groups" for OpenGL compute shaders?
glDispatchCompute has the number of work groups as arguments.
What is the point of having work groups? How are they useful, compared to just having NxM independent pixel calculations with a known (x,...
5
votes
1
answer
5k
views
Threads per compute shader group
The maximum allowed number of threads per compute shader group is 1024 for Shader Model 5.0. Is it advisable with regard to performance to stay close to this maximum number?
In order to resolve SSAA ...
5
votes
1
answer
1k
views
Threads lockstep and conditions in compute shader
I'm working with DirectCompute, but this question can be applied to general gpu programming I suppose.
As far as I know the threads in a group works in a lockstep. ...
4
votes
2
answers
915
views
Can gl_WorkGroupSize be set outside the compute shader?
I am migrating code from CUDA to OpenGL compute shaders.
I could not find a way to set the local workgroup size outside the shader; is there a way to set gl_WorkGroupSize in the calling program like ...
4
votes
1
answer
1k
views
Register pressure in Compute Shader
I'm in the process of writing a Ray Tracer using DirectCompute / HLSL. First, eye rays are generated (one per pixel). Then, rays are traced, shaded and reflected in a loop. Also, shadow rays for each ...
4
votes
1
answer
2k
views
Compute shaders: one-time-only versus persistent buffers
When using a Compute Shader, is it possible to keep a buffer in the GPU memory during the whole run-time duration of the application, so whenever the original Compute Shader or other Compute Shaders ...
4
votes
1
answer
436
views
How to prevent moire artifacts in this light casting algorithm?
I am writing a 2D light casting algorithm with OpenGL compute shaders. The algorithm is simple:
For each light source shoot out light rays from it, the ray begins at the light coordinates, it ends at ...
4
votes
1
answer
2k
views
Compute shader not updating buffer, or vertex buffer unable to read the updates
I'm learning OpenGL compute shaders and following this guy's code, and I have stuff drawing, but not updating. The particles are spread out in their starting positions, but they stay there.
...
4
votes
0
answers
296
views
Direct3D Global Atomic Issue
Recently I ran into an odd issue with some of my DirectX11 DirectCompute code
when trying it on an AMD GPU for the first time where as on a NVIDIA one it had worked fine all through development. The ...
3
votes
1
answer
777
views
Compute Shader shared average value
Short Question:
How can i integrate a buffer variable in a compute shader over each pixel i.e. how can i ensure memory coherence in such a case?
Long Question:
I've written a deferred renderer with ...
3
votes
1
answer
2k
views
Buffer of arrays in HLSL compute shader
I'm trying to follow along with a tutorial that uses an OpenGL compute shader, but I'm using D3D11. What they do is:
...
3
votes
2
answers
6k
views
Optimizing compute shader with thread group shared memory
I'm currently learning compute shaders and I'm trying to write an optimized Game Of Life. I have a first version working that uses a Shader Storage Buffer Object. I dispatch a thread per cell I want ...
3
votes
1
answer
448
views
Compute shader textures compared 2D float4 arrays
I am wondering is there a difference in performance between using floating point textures as my 2D float4 array vs just passing in 2D float4 arrays?
2D float arrays eliminate the need to do texture ...
2
votes
1
answer
5k
views
Performance difference in OpenGL compute shader vs Vulkan Compute Shader vs Cuda/OpenCL and others
I have been told there is no performance difference if you are skilled enough when it comes to gpu computing. And cuda only performs better because nvidia wants it to. I have also read graphic api's ...
2
votes
1
answer
5k
views
CUDA/OpenCL vs OpenGL compute shader for Path tracer
So I want to implement a path tracer and I am confused between GPGPU computing or using OpenGL's compute shaders. I've already implemented a raytracer using GL's compute shaders.
What are the main ...
2
votes
1
answer
2k
views
Sharing memory between compute shader and pixel shader
I am relatively new to compute shaders and gpgpu in general so bear with me if i am missing the point somewhere.
The main thing i do not yet understand / see is how to get memory from a compute ...
2
votes
1
answer
539
views
GLSL Compute Shader doesn't run for large inputs
The shader takes an SSBO of Photons that have a position, direction, wavelength and intensity and each thread is responsible for tracing exactly one photon through the grid, where at each grid cell ...
2
votes
2
answers
3k
views
How to use the data manipulated in OpenGL Compute Shader
I'm working with OpenGL and facing some difficulties because I'm not familiar with OpenGL. I tried to search related example in Google, but I could not find some useful code.
There are five arrays.
...
2
votes
2
answers
2k
views
Raytracing in OpenGL using Compute Shaders
I Recently posted this question on SO but didn't got any response so i thought to post it here since it's somewhat related to Raytracing.
I am making a real time ray tracer in OpenGL using Compute ...
2
votes
1
answer
521
views
Mipmap sampler in Metal compute kernel (not vertex or fragment shader)
I have a source texture (480x480) that was created with mipmapped set to true (error checking removed to simply this post), and a dest texture (100x100):
...
2
votes
1
answer
3k
views
Using buffers correctly in OpenGL compute shaders
I'm re-writing an algorithm that I first wrote using matrix/vector operation into OpenGL kernels in order to try to maximiz the performances.
I have a basic knowledge of OpenGL, so I was able to get ...
2
votes
1
answer
1k
views
Feeding vertex data to a compute shader
I'm writing a CAD program in vulkan. In my current design, I have line paths represented as large vertex buffers for rendering. I would like to implement an algorithm for extruding the path outwards, ...
2
votes
0
answers
551
views
How to retrieve data from Compute Shader to CPU?
I want to retrieve data that has created by the compute shader but have no clue how it works. After researching a few forums and articles on how it should work and this is what I came up with.
Compute ...
2
votes
0
answers
1k
views
Groupshared memory and parallel reduction over multiple kernel dispatch
I am doing some parallel reduction and mostly following these nVidia slides. However they are not very detailed in places or I might be missing/misunderstanding something.
Edit 2:
While I figured ...
1
vote
1
answer
1k
views
GLSL Compute Shader Setting "shared" memory buffer size
Is it possible to set the size of the shared memory of a compute shader workgroup from the host code? There is a way to do this in CUDA and I am suspecting that, since there is an GLSL extension to ...
1
vote
1
answer
965
views
Procedural terrain: What's the best approach to calculate noise in the GPU?
A few years ago I started creating a procedural planet engine/renderer for a game in Unity, which after a couple of years I had to stop developing due to lack of time. At the time i didn't know too ...
1
vote
1
answer
796
views
Controling order of execution of a (compute) shader on an array of vertices (data) in Vulkan
Is it possible to force Vulkan to execute a shader on vertices (data) in a semi-consecutive manner?
For example, if the data passed to the shaders as a binary tree, shader would process it one layer ...
1
vote
2
answers
3k
views
Passing parameters in Metal Compute Kernel using Swift 4
On the CPU side, I have a structure I want to pass to the compute kernel:
...
1
vote
1
answer
100
views
GLSL trying to bind two different layers from the same texture array as images. Should it work and if so what am I doing wrong?
I am new at this particular site in the SE ecosystem, but not to computer graphics in general. If I'm in the wrong spot feel free to redirect me.
My question regards glsl programming and binding two ...
1
vote
1
answer
900
views
On modern GPUs, what hardware do vertex/pixel shaders have access to that compute shaders don't?
Suppose that someone implemented rendering for a video game using entirely GPGPU apis, like compute shaders or CUDA.
Would it be possible to achieve the same performance as standard graphics pipelines ...
1
vote
1
answer
205
views
SSAO with reconstructed depths yields strip artifacts
I wrote an ssao algorithm with compute shaders and view-position-reconstruction from the depth buffer. It works great for objects near by but results in strip or banding artifacts for large planes ...
1
vote
1
answer
98
views
Is glDispatchCompute(a,b,c) any faster than glDispatchCompute(a*b*c,1,1)?
In my application, there is no inherent 2D or 3D structure to the computer shader instances. So having multiple dimensions doesn't benefit me semantically in any way. I am wondering, whether it still ...
1
vote
1
answer
199
views
Workgroup size performance change?
I know, that when using compute shader, the invocations should to be grouped with respect to a multiple of the hardware minimum workgroup size (Nvidia 32, AMD 64). Otherwise cores are blocked. In case ...
1
vote
1
answer
231
views
Having trouble understanding advection from GPU gems fluid dynamics example
So I am trying to implement a fluid simulation, as described in Chapter 38 of GPU Gems.
I am also drawing heavily from the excellent implementation by Pavel.
Where I'm getting a bit stuck is with ...
1
vote
1
answer
2k
views
Compute shader workgroups execution and size [closed]
I want to clarify how are workgroups executed on various GPUs, thus I have several questions. I know that different GPU architectures work differently, but I expect an answer YES if there is single (...
1
vote
2
answers
589
views
Is there an efficient way to achieve color blending in compute shaders?
What I want is a function like imageStore, but instead of replacing a value - applying a blend operation to it, e.g. addition. It is not possible to do something ...
1
vote
1
answer
67
views
Mat4 that is written to a storage buffer in a compute shader has an altered value when read back
I am attempting to use a compute shader to calculate joint transforms for animations.
I use a loop to calculate the global joint transforms from the local transforms. Relevant code below:
...
1
vote
1
answer
130
views
Reading from buffer versus calculating on the fly performance
I am creating a fast fourier transform algorithm for the compute shader - i am no expert on how GPUs really run optimally so thought i would ask here.
I have the option to calculate on the fly or ...