Skip to content

Commit

Permalink
ensure we use the gpu from hgi.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <devs@wabi.foundation>
  • Loading branch information
furby-tm committed Dec 29, 2024
1 parent a8bdc38 commit 2887880
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Sources/UsdView/Hydra/Hydra+RenderEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
import Foundation
import PixarUSD

#if canImport(Metal) && !os(visionOS)
import Metal
import MetalKit
#endif // canImport(Metal) && !os(visionOS)

public enum Hydra
{
public class RenderEngine
Expand Down Expand Up @@ -51,5 +56,10 @@ public enum Hydra

engine.render(root: stage.getPseudoRoot(), params: params)
}

public var hydraDevice: MTLDevice
{
hgi.device
}
}
}
5 changes: 2 additions & 3 deletions Sources/UsdView/Hydra/Hydra+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public extension Hydra.Viewport
init(engine: Hydra.RenderEngine, rgba: (Double, Double, Double, Double))
{
#if canImport(Metal) && !os(visionOS)
let device = MTLCreateSystemDefaultDevice()!
let renderer = Hydra.MTLRenderer(device: device)!
self.init(hydra: engine, device: device, renderer: renderer, rgba: rgba)
let renderer = Hydra.MTLRenderer(device: engine.hydraDevice)!
self.init(hydra: engine, renderer: renderer, rgba: rgba)
#endif // canImport(Metal) && !os(visionOS)
}
}
4 changes: 2 additions & 2 deletions Sources/UsdView/Hydra/MTL/Hydra+MTLView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ import PixarUSD

var rgba: (Double, Double, Double, Double)

public init(hydra: Hydra.RenderEngine, device: MTLDevice, renderer: MTLRenderer, rgba: (Double, Double, Double, Double))
public init(hydra: Hydra.RenderEngine, renderer: MTLRenderer, rgba: (Double, Double, Double, Double))
{
self.hydra = hydra
self.device = device
self.device = hydra.hydraDevice
self.renderer = renderer
self.rgba = rgba
}
Expand Down

0 comments on commit 2887880

Please sign in to comment.