From 19014e0ba70d92c3257cf7a69f7018123d6028e6 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 26 May 2018 11:29:19 -1000 Subject: [PATCH] synchronize macOS with latest changes --- include/boo/graphicsdev/Metal.hpp | 2 +- lib/audiodev/AQS.cpp | 1 + lib/graphicsdev/Metal.mm | 28 +++++++++++------------ lib/mac/WindowCocoa.mm | 38 ++++++++++++++----------------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/boo/graphicsdev/Metal.hpp b/include/boo/graphicsdev/Metal.hpp index 6eb7538..ef28c58 100644 --- a/include/boo/graphicsdev/Metal.hpp +++ b/include/boo/graphicsdev/Metal.hpp @@ -19,7 +19,7 @@ public: friend class MetalDataFactoryImpl; MetalDataFactory& m_parent; ObjToken m_data; - Context(MetalDataFactory& parent); + Context(MetalDataFactory& parent __BooTraceArgs); ~Context(); public: Platform platform() const { return Platform::Metal; } diff --git a/lib/audiodev/AQS.cpp b/lib/audiodev/AQS.cpp index 41f34e3..da36dd2 100644 --- a/lib/audiodev/AQS.cpp +++ b/lib/audiodev/AQS.cpp @@ -629,6 +629,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine m_5msFrames = actualSampleRate * 5 / 1000; ChannelMap& chMapOut = m_mixInfo.m_channelMap; + chMapOut.m_channelCount = 0; if (chCount > 2) { AudioChannelLayout layout; diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index 2700ac7..cd81b8b 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -116,7 +116,7 @@ class MetalDataFactoryImpl : public MetalDataFactory, public GraphicsDataFactory m_gammaBinding = ctx.newShaderDataBinding(m_gammaShader, m_gammaVFMT, m_gammaVBO.get(), {}, {}, 0, nullptr, nullptr, 2, texs, nullptr, nullptr); return true; - }); + } BooTrace); } public: @@ -139,8 +139,8 @@ public: Platform platform() const { return Platform::Metal; } const char* platformName() const { return "Metal"; } - void commitTransaction(const std::function&); - ObjToken newPoolBuffer(BufferUse use, size_t stride, size_t count); + void commitTransaction(const std::function& __BooTraceArgs); + ObjToken newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs); void _unregisterShareableShader(uint64_t srcKey, uint64_t binKey) { m_sharedShaders.erase(srcKey); } static bool CheckForMetalCompiler() @@ -1576,8 +1576,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue } }; -MetalDataFactory::Context::Context(MetalDataFactory& parent) -: m_parent(parent), m_data(new BaseGraphicsData(static_cast(parent))) {} +MetalDataFactory::Context::Context(MetalDataFactory& parent __BooTraceArgs) +: m_parent(parent), m_data(new BaseGraphicsData(static_cast(parent) __BooTraceArgsUse)) {} MetalDataFactory::Context::~Context() {} @@ -1819,28 +1819,28 @@ MetalDataFactory::Context::newShaderDataBinding(const ObjToken& } } -void MetalDataFactoryImpl::commitTransaction(const FactoryCommitFunc& trans) +void MetalDataFactoryImpl::commitTransaction(const FactoryCommitFunc& trans __BooTraceArgs) { - MetalDataFactory::Context ctx(*this); + MetalDataFactory::Context ctx(*this __BooTraceArgsUse); trans(ctx); } -ObjToken MetalDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count) +ObjToken MetalDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs) { - ObjToken pool(new BaseGraphicsPool(*this)); + ObjToken pool(new BaseGraphicsPool(*this __BooTraceArgsUse)); MetalCommandQueue* q = static_cast(m_parent->getCommandQueue()); return {new MetalGraphicsBufferD(pool, q, use, m_ctx, stride, count)}; } -IGraphicsCommandQueue* _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow, - IGraphicsContext* parent) +std::unique_ptr _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow, + IGraphicsContext* parent) { - return new struct MetalCommandQueue(ctx, parentWindow, parent); + return std::make_unique(ctx, parentWindow, parent); } -IGraphicsDataFactory* _NewMetalDataFactory(IGraphicsContext* parent, MetalContext* ctx) +std::unique_ptr _NewMetalDataFactory(IGraphicsContext* parent, MetalContext* ctx) { - return new class MetalDataFactoryImpl(parent, ctx); + return std::make_unique(parent, ctx); } } diff --git a/lib/mac/WindowCocoa.mm b/lib/mac/WindowCocoa.mm index cdb06fd..8798073 100644 --- a/lib/mac/WindowCocoa.mm +++ b/lib/mac/WindowCocoa.mm @@ -196,19 +196,19 @@ class GraphicsContextCocoaMetal; namespace boo { static logvisor::Module Log("boo::WindowCocoa"); -IGraphicsCommandQueue* _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx); -IGraphicsDataFactory* _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx); -IGraphicsCommandQueue* _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow, - IGraphicsContext* parent); -IGraphicsDataFactory* _NewMetalDataFactory(IGraphicsContext* parent, MetalContext* ctx); +std::unique_ptr _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx); +std::unique_ptr _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx); +std::unique_ptr _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow, + IGraphicsContext* parent); +std::unique_ptr _NewMetalDataFactory(IGraphicsContext* parent, MetalContext* ctx); void _CocoaUpdateLastGLCtx(NSOpenGLContext* lastGLCtx); class GraphicsContextCocoaGL : public GraphicsContextCocoa { GraphicsContextCocoaGLInternal* m_nsContext = nullptr; - IGraphicsCommandQueue* m_commandQueue = nullptr; - IGraphicsDataFactory* m_dataFactory = nullptr; + std::unique_ptr m_dataFactory; + std::unique_ptr m_commandQueue; NSOpenGLContext* m_mainCtx = nullptr; NSOpenGLContext* m_loadCtx = nullptr; @@ -228,8 +228,6 @@ public: ~GraphicsContextCocoaGL() { m_commandQueue->stopRenderer(); - delete m_commandQueue; - delete m_dataFactory; printf("CONTEXT DESTROYED\n"); } @@ -281,12 +279,12 @@ public: IGraphicsCommandQueue* getCommandQueue() { - return m_commandQueue; + return m_commandQueue.get(); } IGraphicsDataFactory* getDataFactory() { - return m_dataFactory; + return m_dataFactory.get(); } IGraphicsDataFactory* getMainContextDataFactory() @@ -299,7 +297,7 @@ public: Log.report(logvisor::Fatal, "unable to make main NSOpenGLContext"); } [m_mainCtx makeCurrentContext]; - return m_dataFactory; + return m_dataFactory.get(); } IGraphicsDataFactory* getLoadContextDataFactory() @@ -312,7 +310,7 @@ public: Log.report(logvisor::Fatal, "unable to make load NSOpenGLContext"); } [m_loadCtx makeCurrentContext]; - return m_dataFactory; + return m_dataFactory.get(); } void present() @@ -372,8 +370,8 @@ class GraphicsContextCocoaMetal : public GraphicsContextCocoa { GraphicsContextCocoaMetalInternal* m_nsContext = nullptr; - IGraphicsCommandQueue* m_commandQueue = nullptr; - IGraphicsDataFactory* m_dataFactory = nullptr; + std::unique_ptr m_dataFactory; + std::unique_ptr m_commandQueue; public: IWindow* m_parentWindow; @@ -391,8 +389,6 @@ public: ~GraphicsContextCocoaMetal() { m_commandQueue->stopRenderer(); - delete m_commandQueue; - delete m_dataFactory; m_metalCtx->m_windows.erase(m_parentWindow); } @@ -445,22 +441,22 @@ public: IGraphicsCommandQueue* getCommandQueue() { - return m_commandQueue; + return m_commandQueue.get(); } IGraphicsDataFactory* getDataFactory() { - return m_dataFactory; + return m_dataFactory.get(); } IGraphicsDataFactory* getMainContextDataFactory() { - return m_dataFactory; + return m_dataFactory.get(); } IGraphicsDataFactory* getLoadContextDataFactory() { - return m_dataFactory; + return m_dataFactory.get(); } void present()