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

VkQueue flags #627

Closed
AnonN10 opened this issue Sep 4, 2022 · 6 comments
Closed

VkQueue flags #627

AnonN10 opened this issue Sep 4, 2022 · 6 comments

Comments

@AnonN10
Copy link

AnonN10 commented Sep 4, 2022

Please specify in the documentation which flags should a VkQueue passed to ktxVulkanDeviceInfo_Construct have.

@MarkCallow
Copy link
Collaborator

No flags are required. Anyway there is only one flag VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT. It is entirely up to application if it wants to use it, provided protected memory is available. An application that does use PM will have to use VK_IMAGE_TILING_OPTIMAL when calling ktxTexture_VkUploadEx.

Is this what you want to have documented?

@AnonN10
Copy link
Author

AnonN10 commented Oct 12, 2022

No, VkQueueFlagBits flags

@MarkCallow
Copy link
Collaborator

Ahh! Okay. I plan to make the change to the documentation shown below. Please review.

I realized in investigating this that ktxVulkanDeviceInfo has no knowledge of the queue family index of the queue - I can't find any way to query it when I only have the VkQueue handle - so there is no way that ktxTexture_VkUploadEx can be modified to create shared images. It looks like at some point I'll have to add some new functions. So far nobody has requested shared image support.

diff --git a/lib/vkloader.c b/lib/vkloader.c
index eeabf490..2940aeb9 100644
--- a/lib/vkloader.c
+++ b/lib/vkloader.c
@@ -183,6 +183,19 @@ ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This,
  * device memory properties for ease of use when allocating device memory for
  * the images.
  *
+ * If @c VK_IMAGE_TILING_OPTIMAL will be passed to ktxTexture_VkUploadEx(), the
+ * family of the @a queue parameter must support transfers. This is true if
+ * any of @c VK_QUEUE_GRAPHICS_BIT, @c VK_QUEUE_COMPUTE_BIT or
+ * @c VK_QUEUE_TRANSFER_BIT is set in the @c queueFlags property of the queue's
+ * @c VkQueueFamilyProperties. If protected memory is being used, i.e
+ * @c queueFlags has @c VK_QUEUE_PROTECTED_BIT set, then
+ * @c VK_IMAGE_TILING_OPTIMAL must be passed to ktxTexture_VkUploadEx().
+ *
+ * All VkImages and intermediate VkBuffers used in VkUploadEx() will be created
+ * with @c VK_SHARING_MODE_EXCLUSIVE set so the queue family index property
+ * of their CreateInfo structures is ignored.
+ * of their CreateInfo structures is ignored.
+ *
  * Pass a valid ktxVulkanDeviceInfo* to any Vulkan KTX image loading
  * function to provide it with the information.
  *
@@ -344,7 +357,7 @@ do {                             \
     result = This->vkFuncs.vkAllocateCommandBuffers(device, &cmdBufInfo,
                                                     &This->cmdBuffer);
     if (result != VK_SUCCESS) {
-        return KTX_OUT_OF_MEMORY; // XXX Consider an equivalent to pGlError
+        return KTX_OUT_OF_MEMORY; // TODO: Consider an equivalent to pGlError
     }
     return KTX_SUCCESS;

@MarkCallow
Copy link
Collaborator

@AnonN10 please review the proposed change today. I want to include this in the release that I want to build tomorrow at the latest.

@AnonN10
Copy link
Author

AnonN10 commented Oct 14, 2022

All good I think. Regarding shared images, if I understand correctly you mean VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT flag? It was enough for me to create a variant of ktxTexture_VkUploadEx which exposes flags to be able to share images between image views with compatible formats like UNORM/SRGB.
33d07be

@MarkCallow
Copy link
Collaborator

Regarding shared images,

In this case sharing means the image can be used with queues from multiple queue families which must be specified when the image is created. No sharing means the image can be used only with queues the family of the queue used to create the image.

MarkCallow added a commit that referenced this issue Oct 14, 2022
Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 21, 2024
…roup#639)

Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
…roup#639)

Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
…roup#639)

Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
…roup#639)

Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
…roup#639)

Bug fix: when creating the VkDevice in VulkanAppSDL use the family
index of the suitable queue determined by VulkanSwapchain::initSurface.
It was using index  0.

Convert a few TODOs and XXXs to TODO: for proper parsing by Xcode's
editor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants