c/client: Respect native compositor's extra usage bits

This commit is contained in:
Jakob Bornecrantz 2023-04-07 19:10:46 +01:00
parent 1adf46b02a
commit a03d1421b8
4 changed files with 48 additions and 16 deletions

View file

@ -389,7 +389,11 @@ try {
struct xrt_swapchain_create_info xinfo = *info;
struct xrt_swapchain_create_info vkinfo = *info;
// Update the create info.
xinfo.bits = (enum xrt_swapchain_usage_bits)(xsccp.extra_bits | xinfo.bits);
vkinfo.format = vk_format;
vkinfo.bits = (enum xrt_swapchain_usage_bits)(xsccp.extra_bits | vkinfo.bits);
std::unique_ptr<struct client_d3d11_swapchain> sc = std::make_unique<struct client_d3d11_swapchain>();
sc->data = std::make_unique<client_d3d11_swapchain_data>(c->log_level);

View file

@ -425,7 +425,11 @@ try {
struct xrt_swapchain_create_info xinfo = *info;
struct xrt_swapchain_create_info vkinfo = *info;
// Update the create info.
xinfo.bits = (enum xrt_swapchain_usage_bits)(xsccp.extra_bits | xinfo.bits);
vkinfo.format = vk_format;
vkinfo.bits = (enum xrt_swapchain_usage_bits)(xsccp.extra_bits | vkinfo.bits);
std::unique_ptr<struct client_d3d12_swapchain> sc = std::make_unique<struct client_d3d12_swapchain>();
sc->data = std::make_unique<client_d3d12_swapchain_data>(c->log_level);

View file

@ -416,8 +416,23 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
struct xrt_swapchain **out_xsc)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain_create_properties xsccp = {0};
xrt_result_t xret = XRT_SUCCESS;
// Do before getting the context, not using ourselves.
xret = xrt_comp_get_swapchain_create_properties(xc, info, &xsccp);
if (xret != XRT_SUCCESS) {
U_LOG_E("Failed to get create properties: %u", xret);
return xret;
}
// Check before setting the context.
int64_t vk_format = gl_format_to_vk(info->format);
if (vk_format == 0) {
U_LOG_E("Invalid format!");
return XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED;
}
xret = client_gl_compositor_context_begin(xc);
if (xret != XRT_SUCCESS) {
return xret;
@ -432,18 +447,16 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
}
}
int64_t vk_format = gl_format_to_vk(info->format);
if (vk_format == 0) {
U_LOG_E("Invalid format!");
client_gl_compositor_context_end(xc);
return XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED;
}
struct xrt_swapchain_create_info xinfo = *info;
xinfo.format = vk_format;
struct xrt_swapchain_native *xscn = NULL; // Has to be NULL.
xret = xrt_comp_native_create_swapchain(c->xcn, &xinfo, &xscn);
struct xrt_swapchain_create_info vkinfo = *info;
// Update the create info.
xinfo.bits |= xsccp.extra_bits;
vkinfo.format = vk_format;
vkinfo.bits |= xsccp.extra_bits;
struct xrt_swapchain_native *xscn = NULL; // Has to be NULL.
xret = xrt_comp_native_create_swapchain(c->xcn, &vkinfo, &xscn);
if (xret != XRT_SUCCESS) {
client_gl_compositor_context_end(xc);
@ -462,7 +475,7 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
struct xrt_swapchain *xsc = &xscn->base;
struct client_gl_swapchain *sc = NULL;
if (NULL == c->create_swapchain(xc, info, xscn, &sc)) {
if (NULL == c->create_swapchain(xc, &xinfo, xscn, &sc)) {
// Drop our reference, does NULL checking.
xrt_swapchain_reference(&xsc, NULL);
client_gl_compositor_context_end(xc);

View file

@ -614,8 +614,19 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
VkResult ret;
xrt_result_t xret;
struct xrt_swapchain_create_properties xsccp = XRT_STRUCT_INIT;
xret = xrt_comp_get_swapchain_create_properties(&c->xcn->base, info, &xsccp);
if (xret != XRT_SUCCESS) {
VK_ERROR(vk, "Failed to get create properties: %u", xret);
return xret;
}
// Update the create info.
struct xrt_swapchain_create_info xinfo = *info;
xinfo.bits |= xsccp.extra_bits;
struct xrt_swapchain_native *xscn = NULL; // Has to be NULL.
xret = xrt_comp_native_create_swapchain(c->xcn, info, &xscn);
xret = xrt_comp_native_create_swapchain(c->xcn, &xinfo, &xscn);
if (xret != XRT_SUCCESS) {
return xret;
@ -624,9 +635,9 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
struct xrt_swapchain *xsc = &xscn->base;
VkAccessFlags barrier_access_mask = vk_csci_get_barrier_access_mask(info->bits);
VkImageLayout barrier_optimal_layout = vk_csci_get_barrier_optimal_layout(info->format);
VkImageAspectFlags barrier_aspect_mask = vk_csci_get_barrier_aspect_mask(info->format);
VkAccessFlags barrier_access_mask = vk_csci_get_barrier_access_mask(xinfo.bits);
VkImageLayout barrier_optimal_layout = vk_csci_get_barrier_optimal_layout(xinfo.format);
VkImageAspectFlags barrier_aspect_mask = vk_csci_get_barrier_aspect_mask(xinfo.format);
struct client_vk_swapchain *sc = U_TYPED_CALLOC(struct client_vk_swapchain);
sc->base.base.destroy = client_vk_swapchain_destroy;
@ -639,7 +650,7 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
sc->xscn = xscn;
for (uint32_t i = 0; i < xsc->image_count; i++) {
ret = vk_create_image_from_native(vk, info, &xscn->images[i], &sc->base.images[i], &sc->mems[i]);
ret = vk_create_image_from_native(vk, &xinfo, &xscn->images[i], &sc->base.images[i], &sc->mems[i]);
if (ret != VK_SUCCESS) {
return XRT_ERROR_VULKAN;