Java 类org.lwjgl.vulkan.VkCommandBufferBeginInfo 实例源码

项目:lwjgl3-swt    文件:ClearScreenDemo.java   
private static void submitPostPresentBarrier(long image, VkCommandBuffer commandBuffer, VkQueue queue) {
    VkCommandBufferBeginInfo cmdBufInfo = VkCommandBufferBeginInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO)
            .pNext(NULL);
    int err = vkBeginCommandBuffer(commandBuffer, cmdBufInfo);
    cmdBufInfo.free();
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to begin command buffer: " + translateVulkanResult(err));
    }

    VkImageMemoryBarrier.Buffer postPresentBarrier = createPostPresentBarrier(image);
    vkCmdPipelineBarrier(
        commandBuffer,
        VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
        VK_FLAGS_NONE,
        null, // No memory barriers,
        null, // No buffer barriers,
        postPresentBarrier); // one image barrier
    postPresentBarrier.free();

    err = vkEndCommandBuffer(commandBuffer);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to wait for idle queue: " + translateVulkanResult(err));
    }

    // Submit the command buffer
    submitCommandBuffer(queue, commandBuffer);
}
项目:autostack    文件:ClearScreenDemoUseNewStack.java   
@UseNewStack
private static void submitPostPresentBarrier(long image, VkCommandBuffer commandBuffer, VkQueue queue) {
    VkCommandBufferBeginInfo cmdBufInfo = VkCommandBufferBeginInfo.callocStack()
            .sType(VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO)
            .pNext(NULL);
    int err = vkBeginCommandBuffer(commandBuffer, cmdBufInfo);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to begin command buffer: " + translateVulkanResult(err));
    }

    VkImageMemoryBarrier.Buffer postPresentBarrier = VkImageMemoryBarrier.callocStack(1)
            .sType(VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER)
            .pNext(NULL)
            .srcAccessMask(0)
            .dstAccessMask(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)
            .oldLayout(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
            .newLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
            .srcQueueFamilyIndex(VK_QUEUE_FAMILY_IGNORED)
            .dstQueueFamilyIndex(VK_QUEUE_FAMILY_IGNORED)
            .image(image);
    postPresentBarrier.subresourceRange()
            .aspectMask(VK_IMAGE_ASPECT_COLOR_BIT)
            .baseMipLevel(0)
            .levelCount(1)
            .baseArrayLayer(0)
            .layerCount(1);
    vkCmdPipelineBarrier(
        commandBuffer,
        VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
        VK_FLAGS_NONE,
        null, // No memory barriers,
        null, // No buffer barriers,
        postPresentBarrier); // one image barrier

    err = vkEndCommandBuffer(commandBuffer);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to wait for idle queue: " + translateVulkanResult(err));
    }

    // Submit the command buffer
    submitCommandBuffer(queue, commandBuffer);
}
项目:autostack    文件:ClearScreenDemoUseCallerStack.java   
@UseNewStack
private static void submitPostPresentBarrier(long image, VkCommandBuffer commandBuffer, VkQueue queue) {
    VkCommandBufferBeginInfo cmdBufInfo = VkCommandBufferBeginInfo.callocStack()
            .sType(VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO)
            .pNext(NULL);
    int err = vkBeginCommandBuffer(commandBuffer, cmdBufInfo);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to begin command buffer: " + translateVulkanResult(err));
    }

    VkImageMemoryBarrier.Buffer postPresentBarrier = VkImageMemoryBarrier.callocStack(1)
            .sType(VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER)
            .pNext(NULL)
            .srcAccessMask(0)
            .dstAccessMask(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)
            .oldLayout(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
            .newLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
            .srcQueueFamilyIndex(VK_QUEUE_FAMILY_IGNORED)
            .dstQueueFamilyIndex(VK_QUEUE_FAMILY_IGNORED)
            .image(image);
    postPresentBarrier.subresourceRange()
            .aspectMask(VK_IMAGE_ASPECT_COLOR_BIT)
            .baseMipLevel(0)
            .levelCount(1)
            .baseArrayLayer(0)
            .layerCount(1);
    vkCmdPipelineBarrier(
        commandBuffer,
        VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
        VK_FLAGS_NONE,
        null, // No memory barriers,
        null, // No buffer barriers,
        postPresentBarrier); // one image barrier

    err = vkEndCommandBuffer(commandBuffer);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to wait for idle queue: " + translateVulkanResult(err));
    }

    // Submit the command buffer
    submitCommandBuffer(queue, commandBuffer);
}
项目:oreon-engine    文件:VKRenderEngine.java   
void recreate(VkCommandBuffer setupCommandBuffer,
              VkDevice device,
              VkPhysicalDevice physicalDevice,
              long surface,
              ColorFormatAndSpace colorFormatAndSpace,
              VkQueue queue,
              long renderPass,
              long renderCommandPool,
              long pipeline,
              Vertices vertices) {
    // Begin the setup command buffer (the one we will use for swapchain/framebuffer creation)
    VkCommandBufferBeginInfo cmdBufInfo = VkCommandBufferBeginInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO)
            .pNext(0);
    int err = vkBeginCommandBuffer(setupCommandBuffer, cmdBufInfo);
    cmdBufInfo.free();
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to begin setup command buffer: " + VKUtil.translateVulkanResult(err));
    }
    long oldChain = swapchain != null ? swapchain.swapchainHandle : VK_NULL_HANDLE;
    // Create the swapchain (this will also add a memory barrier to initialize the framebuffer images)
    swapchain = createSwapChain(device, physicalDevice, surface, oldChain, setupCommandBuffer,
            width, height, colorFormatAndSpace.colorFormat, colorFormatAndSpace.colorSpace);
    err = vkEndCommandBuffer(setupCommandBuffer);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to end setup command buffer: " + VKUtil.translateVulkanResult(err));
    }
    submitCommandBuffer(queue, setupCommandBuffer);
    vkQueueWaitIdle(queue);

    if (framebuffers != null) {
        for (int i = 0; i < framebuffers.length; i++)
            vkDestroyFramebuffer(device, framebuffers[i], null);
    }
    framebuffers = createFramebuffers(device, swapchain, renderPass, width, height);
    // Create render command buffers
    if (renderCommandBuffers != null) {
        vkResetCommandPool(device, renderCommandPool, 0);
    }
    renderCommandBuffers = createRenderCommandBuffers(device, renderCommandPool, framebuffers, renderPass, width, height, pipeline,
            vertices.verticesBuf);

    mustRecreate = false;
}