I am relatively new to using gpu apis, even newer to wgpu, and wanted to mess around with compute shaders drawing to a surface. However, it seems that this is not allowed directly?
During run time upon attempting to create a binding to the texture view from the surface, an error stating that the STORAGE BINDING bit is necessary, however, that is not allowed to be defined during the surface configuration. I have also attempted to have the shader accept the texture as a regular texture rather than a storage texture, but that came with its own error of the binding being invalid.
Is there a good way to write directly to the surface texture, or is it necessary to create a separate storage texture? Does the render pipeline under the hood not write directly to the surface's texture view? If a separate texture (which I am guessing it is), is there a best method to follow?
The compute shader cannot write to surface texture directly, that is the responsibility of the fragment shader.
Since swapchain uses double or multi-buffering technology, the surface texture changes from frame to frame; Also, the usage of surface texture is
RENDER_ATTACHMENT
, which means that it can only be used forRenderPass
's color_attachments;Compute shader can only output
Storaga Buffer
andStorage Texture
, these two types of data can be used by binding to a fragment shader.