mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
vulkan: Add pixel-formats to query format properties
We need a database of pixel format properties to remove hardcoded magic numbers. This commit creates a simple function to query the bytes per pixel for common RGBA formats. This should be promoted to or superseeded by a common spa namespaced version.
This commit is contained in:
parent
49b67742c6
commit
c3327742cc
6 changed files with 57 additions and 3 deletions
|
|
@ -248,13 +248,13 @@ int vulkan_read_pixels(struct vulkan_base *s, struct vulkan_read_pixels_info *in
|
|||
|
||||
const char *d = (const char *)v + img_sub_layout.offset;
|
||||
unsigned char *p = (unsigned char *)info->data + info->offset;
|
||||
uint32_t bytes_per_pixel = 16;
|
||||
uint32_t pack_stride = img_sub_layout.rowPitch;
|
||||
spa_log_trace_fp(s->log, "Read pixels: %p to %p, stride: %d, width %d, height %d, offset %d, pack_stride %d", d, p, info->stride, info->size.width, info->size.height, info->offset, pack_stride);
|
||||
if (pack_stride == info->stride) {
|
||||
memcpy(p, d, info->stride * info->size.height);
|
||||
} else {
|
||||
for (uint32_t i = 0; i < info->size.height; i++) {
|
||||
memcpy(p + i * info->stride, d + i * pack_stride, info->size.width * bytes_per_pixel);
|
||||
memcpy(p + i * info->stride, d + i * pack_stride, info->size.width * info->bytes_per_pixel);
|
||||
}
|
||||
}
|
||||
vkUnmapMemory(s->device, vk_buf->memory);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue