Skip to content

Commit 89bea3c

Browse files
committed
fix blit framebuffer utility method
1 parent adece8f commit 89bea3c

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

‎src/main/java/net/vulkanmod/vulkan/texture/ImageUtil.java‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void downloadTexture(VulkanImage image, long ptr) {
5050
pStagingBuffer, pStagingAllocation);
5151

5252
copyImageToBufferCmd(stack, commandBuffer.getHandle(), pStagingBuffer.get(0), image.getId(), 0, image.width,
53-
image.height, 0, 0, 0, 0, 0);
53+
image.height, 0, 0, 0, 0, 0);
5454
image.transitionImageLayout(stack, commandBuffer.getHandle(), prevLayout);
5555

5656
long fence = DeviceManager.getGraphicsQueue().submitCommands(commandBuffer);
@@ -65,7 +65,7 @@ public static void downloadTexture(VulkanImage image, long ptr) {
6565

6666
public static void copyImageToBuffer(VulkanImage image, Buffer buffer, int mipLevel,
6767
int width, int height, int xOffset, int yOffset,
68-
int bufferOffset, int bufferRowLength, int bufferImageHeight) {
68+
long bufferOffset, int bufferRowLength, int bufferImageHeight) {
6969
try (MemoryStack stack = stackPush()) {
7070
int prevLayout = image.getCurrentLayout();
7171
CommandPool.CommandBuffer commandBuffer = DeviceManager.getGraphicsQueue().beginCommands();
@@ -81,7 +81,7 @@ public static void copyImageToBuffer(VulkanImage image, Buffer buffer, int mipLe
8181
}
8282

8383
public static void copyImageToBufferCmd(MemoryStack stack, VkCommandBuffer commandBuffer, long buffer, long image,
84-
int mipLevel, int width, int height, int xOffset, int yOffset, int bufferOffset,
84+
int mipLevel, int width, int height, int xOffset, int yOffset, long bufferOffset,
8585
int bufferRowLength, int bufferImageHeight) {
8686
VkBufferImageCopy.Buffer region = VkBufferImageCopy.calloc(1, stack);
8787
region.bufferOffset(bufferOffset);
@@ -97,18 +97,13 @@ public static void copyImageToBufferCmd(MemoryStack stack, VkCommandBuffer comma
9797
vkCmdCopyImageToBuffer(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffer, region);
9898
}
9999

100-
public static void blitFramebuffer(VulkanImage dstImage, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) {
100+
public static void blitFramebuffer(VulkanImage srcImage, VulkanImage dstImage) {
101101
try (MemoryStack stack = stackPush()) {
102-
103102
VkCommandBuffer commandBuffer = Renderer.getCommandBuffer();
104103

105104
Renderer.getInstance().endRenderPass(commandBuffer);
106105

107106
dstImage.transitionImageLayout(stack, commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
108-
109-
// TODO: hardcoded srcImage
110-
VulkanImage srcImage = Renderer.getInstance().getSwapChain().getColorAttachment();
111-
112107
srcImage.transitionImageLayout(stack, commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
113108

114109
VkImageBlit.Buffer blit = VkImageBlit.calloc(1, stack);
@@ -129,12 +124,14 @@ public static void blitFramebuffer(VulkanImage dstImage, int srcX0, int srcY0, i
129124
dstImage.getId(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, blit, VK_FILTER_LINEAR);
130125

131126
dstImage.transitionImageLayout(stack, commandBuffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
132-
133-
Renderer.getInstance().getMainPass().rebindMainTarget();
134-
135127
}
136128
}
137129

130+
public static void blitFramebuffer(VulkanImage dstImage, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) {
131+
// TODO: implement blit
132+
// blitFramebuffer(Renderer.getInstance().getSwapChain().getColorAttachment(), dstImage);
133+
}
134+
138135
public static void generateMipmaps(VulkanImage image) {
139136
try (MemoryStack stack = stackPush()) {
140137

0 commit comments

Comments
 (0)