590 questions
-3
votes
1
answer
98
views
How to set up WebGPU work groups with fully independent tasks?
I am new to using WebGPU. I'm using the rust wgpu crate with compute shaders to run a cryptographic task at high speed.
My shader is quite simple: Take a common input state, append a unique per-thread ...
0
votes
1
answer
56
views
Defining shader @workgroup_size(x,y,z) at runtime in wgpu?
Is it at all possible to dynamically define the dimensions of a @compute @workgroup_size(x,y,z) at runtime in wgpu?
My program basically needs to downscale an image in a compute shader to compare ...
1
vote
1
answer
154
views
glMemoryBarrier and compute shaders clarification
I've read the Khronos wiki Memory_Model page and the glMemoryBarrier
docs, and I'm still confused.
I have two buffers for vertex data (A and B) that I glMapBufferRange, memcpy into them, then ...
2
votes
1
answer
84
views
How to dispatch compute shader on a region of an image?
For example, store the output of the compute shader on a 640x640 region within a 1920x1080 image at offset 128x128 from top-left corner.
It could be done by allocating a 640x640 image, writing on it ...
0
votes
2
answers
204
views
Fastest way to accumulate (reduce) a StructuredBuffer<float> in a compute shader
I've got a RWStructeredBuffer<float> tau I'm writing to in a ray generation shader rayGen. The DispatchRays dimension are (tauWidth, tauHeight, 1) and tau has exactly tauWidth * tauHeight ...
1
vote
1
answer
157
views
Parallel reduction with single wave
Following these slides https://www.nvidia.com/content/GTC-2010/pdfs/2260_GTC2010.pdf when doing a parallel reduction you should avoid GroupMemoryBarrierWithGroupSync when reducing the last 2*...
0
votes
0
answers
23
views
Computer shader data sharing among threads,
I have a compute shader in Vulkan, where I launch N threads with eight sub-threads each. Each subgroup of 8 threads share an eight element 'location' array. Each of the sub-threads calculate a number ...
2
votes
0
answers
78
views
Compute Shader SSBO Only Writing to First Element – Why?
I'm working with a Shader Storage Buffer Object (SSBO) in a compute shader, but I'm encountering an issue where only the first element of my array of structs is being written to. The remaining ...
0
votes
0
answers
24
views
Writing to a DEPTH24STENCIL8 depth buffer as a RGBA8 buffer from a compute shader [duplicate]
I'm looking for a way to write to the depth buffer directly from a compute shader, I have figured out how to do this, just not how to do it properly, for now, I am binding the depth buffer to binding ...
0
votes
1
answer
223
views
DirectX12 Compute Shader Pipeline Question
Please help to understand what is wrong in this simple DirectX12 pipeline. I'm pretty new to DirectX12 and was not able to find any simple working C++ example of compute shader in the internet.
Below ...
0
votes
0
answers
163
views
How do I update Godot4 mesh normals during runtime by writing into the buffer directly?
I'm working on a procedural planet generator. My implementation is running a compute shader that calculates vertice positions based on noise algorithms and writing the vertex data directly into the ...
0
votes
0
answers
43
views
Keyframed transition animation in threejs
I have an array of regular hexagons, those hexagons all together cover a surface (equivalent of the surface of my viewport), they are ordered from the center of the surface to the edges, each hexagon ...
-1
votes
1
answer
132
views
'redefinition of script' and 'type is ambiguous' errors
I'm writing a compute shader in unity and am writing various HLSL scripts which will be referenced in the compute shader using #include.
I have a struct called Move, in a script called MoveC.hlsl. I ...
0
votes
0
answers
32
views
Write Data contiguously across threads
I have a compute shader that culls object triangles against frustums.
For culling, I use a huge vertex and index buffer and a pair of (offset, count) to identify the range of vertices for a single ...
0
votes
0
answers
62
views
Problem Writing to an Image Texture Using a Compute Shader
I'm building a sparse voxel octree game engine and I'm having problems writing in a compute shader. I simplified my algorithm because I only need to write to the texture. Here is what I tried:
...
0
votes
1
answer
67
views
Webgl: Maintaining particle positions with mouse offsets in GPGPU
I have a simple particle square that I want to move with the mouse movement, mapped to -1 to 1, in such a way that its bottom left point sticks to the cursor.
This is fairly easy in vertex shade where ...
1
vote
1
answer
176
views
My Compute Shader doesn't have any outside effects
I'm trying to write a compute shader in GLSL with OpenGL, GLFW, GLEW, and GLM. The problem is that the compute shader either isn't running or isn't modifying any buffers. I have the latest NVIDIA 4060 ...
1
vote
0
answers
455
views
How to get shadow from additional light in Unity custom shader?
I’m working on a project in Unity where I’m using a compute shader to render grass. The rendering path is Forward+, and I’m trying to make the additional lights affect the grass. I want to achieve ...
1
vote
1
answer
140
views
Unpack/Pack SNorm16 in HLSL compute shader
I'm trying to unpack SNorm16 values in HLSL compute shader. Since SNorm16x4 = 8 bytes total, and Load/Store functions can only read/write 4 bytes I'm trying to get two 4 bytes values as packed to 1 ...
0
votes
1
answer
115
views
Compute shader occlusion test only works with scene camera
Using Unity 2022.3.40f1 and URP.
I'm trying to implement occlusion culling with the depth buffer in a compute shader.
I don't know what's wrong here but my code only works fine with the scene camera ...
0
votes
1
answer
107
views
Raymarching compute shader error in Unity VR
I am trying to apply a raymarching shader to my Unity VR project.
It is supposed to apply a shader to particles that represent a fluid using Smooth Particle Hydrodynamics.
However, I am running into ...
0
votes
0
answers
110
views
Smoothing normal on GPU (using geometry shader) without knowledge to adjacent faces
Smoothing normal on GPU might be a common question because you really can generate flat normal by triangle primitives , but you don't have adjacent faces so it is not possible to smooth normal . I ...
1
vote
0
answers
86
views
Metal Compute Shader Incorrect Output
I am writing an FFT in GLSL and compiling to MSL using glslang and SpirvCross to support macOS. The code works fine on Windows with GLSL, but on Metal I see output that makes no sense. However, I have ...
1
vote
0
answers
52
views
Unity: Set a mesh directly on the GPU
In unity I'm constructing a mesh on the GPU. Currently, I have to write the vertices / indices back to the CPU before setting them again in the mesh. This is very inefficient and takes about 90% of ...
1
vote
0
answers
59
views
Unity compute shader thread syncing issue
So I am writing a marching cubes compute shader. It’s going reasonably well and does work. I am in the processing of modifying it to remove all duplicate vertices. I want to do this in the shader. I ...
2
votes
0
answers
108
views
Why did my optimization of compute shader cache hit ratio have the opposite effect?
I wrote a compute shader in ue4 that each thread needs to get the value of a structured buffer corresponding to its own id.As shown in the figure below, for example, my texture is 8x8, the thread ...
0
votes
0
answers
93
views
WGPU compute shader inexplicably returns no data
I have a wgsl compute shader, that essentially checks pairs of datapoints and counts the number pairs that meet a certain requirement (passes(i,j) is true) for each point. (ie. if there are 5 passing ...
3
votes
0
answers
208
views
Can I use a GPUBuffer which is the output of a compute shader as a Three.js or Babylon.js vertex position buffer?
I am experimenting whith webgpu. I found out that transferring data between cpu and gpu can be quite slow.
My goal is to simulate particle physics on the gpu using webgpu's compute shaders, then use ...
0
votes
1
answer
355
views
How do I achieve the ping-ponging technique in HLSL compute shaders?
I am doing a fluid simulation, and implementing such simulation with the CPU is very slow, especially when the simulation grid size gets bigger or is a 3d grid. So I used shaders to get the ...
0
votes
0
answers
88
views
Unexpected results from Metal computing
EDIT:
In the comment below, pmdj pointed out 2 bugs in my code.
For clarity, I will not copy all the code and output buffer contents. Instead I modified both and left the originals as comments.
...
1
vote
1
answer
349
views
Is this WebGPU compute shader badly designed?
I am having unexpected results while comparing a WebGPU compute shader with it's cpu equivalent.
This is a CPU version of a function that does Verlet Integration for simulating particles.
...
0
votes
0
answers
65
views
How to retain bits on lowp float when using `imageLoad` and `imageStore`
I would like to use all 8-bits as flags on a lowp float stored in an image. However, for some reason the data is never retained when I read it back. I use uintBitsToFloat and floatBitsToUint like so.
(...
0
votes
1
answer
169
views
How to churn different inputs using only single premade WGSL pipeline?
I have coded a WGSL compute shader that outputs the result given an input as argument.
Now I need to run this shader many times using different inputs. All of the compute shader steps should be the ...
2
votes
1
answer
429
views
Load raw texture data / Getting data from compute shader
Overview
I have been working on a compute shader for awhile now. Initially it would take in 1 camera feed of 320x256 pixels. This all works great.
Now I want to be able to handle multiple cameras, ...
1
vote
0
answers
116
views
How do I simulate collisions between spheres in a compute shader? (GLSL)
I have a system of 1000 particles that go through a sort of n-body simulation on the GPU, where each particle can interact with each other particle. I would like to achieve something that looks like ...
2
votes
1
answer
1k
views
What's the point for compute shader to have local size in addition to work groups?
What's the difference between:
void glDispatchCompute(1, 1, 1);
layout(local_size_x = 100, local_size_y = 100, local_size_z = 1) in;
and:
void glDispatchCompute(100, 100, 1);
layout(...
0
votes
2
answers
1k
views
I keep getting this strange error "undeclared identifier"
So Im trying to make a compute shader for my unity game, and I keep getting this strange error:
Shader error in 'PathTracing': undeclared identifier 'intersectionPos' at kernel CSMain at PathTracing....
1
vote
0
answers
137
views
Compute Buffer of bytes to RWTexture2D float4 in Compute Shader
I'm struggling with a Compute Shader whose purpose is to take a byte array of rgba values and write them to a render texture. I'm passing in ints (as I don't believe I can use byte itself) to the ...
0
votes
2
answers
279
views
How to properly parallelize rescaling of a texture in a compute shader?
I have a RWTexture2D<float4> which was filled by a ray generation shader. I need to scale every pixel by a common constant value, which is only known after the ray generation shader has finished....
1
vote
0
answers
57
views
MTLBuffers returning "shifted" values in kernel shader using structs, works on simulator, not on device
I'm writing an iOS app (currently running on iPad) and I'm using some metal compute shaders for some heavy math processing. Things have been working great but I have run into some issues lately in ...
1
vote
1
answer
275
views
indexing into wgsl array with a variable?
i am making a compute shader to use with bevy 0.12
so im using wgsl.
i want to index into an array like this:
fn is_boxed_in(x: u32, y: u32, z: u32, voxels: array<ShaderVoxel, 4096>) -> bool {...
0
votes
1
answer
73
views
mapping and reading buffer does not give expected outcome
I am trying to run a simple test compute shader.
But when i map the buffer the shader modifies i get back all 0's. Instead of the expected outcome of numbers[index] = numbers[index] + 2u
it also does ...
2
votes
1
answer
596
views
Equivalent to float AtomicAdd in WebGPU
We have an OpenGL solver. Given a list of many items, each has a coordinate and a float value. We run a compute shader of the size of those items that does the computation and adds the value to the ...
0
votes
1
answer
337
views
trouble with using compute shaders for bevy 0.12
I am trying to just test out the compute shaders so I'm trying to add 2 arrays together but I get this error during run time:
thread 'Compute Task Pool (6)' panicked at C:\Users\bramb\.cargo\...
1
vote
0
answers
600
views
what does exactly the function barrier do in GLSL?
I am reading a small github project, within which there is a compute shader code to organize an index buffer of indirect draw call as follows,
layout(local_size_x=1024, local_size_y=1, local_size_z=1) ...
0
votes
2
answers
1k
views
Proper way to read from a texture in a compute shader which uses a storage texture
I've been searching for different resources and it seems to not be possible to read from a storage texture and then write back to it. That's why I've tried to use 2 separate textures: one as ...
0
votes
1
answer
152
views
imageStore causing crash in GL ES 3.1 Compute shader using ANGLE on windows
My goal is to generate a luminance waveform similar to this using a compute shader.
My setup is:
Cpp window application
EGL/egl.h
GLES3/gl31.h (specifically requesting an ES 3.1 context)
libGLESv2....
0
votes
1
answer
178
views
ComputeShader in Unity : Why are the values all wrong?
Here's how the object is defined in C#, for Unity to be able to work with it :
(please note: I left all fields -- even the ones not used in this question -- in case the issue was in an seemingly-...
0
votes
1
answer
95
views
In a tree structure in Unity / C#, how do you sum calculated values from root to leaves using ComputeShaders?
This wouldn't be too hard if this wasn't mixing several worlds : the world of algorithmics, the world of C# and the world of compute shaders (in Unity).
EDIT: This is somewhat related. My scenario is ...
2
votes
1
answer
810
views
Compute shaders : How do you pass not-so-regular structures as parameters?
I am working in C#, with Unity.
I have created a compute shader to which I want to pass my array of C# data structures.
That's when I realized I might have gone overboard with fancy data structures, ...