Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan validation failure: VUID-vkDestroyDevice-device-00378 #2965

Closed
jimblandy opened this issue Aug 15, 2022 · 3 comments · Fixed by #3069
Closed

Vulkan validation failure: VUID-vkDestroyDevice-device-00378 #2965

jimblandy opened this issue Aug 15, 2022 · 3 comments · Fixed by #3069
Labels
api: vulkan Issues with Vulkan area: validation Issues related to validation, diagnostics, and error handling

Comments

@jimblandy
Copy link
Member

Running the following test case elicits validation errors on Vulkan:

#[test]
fn bad_mip_level() {
    fn try_level(mip_level: u32, should_panic: bool) {
        let mut parameters = TestParameters::default();
        if should_panic {
            parameters = parameters.failure();
        }

        initialize_test(parameters, |ctx| {
            let texture = ctx.device.create_texture(&TEXTURE_DESCRIPTOR);
            let buffer = ctx.device.create_buffer(&BUFFER_DESCRIPTOR);

            let mut encoder = ctx.device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
            encoder.copy_buffer_to_texture(
                wgpu::ImageCopyBuffer { 
                    buffer: &buffer,
                    layout: BUFFER_COPY_LAYOUT
                },
                wgpu::ImageCopyTexture {
                    texture: &texture,
                    mip_level,
                    origin: wgpu::Origin3d { x: 0, y: 0, z: 0 },
                    aspect: wgpu::TextureAspect::All,
                },
                wgpu::Extent3d {
                    width: 1,
                    height: 1,
                    depth_or_array_layers: 1,
                },
            );
        });
    }

    try_level(0, false);
    try_level(2, false);

    try_level(3, true);
    try_level(u32::MAX - 1, true);
    try_level(u32::MAX, true);
}

const TEXTURE_SIZE: wgpu::Extent3d = wgpu::Extent3d {
    width: 64,
    height: 64,
    depth_or_array_layers: 1,
};

const TEXTURE_DESCRIPTOR: wgpu::TextureDescriptor = wgpu::TextureDescriptor {
    label: Some("texture_bounds.rs texture"),
    size: TEXTURE_SIZE,
    mip_level_count: 3,
    sample_count: 1,
    dimension: wgpu::TextureDimension::D2,
    format: wgpu::TextureFormat::Rgba8UnormSrgb,
    usage: wgpu::TextureUsages::COPY_DST.union(wgpu::TextureUsages::COPY_SRC),
};

const BYTES_PER_PIXEL: u32 = 4;

const BUFFER_SIZE: u32 = TEXTURE_SIZE.width * TEXTURE_SIZE.height * BYTES_PER_PIXEL;

const BUFFER_COPY_LAYOUT: wgpu::ImageDataLayout = wgpu::ImageDataLayout {
    offset: 0,
    bytes_per_row: NonZeroU32::new(TEXTURE_SIZE.width * BYTES_PER_PIXEL),
    rows_per_image: None,
};

const BUFFER_DESCRIPTOR: wgpu::BufferDescriptor = wgpu::BufferDescriptor {
    label: Some("texture_bounds.rs buffer"),
    size: BUFFER_SIZE as wgt::BufferAddress,
    usage: wgpu::BufferUsages::COPY_SRC,
    mapped_at_creation: false,
};

Validation errors are as follows:

cargo test --package wgpu --test wgpu-tests -- texture_bounds::bad_mip_level --exact --nocapture
   Compiling wgpu v0.13.0 (/home/jimb/rust/wgpu/wgpu)
    Finished test [unoptimized + debuginfo] target(s) in 4.09s
     Running tests/root.rs (target/debug/deps/wgpu_tests-a491ced9a7b7da4c)

running 1 test
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84ca2d80, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84ca2d80[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84ca2d80, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c9c520, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c9c520[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c9c520, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84ca95e0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84ca95e0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84ca95e0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c8c030, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c8c030[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c8c030, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c88c00, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c88c00[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c88c00, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84ca61b0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84ca61b0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84ca61b0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c8f460, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c8f460[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c8f460, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c9f950, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c9f950[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c9f950, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c92890, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c92890[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c92890, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c990f0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c990f0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c990f0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c95cc0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c95cc0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c95cc0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c7ef70, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c7ef70[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c7ef70, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c7bb40, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c7bb40[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c7bb40, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c857d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c857d0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c857d0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84caca10, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84caca10[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84caca10, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0x7f5f84c823a0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandBuffer 0x7f5f84c823a0[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_BUFFER, hndl: 0x7f5f84c823a0, name: ?)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-vkDestroyDevice-device-00378 (0x71500fba)]
    	Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x7f5f848c67c0, type = VK_OBJECT_TYPE_DEVICE; Object 1: handle = 0xa000000000a, type = VK_OBJECT_TYPE_COMMAND_POOL; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x7f5f848c67c0[], VkCommandPool 0xa000000000a[] has not been destroyed. The Vulkan spec states: All child objects created on device must have been destroyed prior to destroying device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyDevice-device-00378)
[2022-08-14T23:58:41Z ERROR wgpu_hal::vulkan::instance] 	objects: (type: DEVICE, hndl: 0x7f5f848c67c0, name: ?), (type: COMMAND_POOL, hndl: 0xa000000000a, name: ?)
thread 'texture_bounds::bad_mip_level' panicked at 'UNEXPECTED TEST FAILURE DUE TO VALIDATION ERROR', wgpu/tests/common/mod.rs:307:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test texture_bounds::bad_mip_level ... FAILED
@jimblandy jimblandy added area: validation Issues related to validation, diagnostics, and error handling api: vulkan Issues with Vulkan labels Aug 15, 2022
@jimblandy
Copy link
Member Author

I suspect this is something like #2959.

@jimblandy
Copy link
Member Author

The vk::CommandPool that doesn't get freed is owned by a wgpu_hal::vulkan::CommandEncoder. These are currently only freed from CommandAllocator::dispose, if they were previously passed to CommandAllocator::release_encoder. The only place release_encoder is ever called is from triage_submissions to free the encoders associated with completed queue submissions. But the encoder in the test case is never submitted.

I guess dropping the last reference to an encoder should also call CommandAllocator::release_encoder?

@jimblandy
Copy link
Member Author

Sanity check: if I actually finish the encoder and submit the command, the validation error does go away. So this is indeed about command encoders that never make it into a queue submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan area: validation Issues related to validation, diagnostics, and error handling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant