Skip to main content

Questions tagged [compute-shader]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
63 votes
3 answers
37k 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 ...
Nathan Reed's user avatar
  • 25.1k
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 ...
Mokosha's user avatar
  • 1,144
14 votes
1 answer
1k 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 ...
Mokosha's user avatar
  • 1,144
11 votes
1 answer
8k 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 ...
geometrian's user avatar
  • 1,990
10 votes
1 answer
618 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 ...
russ's user avatar
  • 2,402
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 ...
FrickeFresh's user avatar
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 ...
Mokosha's user avatar
  • 1,144
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: ...
cupe's user avatar
  • 203
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 ...
Matteo Bertello's user avatar
7 votes
1 answer
795 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,...
David Kuri's user avatar
  • 2,293
6 votes
2 answers
5k 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,...
spraff's user avatar
  • 299
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: ...
Giles Ruscoe's user avatar
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 ...
Maxthecat's user avatar
  • 181
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 ...
Matthias's user avatar
  • 1,084
5 votes
1 answer
2k 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. ...
nikitablack's user avatar
4 votes
2 answers
1k 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 ...
Vectorizer's user avatar
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 ...
David Kuri's user avatar
  • 2,293
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 ...
Brianna Szvenska's user avatar
4 votes
1 answer
470 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 ...
sydd's user avatar
  • 253
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. ...
John Cox's user avatar
  • 161
4 votes
0 answers
311 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 ...
Lemon Drop's user avatar
3 votes
1 answer
1k 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 ...
Sprinklerkopf's user avatar
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: ...
slanden's user avatar
  • 133
3 votes
2 answers
7k 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 ...
François Guthmann's user avatar
3 votes
1 answer
493 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 ...
wduk's user avatar
  • 177
2 votes
1 answer
6k 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 ...
VIVEK Yadav's user avatar
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 ...
gallickgunner's user avatar
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 ...
AverageGatsby's user avatar
2 votes
1 answer
566 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 ...
Jhonny007's user avatar
  • 179
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. ...
shashack's user avatar
  • 523
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 ...
gallickgunner's user avatar
2 votes
1 answer
562 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): ...
Labeno's user avatar
  • 31
2 votes
1 answer
126 views

OpenGL - Compute Shader - How to set local_size

This question is about the best strategy to choose a local_size in OpenGL's compute shader. The application is a Lattice Boltzmann Method (LBM) with a number of cells ranging from 100,000 to 1 million....
techwinder's user avatar
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 ...
04348's user avatar
  • 23
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, ...
Holden Green's user avatar
2 votes
0 answers
628 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 ...
Ethan Ma's user avatar
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 ...
AverageGatsby's user avatar
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: ...
Labeno's user avatar
  • 31
1 vote
1 answer
2k 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 ...
Vectorizer's user avatar
1 vote
1 answer
1k 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 ...
Trap's user avatar
  • 123
1 vote
1 answer
920 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 ...
Karlovsky120's user avatar
1 vote
1 answer
157 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 ...
mathreadler's user avatar
1 vote
1 answer
942 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 ...
while1fork's user avatar
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 (...
Emil Kabirov's user avatar
1 vote
1 answer
275 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 ...
Sprinklerkopf's user avatar
1 vote
1 answer
106 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 ...
user avatar
1 vote
2 answers
872 views

Using imageLoad/imageStore to perform atomic add

I have a rgba16f texture that I fill with values using nvidia GL_NV_shader_atomic_fp16_vector extension, which allows to perform ...
mdkdy's user avatar
  • 2,169
1 vote
2 answers
48 views

GLSL Compute Shader Workgroup Execution

I want to know about "If there is branch command in compute shader, and it leads some workgroup ends earlier than others, then will the 'processing units' allocated for that workgroup be used for ...
idev's user avatar
  • 13
1 vote
1 answer
432 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 ...
Thomas's user avatar
  • 1,295
1 vote
1 answer
352 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 ...
sak's user avatar
  • 169