vulkancompute-shader

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 and then doing a copy to the desired region. Is it possible without the extra allocation?


Solution

  • It can be done, but the compute shader must be programmed to do this. It has to be given a region of the destination image to write to, and thus each shader instance needs to compute where it writes to based on the given region.

    It cannot be done behind the shader's back.