Skip to content

Commit 1ca08a2

Browse files
committed
windows update to v0.19.1.1
1 parent 5adc5b9 commit 1ca08a2

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

src/glfwWindows.jl

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function WGPUCore.getContext(gpuCanvas::GLFWWinCanvas)
122122
gpuCanvas.device, # device::Any
123123
WGPUTextureFormat_R8Unorm, # format::WGPUTextureFormat
124124
WGPUCore.getEnum(WGPUTextureUsage, ["RenderAttachment", "CopySrc"]), # usage::WGPUTextureUsage
125-
WGPUCompositeAlphaMode_PreMultiplied, # compositingAlphaMode::Any
125+
WGPUCompositeAlphaMode_Premultiplied, # compositingAlphaMode::Any
126126
nothing, # size::Any
127127
gpuCanvas.size, # physicalSize::Any
128128
nothing, # pixelRatio::Any
@@ -190,25 +190,30 @@ function WGPUCore.getCurrentTexture(cntxt::GPUCanvasContext)
190190
# if cntxt.device.internal[] == C_NULL
191191
# @error "context must be configured before request for texture"
192192
# end
193+
canvas = cntxt.canvasRef[]
194+
surface = canvas.surfaceRef[]
195+
surfaceTexture = cStruct(WGPUSurfaceTexture;)
193196
if cntxt.currentTexture == nothing
194-
createNativeSwapChainMaybe(cntxt)
195-
id = wgpuSwapChainGetCurrentTextureView(cntxt.internal[]) |> Ref
197+
configureSurface(cntxt)
198+
wgpuSurfaceGetCurrentTexture(surface, surfaceTexture|>ptr)
196199
size = (cntxt.surfaceSize..., 1)
200+
currentTexture = wgpuTextureCreateView(surfaceTexture.texture, C_NULL) |> Ref
197201
cntxt.currentTexture =
198-
WGPUCore.GPUTextureView("swap chain", id, cntxt.device, nothing, size, nothing |> Ref)
202+
WGPUCore.GPUTextureView("swap chain", currentTexture, cntxt.device, nothing, size, nothing |> Ref)
199203
end
200204
return cntxt.currentTexture
201205
end
202206

203207
function WGPUCore.present(cntxt::GPUCanvasContext)
208+
canvas = cntxt.canvasRef[]
204209
if cntxt.internal[] != C_NULL && cntxt.currentTexture.internal[] != C_NULL
205-
wgpuSwapChainPresent(cntxt.internal[])
210+
wgpuSurfacePresent(canvas.surfaceRef[])
206211
end
207212
WGPUCore.destroy(cntxt.currentTexture)
208213
cntxt.currentTexture = nothing
209214
end
210215

211-
function createNativeSwapChainMaybe(canvasCntxt::GPUCanvasContext)
216+
function configureSurface(canvasCntxt::GPUCanvasContext)
212217
canvas = canvasCntxt.canvasRef[]
213218
pSize = canvasCntxt.physicalSize
214219
if pSize == canvasCntxt.surfaceSize
@@ -217,31 +222,35 @@ function createNativeSwapChainMaybe(canvasCntxt::GPUCanvasContext)
217222
canvasCntxt.surfaceSize = pSize
218223
canvasCntxt.usage = WGPUCore.getEnum(WGPUTextureUsage, ["RenderAttachment", "CopySrc"])
219224
presentMode = WGPUPresentMode_Fifo # TODO hardcoded (for other options ref https://docs.rs/wgpu/latest/wgpu/enum.PresentMode.html)
220-
swapChainExtras = cStruct(
221-
WGPUSwapChainDescriptorExtras;
222-
alphaMode=WGPUCompositeAlphaMode_PreMultiplied,
223-
viewFormatCount=1,
224-
viewFormats = [canvasCntxt.format] |> pointer
225-
)
226-
swapChain =
225+
surfaceCapabilities = cStruct(WGPUSurfaceCapabilities;)
226+
227+
wgpuSurfaceGetCapabilities(
228+
canvas.surfaceRef[],
229+
canvas.device.internal[],
230+
surfaceCapabilities |> ptr
231+
)
232+
233+
surfaceConfiguration =
227234
cStruct(
228235
WGPUSwapChainDescriptor;
236+
device = canvasCntxt.device.internal[],
229237
usage = canvasCntxt.usage,
230238
format = canvasCntxt.format,
239+
viewFormatCount = 1,
240+
viewFormats = [canvasCntxt.format] |> pointer,
241+
alphaMode = WGPUCompositeAlphaMode_Opaque,
231242
width = max(1, pSize[1]),
232243
height = max(1, pSize[2]),
233244
presentMode = presentMode,
234-
nextInChain = swapChainExtras |> ptr
245+
nextInChain = C_NULL,
235246
)
236247
if canvasCntxt.surfaceId == nothing
237248
canvasCntxt.surfaceId = getSurfaceIdFromCanvas(canvas)
238249
end
239-
canvasCntxt.internal =
240-
wgpuDeviceCreateSwapChain(
241-
canvasCntxt.device.internal[],
242-
canvasCntxt.surfaceId,
243-
swapChain |> ptr,
244-
) |> Ref
250+
wgpuSurfaceConfigure(
251+
canvas.surfaceRef[],,
252+
surfaceConfiguration |> ptr,
253+
)
245254
end
246255

247256
function WGPUCore.destroyWindow(canvas::GLFWWinCanvas)

src/metalglfw.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,7 @@ function WGPUCore.getCurrentTexture(cntxt::GPUCanvasContext)
230230
# end
231231
canvas = cntxt.canvasRef[]
232232
surface = canvas.surfaceRef[]
233-
surfaceTexture = cStruct(
234-
WGPUSurfaceTexture;
235-
)
236-
233+
surfaceTexture = cStruct(WGPUSurfaceTexture;)
237234
if cntxt.currentTexture == nothing
238235
configureSurface(cntxt)
239236
wgpuSurfaceGetCurrentTexture(surface, surfaceTexture|>ptr)
@@ -274,12 +271,6 @@ function configureSurface(canvasCntxt::GPUCanvasContext)
274271
surfaceCapabilities |> ptr
275272
)
276273

277-
#swapChainExtras = cStruct(
278-
# WGPUSurfaceCapabilities;
279-
# alphaMode=WGPUCompositeAlphaMode_Premultiplied,
280-
# viewFormatCount=1,
281-
# viewFormats = [canvasCntxt.format] |> pointer
282-
#)
283274
surfaceConfiguration =
284275
cStruct(
285276
WGPUSurfaceConfiguration;

0 commit comments

Comments
 (0)