mesa/src/broadcom/vulkan
Juan A. Suarez Romero fc286867fb v3dv: fix misalignment in descriptor layout structure
Current memory layout for v3dv_descriptior_set_layout structure is the
following:

```
                                                                  /* offset           size */
type = struct v3dv_descriptor_set_layout {
    struct vk_object_base base;                                   /*   0                64 */
    VkDescriptorSetLayoutCreateFlags flags;                       /*  64                 4 */
    uint32_t binding_count;                                       /*  68                 4 */
    uint32_t bo_size;                                             /*  72                 4 */
    uint16_t shader_stages;                                       /*  76                 2 */
                                                                  /*         PAD 2         */
    uint32_t descriptor_count;                                    /*  80                 4 */
    uint16_t dynamic_offset_count;                                /*  84                 2 */
                                                                  /*         PAD 2         */
    uint32_t ref_cnt;                                             /*  88                 4 */
    struct v3dv_descriptor_set_binding_layout binding[0];         /*  92                32 */
}                               [...]         binding[1];         /* 124                32 */
```

Besides wasting 4 bytes in padding, the main problem is that `binding`
fields are not aligned to 8 bytes (64-bits), which is undefined behaviour
in C.

Just moving `descriptor_count` field below we get the new layout:

```
                                                                  /* offset           size */
type = struct v3dv_descriptor_set_layout {
    struct vk_object_base base;                                   /*   0                64 */
    VkDescriptorSetLayoutCreateFlags flags;                       /*  64                 4 */
    uint32_t binding_count;                                       /*  68                 4 */
    uint32_t bo_size;                                             /*  72                 4 */
    uint16_t shader_stages;                                       /*  76                 2 */
    uint16_t dynamic_offset_count;                                /*  78                 2 */
    uint32_t descriptor_count;                                    /*  80                 4 */
    uint32_t ref_cnt;                                             /*  84                 4 */
    struct v3dv_descriptor_set_binding_layout binding[0];         /*  88                32 */
}                               [...]         binding[1];         /* 120                32 */
```

Which removes the padding requirement, and more important, make the
`binding` pointers to be correctly aligned.

This has been detected by the Undefined Behaviour Sanitizer (UBSan).

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29911>
2024-07-01 08:02:07 +00:00
..
.dir-locals.el
.editorconfig
meson.build build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
v3dv_android.c v3dv/android: Migrate ANB and AHB to use common helpers 2024-05-16 00:27:24 +00:00
v3dv_bo.c v3dv: store the offset of the BRANCH instruction in a CL 2024-04-03 12:57:56 +02:00
v3dv_bo.h v3dv: store the offset of the BRANCH instruction in a CL 2024-04-03 12:57:56 +02:00
v3dv_cl.c broadcom: move HW-dependant constants to v3d_device_info 2024-06-05 17:14:59 +00:00
v3dv_cl.h v3d,v3dv: document cl_emit_with_prepacked 2024-06-07 09:44:13 +02:00
v3dv_cmd_buffer.c v3dv: do not pass NULL pointer to function not expecting NULLs 2024-07-01 08:02:07 +00:00
v3dv_debug.c v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd 2022-02-18 11:50:07 +01:00
v3dv_debug.h v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd 2022-02-18 11:50:07 +01:00
v3dv_descriptor_set.c vulkan,nir: Refactor ycbcr conversion state into a struct 2023-02-06 18:36:29 +00:00
v3dv_device.c v3dv: do not access member of a NULL structure 2024-07-01 08:02:07 +00:00
v3dv_event.c v3dv: add more checks for device loss 2024-06-12 12:09:00 +00:00
v3dv_formats.c broadcom: use common stype debug 2024-05-10 18:49:38 +00:00
v3dv_image.c v3dv: implement vkGetDeviceImageSubresourceLayoutKHR 2024-06-03 07:59:21 +00:00
v3dv_limits.h v3dv/device: compute maxDescriptorSet*Limits multiplying per-stage by 4 2024-05-29 10:35:27 +00:00
v3dv_meta_clear.c v3dv: fix pipeline leaks when meta pipeline cache is disabled 2024-06-06 07:12:27 +00:00
v3dv_meta_common.h v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd 2022-02-18 11:50:07 +01:00
v3dv_meta_copy.c v3dv: disable some TLB paths for cases of linear depth/stencil stores 2024-06-10 07:25:04 +02:00
v3dv_pass.c v3dv: implement vkGetRenderingAreaGranularityKHR 2024-06-05 14:21:05 +00:00
v3dv_pipeline.c treewide: use nir_def_replace sometimes 2024-06-21 15:36:56 +00:00
v3dv_pipeline_cache.c treewide: Remove vulkan/runtime vulkan/util prefix in include path 2024-03-05 19:05:00 +00:00
v3dv_private.h v3dv: fix misalignment in descriptor layout structure 2024-07-01 08:02:07 +00:00
v3dv_query.c v3dv: add more checks for device loss 2024-06-12 12:09:00 +00:00
v3dv_queue.c v3dv: fix job suspend with command buffer simultaneous use flag 2024-04-03 13:35:54 +02:00
v3dv_uniforms.c broadcom: move HW-dependant constants to v3d_device_info 2024-06-05 17:14:59 +00:00
v3dv_wsi.c v3dv: disallow image stores on VK_KHR_DISPLAY surfaces 2023-12-13 06:17:15 +00:00
v3dvx_cmd_buffer.c v3dv: implement vkCmdBindIndexBuffer2KHR 2024-05-28 11:37:47 +02:00
v3dvx_descriptor_set.c v3dv: add support for multi-planar formats, enable YCbCr 2023-01-16 14:10:21 +00:00
v3dvx_device.c v3dv: restrict to channels when encoding border color 2024-07-01 08:02:07 +00:00
v3dvx_formats.c v3dv: support VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR 2024-06-11 05:32:26 +00:00
v3dvx_image.c v3dv: use new texture shader state rb_swap and reverse fields in v3d 7.x 2023-10-13 22:37:43 +00:00
v3dvx_meta_common.c v3dv: fix a few asserts that check layerCount instead of array_layers 2024-06-06 07:12:27 +00:00
v3dvx_pipeline.c v3dv: drop unused stride field from v3dv_pipeline_vertex_binding 2024-05-28 11:37:19 +02:00
v3dvx_private.h broadcom: move HW-dependant constants to v3d_device_info 2024-06-05 17:14:59 +00:00
v3dvx_query.c v3dv: Use DRM_IOCTL_V3D_GET_COUNTER to get perfcnt information 2024-05-22 05:37:48 +00:00
v3dvx_queue.c v3d,v3dv: don't use max internal bpp for tile sizing in V3D 7.x 2023-10-13 22:37:43 +00:00