diff --git a/specter/include/specter/Button.hpp b/specter/include/specter/Button.hpp index b5af033fe..8fb433056 100644 --- a/specter/include/specter/Button.hpp +++ b/specter/include/specter/Button.hpp @@ -87,6 +87,7 @@ public: friend class Button; void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme); + void destroy() {} }; ~Button() {closeMenu({});} diff --git a/specter/include/specter/FontCache.hpp b/specter/include/specter/FontCache.hpp index dcd64eb49..012388939 100644 --- a/specter/include/specter/FontCache.hpp +++ b/specter/include/specter/FontCache.hpp @@ -58,8 +58,7 @@ class FontAtlas { friend class FontCache; FT_Face m_face; - boo::ITextureSA* m_tex = nullptr; - boo::GraphicsDataToken m_token; + boo::ObjToken m_tex; uint32_t m_dpi; FT_Fixed m_ftXscale; FT_UShort m_ftXPpem; @@ -125,7 +124,7 @@ public: FT_Fixed FT_Xscale() const {return m_ftXscale;} FT_UShort FT_XPPem() const {return m_ftXPpem;} FT_Pos FT_LineHeight() const {return m_lineHeight;} - boo::ITexture* texture() const {return m_tex;} + const boo::ObjToken& texture() const {return m_tex;} bool subpixel() const {return m_subpixel;} const Glyph* lookupGlyph(atUint32 charcode) const diff --git a/specter/include/specter/Icon.hpp b/specter/include/specter/Icon.hpp index 3377562c4..a103ca453 100644 --- a/specter/include/specter/Icon.hpp +++ b/specter/include/specter/Icon.hpp @@ -8,10 +8,10 @@ namespace specter struct Icon { - boo::ITexture* m_tex = nullptr; + boo::ObjToken m_tex; zeus::CVector2f m_uvCoords[4]; Icon() = default; - Icon(boo::ITexture* tex, float rect[4]) + Icon(const boo::ObjToken& tex, float rect[4]) : m_tex(tex) { m_uvCoords[0][0] = rect[0]; @@ -31,25 +31,26 @@ struct Icon template class IconAtlas { - boo::ITexture* m_tex = nullptr; + boo::ObjToken m_tex; Icon m_icons[COLS][ROWS]; Icon MakeIcon(float x, float y) { float rect[] = {x / float(COLS), y / float(ROWS), x / float(COLS) + 1.f / float(COLS), y / float(ROWS) + 1.f / float(ROWS)}; - return Icon(m_tex, rect); + return Icon(m_tex.get(), rect); } public: IconAtlas() = default; operator bool() const {return m_tex != nullptr;} - void initializeAtlas(boo::ITexture* tex) + void initializeAtlas(const boo::ObjToken& tex) { m_tex = tex; for (int c=0 ; c(_m_verts); } - boo::GraphicsDataToken m_windowGfxData; - std::unique_ptr m_cornersOutline[4]; std::unique_ptr m_cornersFilled[4]; diff --git a/specter/include/specter/RootView.hpp b/specter/include/specter/RootView.hpp index 64448502b..63d9d56db 100644 --- a/specter/include/specter/RootView.hpp +++ b/specter/include/specter/RootView.hpp @@ -19,7 +19,7 @@ namespace specter class RootView : public View { boo::IWindow* m_window = nullptr; - boo::ITextureR* m_renderTex = nullptr; + boo::ObjToken m_renderTex; boo::SWindowRect m_rootRect = {}; bool m_resizeRTDirty = false; bool m_destroyed = false; @@ -146,7 +146,7 @@ public: IViewManager& viewManager() const {return m_viewMan;} ViewResources& viewRes() const {return *m_viewRes;} const IThemeData& themeData() const {return *m_viewRes->m_theme;} - boo::ITextureR* renderTex() const {return m_renderTex;} + const boo::ObjToken& renderTex() const {return m_renderTex;} std::vector& accessContentViews() {return m_views;} diff --git a/specter/include/specter/SplitView.hpp b/specter/include/specter/SplitView.hpp index de5ff8083..fcd7bdafe 100644 --- a/specter/include/specter/SplitView.hpp +++ b/specter/include/specter/SplitView.hpp @@ -16,9 +16,10 @@ public: { friend class ViewResources; friend class SplitView; - boo::ITextureS* m_shadingTex; + boo::ObjToken m_shadingTex; void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme); + void destroy() { m_shadingTex.reset(); } }; enum class ArrowDir diff --git a/specter/include/specter/TextView.hpp b/specter/include/specter/TextView.hpp index c8663a4c0..c3287a1f2 100644 --- a/specter/include/specter/TextView.hpp +++ b/specter/include/specter/TextView.hpp @@ -61,8 +61,8 @@ public: private: size_t m_capacity; hecl::VertexBufferPool::Token m_glyphBuf; - boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */ - boo::IShaderDataBinding* m_shaderBinding; + boo::ObjToken m_vtxFmt; /* OpenGL only */ + boo::ObjToken m_shaderBinding; const FontAtlas& m_fontAtlas; Alignment m_align; int m_width = 0; @@ -87,9 +87,9 @@ public: } FontCache* m_fcache = nullptr; - boo::IShaderPipeline* m_regular = nullptr; - boo::IShaderPipeline* m_subpixel = nullptr; - boo::IVertexFormat* m_vtxFmt = nullptr; /* Not OpenGL */ + boo::ObjToken m_regular; + boo::ObjToken m_subpixel; + boo::ObjToken m_vtxFmt; /* Not OpenGL */ void init(boo::GLDataFactory::Context& ctx, FontCache* fcache); #if _WIN32 @@ -101,6 +101,14 @@ public: #if BOO_HAS_VULKAN void init(boo::VulkanDataFactory::Context& ctx, FontCache* fcache); #endif + + void destroy() + { + m_glyphPool.doDestroy(); + m_regular.reset(); + m_subpixel.reset(); + m_vtxFmt.reset(); + } }; TextView(ViewResources& res, View& parentView, const FontAtlas& font, Alignment align=Alignment::Left, size_t capacity=256); diff --git a/specter/include/specter/Toolbar.hpp b/specter/include/specter/Toolbar.hpp index f1fc8ef33..a96fcc4a0 100644 --- a/specter/include/specter/Toolbar.hpp +++ b/specter/include/specter/Toolbar.hpp @@ -14,9 +14,10 @@ public: { friend class ViewResources; friend class Toolbar; - boo::ITextureS* m_shadingTex; + boo::ObjToken m_shadingTex; void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme); + void destroy() { m_shadingTex.reset(); } }; enum class Position diff --git a/specter/include/specter/View.hpp b/specter/include/specter/View.hpp index bb56424d6..9984c37a1 100644 --- a/specter/include/specter/View.hpp +++ b/specter/include/specter/View.hpp @@ -111,8 +111,8 @@ public: struct VertexBufferBinding { typename hecl::VertexBufferPool::Token m_vertsBuf; - boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */ - boo::IShaderDataBinding* m_shaderBinding = nullptr; + boo::ObjToken m_vtxFmt; /* OpenGL only */ + boo::ObjToken m_shaderBinding; void load(const VertStruct* data, size_t count) { @@ -137,7 +137,7 @@ public: } } - operator boo::IShaderDataBinding*() { return m_shaderBinding; } + operator const boo::ObjToken&() { return m_shaderBinding; } }; struct VertexBufferBindingSolid : VertexBufferBinding { @@ -150,7 +150,7 @@ public: void init(boo::IGraphicsDataFactory::Context& ctx, ViewResources& res, size_t count, const hecl::UniformBufferPool::Token& viewBlockBuf, - boo::ITexture* texture); + const boo::ObjToken& texture); }; private: @@ -159,7 +159,6 @@ private: boo::SWindowRect m_subRect; VertexBufferBindingSolid m_bgVertsBinding; SolidShaderVert m_bgRect[4]; - boo::GraphicsDataToken m_gfxData; friend class RootView; View(ViewResources& res); @@ -200,11 +199,11 @@ public: m_texPool.updateBuffers(); } - boo::IShaderPipeline* m_solidShader = nullptr; - boo::IVertexFormat* m_solidVtxFmt = nullptr; /* Not OpenGL */ + boo::ObjToken m_solidShader; + boo::ObjToken m_solidVtxFmt; /* Not OpenGL */ - boo::IShaderPipeline* m_texShader = nullptr; - boo::IVertexFormat* m_texVtxFmt = nullptr; /* Not OpenGL */ + boo::ObjToken m_texShader; + boo::ObjToken m_texVtxFmt; /* Not OpenGL */ void init(boo::GLDataFactory::Context& ctx, const IThemeData& theme); #if _WIN32 @@ -216,12 +215,23 @@ public: #if BOO_HAS_VULKAN void init(boo::VulkanDataFactory::Context& ctx, const IThemeData& theme); #endif + + void destroy() + { + m_bufPool.doDestroy(); + m_solidPool.doDestroy(); + m_texPool.doDestroy(); + + m_solidShader.reset(); + m_solidVtxFmt.reset(); + m_texShader.reset(); + m_texVtxFmt.reset(); + } }; protected: View(ViewResources& res, View& parentView); void buildResources(boo::IGraphicsDataFactory::Context& ctx, ViewResources& res); - void _commitResources(ViewResources& res, const boo::FactoryCommitFunc& commitFunc); void commitResources(ViewResources& res, const boo::FactoryCommitFunc& commitFunc); public: diff --git a/specter/include/specter/ViewResources.hpp b/specter/include/specter/ViewResources.hpp index e2d303f62..274f9e425 100644 --- a/specter/include/specter/ViewResources.hpp +++ b/specter/include/specter/ViewResources.hpp @@ -167,7 +167,6 @@ public: SplitView::Resources m_splitRes; Toolbar::Resources m_toolbarRes; Button::Resources m_buttonRes; - boo::GraphicsDataToken m_resData; specter::FontTag m_mainFont; specter::FontTag m_monoFont; @@ -188,11 +187,6 @@ public: ViewResources& operator=(const ViewResources& other) = delete; ViewResources& operator=(ViewResources&& other) = default; - void destroyResData() - { - m_resData.doDestroy(); - } - void updateBuffers() { m_viewRes.updateBuffers(); @@ -209,6 +203,7 @@ public: } void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, const IThemeData* theme, float pixelFactor); + void destroyResData(); void prepFontCacheSync(); void prepFontCacheAsync(boo::IWindow* window); bool fontCacheReady() const {return m_fcacheReady;} diff --git a/specter/lib/FontCache.cpp b/specter/lib/FontCache.cpp index 3ca2bd370..24f6109e3 100644 --- a/specter/lib/FontCache.cpp +++ b/specter/lib/FontCache.cpp @@ -391,7 +391,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi, WriteCompressed(writer, (atUint8*)texmap.get(), bufSz); - m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { m_tex = ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1, @@ -476,7 +476,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi, WriteCompressed(writer, (atUint8*)texmap.get(), bufSz); - m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { m_tex = ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1, @@ -600,7 +600,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi, if (!ReadDecompressed(reader, (atUint8*)texmap.get(), bufSz)) return; - m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { m_tex = ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1, @@ -685,7 +685,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi, if (!ReadDecompressed(reader, (atUint8*)texmap.get(), bufSz)) return; - m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { m_tex = ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1, diff --git a/specter/lib/ModalWindow.cpp b/specter/lib/ModalWindow.cpp index f68d49caa..5d0f836d0 100644 --- a/specter/lib/ModalWindow.cpp +++ b/specter/lib/ModalWindow.cpp @@ -292,7 +292,7 @@ ModalWindow::ModalWindow(ViewResources& res, View& parentView, m_windowBgClear[3] = 0.0; m_line2Clear[3] = 0.0; - m_windowGfxData = res.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + res.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { buildResources(ctx, res); m_viewBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory); diff --git a/specter/lib/SplitView.cpp b/specter/lib/SplitView.cpp index 21bb10d7d..abc54e272 100644 --- a/specter/lib/SplitView.cpp +++ b/specter/lib/SplitView.cpp @@ -29,7 +29,7 @@ SplitView::SplitView(ViewResources& res, View& parentView, ISplitSpaceController { buildResources(ctx, res); m_splitBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory); - m_splitVertsBinding.init(ctx, res, 4, m_splitBlockBuf, res.m_splitRes.m_shadingTex); + m_splitVertsBinding.init(ctx, res, 4, m_splitBlockBuf, res.m_splitRes.m_shadingTex.get()); return true; }); } diff --git a/specter/lib/TextView.cpp b/specter/lib/TextView.cpp index 07a890caa..c69600e5b 100644 --- a/specter/lib/TextView.cpp +++ b/specter/lib/TextView.cpp @@ -254,7 +254,7 @@ void TextView::Resources::init(boo::MetalDataFactory::Context& ctx, FontCache* f m_vtxFmt = ctx.newVertexFormat(13, vdescs); m_regular = - ctx.newShaderPipeline(VS, FSReg, m_vtxFmt, 1, + ctx.newShaderPipeline(VS, FSReg, nullptr, nullptr, m_vtxFmt, 1, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); } @@ -295,7 +295,7 @@ void TextView::Resources::init(boo::VulkanDataFactory::Context& ctx, FontCache* void TextView::_commitResources(size_t capacity) { auto& res = rootView().viewRes(); - View::_commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool + View::commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool { buildResources(ctx, res); @@ -303,7 +303,7 @@ void TextView::_commitResources(size_t capacity) { m_glyphBuf = res.m_textRes.m_glyphPool.allocateBlock(res.m_factory, capacity); - boo::IShaderPipeline* shader; + boo::ObjToken shader; if (m_fontAtlas.subpixel()) shader = res.m_textRes.m_subpixel; else @@ -311,39 +311,39 @@ void TextView::_commitResources(size_t capacity) auto vBufInfo = m_glyphBuf.getBufferInfo(); auto uBufInfo = m_viewVertBlockBuf.getBufferInfo(); - boo::IGraphicsBuffer* uBufs[] = {uBufInfo.first}; + boo::ObjToken uBufs[] = {uBufInfo.first.get()}; size_t uBufOffs[] = {size_t(uBufInfo.second)}; size_t uBufSizes[] = {sizeof(ViewBlock)}; - boo::ITexture* texs[] = {m_fontAtlas.texture()}; + boo::ObjToken texs[] = {m_fontAtlas.texture().get()}; if (!res.m_textRes.m_vtxFmt) { boo::VertexElementDescriptor vdescs[] = { - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, - {vBufInfo.first, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 0}, - {vBufInfo.first, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 1}, - {vBufInfo.first, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 2}, - {vBufInfo.first, nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 3}, - {vBufInfo.first, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, - {vBufInfo.first, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, - {vBufInfo.first, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, - {vBufInfo.first, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, - {vBufInfo.first, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced} + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 0}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 1}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 2}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::ModelView | boo::VertexSemantic::Instanced, 3}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced} }; m_vtxFmt = ctx.newVertexFormat(13, vdescs, 0, vBufInfo.second); m_shaderBinding = ctx.newShaderDataBinding(shader, m_vtxFmt, - nullptr, vBufInfo.first, nullptr, 1, + nullptr, vBufInfo.first.get(), nullptr, 1, uBufs, nullptr, uBufOffs, uBufSizes, 1, texs, nullptr, nullptr, 0, vBufInfo.second); } else { m_shaderBinding = ctx.newShaderDataBinding(shader, res.m_textRes.m_vtxFmt, - nullptr, vBufInfo.first, nullptr, 1, + nullptr, vBufInfo.first.get(), nullptr, 1, uBufs, nullptr, uBufOffs, uBufSizes, 1, texs, nullptr, nullptr, 0, vBufInfo.second); } diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index 9bc1a5eab..692d2b139 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -34,7 +34,7 @@ Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned { buildResources(ctx, res); m_tbBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory); - m_vertsBinding.init(ctx, res, 10, m_tbBlockBuf, res.m_toolbarRes.m_shadingTex); + m_vertsBinding.init(ctx, res, 10, m_tbBlockBuf, res.m_toolbarRes.m_shadingTex.get()); return true; }); setBackground(res.themeData().toolbarBackground()); diff --git a/specter/lib/View.cpp b/specter/lib/View.cpp index 79377d682..75ff52819 100644 --- a/specter/lib/View.cpp +++ b/specter/lib/View.cpp @@ -270,7 +270,7 @@ void View::Resources::init(boo::MetalDataFactory::Context& ctx, const IThemeData }; m_solidVtxFmt = ctx.newVertexFormat(2, solidvdescs); - m_solidShader = ctx.newShaderPipeline(SolidVS, SolidFS, m_solidVtxFmt, 1, + m_solidShader = ctx.newShaderPipeline(SolidVS, SolidFS, nullptr, nullptr, m_solidVtxFmt, 1, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); @@ -281,7 +281,7 @@ void View::Resources::init(boo::MetalDataFactory::Context& ctx, const IThemeData }; m_texVtxFmt = ctx.newVertexFormat(2, texvdescs); - m_texShader = ctx.newShaderPipeline(TexVS, TexFS, m_texVtxFmt, 1, + m_texShader = ctx.newShaderPipeline(TexVS, TexFS, nullptr, nullptr, m_texVtxFmt, 1, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); } @@ -369,16 +369,9 @@ void View::draw(boo::IGraphicsCommandQueue* gfxQ) } } -void View::_commitResources(ViewResources& res, const boo::FactoryCommitFunc& commitFunc) -{ - m_gfxData = res.m_factory->commitTransaction(commitFunc); -} - void View::commitResources(ViewResources& res, const boo::FactoryCommitFunc& commitFunc) { - if (m_gfxData) - Log.report(logvisor::Fatal, "multiple resource commits not allowed"); - _commitResources(res, commitFunc); + res.m_factory->commitTransaction(commitFunc); } void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ctx, @@ -389,7 +382,7 @@ void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ct auto vBufInfo = m_vertsBuf.getBufferInfo(); auto uBufInfo = viewBlockBuf.getBufferInfo(); - boo::IGraphicsBuffer* bufs[] = {uBufInfo.first}; + boo::ObjToken bufs[] = {uBufInfo.first.get()}; size_t bufOffs[] = {size_t(uBufInfo.second)}; size_t bufSizes[] = {sizeof(ViewBlock)}; @@ -397,12 +390,12 @@ void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ct { boo::VertexElementDescriptor vdescs[] = { - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4}, - {vBufInfo.first, nullptr, boo::VertexSemantic::Color} + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Color} }; m_vtxFmt = ctx.newVertexFormat(2, vdescs, vBufInfo.second); m_shaderBinding = ctx.newShaderDataBinding(res.m_viewRes.m_solidShader, - m_vtxFmt, vBufInfo.first, nullptr, + m_vtxFmt, vBufInfo.first.get(), nullptr, nullptr, 1, bufs, nullptr, bufOffs, bufSizes, 0, nullptr, nullptr, nullptr, vBufInfo.second); } @@ -410,7 +403,7 @@ void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ct { m_shaderBinding = ctx.newShaderDataBinding(res.m_viewRes.m_solidShader, res.m_viewRes.m_solidVtxFmt, - vBufInfo.first, nullptr, + vBufInfo.first.get(), nullptr, nullptr, 1, bufs, nullptr, bufOffs, bufSizes, 0, nullptr, nullptr, nullptr, vBufInfo.second); } @@ -419,27 +412,27 @@ void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ct void View::VertexBufferBindingTex::init(boo::IGraphicsDataFactory::Context& ctx, ViewResources& res, size_t count, const hecl::UniformBufferPool::Token& viewBlockBuf, - boo::ITexture* texture) + const boo::ObjToken& texture) { m_vertsBuf = res.m_viewRes.m_texPool.allocateBlock(res.m_factory, count); auto vBufInfo = m_vertsBuf.getBufferInfo(); auto uBufInfo = viewBlockBuf.getBufferInfo(); - boo::IGraphicsBuffer* bufs[] = {uBufInfo.first}; + boo::ObjToken bufs[] = {uBufInfo.first.get()}; size_t bufOffs[] = {size_t(uBufInfo.second)}; size_t bufSizes[] = {sizeof(ViewBlock)}; - boo::ITexture* tex[] = {texture}; + boo::ObjToken tex[] = {texture}; if (!res.m_viewRes.m_texVtxFmt) { boo::VertexElementDescriptor vdescs[] = { - {vBufInfo.first, nullptr, boo::VertexSemantic::Position4}, - {vBufInfo.first, nullptr, boo::VertexSemantic::UV4} + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::Position4}, + {vBufInfo.first.get(), nullptr, boo::VertexSemantic::UV4} }; m_vtxFmt = ctx.newVertexFormat(2, vdescs, vBufInfo.second); m_shaderBinding = ctx.newShaderDataBinding(res.m_viewRes.m_texShader, - m_vtxFmt, vBufInfo.first, nullptr, + m_vtxFmt, vBufInfo.first.get(), nullptr, nullptr, 1, bufs, nullptr, bufOffs, bufSizes, 1, tex, nullptr, nullptr, vBufInfo.second); } @@ -447,7 +440,7 @@ void View::VertexBufferBindingTex::init(boo::IGraphicsDataFactory::Context& ctx, { m_shaderBinding = ctx.newShaderDataBinding(res.m_viewRes.m_texShader, res.m_viewRes.m_texVtxFmt, - vBufInfo.first, nullptr, + vBufInfo.first.get(), nullptr, nullptr, 1, bufs, nullptr, bufOffs, bufSizes, 1, tex, nullptr, nullptr, vBufInfo.second); } diff --git a/specter/lib/ViewResources.cpp b/specter/lib/ViewResources.cpp index de7638c49..ea45818d9 100644 --- a/specter/lib/ViewResources.cpp +++ b/specter/lib/ViewResources.cpp @@ -17,7 +17,7 @@ void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache, m_curveFont = fcache->prepCurvesFont(factory, AllCharFilter, false, 8.f, dpi); - m_resData = factory->commitTransaction( + factory->commitTransaction( [&](boo::IGraphicsDataFactory::Context& ctx) -> bool { switch (ctx.platform()) @@ -48,6 +48,15 @@ void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache, }); } +void ViewResources::destroyResData() +{ + m_viewRes.destroy(); + m_textRes.destroy(); + m_splitRes.destroy(); + m_toolbarRes.destroy(); + m_buttonRes.destroy(); +} + void ViewResources::prepFontCacheSync() { unsigned dpi = 72.f * m_pixelFactor;