Git Product home page Git Product logo

hello_triangle's People

Contributors

krooze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hello_triangle's Issues

fpsCounter didn't show fps counter in window's title

I faced the problem of fpsCounter which relates directly to VK_LAYER_LUNARG_monitor didn't show FPS counter on window's title on Ubuntu 19.10.

It happened to me in another glfw-based application as well. But vkcube as bundled from SDK works fine and able to show FPS counter.

Any ideas of what problem might be?

build on ubuntu

What environment variables do I set to build on Ubuntu?

$ cmake .
WSI: USE_PLATFORM_GLFW
Vulkan SDK path: /home/pem/vulkan/1.3.216.0
-- Using X11 for window creation
Vulkan include dir: VULKAN_INCLUDE-NOTFOUND
Vulkan libs: VULKAN_LIBRARY-NOTFOUND
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
VULKAN_INCLUDE
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
   used as include directory in directory /home/pem/pemcode/Hello_Triangle
VULKAN_LIBRARY
    linked by target "HelloTriangle" in directory /home/pem/pemcode/Hello_Triangle

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of
  "HelloTriangle":

    "VULKAN_INCLUDE-NOTFOUND"



-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Why MaxFlightNumb should be always 2?

Hi @krOoze. I'm referring to your code for my vulkan engine.
Always Thank you for your good resource.

I assume that Your tutorial code is using triple buffering.

I have questions for these lines

// workaround for validation layer "leak" + might also help driver to cleanup old resources
// this should not be needed for real-word app, because they are likely to use fences naturaly (e.g. user input reaction)
// read https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/1628
const uint32_t maxInflightSubmissions = 2; // more than 2 probably does not make much sense
uint32_t submissionNr = 0; // index of the current submission modulo maxInflightSubmission
vector<VkFence> submissionFences;

I want to know why more than 2 does not make sense. Because, When you have 3 swapchain images, I think you can submit 3 images, which is achieved by vkQueueSubmit() limited by 3 fences respectively.
So, I think we should always create the same number of sync objects as the number of the swapchain images.

In addition, when you create sync object,

imageReadySs = initSemaphores( device, maxInflightSubmissions );
renderDoneS = initSemaphore( device );
submissionFences = initFences( device, maxInflightSubmissions, VK_FENCE_CREATE_SIGNALED_BIT ); // signaled fence means previous execution finished, so we start rendering presignaled
submissionNr = 0;

You just created only one renderDoneSemaphore for sync object.
And this makes me confused with the triple buffering system with Vulkan.
Because when you try to submit one image, You will construct one set of sync objects, command buffers. So, I think you have to use another semaphore when you try to submit the next image.

Specifically, I mean that when you do vkQueueSubmit, you are submitting a combination of command buffers and sync objects to the GPU queue. So, I think the driver and the GPU will use the set of command buffers and sync objects to process rendering process and synchronization.

That's the reason why I think We should have the same number of renderingDone semaphore as the swapchain image count.

I pushed my version on my fork. You can view the changes.
ChanLee1123@a60f966

Thanks in advance!

Question about the frame synchronization model

In your frame synchronization model you wait for the submission fence, i.e. for the rendering to be complete, but not for the presentation to be complete. I mean you could wait for the acquire fence (the fence which is signaled by vkAcquireNextImageKHR) of the next oldest frame to know that the oldest frame which you reuse is completed the presentation.

Is there any explicit reason of your choice? I'm trying to evaluate the pros/cons of the two approaches.

Also, rather a mention than a critique, since this model is a perfect fit for a simple app like hello HelloTriangle, it scales to real-world applications in a way that if you issue multiple vkQueueSubmit per frame, then you have to wait the fences of all vkQueueSubmit issued on that frame - one would think that waiting the fence of the last vkQueueSubmit results in proper synchronization, but if there are no dependencies between the last and previous submissions, then the last submission can complete out of order, before the previous submissions, which would lead to insufficient synchronization.

In the meantime I realized that according to the spec:

When a fence is submitted to a queue as part of a queue submission command, it defines a memory dependency on the batches that were submitted as part of that command, and defines a fence signal operation which sets the fence to the signaled state.

The first synchronization scope includes every batch submitted in the same queue submission command. Fence signal operations that are defined by vkQueueSubmit additionally include in the first synchronization scope all commands that occur earlier in submission order. Fence signal operations that are defined by vkQueueSubmit or vkQueueBindSparse additionally include in the first synchronization scope any semaphore and fence signal operations that occur earlier in signal operation order.

The second synchronization scope only includes the fence signal operation.

Which, as I read, means that it is sufficient to wait the fence of the last vkQueueSubmit per frame, since even if the submitted commands complete out of order, the fence signal operations of the submissions complete in order.

I also realized that your choice of sync model wait-on-submit is superior to wait-on-acquire-next, since it never waits for the presentation engine to release an image (B) to start building a new frame, instead it waits only the GPU to complete a frame (A), which spares the time between A and B, leading to better CPU/GPU utilization.

So I think I just answered my own questions ๐Ÿ‘ฝ

Validation Error caused by vkAllocateMemory-deviceCoherentMemory

Hello.

When I ran this example on my ryzen 2200g video chip with validation layers enabled, I have the following warning, raised from initMemory function:

VALIDATION+ERROR: [Device(0x1E7AB642BC0)]: VUID-vkAllocateMemory-deviceCoherentMemory-02790(-2010063723), "Validation Error: [ VUID-vkAllocateMemory-deviceCoherentMemory-02790 ] Object
0: handle = 0x1e7ab642bc0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x8830dc95 | vkAllocateMemory: attempting to allocate memory type 6, which includes the VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD memory property, but the deviceCoherentMemory feature is not enabled. The Vulkan spec states: If the deviceCoherentMemory feature is not enabled, pAllocateInfo->memoryTypeIndex must not identify a memory type supporting VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD. (https://vulkan.lunarg.com/doc/view/1.2.176.1/windows/1.2-extensions/vkspec.html#VUID-vkAllocateMemory-deviceCoherentMemory-02790)"

idk why this happens with VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT instead of VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD, but probably the VK_AMD_device_coherent_memory device extension must be enabled on AMD devices.

Seems this documentation is related: https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/vk_amd_device_coherent_memory.html

Feature request: c branch

Would you mind creating a c branch? When looking at the cpp file I am not sure if its trivial to translate the c++ code into c ?

failing VULKAN_VALIDATION

I compiled HelloTriangle succesfully, but when trying to run it I get

ERROR: Terminated due to an uncaught exception: VULKAN_VALIDATION is enabled but VK_LAYER_KHRONOS_validation layers are not supported!

Does this mean my version of Vulkan is wrong? I use SDK 1.2.148.1.

DXGI based swapchain wrapper

This is a follow-up question to KhronosGroup/Vulkan-Docs#366 (comment)

I decided to start from scratch. My new effort will be to UWP/DX12 on the Windows based platforms and Vulkan for non-Mac platforms, eventually Metal on Mac. I'll forgo SDL2 or any other libraries and do everything natively. In that context I want to forgo doing a Win32 application. Is DXGI feasible enough to share the DX12 code with a Vulkan renderer even if it is just for development purposes to save time on redoing the same stuff with a different API? DXGI should be enough to enumerate monitors, screens, setup windows etc. I guess.

Windows/MSVC is my primary development platform and the targets are UWP/Xbox, Android, Apple.

Untested MacOS support

I have no way to test MacOS support. But theoretically GLFW should be able to handle it. I would be grateful if someone tests it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.