Hi! Since I use a multiview I’ve this error :
validation layer: vkCmdDraw(): Shader in VK_SHADER_STAGE_VERTEX_BIT uses push-constant statically but vkCmdPushConstants was not called yet for pipeline layout VkPipelineLayout 0xafccd500000003ee.
The Vulkan spec states: If the maintenance4 feature is not enabled, then for each push constant that is statically used by a bound shader, a push constant value must have been set for the same pipeline bind point, with a VkPipelineLayout that is compatible for push constants, with the VkPipelineLayout used to create the current VkPipeline or the VkDescriptorSetLayout and VkPushConstantRange arrays used to create the current VkShaderEXT , as described in Pipeline Layout Compatibility (https://vulkan.lunarg.com/doc/view/1.4.309.0/windows/antora/spec/latest/chapters/drawing.html#VUID-vkCmdDraw-maintenance4-08602)
I don’t understand why I’ve this error, here is my vertex shader code :
const std::string linkedListVertexShader2 = R"(#version 460
#extension GL_EXT_multiview : enable
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec2 texCoords;
layout (location = 3) in vec3 normals;
layout (push_constant)uniform PushConsts {
mat4 projectionMatrix;
mat4 viewMatrix;
mat4 worldMat;
} pushConsts;
layout (location = 0) out vec4 frontColor;
layout (location = 1) out vec2 fTexCoords;
layout (location = 2) out uint layer;
layout (location = 3) out vec3 normal;
void main () {
gl_Position = vec4(position, 1.f) * pushConsts.worldMat * pushConsts.viewMatrix * pushConsts.projectionMatrix;
gl_PointSize = 2.0f;
frontColor = color;
fTexCoords = texCoords;
normal = normals;
layer = gl_ViewIndex;
})";
And I set push constant ranges like this :
for (unsigned int j = 0; j < NBDEPTHSTENCIL; j++) {
for (unsigned int i = 0; i < Batcher::nbPrimitiveTypes - 1; i++) {
if (j == 0) {
VkPushConstantRange push_constant;
//this push constant range starts at the beginning
push_constant.offset = 0;
//this push constant range takes up the size of a MeshPushConstants struct
push_constant.size = sizeof(LinkedList2PC);
//this push constant range is accessible only in the vertex shader
push_constant.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
pipelineLayoutInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][NODEPTHNOSTENCIL].pPushConstantRanges = &push_constant;
pipelineLayoutInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][NODEPTHNOSTENCIL].pushConstantRangeCount = 1;
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][NODEPTHNOSTENCIL].depthCompareOp = VK_COMPARE_OP_ALWAYS;
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][NODEPTHNOSTENCIL].front = {};
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][NODEPTHNOSTENCIL].back = {};
environmentMap.createGraphicPipeline(static_cast<sf::PrimitiveType>(i), states, NODEPTHNOSTENCIL, NBDEPTHSTENCIL);
} else {
VkPushConstantRange push_constant;
//this push constant range starts at the beginning
push_constant.offset = 0;
//this push constant range takes up the size of a MeshPushConstants struct
push_constant.size = sizeof(LinkedList2PC);
//this push constant range is accessible only in the vertex shader
push_constant.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
pipelineLayoutInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][DEPTHNOSTENCIL].pPushConstantRanges = &push_constant;
pipelineLayoutInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][DEPTHNOSTENCIL].pushConstantRangeCount = 1;
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][DEPTHNOSTENCIL].depthCompareOp = VK_COMPARE_OP_GREATER;
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][DEPTHNOSTENCIL].front = {};
depthStencilCreateInfo[sLinkedList2.getId() * (Batcher::nbPrimitiveTypes - 1)+i][environmentMap.getId()][DEPTHNOSTENCIL].back = {};
environmentMap.createGraphicPipeline(static_cast<sf::PrimitiveType>(i), states, DEPTHNOSTENCIL, NBDEPTHSTENCIL);
}
}
}
And I call vkCmdPushConstants but event when calling this command I get the error message.
void ReflectRefractRenderComponent::createCommandBufferVertexBuffer(RenderStates currentStates) {
environmentMap.beginRecordCommandBuffers();
Shader* shader = const_cast<Shader*>(currentStates.shader);
unsigned int currentFrame = environmentMap.getCurrentFrame();
std::vector<VkCommandBuffer> commandBuffers = environmentMap.getCommandBuffers();
vkCmdPipelineBarrier(commandBuffers[currentFrame], VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 0, nullptr);
VkMemoryBarrier memoryBarrier;
memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
memoryBarrier.pNext = VK_NULL_HANDLE;
memoryBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
memoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
vkCmdPipelineBarrier(commandBuffers[currentFrame], VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr);
vkCmdPushConstants(commandBuffers[currentFrame], environmentMap.getPipelineLayout()[shader->getId() * (Batcher::nbPrimitiveTypes - 1) + vb.getPrimitiveType()][environmentMap.getId()][NODEPTHNOSTENCIL], VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(LinkedList2PC), &linkedList2PC);
environmentMap.drawVertexBuffer(commandBuffers[currentFrame], currentFrame, vb, NODEPTHNOSTENCIL, currentStates);
environmentMap.display();
}
Thanks.