attackgoat / screen-13

Screen 13 is an easy-to-use Vulkan rendering engine in the spirit of QBasic.
Apache License 2.0
251 stars 13 forks source link

SYNC-HAZARD-WRITE-AFTER-WRITE when writing to multiple mips in the same dispatch #85

Open DGriffin91 opened 2 weeks ago

DGriffin91 commented 2 weeks ago

I have a compute shader that writes to multiple mips of the same texture in one dispatch. When I run it I get SYNC-HAZARD-WRITE-AFTER-WRITE

Minimal code example (based on screen-13 triangle example, with current main 0.38 ash support, bdc4a819ba44be7d337a839f4ec0d180f0594076) https://gist.github.com/DGriffin91/d792f15c1d0ae0c323f3b64e50968abf

In this example the mips are created as expected and if you uncomment the pass that displays the mip it does display.

In my app, it actually results in ERROR_OUT_OF_POOL_MEMORY if I try to sample the mip in another pass. But seems to otherwise create the mips as expected (viewed in render doc) if I don't try to sample them.

Edit: In my app I made a simpler pass to just render a debug output of the textures and it this doesn't cause the ERROR_OUT_OF_POOL_MEMORY but does still show the WRITE-AFTER-WRITE

DGriffin91 commented 2 weeks ago

It looks like in the bindings only the first and last mip show a subresource access. Not sure if this could be related.

.record_compute(move |compute, bindings| {
    dbg!(&bindings);
    compute.dispatch(width / 8 + 1, height / 8 + 1, 1);
});
3: [
    SubresourceAccess {
        access: General,
        subresource: Some(
            Image(
                ImageSubresource {
                    array_layer_count: Some(1),
                    aspect_mask: COLOR,
                    base_array_layer: 0,
                    base_mip_level: 0,
                    mip_level_count: Some(1),
                },
            ),
        ),
    },
    SubresourceAccess {
        access: General,
        subresource: Some(
            Image(
                ImageSubresource {
                    array_layer_count: Some(1),
                    aspect_mask: COLOR,
                    base_array_layer: 0,
                    base_mip_level: 2,
                    mip_level_count: Some(1),
                },
            ),
        ),
    },
],