Skip to content

Commit 160fcb1

Browse files
committed
Fix crash on clear when no framebuffer is bound
1 parent 922114a commit 160fcb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/net/vulkanmod/render/engine/VkCommandEncoder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void clearColorAndDepthTextures(GpuTexture colorAttachment, int clearColo
217217
((VkGpuTexture) depthAttachment).setDepthClearValue((float) clearDepth);
218218

219219
Framebuffer boundFramebuffer = Renderer.getInstance().getBoundFramebuffer();
220-
if (boundFramebuffer.getColorAttachment() == ((VkGpuTexture) colorAttachment).getVulkanImage()
220+
if (boundFramebuffer != null && boundFramebuffer.getColorAttachment() == ((VkGpuTexture) colorAttachment).getVulkanImage()
221221
&& boundFramebuffer.getDepthAttachment() == ((VkGpuTexture) depthAttachment).getVulkanImage())
222222
{
223223
fbo.clearAttachments();
@@ -238,7 +238,7 @@ public void clearColorAndDepthTextures(GpuTexture colorAttachment, int clearColo
238238
y0 = framebufferHeight - height - y0;
239239

240240
Framebuffer boundFramebuffer = Renderer.getInstance().getBoundFramebuffer();
241-
if (boundFramebuffer.getColorAttachment() == ((VkGpuTexture) colorAttachment).getVulkanImage()
241+
if (boundFramebuffer != null && boundFramebuffer.getColorAttachment() == ((VkGpuTexture) colorAttachment).getVulkanImage()
242242
&& boundFramebuffer.getDepthAttachment() == ((VkGpuTexture) depthAttachment).getVulkanImage())
243243
{
244244
Renderer.clearAttachments(0x4100, x0, y0, width, height);
@@ -257,7 +257,7 @@ public void clearDepthTexture(GpuTexture depthAttachment, double clearDepth) {
257257
}
258258
else {
259259
Framebuffer boundFramebuffer = Renderer.getInstance().getBoundFramebuffer();
260-
if (boundFramebuffer.getDepthAttachment() == ((VkGpuTexture) depthAttachment).getVulkanImage()) {
260+
if (boundFramebuffer != null && boundFramebuffer.getDepthAttachment() == ((VkGpuTexture) depthAttachment).getVulkanImage()) {
261261
VRenderSystem.clearDepth(clearDepth);
262262
Renderer.clearAttachments(0x100);
263263
}

0 commit comments

Comments
 (0)