PacktPublishing / Mastering-Graphics-Programming-with-Vulkan

MIT License
539 stars 73 forks source link

Chapter2: Descriptor index 22 is uninitialized #23

Closed dorian-apanel-intel closed 1 year ago

dorian-apanel-intel commented 1 year ago

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.

dorian-apanel-intel commented 1 year ago

Issue can be seen using Renderdoc: image

dorian-apanel-intel commented 1 year ago

Descriptor array that is used in global_textures is not updated in first frame at all. It is updated later, in section // Handle deferred writes to bindless textures. It has to be initialized with some default textures or not used in such case.

theWatchmen commented 1 year ago

PR has been merged and ported fix to remaining chapters.

dorian-apanel-intel commented 1 year ago

Thanks :)

Partially verified here: https://github.com/PacktPublishing/Mastering-Graphics-Programming-with-Vulkan/pull/26#issuecomment-1510909067