Skip to content

Commit a9de0a3

Browse files
committed
alphaMode is required for special cases like 3D gaussian splatting
1 parent 6ae1b75 commit a9de0a3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/metalglfw.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function WGPUCore.getContext(gpuCanvas::GLFWMacCanvas)
158158
gpuCanvas.device, # device::Any
159159
WGPUTextureFormat(0), # format::WGPUTextureFormat
160160
WGPUTextureUsage_RenderAttachment, # usage::WGPUTextureUsage
161-
nothing, # compositingAlphaMode::Any
161+
WGPUCompositeAlphaMode_PreMultiplied, # compositingAlphaMode::Any
162162
nothing, # size::Any
163163
gpuCanvas.size, # physicalSize::Any
164164
nothing, # pixelRatio::Any
@@ -186,6 +186,7 @@ function WGPUCore.configure(
186186
canvasContext.usage = usage
187187
canvasContext.compositingAlphaMode = compositingAlphaMode
188188
canvasContext.size = size
189+
189190
end
190191

191192
function WGPUCore.unconfigure(canvasContext::GPUCanvasContext)
@@ -254,6 +255,12 @@ function createNativeSwapChainMaybe(canvasCntxt::GPUCanvasContext)
254255
canvasCntxt.surfaceSize = pSize
255256
canvasCntxt.usage = WGPUTextureUsage_RenderAttachment
256257
presentMode = WGPUPresentMode_Fifo
258+
swapChainExtras = cStruct(
259+
WGPUSwapChainDescriptorExtras;
260+
alphaMode=WGPUCompositeAlphaMode_PreMultiplied,
261+
viewFormatCount=1,
262+
viewFormats = [canvasCntxt.format] |> pointer
263+
)
257264
swapChain =
258265
cStruct(
259266
WGPUSwapChainDescriptor;
@@ -262,6 +269,7 @@ function createNativeSwapChainMaybe(canvasCntxt::GPUCanvasContext)
262269
width = max(1, pSize[1]),
263270
height = max(1, pSize[2]),
264271
presentMode = presentMode,
272+
nextInChain=swapChainExtras |> ptr
265273
)
266274
if canvasCntxt.surfaceId == nothing
267275
canvasCntxt.surfaceId = getSurfaceIdFromCanvas(canvas)

0 commit comments

Comments
 (0)