Giter Site home page Giter Site logo

mastering-graphics-programming-with-vulkan's Introduction

Mastering Graphics Programming with Vulkan

This is the code repository for Mastering Graphics Programming with Vulkan, published by Packt.

Develop a modern rendering engine from first principles to state-of-the-art techniques

What is this book about?

Vulkan is now an established and flexible multi-platform graphics API. It has been adopted in many industries, including game development, medical imaging, movie productions, and media playback. Learning Vulkan is a foundational step to understanding how a modern graphics API works, both on desktop and mobile.

This book covers the following exciting features:

  • Understand resources management and modern bindless techniques
  • Get comfortable with how a frame graph works and know its advantages
  • Explore how to render efficiently with many light sources
  • Discover how to integrate variable rate shading
  • Understand the benefits and limitations of temporal anti-aliasing
  • Get to grips with how GPU-driven rendering works
  • Explore and leverage ray tracing to improve render quality

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, chapter2.

The code has been tested with the following software:

  • Visual Studio 2019 Community Edition 16.11.8 (Windows)
  • gcc 9 (Linux)
  • CMake 3.22.1
  • Vulkan SDK 1.2.198.1 or above
  • SDL version 2.0.18
  • assimp 5.2.2

Getting the code

This repository includes a submodule that makes it easier to get glTF models. To make sure the submodule is initialized properly, run the following command when cloning the repository: git clone --recurse-submodules https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan

To download the glTF assets using the bootstrap script, run the following command: python ./bootstrap.py

Alternatively, you get manually download the models from https://github.com/KhronosGroup/glTF-Sample-Models. We tested only only a subset of glTF 2.0 models.

Windows

We provide a Visual Studio solution containing the code for all chapters, located at project\RaptorEngine.sln.

Linux

We provide the assimp library as part of this repo, while the SDL library has to be installed manually. On Debian and Ubuntu this can be done as follows: sudo apt install libsdl2-dev

Assuming you unpacked the Vulkan SDK in ~/vulkan/1.2.198.1, you have to add the following lines to your .bashrc file:

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

To generate the Make file, run the following command: cmake -B build -DCMAKE_BUILD_TYPE=Debug

To build a given chapter, run the following command: cmake --build build --target Chapter1 -- -j 4

Following is what you need for this book: This book is for professional graphics and game developers who want to gain in-depth knowledge about how to write a modern and performant rendering engine in Vulkan. Familiarity with basic concepts of graphics programming (i.e. matrices, vectors, etc.) and fundamental knowledge of Vulkan are required.

With the following software and hardware list you can run all code files present in the book (Chapter 1-15).

Software and Hardware List

Chapter Software required OS required
1-15 Vulkan 1.2 Windows or Linux

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Errata

  • Page 6 (Almost at the end of the page): $ cmake --build build --target chapter1 -- -j 4 should be $ cmake --build build --target Chapter1 -- -j 4

Get to Know the Authors

Marco Castorina first got familiar with Vulkan while working as a driver developer at Samsung. Later he developed a 2D and 3D renderer in Vulkan from scratch for a leading media-server company. He recently joined the games graphics performance team at AMD. In his spare time, he keeps up to date with the latest techniques in real-time graphics. He also likes cooking and playing guitar.

Gabriel Sassone is a rendering enthusiast currently working as a Principal Rendering Engineer at Multiplayer Group. Previously working for Avalanche Studios, where his first contact with Vulkan happened, where they developed the Vulkan layer for the proprietary Apex Engine and its Google Stadia Port. He previously worked at ReadyAtDawn, Codemasters, FrameStudios, and some non-gaming tech companies. His spare time is filled with music and rendering, gaming, and outdoor activities.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781803244792

mastering-graphics-programming-with-vulkan's People

Contributors

corporateshark avatar dorian-apanel-intel avatar jorenjoestar avatar jsjtxietian avatar packt-itservice avatar packt-simrana avatar packtaamira avatar sndels avatar thewatchmen avatar vigdail 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mastering-graphics-programming-with-vulkan's Issues

