compute-shader

Compute Shader write to texture

只谈情不闲聊 提交于 2019-12-22 05:32:12
问题 I have implemented CPU code that copies a projected texture to a larger texture on a 3d object, 'decal baking' if you will, but now I need to implement it on the GPU. To do this I hope to use compute shader as its quite difficult to add an FBO in my current setup. Example image from my current implementation This question is more about how to use Compute shaders but for anyone interested, the idea is based on an answer I got from user jozxyqk, seen here: https://stackoverflow.com/a/27124029

DirectX 11 compute shader for ray/mesh intersect

被刻印的时光 ゝ 提交于 2019-12-21 21:34:15
问题 I recently converted a DirectX 9 application that was using D3DXIntersect to find ray/mesh intersections to DirectX 11. Since D3DXIntersect is not available in DX11, I wrote my own code to find the intersection, which just loops over all the triangles in the mesh and tests them, keeping track of the closest hit to the origin. This is done on the CPU side and works fine for picking via the GUI, but I have another part of the application that creates a new mesh from an existing one based on

Are there DirectX guidelines for binding and unbinding resources between draw calls?

我怕爱的太早我们不能终老 提交于 2019-12-21 05:21:35
问题 All DirectX books and tutorials strongly recommend reducing resource allocations between draw calls to a minimum – yet I can’t find any guidelines that get more into details. Reviewing a lot of sample code found in the web, I have concluded that programmers have completely different coding principles regarding this subject. Some even set and unset VS/PS VS/PS ResourceViews RasterizerStage DepthStencilState PrimitiveTopology ... before and after every draw call (although the setup remains

OpenGL compute shader buffer allocation fails

好久不见. 提交于 2019-12-12 18:20:40
问题 I am trying to use a buffer in a compute shader like this: layout (binding = 1, std430) writeonly buffer bl1 { uint data[gl_WorkGroupSize.x * gl_NumWorkGroups.x * gl_NumWorkGroups.y]; }; but I get the following error (because of using gl_NumWorkGroups for the size): Array size must be a constant integer expression How can I work around this? 回答1: Stop putting in a length at all: layout (binding = 1, std430) writeonly buffer bl1 { uint data[]; }; This is a feature unique to SSBOs. And you can

How Do I Use an HTML5 Canvas as a WebGL Texture

送分小仙女□ 提交于 2019-12-12 07:33:44
问题 I want to: Set Uniform values for case i. Render compute shader for case i to an HTML5 <canvas> tag. Use the <canvas> contents (case i render output) as a texture in the next render pass. Repeat for all cases. Extract answers into JS from color data. I'm trying to make a compute shader and need to carry a value per pixel (fragment) on each render pass. A simple example would be incrementing the blue value of a pixel on each render call. I.e. pass 1: b=1 pass 2: b=2 pass 2: b=3 etc. Is this

Compute shader only updates part of data

不问归期 提交于 2019-12-11 22:52:40
问题 I'm stuck with my program rendering all the particles, but only updating 1 particle on 3. Here's what I've done to test it. I made a vbo with 10 of my particles, put them all aligned veticaly and set the compute shader to modify their x position every update (pos.x+=0.1). Here's the result after about 1-2 seconds (image is 1:5 scale) : I use local_size_x = 1, local_size_y = 1 and local_size_z = 1, then DispatchCompute(10,1,1) . Am I doing something wrong with the invocation ids? Update

Is there a time border for OpenGL Compute Shaders?

那年仲夏 提交于 2019-12-11 03:44:53
问题 I am using the OpenGL Compute Shaders to do some calculation on data. Everything works fine except that it does not seem to be possible to run one shader much more than 10 seconds. I measure the time with glBeginQuery(...) and glEndQuery(...) . The shader runs between 1 ms and 10 seconds good. I just add some data without any shader invocations to increase the time the shader needs. But I can not add more Data when the shader needs a bit more than 10 seconds. Then, the program freezes and I

GLSL memoryBarrierShared() usefulness?

随声附和 提交于 2019-12-08 17:23:11
问题 I am wondering about the usefulness of memoryBarrierShared. Indeed, when I am looking the documentation for barrier function : I read : For any given static instance of barrier in a compute shader, all invocations within a single work group must enter it before any are allowed to continue beyond it. This ensures that values written by one invocation prior to a given static instance of barrier can be safely read by other invocations after their call to the same static instance of barrier.

Trouble with imageStore() (OpenGL 4.3)

Deadly 提交于 2019-12-07 12:02:49
问题 I'm trying to output some data from compute shader to a texture, but imageStore() seems to do nothing. Here's the shader: #version 430 layout(RGBA32F) uniform image2D image; layout (local_size_x = 1, local_size_y = 1) in; void main() { imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(0.0f, 1.0f, 1.0f, 1.0f)); } and the application code is here: GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL

How to measure time performance of a compute shader?

浪尽此生 提交于 2019-12-07 11:22:06
问题 i need to measure the time of a compute shader. But of course this is not trivial. From OpenGL Wiki - Performance I got, that it is usefull to use glFinish() before and after the shader call. But they say also that it is not that good to use it. Is there a good possibility to measure the time of my shader? Is there anyways the possibility to measure the time of a compute shader? My code looks like something like this: renderloop() { //(1) //(2) if(updateFunction) //this is done just one time