private static long createClearRenderPass(VkDevice device, int colorFormat) { VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.callocStack(1) .format(colorFormat) .samples(VK_SAMPLE_COUNT_1_BIT) .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) .storeOp(VK_ATTACHMENT_STORE_OP_STORE) .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) .initialLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkAttachmentReference.Buffer colorReference = VkAttachmentReference.callocStack(1) .attachment(0) .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkSubpassDescription.Buffer subpass = VkSubpassDescription.callocStack(1) .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS) .flags(VK_FLAGS_NONE) .pInputAttachments(null) .colorAttachmentCount(colorReference.remaining()) .pColorAttachments(colorReference) .pResolveAttachments(null) .pDepthStencilAttachment(null) .pPreserveAttachments(null); VkRenderPassCreateInfo renderPassInfo = VkRenderPassCreateInfo.callocStack() .sType(VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO) .pNext(NULL) .pAttachments(attachments) .pSubpasses(subpass) .pDependencies(null); LongBuffer pRenderPass = stackMallocLong(1); int err = vkCreateRenderPass(device, renderPassInfo, null, pRenderPass); long renderPass = pRenderPass.get(0); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create clear render pass: " + translateVulkanResult(err)); } return renderPass; }
private long createRenderPass(VkDevice device, int colorFormat) { VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.calloc(1) .format(colorFormat) .samples(VK_SAMPLE_COUNT_1_BIT) .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) .storeOp(VK_ATTACHMENT_STORE_OP_STORE) .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) .initialLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkAttachmentReference.Buffer colorReference = VkAttachmentReference.calloc(1) .attachment(0) .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkSubpassDescription.Buffer subpass = VkSubpassDescription.calloc(1) .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS) .flags(0) .pInputAttachments(null) .colorAttachmentCount(colorReference.remaining()) .pColorAttachments(colorReference) // <- only color attachment .pResolveAttachments(null) .pDepthStencilAttachment(null) .pPreserveAttachments(null); VkRenderPassCreateInfo renderPassInfo = VkRenderPassCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO) .pNext(0) .pAttachments(attachments) .pSubpasses(subpass) .pDependencies(null); LongBuffer pRenderPass = memAllocLong(1); int err = vkCreateRenderPass(device, renderPassInfo, null, pRenderPass); long renderPass = pRenderPass.get(0); memFree(pRenderPass); renderPassInfo.free(); colorReference.free(); subpass.free(); attachments.free(); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create clear render pass: " + VKUtil.translateVulkanResult(err)); } return renderPass; }
private static long createClearRenderPass(VkDevice device, int colorFormat) { VkAttachmentDescription.Buffer attachments = VkAttachmentDescription.calloc(1) .format(colorFormat) .samples(VK_SAMPLE_COUNT_1_BIT) .loadOp(VK_ATTACHMENT_LOAD_OP_CLEAR) .storeOp(VK_ATTACHMENT_STORE_OP_STORE) .stencilLoadOp(VK_ATTACHMENT_LOAD_OP_DONT_CARE) .stencilStoreOp(VK_ATTACHMENT_STORE_OP_DONT_CARE) .initialLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) .finalLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkAttachmentReference.Buffer colorReference = VkAttachmentReference.calloc(1) .attachment(0) .layout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkSubpassDescription.Buffer subpass = VkSubpassDescription.calloc(1) .pipelineBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS) .flags(VK_FLAGS_NONE) .pInputAttachments(null) .colorAttachmentCount(colorReference.remaining()) .pColorAttachments(colorReference) .pResolveAttachments(null) .pDepthStencilAttachment(null) .pPreserveAttachments(null); VkRenderPassCreateInfo renderPassInfo = VkRenderPassCreateInfo.calloc() .sType(VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO) .pNext(NULL) .pAttachments(attachments) .pSubpasses(subpass) .pDependencies(null); LongBuffer pRenderPass = memAllocLong(1); int err = vkCreateRenderPass(device, renderPassInfo, null, pRenderPass); long renderPass = pRenderPass.get(0); memFree(pRenderPass); renderPassInfo.free(); colorReference.free(); subpass.free(); attachments.free(); if (err != VK_SUCCESS) { throw new AssertionError("Failed to create clear render pass: " + translateVulkanResult(err)); } return renderPass; }