Skip to content

Commit a04c526

Browse files
committed
Better compositeAlpha handling for swapchains
1 parent 9c3fd2c commit a04c526

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/java/net/vulkanmod/vulkan/framebuffer/SwapChain.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,19 @@ private void createSwapChain() {
121121
}
122122

123123
createInfo.preTransform(surfaceProperties.capabilities.currentTransform());
124-
createInfo.compositeAlpha(VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR);
124+
125+
int supportedCompositeAlpha = surfaceProperties.capabilities.supportedCompositeAlpha();
126+
if((supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) != 0) {
127+
createInfo.compositeAlpha(VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR);
128+
}else if((supportedCompositeAlpha & VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) != 0){
129+
// PowerVR GE8320 Vulkan drivers don't support the alpha composite opaque bit.
130+
// In that case, use the inherit mode if supported.
131+
createInfo.compositeAlpha(VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR);
132+
} else {
133+
// Not sure how to handle the other cases, to be honest...
134+
throw new RuntimeException("Neither opaque, nor inherited alpha compositing modes are supported.");
135+
}
136+
125137
createInfo.presentMode(presentMode);
126138
createInfo.clipped(true);
127139

0 commit comments

Comments
 (0)