Closed bkolligs closed 10 months ago
@bkolligs Hi Ben, I'm running into the same issue on Zorin.
"vkCreateShaderModule: parameter pCreateInfo->codeSize / 4 must be greater than 0." It didn't compile the shader. When I save the GLSL code you posted above in a file vertex.vert and compile it, it works. --> Most likely it doesn't find the compiler. I haven't set the bash variables yet. Did you?
export VULKAN_SDK=~/vulkan/1.2.198.1/x86_64 export PATH=$VULKAN_SDK/bin:$PATH export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d
Check out this line: https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan/blob/2ad4e94a0e003d37dd3dbef46cc033a483f133d6/source/chapter1/graphics/gpu_device.cpp#L1048
I have on my system:
~/dev/book >>> which glslangValidator
/usr/bin/glslangValidator
^^^
"/usr" should be VULKAN_SDK
see also "gpu_device.cpp", line 615 https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan/blob/2ad4e94a0e003d37dd3dbef46cc033a483f133d6/source/chapter1/graphics/gpu_device.cpp#L615 https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan/blob/2ad4e94a0e003d37dd3dbef46cc033a483f133d6/source/chapter1/graphics/gpu_device.cpp#L616
So with "export VULKAN_SDK=/usr", and "./build/source/chapter1/Chapter1 ./deps/src/glTF-Sample-Models/2.0/BarramundiFish/glTF/BarramundiFish.gltf", and a scale of 100, I get
On a side note, I also had to change "SDL2::SDL2" to "${SDL2_LIBRARIES}" in the CMakeLists.txt files in all 15 chapters.
I am on Ubuntu 22. What version of Vulkan are you using @beaumanvienna ? I am using version 1.3.261. I am getting Imgui render pass issues now, despite the window opening.
MessageID: VUID-vkCmdDrawIndexed-renderPass-02684 -1934215230
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0xcb1c7c000000001b, name = Swapchain, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x2e2cd000000002b, name = Pipeline_ImGui, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed: RenderPasses incompatible between active render pass w/ VkRenderPass 0xcb1c7c000000001b[Swapchain] and pipeline state object w/ VkRenderPass 0x2e2cd000000002b[Pipeline_ImGui] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.3.261.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)
MessageID: VUID-vkCmdDrawIndexed-renderPass-02684 -1934215230
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0xcb1c7c000000001b, name = Swapchain, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x2e2cd000000002b, name = Pipeline_ImGui, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed: RenderPasses incompatible between active render pass w/ VkRenderPass 0xcb1c7c000000001b[Swapchain] and pipeline state object w/ VkRenderPass 0x2e2cd000000002b[Pipeline_ImGui] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.3.261.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)
MessageID: VUID-vkCmdDrawIndexed-renderPass-02684 -1934215230
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0xcb1c7c000000001b, name = Swapchain, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x2e2cd000000002b, name = Pipeline_ImGui, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed: RenderPasses incompatible between active render pass w/ VkRenderPass 0xcb1c7c000000001b[Swapchain] and pipeline state object w/ VkRenderPass 0x2e2cd000000002b[Pipeline_ImGui] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.3.261.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)
MessageID: VUID-vkCmdDrawIndexed-renderPass-02684 -1934215230
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0xcb1c7c000000001b, name = Swapchain, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x2e2cd000000002b, name = Pipeline_ImGui, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed: RenderPasses incompatible between active render pass w/ VkRenderPass 0xcb1c7c000000001b[Swapchain] and pipeline state object w/ VkRenderPass 0x2e2cd000000002b[Pipeline_ImGui] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.3.261.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)
Tried using Vulkan 1.2.198 instead and I get the same render pass error
Despite the render pass error, it still renders the geometry so I'll close this.
@beaumanvienna Thanks for your comment and the help! I'll make a note to add a better failure message if the compiler path is invalid.
@bkolligs We get the swapchain format from the supported formats exposed by the driver, but maybe there is a mismatch with the format we use for the ImGui pass. I'll double check.
Thanks for reporting the issue!
I think I found the problem with at least chapter 2 and 3: we compile the shaders through CMake (rather than at runtime as we do for other chapters). I added a check to make sure the compiler path is valid. For the other chapters, failing to find the compiler executable should already result in an error message.
Still looking into the swapchain format issue :)
I will reopen so you can track the swap chain issue
@beaumanvienna Thanks for your comment and the help! I'll make a note to add a better failure message if the compiler path is invalid.
Thanks for reporting the issue!
You're welcome! Maybe change it to shaderc altogether?
I noticed one more thing, I believe you have the -j4
for MAKEFLAGS still with a space in between the j and the 4. Did you try to fix it in the errata? (see also my edit below, the space is Ok, which renders the errata unnecessary)
https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan#linux and here https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan#errata
EDIT: Wait, it does work with the space in between j and 4. I think you can remove the errata entirely then.
time cmake --build build --target Chapter1 -- -j16
--> 43.25s user 1.96s system 509% cpu 8.880 total
(the linking stages are single thread, hence the CPU usage does not go up 16x)
time cmake --build build --target Chapter1 -- -j 16
--> 42.77s user 1.94s system 499% cpu 8.955 total
time cmake --build build --target Chapter1 -- -j 2
--> 34.04s user 1.56s system 186% cpu 19.128 total
I looked this up in the cmake documentation, the space is allowed
@bkolligs I had a better look at the code for the swapchain and render pass format, and it looks correct. If we fail to find a format we want though I think we don't populate one of the structures correctly. Could you try and apply this patch?
diff --git a/source/chapter2/graphics/gpu_device.cpp b/source/chapter2/graphics/gpu_device.cpp
index 21e79d1..64e0e80 100644
--- a/source/chapter2/graphics/gpu_device.cpp
+++ b/source/chapter2/graphics/gpu_device.cpp
@@ -506,7 +506,6 @@ void GpuDevice::init( const DeviceCreation& creation ) {
for ( u32 j = 0; j < supported_count; j++ ) {
if ( supported_formats[ j ].format == surface_image_formats[ i ] && supported_formats[ j ].colorSpace == surface_color_space ) {
vulkan_surface_format = supported_formats[ j ];
- swapchain_output.color( surface_image_formats[ j ] );
format_found = true;
break;
}
@@ -523,6 +522,8 @@ void GpuDevice::init( const DeviceCreation& creation ) {
}
rfree( supported_formats, allocator );
+ swapchain_output.color( vulkan_surface_format.format );
+
set_present_mode( present_mode );
//////// Create swapchain
If you haven't done this before, copy this text into a file called (say) a.patch
in the root folder of this repo, then run git apply a.patch
. If you still get the validation error, could you check which formats are being used here and here?
@beaumanvienna The errata is to fix the typo for chapter1
-> Chapter1
, not the cmake flags :)
@theWatchmen I can confirm your patch fixes,
MessageID: VUID-vkCmdDrawIndexed-renderPass-02684 -1934215230
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0x1c000000001c, name = Swapchain, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x2c000000002c, name = Pipeline_ImGui, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed: RenderPasses incompatible between active render pass w/ VkRenderPass 0x1c000000001c[Swapchain] and pipeline state object w/ VkRenderPass 0x2c000000002c[Pipeline_ImGui] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.3.261.1/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)
when running the Sponza model.
I needed this for chapter 1 too (not got to chapter 2 yet). I tested with an AMD Radeon RX 6600, using SDK 1.3.261.1
@theWatchmen after applying the patch I am able to run chapter 1! Thanks.
I have now applied the fix to all chapters :) I'll leave this open for a few days just in case.
I got your book in the meantime :-) Thank you, Sir! On a side note: https://www.youtube.com/@beaumanvienna6844 I just finished skeletal animation with gltf and multiple animations, a new video is in the making ...
Closing this as it should be solved.
Reopening what was referenced in #45 with more detail. When I try to compile
Chapter2
and run it with a GLTF file I get the following issue:This shader is not included in the
source/chapter2/shaders
subdirectory, which makes me think it's an issue with the IMGUI specific shader here: https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan/blob/2ad4e94a0e003d37dd3dbef46cc033a483f133d6/source/chapter2/graphics/raptor_imgui.cpp#L30-L44