VulkanTutorial | Tutorial for the Vulkan graphics and compute API | Graphics library
kandi X-RAY | VulkanTutorial Summary
kandi X-RAY | VulkanTutorial Summary
This repository hosts the contents of [vulkan-tutorial.com] The website itself is based on [daux.io] which supports [GitHub flavored Markdown] The actual site runs daux.io with a custom theme and a few modifications (and this is built into a [Docker image] Use issues and pull requests to provide feedback related to the website. If you have a problem with your code, then use the comments section in the related chapter to ask a question. Please provide your operating system, graphics card, driver version, source code, expected behaviour and actual behaviour.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of VulkanTutorial
VulkanTutorial Key Features
VulkanTutorial Examples and Code Snippets
Community Discussions
Trending Discussions on VulkanTutorial
QUESTION
I am following a Vulkan tutorial and I choose CMake as my build system. However, the build fails every time because it is trying to link with a file called 'vulkan.lib' from what I know, there's no such file as vulkan.lib because the actual library file for Vulkan is 'vulkan-1.lib'
Here is my CMake script:
...ANSWER
Answered 2022-Mar-26 at 05:54Thanks to @Stephen Newell's comment I solved it by getting rid of the vulkan
in the second target_link_libraries
call and it worked.
QUESTION
I'm following the Vulkan tutorial about uniform buffers and I'm confused as to why we need to provide descriptor set layouts where all the informations they provide seem to already be in the VkWriteDescriptorSet
structures with pass in to function vkUpdateDescriptorSets
.
Why does Vulkan need both pieces of information and not just what we provide through vkUpdateDescriptorSets
?
From the tutorial's code:
...ANSWER
Answered 2021-Aug-26 at 15:15You need a descriptor set layout before you write to a descriptor set for the same reason you need a class before you can instantiate it. You can't do A a;
for some type A
before you define what A
is. VkWriteDescriptorSet
is like doing a.x = whatever
; it doesn't make sense until you know what a
is, and that requires having the class definition for A
.
Descriptor set layouts define what a descriptor set looks like. It specifies all of the things that go into one. vkAllocateDescriptorSets
is how you create an instance of a descriptor set layout (in our analogy, it's A a;
, with the set being a
). VkWriteDescriptorSet
is how you provide the data that goes into a descriptor set (in our analogy, it's like a.x = whatever;
, only potentially for multiple members).
VkWriteDescrptorSet
has a lot of data that is redundantly specified in the descriptor set layout so that the implementation does not have to store the set layout as raw data.
Let's say that binding 2 in a descriptor set is a UBO of length X. And you want to attack a buffer range to that UBO descriptor. To do that, the implementation may need to know that it is a UBO descriptor and what its length is. If it does need to know that, then it would also need to store that information inside the descriptor set.
That forces the implementation to store extra data that's only useful for writing to the descriptor. If that descriptor is only set once and never again or otherwise modified infrequently (as descriptors often are), the implementation has to keep a bunch of information around for no reason.
So Vulkan makes you decide whether to keep the information around or not.
QUESTION
I'm building a headless vulkan renderer and cannot understand this validation error I received:
...ANSWER
Answered 2021-May-05 at 22:23VkSubpassDescription subpass;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &color_ref;
subpass.pDepthStencilAttachment = &depth_ref;
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
QUESTION
Assume a vertex buffer in device memory and a staging buffer that's host coherent and visible. Also assume a desktop system with a discrete GPU (so separate memories). And lastly, assume correct inter-frame synchronization.
I see two general possible ways of updating a vertex buffer:
Map +
memcpy
+ unmap into the staging buffer, followed by a transient (single command) command buffer that contains avkCmdCopyBuffer
, submit it to the graphics queue and wait for the queue to idle, then free the transient command buffer. After that submit the regular frame draw queue to the graphics queue as usual. This is the code used on https://vulkan-tutorial.com (for example, this .cpp file).Similar to above, only instead use additional semaphores to signal after the staging buffer copy submit, and wait in the regular frame draw submit, thus skipping the "wait-for-idle" command.
#2 sort of makes sense to me, and I've repeatedly read not to do any "wait-for-idle" operations in Vulkan because it synchronizes the CPU with the GPU, but I've never seen it used in any tutorial or example online. What do the pros usually do if the vertex buffer has to be updated relatively often?
...ANSWER
Answered 2020-Dec-06 at 18:12First, if you allocated coherent memory, then you almost certainly did so in order to access it from the CPU. Which requires mapping it. Vulkan is not OpenGL; there is no requirement that memory be unmapped before it can be used (and OpenGL doesn't even have that requirement anymore).
Unmapping memory should only ever be done when you are about to delete the memory allocation itself.
Second, if you think of an idea that involves having the CPU wait for a queue or device to idle before proceeding, then you have come up with a bad idea and should use a different one. The only time you should wait for a device to idle is when you want to destroy the device.
Tutorial code should not be trusted to give best practices. It is often intended to be simple, to make it easy to understand a concept. Simple Vulkan code often gets in the way of performance (and if you don't care about performance, you shouldn't be using Vulkan).
In any case, there is no "most generally correct way" to do most things in Vulkan. There are lots of definitely incorrect ways, but no "generally do this" advice. Vulkan is a low-level, explicit API, and the result of that is that you need to apply Vulkan's tools to your specific circumstances. And maybe profile on different hardware.
For example, if you're generating completely new vertex data every frame, it may be better to see if the implementation can read vertex data directly from coherent memory, so that there's no need for a staging buffer at all. Yes, the reads may be slower, but the overall process may be faster than a transfer followed by a read.
Then again, it may not. It may be faster on some hardware, and slower on others. And some hardware may not allow you to use coherent memory for any buffer that has the vertex input usage at all. And even if it's allowed, you may be able to do other work during the transfer, and thus the GPU spends minimal time waiting before reading the transferred data. And some hardware has a small pool of device-local memory which you can directly write to from the CPU; this memory is meant for these kinds of streaming applications.
If you are going to do staging however, then your choices are primarily about which queue you submit the transfer operation on (assuming the hardware has multiple queues). And this primarily relates to how much latency you're willing to endure.
For example, if you're streaming data for a large terrain system, then it's probably OK if it takes a frame or two for the vertex data to be usable on the GPU. In that case, you should look for an alternative, transfer-only queue on which to perform the copy from the staging buffer to the primary memory. If you do, then you'll need to make sure that later commands which use the eventual results synchronize with that queue, which will need to be done via a semaphore.
If you're in a low-latency scenario where the data being transferred needs to be used this frame, then it may be better to submit both to the same queue. You could use an event to synchronize them rather than a semaphore. But you should also endeavor to put some kind of unrelated work between the transfer and the rendering operation, so that you can take advantage of some degree of parallelism in operations.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install VulkanTutorial
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page