Command buffer submitted to wrong queue (Intel A770, Chapter 5)

When running on Intel A770, following core validation error is triggered in Chapter5:

VUID-vkQueueSubmit2-commandBuffer-03878(ERROR / SPEC): msgNum: -628003580 - Validation Error: [ VUID-vkQueueSubmit2-commandBuffer-03878 ] Object 0: handle = 0x22e857a8750, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x22e853d52c0, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0xda916d04 | vkQueueSubmit2(): pSubmits[0].pCommandBufferInfos[0].commandBuffer Primary VkCommandBuffer 0x22e857a8750[] created in queue family 0 is being submitted on VkQueue 0x22e853d52c0[] from queue family 1. The Vulkan spec states: The commandBuffer member of any element of the pCommandBufferInfos member of any element of pSubmits must have been allocated from a VkCommandPool that was created for the same queue family queue belongs to (https://vulkan.lunarg.com/doc/view/1.3.239.0/windows/1.3-extensions/vkspec.html#VUID-vkQueueSubmit2-commandBuffer-03878)
    Objects: 2
       [0]  0x22e857a8750, type: 6, name: NULL
       [1]  0x22e853d52c0, type: 4, name: NULL
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in RaptorEngine_Chapter5_Debug.exe.

Command buffer created for universal queue is submitted to compute only queue.

Log regarding queues:

GPU Used: Intel(R) Arc(TM) A770M Graphics
Family 0, flags 15 queue count 1
Family 1, flags 2 queue count 1
Family 2, flags 4 queue count 1

seems can't compile for aarch64 system

Hi there, I really love the book, and really want to try it on nvidia aarch64 device (I have agx orion), and it seems some of the functions in foundation layer need SSE support, could we have a branch without SSE? I have no problem running Vulkan SDK examples, so I am pretty sure with some modification, your Raptor engine should run happily on my agx orion

Thanks

RenderDoc cannot capture the application

Not sure if this is a RenderDoc bug or an issue with how vulkan is set up but just trying to take a capture of chapter 2 demo with RenderDoc and it seems it cannot figure out the api. The status window says "Connection Established" and runs the app properly but under the "API" field says "None". As a result the F12 to take captures doesn't work. Also there is no renderdoc overlay on the demo window.

image

Memory leak in Chapter 5

To reproduce:

  1. Compile and run chapter 5 from debugger.
  2. After cloth is seen, close main window (x)
  3. Observe assert trigerred:

RASSERTM( stats.allocated_bytes == 0, "Allocations still present. Check your code!" );
stats.allocated_bytes is 0x240

DebugOutput tail:

Gpu Device shutdown
InputService shutdown
The thread 0x7588 has exited with code 0 (0x0).
'RaptorEngine_Chapter5_Debug.exe' (Win32): Unloaded 'C:\Windows\System32\avrt.dll'
The thread 0x5770 has exited with code 0 (0x0).
WindowService shutdown
Found active allocation 000002AA35888240, 576
HeapAllocator Shutdown.
===============
FAILURE! Allocated memory detected. allocated 576, total 2147483648
===============

D:\testsuites\Mastering-Graphics-Programming-with-Vulkan\source\raptor\foundation\memory.cpp(156) : Allocations still present. Check your code!

Callstack:

>	RaptorEngine_Chapter5_Debug.exe!raptor::HeapAllocator::shutdown() Line 156	C++	Symbols loaded.
 	RaptorEngine_Chapter5_Debug.exe!raptor::MemoryService::shutdown() Line 61	C++	Symbols loaded.
 	RaptorEngine_Chapter5_Debug.exe!main(int argc, char * * argv) Line 480	C++	Symbols loaded.
 	RaptorEngine_Chapter5_Debug.exe!invoke_main() Line 79	C++	Non-user code. Symbols loaded.
 	RaptorEngine_Chapter5_Debug.exe!__scrt_common_main_seh() Line 288	C++	Non-user code. Symbols loaded.
 	RaptorEngine_Chapter5_Debug.exe!__scrt_common_main() Line 331	C++	Non-user code. Symbols loaded.

debug_mesh pipeline validation error.

With core checks of validation layers, running Chapter 6 produces following error:

...
Parsing GPU Technique debug
temp.shader

temp.shader

UNASSIGNED-CoreValidation-Shader-InputNotProduced(ERROR / SPEC): msgNum: 602160055 - Validation Error: [ UNASSIGNED-CoreValidation-Shader-InputNotProduced ] Object 0: handle = 0x5131e00000000419, name = debug_mesh, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x23e43bb7 | Vertex shader consumes input at location 0 but not provided
    Objects: 1
       [0]  0x5131e00000000419, type: 15, name: debug_mesh
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in RaptorEngine_Chapter6_Debug.exe.

Do any of the glTF-Sample-Models work ?

I've tried a few of the glTF-Sample-Models with Chapter 1 and none of them render anything. I get the two windows rendering fine but no model... it's just a green background. I've tried Box, Cube. Suzanne... all load without error but don't actually render anything. Am I doing something wrong ?

No rule to make target 'chapter1'

This is Debian Linux.

Targets RaptorFoundation and RaptorApp build just fine, chapter1 won't.

Unfortunately I am unfamiliar with the cmake file syntax.

Missing assets before running project 1

Saw that there are already a couple closed issues about this, but may want to add a note about running the script manually. Even with the updated git command the dependency files did not get downloaded automatically. Had to explicitly run the python script to trigger the bootstrap. May be worthwhile to add to the readme that you should run "python ./bootstrap.py" to get the files.

So much differences in code between chapter 1 and 2, undocumented

Hello, I am using your book, and comparing chapter 1's and 2's code, I have spotted a lot of differences, not directly linked with chapter's 2 content.

I can see the lighting changed, and there is mipmap support. Would it be possible to get a list of intended changes so that I can understand the code by comparing it ?

Wrong depth image transition (VK_IMAGE_LAYOUT_UNDEFINED -> VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)

There is a wrong transition of depth image to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout.

In following line:

transition_image_layout( command_buffer->vk_command_buffer, depth_texture_vk->vk_image, depth_texture_vk->vk_format, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, true );

Vk Spec states:
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR must only be used for presenting a presentable image for display

Validation layers are currently silent about this, but there is already an issue created for it KhronosGroup/Vulkan-ValidationLayers#4309

Zero size framebuffer if dynamic rendering not available. (Chapter 7)

When VK_KHR_dynamic_rendering extension is not present, or is ignored by following change:

if ( !creation.force_disable_dynamic_rendering && !strcmp( extensions[ i ].extensionName, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME ) ) {
    //dynamic_rendering_extension_present = true;
    continue;
}

Then following core validation error appears:

VUID-VkFramebufferCreateInfo-width-00885(ERROR / SPEC): msgNum: -1231547098 - Validation Error: [ VUID-VkFramebufferCreateInfo-width-00885 ] Object 0: handle = 0x20e04bf3480, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xb6981526 | vkCreateFramebuffer(): Requested VkFramebufferCreateInfo width must be greater than zero. The Vulkan spec states: width must be greater than 0 (https://vulkan.lunarg.com/doc/view/1.3.231.1/windows/1.3-extensions/vkspec.html#VUID-VkFramebufferCreateInfo-width-00885)
    Objects: 1
       [0]  0x20e04bf3480, type: 3, name: NULL
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in RaptorEngine_Chapter7_Debug.exe.

Callstack:

>	RaptorEngine_Chapter7_Debug.exe!raptor::vulkan_create_framebuffer(raptor::GpuDevice & gpu, raptor::Framebuffer * framebuffer) Line 2211	C++	Symbols loaded.
 	RaptorEngine_Chapter7_Debug.exe!raptor::GpuDevice::create_framebuffer(const raptor::FramebufferCreation & creation) Line 2430	C++	Symbols loaded.
 	RaptorEngine_Chapter7_Debug.exe!raptor::create_framebuffer(raptor::FrameGraph * frame_graph, raptor::FrameGraphNode * node) Line 380	C++	Symbols loaded.
 	RaptorEngine_Chapter7_Debug.exe!raptor::FrameGraph::compile() Line 668	C++	Symbols loaded.
 	RaptorEngine_Chapter7_Debug.exe!main(int argc, char * * argv) Line 278	C++	Symbols loaded.

Note: Tested on Intel A770 and NVidia GeForce GT 1030 (No mesh shaders)

gltf Models Not Loading

There is an issue loading gltf model other than Sponza.

Its easy to reproduce, just try to load any other model - duck.gltf for example.

It looks like the problem is related to the following comment at line 501:main.cpp
// NOTE(marco): for now we expect all three textures to be defined. In the next chapter
// we'll relax this constraint thanks to bindless rendering!

This approach eventually causes skipping of mesh_draws.push( mesh_draw );
for many gltf models.

I cannot load models in Chapter 2 either.

Would be great if you guys could fix this so people starting out could load other models.

Feature: Imgui with multiviewports and docking

Hello!

Do you have any plans to add support for Imgui with multiviewports and docking?

It looks like it would be a major structural change. Do you have a tip on how to detach the swapchains from the GPUDevice class and "bind" them to a window?

Thanks a lot for your awesome project!

Compilation of IMGUI shader, and IMGUI render pass not working on Linux

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:

./build/source/chapter2/Chapter2 deps/src/glTF-Sample-Models/2.0/Box/glTF/Box.gltf 
Memory Service Init
HeapAllocator of size 33560976 created
WindowService init
Window created successfully
InputService init
Gpu Device init
GPU Used: Intel(R) Graphics (ADL GT2)
Create swapchain 1280 800 - saved 1280 800, min image 3
Renderer init
sh: 1: Syntax error: word unexpected

Error in creation of shader ImGui, stage VERTEX. Writing shader:
1: #version 450
2: layout( location = 0 ) in vec2 Position;
3: layout( location = 1 ) in vec2 UV;
4: layout( location = 2 ) in uvec4 Color;
5: layout( location = 0 ) out vec2 Frag_UV;
6: layout( location = 1 ) out vec4 Frag_Color;
7: layout (location = 2) flat out uint texture_id;
8: layout( std140, binding = 0 ) uniform LocalConstants { mat4 ProjMtx; };
9: void main()
10: {
11:     Frag_UV = UV;
12:     Frag_Color = Color / 255.0f;
13:     texture_id = gl_InstanceIndex;
14:     gl_Position = ProjMtx * vec4( Position.xy,0,1 );
15: }
 MessageID: VUID_Undefined 2044605652
Message: Validation Error: [ VUID_Undefined ] | MessageID = 0x79de34d4 | vkCreateShaderModule: parameter pCreateInfo->codeSize / 4 must be greater than 0.

 MessageID: VUID-VkShaderModuleCreateInfo-pCode-01379 706474367
Message: Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01379 ] | MessageID = 0x2a1bf17f | SPIR-V module not valid: Invalid SPIR-V magic number. The Vulkan spec states: If pCode is a pointer to GLSL code, it must be valid GLSL code written to the GL_KHR_vulkan_glsl GLSL extension specification (https://vulkan.lunarg.com/doc/view/1.3.261.0/linux/1.3-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-01379)

Aborted (core dumped)

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:

static const char* g_vertex_shader_code = {
"#version 450\n"
"layout( location = 0 ) in vec2 Position;\n"
"layout( location = 1 ) in vec2 UV;\n"
"layout( location = 2 ) in uvec4 Color;\n"
"layout( location = 0 ) out vec2 Frag_UV;\n"
"layout( location = 1 ) out vec4 Frag_Color;\n"
"layout( std140, binding = 0 ) uniform LocalConstants { mat4 ProjMtx; };\n"
"void main()\n"
"{\n"
" Frag_UV = UV;\n"
" Frag_Color = Color / 255.0f;\n"
" gl_Position = ProjMtx * vec4( Position.xy,0,1 );\n"
"}\n"
};

Overflow converting values and unable to load other models

When running the default Chapter 1, the console prints an endless stream of:
Overflow converting values 18446744069414584320, 2147483647
Overflow converting values 18446744069414584320, 2147483647
Overflow converting values 18446744069414584320, 2147483647
Overflow converting values 18446744069414584320, 2147483647
Overflow converting values 18446744069414584320, 2147483647

I think maybe they are validation errors?
The default scene, Sponza does appear, and I can navigate around.

However, trying to load other models, such as Duck, just shows solid green background. I tried various zoom levels but cannot see model.

It also prints endless stream of errors.

The gltf files does load fine into unreal.

Mac version

Hello, I would like to know if you would consider doing a version of the sources for Mac as it is compatible with Vulkan now

Chapter2: Descriptor index 22 is uninitialized

There is and issue with uninitialized descriptor in Chapter 2 code.
It causes page fault on Intel HW, but can be detected on NVidia using latest SDK Validation Layers with "GPU Assisted" preset enabled.

UNASSIGNED-Descriptor uninitialized(ERROR / SPEC): msgNum: -1993010233 - Validation Error: [ UNASSIGNED-Descriptor uninitialized ] Object 0: handle = 0x207718ce700, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x893513c7 | Descriptor index 22 is uninitialized. Command buffer (0x20771d65700). Draw Index 0x6. Pipeline (c)(0x207721bd690). Shader Module (main)(0x20771e4cae0). Shader Instruction Index = 317.  Stage = Fragment.  Fragment coord (x,y) = (1278.5, 18.5).  Shader validation error occurred in file temp.shader at line 110.Unable to find suitable #line directive in SPIR-V OpSource.
    Objects: 1
       [0]  0x207718ce700, type: 4, name: NULL
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in RaptorEngine_Chapter2_Debug.exe.

Occurs in seventh draw of third compiled pipeline. (first draw that actually spawn fragments)
Stripping fragment shader to just:

vec4 base_colour = texture(global_textures[nonuniformEXT(textures.x)], vTexcoord0) * base_color_factor;
frag_color = vec4( encode_srgb( material_colour ), base_colour.a );

Also gives the same error.

a little confused

Hello, I am a reader of the Master book and would like to ask a question that has nothing to do with bugs. I am very confused about the following writing or function naming.
FrameGraphResource* resource = frame_graph->access_resource( node->inputs[ r ] ); // Get an input resource

FrameGraphResource* output_resource = frame_graph->get_resource( resource->name ); // It looks like the resource is obtained again by its own name. Why does this represent an output resource?

Loading gltf files bug makes it impossible to open gltf files

most of the gltf files supply their paths relative to the gltf file.
the engine does not take this into account and tries to open the uri directly through stb.
file path correctness IS NOT CHECKED! so uninitialized int values are then used for mip calculations for example.

when the working directory is set to the same directory as the gltf file the gltf file cant be opened since file_directory_from_path cannot deal with paths not including at least one forward or backslash.

as a purchaser of the book i am very disappointment in the quality and robustness of these examples. there are countless trivial issues i find just by reading through the code that shouldnt make it past any reasonable code review. neither on windows nor on linux the example works out of the box.
It makes following the book a lot harder and diminishes some of the value of the purchase.

Issues with RX6600

Hi, I'm having lots of issues while running the examples in my machine with an RX6600.

Basically, only the first example runs correctly. The other examples either crash, or show validation errors and visual glitches.

vlcsnap-2023-04-10-20h05m18s511

failed to build Project1.sln

Error when building project1.sln with Visual Studio 2019.
Seems caused by the path "project..\binaries"

Other projects get built just fine, except for project 1.

_Severity Code Description Project File Line Suppression State
Error MSB3073 The command "copy /Y F:\Mastering-Graphics-Programming-with-Vulkan\project..\binaries\SDL2-2.0.18\lib\x64\SDL2.dll F:\Mastering-Graphics-Programming-with-Vulkan\project..\binaries
copy /Y F:\Mastering-Graphics-Programming-with-Vulkan\project..\binaries\assimp\windows\bin\assimp-vc142-mt.dll F:\Mastering-Graphics-Programming-with-Vulkan\project..\binaries
:VCEnd" exited with code 1. RaptorEngine_Chapter1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 155

Exits directly

  • Open the .sln with Visual Studio 2022.
  • Debug Chapter 1's project.

RaptorEngine_Chapter1_Debug.exe (process 91692) exited with code -1.

Can't run chapters 8,9,10,11,13,14 on Windows with the same error.

Hi. I'm receiving the following errors when running chapters 8 through 15 except for chapter 12 which runs fine.

Specs:

OS: Windows 11
GPU: AMD Radeon RX 6700 XT
Driver: 24.3.1 AMD Adrenaline
Vulkan SDK: 1.3.268.0

Error
It is the output from running chapter 8, but all other chapters in the title at least show this error

Created technique main in 0.548359 seconds
Parsing GPU Technique pbr_lighting
Created technique pbr_lighting in 0.040583 seconds
Parsing GPU Technique depth_of_field
Created technique depth_of_field in 0.016138 seconds
Parsing GPU Technique cloth
Cannot find render pass . Defaulting to swapchain
Created technique cloth in 0.011523 seconds
Parsing GPU Technique debug
temp.shader

temp.shader

 MessageID: UNASSIGNED-CoreValidation-Shader-OutputNotConsumed 101294395
Message: Validation Performance Warning: [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] Object 0: handle = 0x7efb46000000018f, name = debug_line, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x609a13b | vkCreateGraphicsPipelines(): pCreateInfos[0].pVertexInputState Vertex attribute at location 0 not consumed by vertex shader.

Created technique debug in 0.302037 seconds
Parsing GPU Technique culling
Cannot find render pass culling_pass. Defaulting to swapchain
Created technique culling in 0.027143 seconds
Loaded scene Sponza.gltf in 0.481570 seconds.
Stats:
        Reading GLTF file 0.115696 seconds
        Textures Creating 0.062430 seconds
        Creating Samplers 0.000031 seconds
        Reading Buffers Data 0.002655 seconds
        Creating Buffers 0.300756 seconds
Total meshlet instances 3521
 MessageID: VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 -1094930823
Message: Validation Error: [ VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 ] | MessageID = 0xbebcae79 | vkCreateImage(): pCreateInfo The following parameters -
format (VK_FORMAT_D16_UNORM)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_OPTIMAL)
usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
flags (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT|VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
returned (VK_ERROR_FORMAT_NOT_SUPPORTED) when calling vkGetPhysicalDeviceImageFormatProperties2. The Vulkan spec states: Each of the following values (as described in Image Creation Limits) must not be undefined : imageCreateMaxMipLevels, imageCreateMaxArrayLayers, imageCreateMaxExtent, and imageCreateSampleCounts (https://vulkan.lunarg.com/doc/view/1.3.268.0/windows/1.3-extensions/vkspec.html#VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251)

D:\Mastering-Graphics-Programming-with-Vulkan\source\chapter8\graphics\gpu_device.cpp(3347) : FALSE

image

Assets?

Usage: chapter1 [path to glTF model]\n

Assets? or ???

Question about frustum aligned 3D texture

Not sure if this is the right place to ask. In chapter 10, a 3D texture is introduced which is frustum aligned. I don't understand this mapping between the texture and the camera frustum. The book briefly mentions

This mapping is already happening in the different stages of rendering, for example, when multiplying a vertex position for the view-projection matrix, so it is not something new.

But looking at the shader code, the function world_from_froxel doesn't take screen size or resolution into account, so, how do we ensure that the froxels cover the whole screen (assuming the Z direction is just hard coded to have 128 slices)?

Issue with renderdoc capture from Chapter 11

I'm trying to take a capture using renderdoc latest version (1.31) from Chapter11 demo but renderdoc fails to launch the application on startup (previous chapters worked fine). Not sure if this is due to some validation layer errors or something is wrong on my pc. Can someone else also test this to see if renderdoc can launch that specific chapter demo? Also I appreciate if someone provides an alternative way to study frame. I tried Nsight but it doesn't show the UAV contents which I'm looking for.

Vulkan validation error on Linux (Ubuntu 22.04)

When running chapter 1 the following output occurs every frame:

MessageID: VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06211 1886124171
Message: Validation Error: [ VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06211 ] Object 0: handle = 0x555555d8d4c0, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x706bf88b | vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is not supported by the physicalDevice. The Vulkan spec states: surface must be supported by physicalDevice, as reported by vkGetPhysicalDeviceSurfaceSupportKHR or an equivalent platform-specific mechanism (https://vulkan.lunarg.com/doc/view/1.3.239.0/linux/1.3-extensions/vkspec.html#VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06211)

Include error <spirv_cross/spirv.h> on Linux

The chapter 1 target builds fine... chapter 2 fails with:

[build] /home/link/Code/Mastering-Graphics-Programming-with-Vulkan/source/chapter2/./graphics/spirv_parser.hpp:9:10: fatal error: spirv_cross/spirv.h: No such file or directory
[build] 9 | #include <spirv_cross/spirv.h>
[build] | ^~~~~~~~~~~~~~~~~~~~~
[build] compilation terminated.

File is present in the LunarG SDK but the current build scripts don't add it in the include paths.

Transfer Synchronization

Hello!
I've been reading the book and wanted to follow up on something. In Chapter 3 you introduce the AsyncronousLoader and talk about creating semaphores and fences for synchronization..

However, transfer_complete_semaphore is never actually used in the code..

I'm just curious as to whether that is a mistake or not, since it doesn't get mentioned again? ๐Ÿ˜„

Thanks

Chapters 4+ generate validation errors if multiple discrete GPUs installed

Chapter 3 always selects the first GPU device.
Chapter 4 onwards selects the LAST discrete GPU device, or the LAST integrated GPU device if no discrete.
On my machine I have 2 GTX 1080s, so this code selects device 0 for chapter 3, and device 1 for all later chapters.
There are no validation warnings for the chapter 3 code.
For chapter 4:
Call to vkGetPhysicalDeviceSurfaceFormatsKHR gives:
MessageID: VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06211 1886124171
Message: Validation Error : [VUID - vkGetPhysicalDeviceSurfaceFormatsKHR - surface - 06211] Object 0 : handle = 0x1a69c35dbd0, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x706bf88b | vkGetPhysicalDeviceSurfaceFormatsKHR() : surface is not supported by the physicalDevice.The Vulkan spec states : surface must be supported by physicalDevice, as reported by vkGetPhysicalDeviceSurfaceSupportKHR or an equivalent platform - specific mechanism(https ://[vulkan.lunarg.com/doc/view/1.2.198.1/windows/1.2-extensions/vkspec.html#VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06211]

And every frame yields:
MessageID: VUID - vkQueuePresentKHR - pSwapchains - 01292 - 193100549
Message: Validation Error : [VUID - vkQueuePresentKHR - pSwapchains - 01292] Object 0 : handle = 0x628d6100000000f7, type = VK_OBJECT_TYPE_SWAPCHAIN_KHR; | MessageID = 0xf47d84fb | vkQueuePresentKHR: Presenting pSwapchains[0] image on queue that cannot present to this surface.The Vulkan spec states : Each element of pSwapchains member of pPresentInfo must be a swapchain that is created for a surface for which presentation is supported from queue as determined using a call to vkGetPhysicalDeviceSurfaceSupportKHR(https ://[vulkan.lunarg.com/doc/view/1.2.198.1/windows/1.2-extensions/vkspec.html#VUID-vkQueuePresentKHR-pSwapchains-01292]

If GpuDevice::init is modified to select the first discrete device then these errors go away.
I don't know what changes are needed to solve this if using other than the first discrete device.

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.