compute-shader

What is the difference between OpenCL and OpenGL's compute shader?

可紊 提交于 2021-02-05 12:54:07
问题 I know OpenCL gives control of the GPU's memory architecture and thus allows better optimization, but, leaving this aside, can we use Compute Shaders for vector operations (addition, multiplication, inversion, etc.)? 回答1: In contrast to the other OpenGL shader types, compute shaders are not directly related to computer graphics and provide a much more direct abstraction of the underlying hardware, similar to CUDA and OpenCL. It provides customizable work group size, shared memory, intra-group

OpenGL compute shader - strange results

本秂侑毒 提交于 2020-08-15 05:26:43
问题 I'm trying to implement a multipass compute shader for image processing. There is an input image and an output image in each pass. The next pass' input image is the previous ones' output. This is the first time for me using compute shader in OpenGL so there may be some problems with my setup. I'm using OpenCV's Mat as the container to read/copy operations. There are some parts of the code which isn't related to the problem so I didn't include. Some of these parts include loading the image or

How to index array in compute shader?

こ雲淡風輕ζ 提交于 2020-01-22 03:45:07
问题 Hello I am using compute shader for updating heights of terrain. I store data in 1D array. I would like to access individual elements of array in compute shader. Is it possible? #type compute #version 430 //Size of compute shader local work group - x=32, y=32, z=1(default) layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; layout(std430, binding = 0) buffer buffer_InPos { vec4 InPos[]; }; layout(std430, binding = 1) buffer buffer_InNormal { vec4 InNormal[]; }; uniform vec2 u

Confused about thread_position_in_grid

淺唱寂寞╮ 提交于 2020-01-21 14:00:08
问题 I'm working on a compute shader in Metal on macOS. I'm trying to do some very basic things to learn how they work. I'm seeing some output I don't understand. I thought I would start by trying to generate a simple 2D gradient. The red channel would increase from 0 to 1 along the width and the green channel would increase from 0 to 1 along the height. So I wrote this kernel: kernel void myKernel(texture2d<half, access::write> outTexture [[ texture(MBKT_OutputTexture) ]], uint2 gid [[thread

How to index array in compute shader?

白昼怎懂夜的黑 提交于 2020-01-20 09:36:49
问题 Hello I am using compute shader for updating heights of terrain. I store data in 1D array. I would like to access individual elements of array in compute shader. Is it possible? #type compute #version 430 //Size of compute shader local work group - x=32, y=32, z=1(default) layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; layout(std430, binding = 0) buffer buffer_InPos { vec4 InPos[]; }; layout(std430, binding = 1) buffer buffer_InNormal { vec4 InNormal[]; }; uniform vec2 u

How to index array in compute shader?

自古美人都是妖i 提交于 2020-01-20 09:35:10
问题 Hello I am using compute shader for updating heights of terrain. I store data in 1D array. I would like to access individual elements of array in compute shader. Is it possible? #type compute #version 430 //Size of compute shader local work group - x=32, y=32, z=1(default) layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; layout(std430, binding = 0) buffer buffer_InPos { vec4 InPos[]; }; layout(std430, binding = 1) buffer buffer_InNormal { vec4 InNormal[]; }; uniform vec2 u

SSBO as bigger UBO?

拜拜、爱过 提交于 2020-01-20 04:56:30
问题 i am currently doing so rendering in OpenGL 4.3 using UBOs to store all my constant data on the GPU. (Stuff like material descriptions, matrices, ...). It works however the small size of UBO (64kB on my implementation) forces me to switch buffers numerous times slowing rendering, i am looking for similar a way to store a few MB. After a little research i saw that SSBO allow exactly that but also have unwanted 'features' : they can be written from the shader and might be slower to read. Is