Partage
  • Partager sur Facebook
  • Partager sur Twitter

Validation layer erreur avec VULKAN.

Sujet résolu
    7 mai 2024 à 13:07:23

    Salut! j'essaye de faire du rendu hors écran avec vulkan mais j'ai un message d'erreur que je ne comprend pas.

    C'est lorsque j'essaye d'attacher l'imageview de ma texture ici :

    void RenderTexture::createFramebuffers() {
                swapChainFramebuffers.resize(getSwapchainImages().size());
    
                for (size_t i = 0; i < getSwapchainImages().size(); i++) {
                    VkImageView attachments[] = {
                        m_texture.getImageView()
                    };
    
                    VkFramebufferCreateInfo framebufferInfo{};
                    framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
                    framebufferInfo.renderPass = renderPass;
                    framebufferInfo.attachmentCount = 1;
                    framebufferInfo.pAttachments = attachments;
                    framebufferInfo.width = getSwapchainExtents().width;
                    framebufferInfo.height = getSwapchainExtents().height;
                    framebufferInfo.layers = 1;
    
                    if (vkCreateFramebuffer(vkSettup.getDevice(), &framebufferInfo, nullptr, &swapChainFramebuffers[i]) != VK_SUCCESS) {
                        throw core::Erreur(0, "failed to create framebuffer!", 1);
                    }
                }
            }

    Et la création de la renderpass :

    void RenderTexture::createRenderPass() {
                VkAttachmentDescription colorAttachment{};
                colorAttachment.format =    getSwapchainImageFormat();
                colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
                colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
                colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
                colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
                colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
                colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
                colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
    
                VkAttachmentReference colorAttachmentRef{};
                colorAttachmentRef.attachment = 0;
                colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
    
                VkSubpassDescription subpass{};
                subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
                subpass.colorAttachmentCount = 1;
                subpass.pColorAttachments = &colorAttachmentRef;
    
                VkRenderPassCreateInfo renderPassInfo{};
                renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
                renderPassInfo.attachmentCount = 1;
                renderPassInfo.pAttachments = &colorAttachment;
                renderPassInfo.subpassCount = 1;
                renderPassInfo.pSubpasses = &subpass;
                VkSubpassDependency dependency{};
                dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
                dependency.dstSubpass = 0;
                dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
                dependency.srcAccessMask = 0;
                dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
                dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
                renderPassInfo.dependencyCount = 1;
                renderPassInfo.pDependencies = &dependency;
                if (vkCreateRenderPass(vkSettup.getDevice(), &renderPassInfo, nullptr, &renderPass) != VK_SUCCESS) {
                    throw core::Erreur(0, "failed to create render pass!", 1);
                }
    
            }

    Merci.

    EDIT fallait rajouté ça ici VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT  lors de la création de la texture :

    imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;


    résolu!

    -
    Edité par OmbreNoire 7 mai 2024 à 14:17:28

    • Partager sur Facebook
    • Partager sur Twitter

    Validation layer erreur avec VULKAN.

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    • Editeur
    • Markdown