Vulkan | Examples and demos for the new Vulkan API | Graphics library
kandi X-RAY | Vulkan Summary
kandi X-RAY | Vulkan Summary
A comprehensive collection of open source C++ examples for Vulkan, the new generation graphics and compute API from Khronos.
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 Vulkan
Vulkan Key Features
Vulkan Examples and Code Snippets
Community Discussions
Trending Discussions on Vulkan
QUESTION
In my understanding, VkPhysicalDevice represents an implementation of Vulkan, which could be represented as a GPU and its drivers. We are supposed to record commands with VkCommandBuffers and send them through queues to, potentially, multithread the work we send to the gpu. That is why I understand the fact there can be multiple queues. I understand as well that QueueFamilies groups queues depending on the features they can do (the extensions available for them e.g. presentation, as well as graphics computations, transfer, etc).
However, if a GPU is able to do Graphics work, why are there queues unable to do so? I heard that using queues with less features could be faster, but why? What is a queue concretely? Is it only tied to vulkan implementation? Or is it related to hardware specific things?
I just don't understand why queues with different features exist, and even after searching through the Vulkan doc, StackOverflow, vulkan-tutorial and vkguide, the only thing I found was "Queues in Vulkan are an “execution port” for GPUs.", which I don't really understand and on which I can't find anything on google.
Thank you in advance for your help!
...ANSWER
Answered 2022-Apr-03 at 21:56A queue is a thing that consumes and executes commands, such that each queue (theoretically) executes separately from every other queue. You can think of a queue as a mouth, with commands as food.
Queues within a queue family typically execute commands using the same underlying hardware to process them. This would be like a creature with multiple mouths but all of them connect to the same digestive tract. How much food they can eat is separate from how much food they can digest. Food eaten by one mouth may have to wait for food previously eaten by another to pass through the digestive tract.
Queues from different families may (or may not) have distinct underlying execution hardware. This would be like a creature with multiple mouths and multiple digestive tracts. If a mouth eats, that food need not wait for food from a different mouth to digest.
Of course, distinct underlying execution hardware is typically distinct for a reason. Several GPUs have specialized DMA hardware for doing copies to/from device-local memory. Such hardware will typically expose a queue family that only allows transfer operations, and those transfer operations may be restricted in their byte alignment compared to transfers done on graphics-capable queues.
Note that these are general rules. Sometimes queues within a family do execute on different hardware, and sometimes queues between families use much of the same hardware. The API and implementations don't always make this clear, so you may have to benchmark different circumstances.
QUESTION
I'm trying to start android emulator on apple silicon mac and I'm always getting the same results:
- Running emulator directly through Android Studio (the latest stable version, Arctic Fox 2020.3.1 Patch 4) causes a problem, when the process qemu-system-arch64 stucks and uses 99% CPU (there is no emulator's screen or something like than). Such behavior produces some logs:
internal-error-msg.txt says:
...ANSWER
Answered 2022-Feb-03 at 21:53Issue was successfully fixed in Android Emulator revision 31.2.7. Just go to Android SDK Manager and update it!
According to android emulator release notes:
QUESTION
Just got a new M1 Mac Mini and I have been having trouble running my Android projects.
I'm using Android Studio (Bumblebee), JDK 11 (tried 17 as well), and Gradle 7.3.
When I try to run the project from AS, it builds fine and then gets stuck on "Waiting for target device to come online" and eventually times out.
If I try to run the emulator again I get a message that the device is already running, including a path to a lock file.
However, I've found that if I run the emulator manually from the CLI, the emulator does open, at which point I can get AS to run the app on said emulator. So the problem is apparently just that AS can't open the AVD.
Command line output when running emulator via adelphia$ emulator -avd Pixel_3a_API_32_arm64-v8a
:
ANSWER
Answered 2022-Feb-02 at 15:36QUESTION
I cannot start the android emulator V30.9.4
I got this error message:
...ANSWER
Answered 2022-Jan-16 at 14:52- Try to use the host system's OpenGL driver:
QUESTION
Setup:
- Windows 11 Home 21H2 22000.132
- AMD Ryzen 5900X
- WSL2
- Android studio lastest build (also tried with latest beta)
Problem: As soon as I install WSL2, the emulator stops working. It's giving the following error message:
...ANSWER
Answered 2021-Aug-19 at 12:54I found and tested in shorter toggle mechanism.
The configuration for Windows Feature:
Windows Subsystem for Linux
is installed.Windows Hypervisor Platform
is installed.Hyper-V
is installed.
If you need the Emulator, you only need to turn off Hypervisor + Restart. Run: bcdedit /set hypervisorlaunchtype off
If you need the Docker back, you can run the hypervisor hence disabling Emulator. Run: bcdedit /set hypervisorlaunchtype auto
You need to restart after setting Hypervisor
You cannot run both at the same time. Another forum worth checking in How about running docker?
in my older answer below.
I think I solved this issue, tested to run from CMD / Android Studio and ran perfectly as before installing WSL. There are several step we go:
Configuring Windows Feature:- Removed
Windows Subsystem for Linux
- Removed
Windows Hypervisor Platform
- Removed
Hyper-V
Here is my current setup:
Reverting AVD setupI know after removing there are some odds because the AVD still get the same error as before and expected to get into WSL. I stumbled and found something when ran:
C:\Users\[NAME]\AppData\Local\Android\Sdk\emulator\emulator-check.exe accel
That command will check the current accel. It explains that the Hypervisor need to be set off and give specific help:
run bcdedit /set hypervisorlaunchtype off
.
After running the bcdedit, I restarted and all is reverted. Now I can run emulator both from CMD and Android Studio perfectly.
How about running docker?Sad truth, yeah you cannot run both pararel. There are several workaround in this forum:
How can I run both Docker and Android Studio Emulator on Windows?
Several option ranging from changing emulator, add & remove docker when in need using above step, created nested vm, etc. My personal choice right now is using another Emulator for the time being and removed docker for the latter.
QUESTION
Let's first acknowledge that OpenGL is deprecated by Apple, that the last supported version is 4.1 and that that's a shame but hey, we've got to move forward somehow and Vulkan is the way :trollface: Now that that's out of our systems, let's have a look at this weird bug I found. And let me be clear that I am running this on an Apple Silicon M1, late 2020 MacBook Pro with macOS 11.6. Let's proceed.
I've been following LearnOpenGL and I have published my WiP right here to track my progress. All good until I got to textures. Using one texture was easy enough so I went straight into using more than one, and that's when I got into trouble. As I understand it, the workflow is more or less
- load pixel data in a byte array called
textureData
, plus extra info glGenTextures(1, &textureID)
glBindTexture(GL_TEXTURE_2D, textureID)
- set parameters at will
glTexImage2D(GL_TEXTURE_2D, ... , textureData)
glGenerateMipmap(GL_TEXTURE_2D)
(although this may be optional)
which is what I do around here, and then
glUniform1i(glGetUniformLocation(ID, "textureSampler"), textureID)
- rinse and repeat for the other texture
and then, in the drawing loop, I should have the following:
glUseProgram(shaderID)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, textureID)
glActiveTexture(GL_TEXTURE1)
glBindTexture(GL_TEXTURE_2D, otherTextureID)
I then prepare my fancy fragment shader as follows:
...ANSWER
Answered 2021-Dec-13 at 19:23Instead of passing a texture handle to glUniform1i(glGetUniformLocation(ID, "textureSampler"), ...)
, you need to pass a texture slot index.
E.g. if you did glActiveTexture(GL_TEXTUREn)
before binding the texture, pass n
.
QUESTION
I can't recall if I have ever tinkered with the settings of Android Emulator, but I've been testing my app on an Android Emulator using Android Studio, and every time I take a screenshot, it crashes.
I tried deleting, and wiping, and creating a new Emulator. None of it works. I tried also to take a screenshot without running my app, with a fresh emulator, and the same problem occurs. It just crashes whenever I try to take a picture.
Android Studio reports this error:
Blockquote WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator. WARNING | cannot add library /Users/sbenati/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed INFO | configAndStartRenderer: setting vsync to 60 hz INFO | added library /Users/sbenati/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib WARNING | cannot add library /Users/sbenati/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed INFO | added library /Users/sbenati/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib INFO | Started GRPC server at 127.0.0.1:8554, security: Local INFO | Advertising in: /Users/sbenati/Library/Caches/TemporaryItems/avd/running/pid_935.ini
My machine is a Mac with 32GB of RAM and i7 CPU, so I can't imaging this an issue with system performance.
If no one has any suggestions, I will have to just reinstall everything. Thanks for the tips everyone.
Edit:
I ran this on a new Mac mini I recently acquired, and got this really helpful message. I traced it down to a suggested solution about switching off Vulcan, but it did not work for me.
...ANSWER
Answered 2021-Dec-04 at 02:28I've been having the same problem (I'm on macOS Monterey), each time I try to take a screenshot the emulator crashes.
Sadly I haven't found a direct solution to this problem, that is a solution fixing the issue in the simulator. But I have learned that it is possible to take screenshots of the app from inside Android Studio, using Logcat.
Essentially, when you're running your app, if you go to the Logcat tab, there is a screenshot option which does seem to work without crashing. I've added a link to developer.android.com which explains how to do it.
Even thought this doesn't exactly fix the problem I hope it helps!
Take a screenshot (through android studio)
Edit:
I am happy to report that after a recent update for the emulator released by the developers, the issue no longer exists for me! The screenshot button has now started working again.
So if someone has the issue, I believe it can now be fixed by just updating your emulator to the latest version available.
QUESTION
I'm building a game with raylib and made my own custom button in different files to reuse it when I need it.
I watched tons of videos and read docs but I don't know why it throws undefined reference to CustomButton::CustomButton()
.
Here's the error:
...ANSWER
Answered 2021-Nov-26 at 18:03Ok I solved it via adding:
QUESTION
I'm learning vulkan, and as a (very) simple project I want to simply clear a single swapchain image to a single color (red). My code works, but I get two validation errors. I would like to know:
- How can I fix the validation errors in my code
- Is there a better way to simply clear swapchain images
Regarding (2): I specifically don't want to use a graphics pipeline: in the future I would like to use a compute shader to draw directly to the screen.
My current approachMy project uses vk-bootstrap to set up, and then I try to render a single frame as follows:
- Acquire an image from the swapchain
- Record a command buffer with the following commands:
vkCmdPipelineBarrier
vkCmdClearColorImage
vkEndCommandBuffer
- Submit the command buffer to the graphics queue
- present the previously acquired swapchain image using
vkQueuePresentKHR
The relevant code can be found below, but it seems that the validation errors arise from the calls to vkCmdClearColorImage
and vkQueuePresentKHR
.
The first validation error is from the vkCmdClearColorImage
call, and seems to be triggered by my choice of layout
:
ANSWER
Answered 2021-Nov-11 at 12:33I found a solution which works but seems kinda gross. Basically I modify step (2) to the following:
- Record a command buffer with the following commands:
vkCmdPipelineBarrier
vkCmdClearColorImage
vkCmdPipelineBarrier
vkEndCommandBuffer
Essentially the logical flow of this pipeline is:
- Using a barrier, convert image from
VK_IMAGE_LAYOUT_UNDEFINED
toVK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
- Clear image using
vkCmdClearColorImage
- Using a barrier, convert the image to
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
so it can be presented
This works because:
vkCmdClearColorImage
requires the image to have layoutVK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
, butvkQueuePresent
requires the image to have layoutVK_IMAGE_LAYOUT_PRESENT_SRC_KHR
Since this seems a little hacky / gross, I will leave this question open for a while to see if anyone has a better solution. For completeness, here is the new code for step (2)
Modified code for step (2)QUESTION
This table shows the percentage of GPUs that support any given image format for different uses, such as sampling, transferring, as a depth and stencil buffer etc. If you look at it you'll see that that many of the most common formats are supported for uses such as sampling and depth buffer usage with the percentage showing as 99% or 100%, while the support for TRANSFER_SRC and TRANSFER_DST is at 78%. I'm wondering why this is, given that pretty much any format should be able to be transferred for reading it and writing it. When uploading an image to be used as a texture don't you need the TRANSFER_DST bit to be set as a flag? Similarly does this mean that there are GPUs that support something like R8G8B8A8_UINT (100% of them apparently), but only 78% of them support transferring them? This doesn't make sense to me. Strangely where the support for TRANSFER_SRC and TRANSFER_DST shows 78% for many of them the BLIT_SRC and BLIT_DST show 100%. The tutorials I've followed show the uploading of textures using copy commands and TRANSFER_DST to copy images to the GPU, for example when copying an image from a staging buffer.
...ANSWER
Answered 2021-Oct-18 at 18:26This is purely a historical artifact. That database was created very early in Vulkan's life, and it has entries from a long time ago.
Vulkan 1.0 did not have FORMAT_FEATURE_TRANSFER_SRC/DEST
as options. If the implementation provided any usage support for a format, then images in that format could be used in transfer operations, period. The feature src/dest options were added in KHR_maintenance1 (adopted into Vulkan 1.1). The purpose of this was as follows:
Allow implementations to express support for doing just transfers and clears of image formats that they otherwise support no other format features for. This is done by adding new format feature flags
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR
andVK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR
.
For backwards compatibility, the extension also requires that SRC/DST support must be provided for any format that is required to be able to be used as a sampled image.
The 22% of "GPUs" that "don't support src/dst" in that database are from GPUs that were never updated to more recent versions of Vulkan.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Vulkan
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