Skip to content

Commit

Permalink
fix: file name cases, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed May 9, 2024
1 parent 07570ad commit 5320d2c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 31 deletions.
1 change: 0 additions & 1 deletion examples/common/entry/SwiftBridgingHeader.h

This file was deleted.

34 changes: 11 additions & 23 deletions examples/common/entry/entry_visionos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,40 @@ struct ContentStageConfiguration: CompositorLayerConfiguration {
func makeConfiguration(capabilities: LayerRenderer.Capabilities, configuration: inout LayerRenderer.Configuration) {
configuration.depthFormat = .depth32Float
configuration.colorFormat = .bgra8Unorm_srgb

let foveationEnabled = capabilities.supportsFoveation
configuration.isFoveationEnabled = foveationEnabled

let options: LayerRenderer.Capabilities.SupportedLayoutsOptions = foveationEnabled ? [.foveationEnabled] : []
let supportedLayouts = capabilities.supportedLayouts(options: options)

configuration.layout = supportedLayouts.contains(.layered) ? .layered : .dedicated
}
}

class Renderer {
let arSession: ARKitSession
let worldTracking: WorldTrackingProvider
let layerRenderer: LayerRenderer
var bgfxAdapter: BgfxAdapter

init(_ layerRenderer: LayerRenderer) {
self.layerRenderer = layerRenderer
bgfxAdapter = BgfxAdapter(layerRenderer)
worldTracking = WorldTrackingProvider()
arSession = ARKitSession()
}

func startRenderLoop() {
Task {
do {
try await arSession.run([worldTracking])
} catch {
fatalError("Failed to initialize ARSession")
}

let renderThread = Thread {
self.renderLoop()
}
renderThread.name = "Render Thread"
renderThread.start()
}
}


func renderLoop() {
while true {
if layerRenderer.state == .invalidated {
print("Layer is invalidated")

bgfxAdapter.shutdown()
return
} else if layerRenderer.state == .paused {
Expand All @@ -72,10 +60,10 @@ class Renderer {
struct ExampeApp: App {
@State private var showImmersiveSpace = false
@State private var immersiveSpaceIsShown = false

@Environment(\.openImmersiveSpace) var openImmersiveSpace
@Environment(\.dismissImmersiveSpace) var dismissImmersiveSpace

var body: some Scene {
WindowGroup {
VStack {
Expand All @@ -101,7 +89,7 @@ struct ExampeApp: App {
}
}
}

}
ImmersiveSpace(id: "ImmersiveSpace") {
CompositorLayer(configuration: ContentStageConfiguration()) { layerRenderer in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_VISIONOS

#include "SwiftAdapter.hpp"
#include "swift_adapter.hpp"

#include <bgfx/platform.h>
#include <bx/uint32_t.h>
Expand Down Expand Up @@ -30,12 +30,14 @@ namespace entry

m_eventQueue.postSizeEvent(s_defaultWindow, _width, _height);


// Prevent render thread creation.
bgfx::renderFrame();

m_thread.init(MainThreadEntry::threadFunc, &m_mte);
}


~Context()
{
m_thread.shutdown();
Expand All @@ -54,6 +56,10 @@ namespace entry
{
BX_UNUSED(_thread);

if (_thread != NULL) {
_thread->setThreadName("Main Thread BGFX");
}

CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle != nil)
{
Expand Down Expand Up @@ -171,12 +177,10 @@ bool BgfxAdapter::initialize(void) {

void BgfxAdapter::shutdown(void) {
if (m_initialized) {
bgfx::shutdown();

AppI *currentApp = entry::getCurrentApp();
currentApp->shutdown();
s_ctx->m_eventQueue.postExitEvent();
s_ctx = NULL;
}

m_initialized = false;
}

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions examples/common/entry/swift_bridging_header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "swift_adapter.hpp"
2 changes: 1 addition & 1 deletion scripts/example-common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ project ("example-common")
}
xcodeprojectopts {
SWIFT_VERSION = "5.0",
SWIFT_OBJC_BRIDGING_HEADER = path.join(BGFX_DIR, "examples/common/entry/SwiftBridgingHeader.h"),
SWIFT_OBJC_BRIDGING_HEADER = path.join(BGFX_DIR, "examples/common/entry/swift_bridging_header.h"),
SWIFT_OBJC_INTEROP_MODE = "objcxx",
}

Expand Down

0 comments on commit 5320d2c

Please sign in to comment.