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

Vulkan 1 3 hello triangle sample #1230

Merged

Conversation

alihuawei
Copy link
Collaborator

This Pull Request introduces a new sample, "Hello Triangle", leveraging Vulkan 1.3 features and modern C++20 language enhancements. The sample aims to provide developers with an updated and clean starting point for learning and experimenting with the latest Vulkan API functionalities.

1: Sample is using vertex buffer to load vertices compared to hardcoded in the vertex shader in hello_triangle 1.0.
2: Sample is using dynamic rendering so frame buffers and Render passes removed.
3: Used Synchronization2 in image layout transition.
3: Updated the code to use VK_DEBUG_UTILS (new) instead VK_DEBUG_REPORT(old).
4: Update the code to use Dynamic pipeline status.
5: Removed unused parameters from functions.
6: Used C++20 initializers.

The sample is built and tested on Windows and Linux OS.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making:
  • My changes build on Windows and Linux.

Sample Checklist

  • I have tested the sample on at least one compliant Vulkan implementation
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@gary-sweet gary-sweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing a change to samples/CMakeLists.txt that actually exposes the sample.

I know very little about the background to this change, but it does seem a little odd that using the newer version of Vulkan results in 200 more lines of code for hello_triangle than we used to have.

@SaschaWillems
Copy link
Collaborator

SaschaWillems commented Nov 23, 2024

This seems to be missing a change to samples/CMakeLists.txt that actually exposes the sample.

I know very little about the background to this change, but it does seem a little odd that using the newer version of Vulkan results in 200 more lines of code for hello_triangle than we used to have.

I think that's at least partially due to the sample doing things that the original hello triangle sample is missing. E.g. creating a proper vertex buffer instead of hardcoding it in the shaders like the non 1.3 sample does. But I agree that this sample could be an opportunity to reduce line count. It does a several not so optimal things 1:1 like the hello triangle sample. E.g. having a function to deduce the shader stage from a file extension while it only uses vertex and fragment shader stages.

@SaschaWillems SaschaWillems self-requested a review November 24, 2024 18:49
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add a few comments, mostly things also not that great with the VK 1.0 hello triangle sample.

But I also noticed lots of validation errors when running this sample that need to be fixed:

[error] -1733013297 Validation Layer: Error: VUID-VkBufferCreateInfo-flags-parameter: Validation Error: [ VUID-VkBufferCreateInfo-flags-parameter ] | MessageID = 0x98b450cf | vkCreateBuffer(): pCreateInfo->flags contains flag bits (0x80) which are not recognized members of VkBufferCreateFlagBits.
The Vulkan spec states: flags must be a valid combination of VkBufferCreateFlagBits values (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkBufferCreateInfo-flags-parameter)
[error] -153856805 Validation Layer: Error: VUID-VkBufferCreateInfo-None-09500: Validation Error: [ VUID-VkBufferCreateInfo-None-09500 ] | MessageID = 0xf6d454db | vkCreateBuffer(): pCreateInfo->usage is zero.
The Vulkan spec states: If the pNext chain does not include a VkBufferUsageFlags2CreateInfoKHR structure, usage must not be 0 (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkBufferCreateInfo-None-09500)
[error] 1895430949 Validation Layer: Error: VUID-VkGraphicsPipelineCreateInfo-topology-08773: Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-topology-08773 ] Object 0: handle = 0xd175b40000000013, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x70f9fb25 | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[0] SPIR-V (Vertex) PointSize is not written to, but Pipeline topology is set to VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the pipeline is being created with a Vertex Execution Model and no TessellationEvaluation or Geometry Execution Model, and the topology member of pInputAssembly is VK_PRIMITIVE_TOPOLOGY_POINT_LIST, and either VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state is not enabled or dynamicPrimitiveTopologyUnrestricted is VK_FALSE, a PointSize decorated variable must be written to if maintenance5 is not enabled (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-topology-08773)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f93d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f93d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6efca0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f93d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f93d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)
[error] -1696391559 Validation Layer: Error: VUID-vkCmdBindVertexBuffers-pBuffers-00627: Validation Error: [ VUID-vkCmdBindVertexBuffers-pBuffers-00627 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x9ae31e79 | vkCmdBindVertexBuffers(): pBuffers[0] (VkBuffer 0xfa21a40000000003[]) was created with VkBufferUsageFlags2KHR(0) but requires VK_BUFFER_USAGE_VERTEX_BUFFER_BIT.
The Vulkan spec states: All elements of pBuffers must have been created with the VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindVertexBuffers-pBuffers-00627)
[error] -901174136 Validation Layer: Error: VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500: Validation Error: [ VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1fb5f6f3830, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xca492c88 | vkCmdDraw():  the last primitive topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-dynamicPrimitiveTopologyUnrestricted-07500)

samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few issues.

samples/CMakeLists.txt Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more validation errors :)

Added a few comments, but mostly (if not all) are cosmetic.

samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp Outdated Show resolved Hide resolved
@SaschaWillems SaschaWillems self-requested a review November 28, 2024 07:08
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample itself looks good to me now :)

One thing that should be expanded though is the readme. Newer samples should come with at least a basic tutorial or overview of what the sample does / how it works.

1: It is using vertex buffer to load vertices compared to hardcoded in shader in hello_triangle 1.0
2: It is using dynamic rendering so frame buffers and Render passes removed
3: Used Synchronization2 in image layout transition.
3: Updated the code to use VK_DEBUG_UTILS (new) instead VK_DEBUG_REPORT(old)
4: Update the code to use Dynamic pipeline status
5: Removed unused parameters from functions
6: Used C++20 initializers
Signed-off-by: aliasifhuawei <[email protected]>
@alihuawei alihuawei force-pushed the external_vulkan_1_3_hello_triangle branch from e6fee4d to 88e2a2a Compare December 9, 2024 19:49
@alihuawei
Copy link
Collaborator Author

I accidentally force-pushed earlier without rebasing my branch on the latest main. I have now rebased my branch onto the latest main, resolved all feedback, and force-pushed the corrected changes. The branch is now clean and ready for review. Apologies for the confusion caused by the rewritten history.

SaschaWillems
SaschaWillems previously approved these changes Dec 11, 2024
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The readme is great and a nice list of things that make VK 1.3 so interesting 👍🏻

Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for correctly checking for the features. Looks good now.

Just one duplicate comment remaining and a couple of suggestions.

@marty-johnson59
Copy link
Contributor

3 approvals - merging. Thanks!

@marty-johnson59 marty-johnson59 merged commit 3792764 into KhronosGroup:main Dec 16, 2024
24 checks passed
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

Successfully merging this pull request may close these issues.

7 participants