a/vk: Make it possible to select vk format in readback pool

This commit is contained in:
Jakob Bornecrantz 2023-05-16 13:15:35 +01:00
parent cc2ebfffba
commit b5a40a1b50
3 changed files with 18 additions and 9 deletions

View file

@ -21,7 +21,8 @@ struct vk_image_readback_to_xf_pool
int num_images; int num_images;
struct vk_image_readback_to_xf images[READBACK_POOL_NUM_FRAMES]; struct vk_image_readback_to_xf images[READBACK_POOL_NUM_FRAMES];
VkExtent2D extent; VkExtent2D extent;
enum xrt_format desired_format; VkFormat vk_format;
enum xrt_format xrt_format;
}; };
static void static void
@ -61,7 +62,7 @@ vk_xf_readback_pool_try_create_new_frame(struct vk_bundle *vk, struct vk_image_r
VkResult res = vk_create_image_advanced( // VkResult res = vk_create_image_advanced( //
vk, // vk, //
extent, // extent, //
VK_FORMAT_R8G8B8A8_SRGB, // pool->vk_format, //
VK_IMAGE_TILING_LINEAR, // VK_IMAGE_TILING_LINEAR, //
usage, // usage, //
memory_property_flags, // memory_property_flags, //
@ -115,7 +116,7 @@ vk_xf_readback_pool_try_create_new_frame(struct vk_bundle *vk, struct vk_image_r
im->base_frame.width = extent.width; im->base_frame.width = extent.width;
im->base_frame.height = extent.height; im->base_frame.height = extent.height;
im->base_frame.size = stride * extent.height; im->base_frame.size = stride * extent.height;
im->base_frame.format = pool->desired_format; im->base_frame.format = pool->xrt_format;
} }
/* /*
@ -176,17 +177,19 @@ void
vk_image_readback_to_xf_pool_create(struct vk_bundle *vk, vk_image_readback_to_xf_pool_create(struct vk_bundle *vk,
VkExtent2D extent, VkExtent2D extent,
struct vk_image_readback_to_xf_pool **out_pool, struct vk_image_readback_to_xf_pool **out_pool,
enum xrt_format desired_format) enum xrt_format xrt_format,
VkFormat vk_format)
{ {
struct vk_image_readback_to_xf_pool *pool = U_TYPED_CALLOC(struct vk_image_readback_to_xf_pool); struct vk_image_readback_to_xf_pool *pool = U_TYPED_CALLOC(struct vk_image_readback_to_xf_pool);
assert(desired_format == XRT_FORMAT_R8G8B8X8 || desired_format == XRT_FORMAT_R8G8B8A8); assert(xrt_format == XRT_FORMAT_R8G8B8X8 || xrt_format == XRT_FORMAT_R8G8B8A8);
int ret = os_mutex_init(&pool->mutex); int ret = os_mutex_init(&pool->mutex);
if (ret != 0) { if (ret != 0) {
assert(false); assert(false);
} }
pool->extent = extent; pool->extent = extent;
pool->num_images = 0; pool->num_images = 0;
pool->desired_format = desired_format; pool->xrt_format = xrt_format;
pool->vk_format = vk_format;
*out_pool = pool; *out_pool = pool;
} }

View file

@ -60,7 +60,8 @@ void
vk_image_readback_to_xf_pool_create(struct vk_bundle *vk, vk_image_readback_to_xf_pool_create(struct vk_bundle *vk,
VkExtent2D extent, VkExtent2D extent,
struct vk_image_readback_to_xf_pool **out_pool, struct vk_image_readback_to_xf_pool **out_pool,
enum xrt_format desired_format); enum xrt_format xrt_format,
VkFormat vk_format);
void void
vk_image_readback_to_xf_pool_destroy(struct vk_bundle *vk, struct vk_image_readback_to_xf_pool **pool_ptr); vk_image_readback_to_xf_pool_destroy(struct vk_bundle *vk, struct vk_image_readback_to_xf_pool **pool_ptr);

View file

@ -591,8 +591,13 @@ renderer_init(struct comp_renderer *r, struct comp_compositor *c)
struct vk_bundle *vk = &r->c->base.vk; struct vk_bundle *vk = &r->c->base.vk;
vk_image_readback_to_xf_pool_create(vk, r->mirror_to_debug_gui.image_extent, &r->mirror_to_debug_gui.pool, vk_image_readback_to_xf_pool_create( //
XRT_FORMAT_R8G8B8X8); vk, //
r->mirror_to_debug_gui.image_extent, //
&r->mirror_to_debug_gui.pool, //
XRT_FORMAT_R8G8B8X8, //
VK_FORMAT_R8G8B8A8_SRGB); //
VkResult ret = vk_cmd_pool_init(vk, &r->mirror_to_debug_gui.cmd_pool, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT); VkResult ret = vk_cmd_pool_init(vk, &r->mirror_to_debug_gui.cmd_pool, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT);
if (ret != VK_SUCCESS) { if (ret != VK_SUCCESS) {
COMP_ERROR(c, "vk_cmd_pool_init: %s", vk_result_string(ret)); COMP_ERROR(c, "vk_cmd_pool_init: %s", vk_result_string(ret));