Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes
Accepted

Compute Shader generating data for use on CPU

Turns out it was an issue with the way I was setting up the compute buffer. Specifically, it was ComputeBufferMode.Dynamic that was incorrect. https://forum.unity....
Basic's user avatar
  • 1,278
3 votes

Compute Shader generating data for use on CPU

I believe the problem is the arguments you are passing to Dispatch. The value that you are calling y is actually the number of ...
PepeOjeda's user avatar
  • 711
3 votes

Pseudo random number generation in compute shader

You have to consider that one GPGPU invocation executes all CSMain in parallel, conceptually all at the same time. So every pixel in your texture will come back ...
Stephane Hockenhull's user avatar
3 votes

Why can't I use the "degrees" character in HLSL comments?

The issue was with the encoding of the file, as it was not encoded in UTF8. Setting it to the UTF8 encoding in VS solved the issue. If you want to know how to set the encoding in a file in VS, follow ...
Keheck's user avatar
  • 31
2 votes
Accepted

DirectX shader - how to spread raytracer computation over multiple frames?

clip() and discard() won't get you any performance increase, nor is it intended to. To understand why, consider how the GPU does ...
3Dave's user avatar
  • 3,141
2 votes

In theory, would an erosion algorithm compute faster on a GPU than CPU?

That depends on the algorithm. Algorithms which perform the same operation on a large amount of data-points without any of these operations being dependent on the other data-points, or in other words,...
Philipp's user avatar
  • 120k
2 votes
Accepted

DirectX 11 Compute Shader error DXGI_ERROR_DEVICE_HUNG

This is called a Timeout Detection and Recovery (TDR) error which by default happens whenever the GPU stops responding for 2 seconds or longer--technically when a single driver packet takes longer ...
Chuck Walbourn's user avatar
2 votes
Accepted

Solving a recursive problem in the geometry (or any other) shader

The problem is that this code needs to run as many times as the depth of the tree, and not all of it can run in parallel. ...which is the prime indicator NOT to process this as such on the GPU. GPU ...
Engineer's user avatar
  • 29.7k
2 votes
Accepted

How to evaluate a binary expression tree in HLSL without recursion or a stack?

Alright, I didn't manage to evaluate the binary expression tree without a stack entirely. I do need a stack but the stack capacity only has to be 2 elements in order to evaluate any binary expression ...
Tuntenfisch's user avatar
2 votes

Marching cube terrain generated by compute shader gives strange error

By default Unity handles only 65535 vertices in the mesh. You need to set Mesh.indexFormat = IndexFormat.UInt32 to handle more vertices.
Arugin's user avatar
  • 121
2 votes
Accepted

Looking for an advice on how to possibly boost my compute shader

When you call Dispatch(960, 540, 1) with [numthreads(1,1,1)] you are basically asking your GPU to distribute the workload on a ...
Sup3rlum's user avatar
2 votes
Accepted

Flickering in mesh created procedurally using compute shaders and compute buffers

So I've finally figured out the issue, it was an oversight on my part when calling computeShader.Dispatch, I had forgotten/overlooked that the parameters that ...
Hex Crown's user avatar
1 vote

Gaps between terrain chunks generated with marching cubes

I fixed this problem. There were 16x16 vertices per mesh and new chunk coordinates were calculated as: ...
aress's user avatar
  • 21
1 vote
Accepted

error X3671: loop termination conditions in varying flow control cannot depend on data read from a UAV

The answer is effectively to use [allow_uav_condition] but in the right place what does not work is to place the condition before the if statement even if it is where I need it ...
philB's user avatar
  • 139
1 vote

Why does it take around 5 times longer to sample large RenderTextures vs. sampling large Texture3D/2Ds in a Compute Shader?

I can think of three possible causes of this: The RenderTexture will be bigger in memory because it's not compressed. This will consume more memory bandwidth on the GPU to sample, and is also likely ...
Adam's user avatar
  • 7,364
1 vote
Accepted

Reliably addressing compute buffer when using large numbers of threads

Well first of all, the way GPUs work is each warp or compute block will have to make a product of 1024, so numthreads(1024,1,1) will do, 64 * 64 * 16 or numthreads(64,64,16) isn't valid. Think of the ...
OwenTheProgrammer's user avatar
1 vote
Accepted

d3d11 compute shader compile failed

You are saying ‘==‘ instead of ‘=‘ when setting your HRESULT.
coulomb's user avatar
  • 150
1 vote

How to evaluate a binary expression tree in HLSL without recursion or a stack?

When implementing something similar, only with post order traversal (evaluation of mathematical structures for ray marching), i encountered the same error with "array reference cannot be used as ...
Lokarian's user avatar
1 vote
Accepted

Get VertexSize of Instance in VertexShader

The "built in" variable is contained in the args buffer. From the unity docs "Buffer with arguments, bufferWithArgs, has to have four integer numbers at given argsOffset offset: vertex count per ...
Zebraman's user avatar
  • 819
1 vote

Batch/Combine multiple Graphics.DrawProcedural-Calls in Unity

Why not just collect a few buffers with different objects and direct them to compute shader? Here is a sketched quick, not tested, example (no time to create the objects themselves). Structurally, I ...
Анатолий Снеговский's user avatar
1 vote

Voxel raycasting algorithm not working correctly

(Apologies, I'm not familiar with Unity/HLSL at all, so my syntax may be wonky.) Let's restart, with ...
Glärbo's user avatar
  • 11
1 vote

Unity3D URP - How do I approach creating Fog of War for 3D top-down stealth game?

Until recently, camera stacking used to be unavailable in the URP. But with the newest release 2020.1 (released just yesterday), it's available again. Although with two limitations: It's unavailable ...
Philipp's user avatar
  • 120k
1 vote

Compute shader: Property at kernel index is not set

You need "link" your StructuredBuffer to a ComputeBuffer that you initialize in the CS script. In your code, you've never specified a compute shader to write to, so the compiler is basically ...
TakeMeHomeCountryRoads's user avatar
1 vote

Unity: running GPU intensive operations in editor mode

I found a possible reason and it works in my case. There's a feature names "Timeout Detection and Recovery(TDR)" on Windows since Vista. And what TDR do is assume a crash and reset the ...
yuans's user avatar
  • 11
1 vote

OpenGL approach to depth-testing-like combination of a large buffer of fragments

When I've done something similar (reprojecting colour-depth images from the Kinect 2 into the game's 3D space), I... ...made a Mesh with a vertex for each texel in the input texture. (You can break ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

Using a Compute Shader in Unity to convert a texture to a float array

Ok, thanks to some direction from @DMGregory I reconsidered and solved my own question. The answer was in two parts: I was combining the x and y coordinates (id.x and id.y) strangely, and I was using ...
EmmetOT's user avatar
  • 121
1 vote
Accepted

Vulkan Storage Buffers, loss of data

It's alignment. Vec3s in storage buffers must be aligned to 16 bytes (same as vec4). replace DataObject with: ...
ratchet freak's user avatar
1 vote
Accepted

How to sort tiled decal list?

OK, I haven't noticed, that in the same presentation I linked in my question, there was an other sorting algorithm for the per-tile LDS particle array, with source code. And that is nearly exactly my ...
János Turánszki's user avatar
1 vote
Accepted

Flowing GPU compute water

When a drop "tried" to visit a vertex, the stencil was marked with InterlockedExchange using the "original value" to determine if it was already stenciled (even ...
Jon's user avatar
  • 3,704

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