OS: Windows 10 (10.0.19045 Build 19045)
Driver: Windows 531.54 (Vulkan Beta Driver)
GPU: GeForce GTX 970
I’ve been trying to write the first triangle program using shader objects (+ dynamic rendering), however reducing the rendering code to the following already fails despite all functions returning VK_SUCCESS
:
VkShaderInfoEXT ShaderInfos[] =
{
{
.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT,
.pNext = NULL,
.flags = VK_SHADER_CREATE_LINK_STAGE_BIT_EXT,
.stage = VK_SHADER_STAGE_VERTEX_BIT,
.nextStage = VK_SHADER_STAGE_FRAGMENT_BIT,
.codeType = VK_SHADER_CODE_TYPE_SPIRV_EXT,
.codeSize = VS.Size,
.pCode = VS.Data,
.pName = "main",
.setLayoutCount = 0,
.pSetLayouts = NULL,
.pushConstantRangeCount = 0,
.pPushConstantRanges = NULL,
.pSpecializationInfo = NULL,
},
{
.sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT,
.pNext = NULL,
.flags = VK_SHADER_CREATE_LINK_STAGE_BIT_EXT,
.stage = VK_SHADER_STAGE_FRAGMENT_BIT,
.nextStage = 0,
.codeType = VK_SHADER_CODE_TYPE_SPIRV_EXT,
.codeSize = FS.Size,
.pCode = FS.Data,
.pName = "main",
.setLayoutCount = 0,
.pSetLayouts = NULL,
.pushConstantRangeCount = 0,
.pPushConstantRanges = NULL,
.pSpecializationInfo = NULL,
},
};
VkShaderEXT Shaders[2] = {0}
if (vkCreateShadersEXT(Device, 2, ShaderInfos, Shaders) == VK_SUCCESS)
{
vkBeginCommandBuffer(Cmd, ...);
vkCmdPipelineBarrier2(Cmd, ...); // Transitions render target to COLOR_ATTACHMENT_OPTIMAL
vkCmdBeginRendering(Cmd, ...);
VkShaderStageFlagBits Stages[] = { VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_FRAGMENT_BIT };
#if 1
// This path results in a constant black image and a stutter on the vkQueueSubmit call
vkCmdBindShadersEXT(Cmd, 2, Stages, Shaders);
#else
// This path results in an image with the clear color specified in through the VkRenderingInfo parameter of vkCmdBeginRendering - as expected
vkCmdBindShadersEXT(Cmd, 2, Stage, NULL);
#endif
vkCmdEndRendering(Cmd);
vkEndCommandBuffer(Cmd);
}
Since the code works as expected without the vkCmdBindShadersEXT
call, I’ve omitted most of the function parameters/structures for brevity, but I can also provide those if need be.
As you can see there’s no actual rendering happening here, no draw commands. Binding the shaders alone causes the rendering to fail and results in a black image and a stutter on the vkQueueSubmit
call. There are no crashes however, the application completes successfully.
I’ve also tried:
- Setting all the required state as described in section 9.1.5. of the Vulkan 1.3.246 spec and issuing a draw command. The result was also a black image in this case.
- Setting up a VK_EXT_debug_utils debug messenger to see if any errors would be caught that way, but it only provided an informative message about the driver path at the beginning of the program; no messages during runtime.
Obviously the validation layer can’t verify whether the usage of VK_EXT_shader_object is correct, as this extension is not yet part of the Vulkan SDK, but it also doesn’t complain about any other issues, so I’m assuming that the code unrelated to this extension is correct.
So my question would be, is there anything wrong with the above code? Are shader objects supposed to work with the current beta driver for simple(r) use cases?