Changes to support new boo object tracker API

This commit is contained in:
Jack Andersen 2017-11-04 20:16:45 -10:00
parent 43077519e1
commit 5dbdd62cae
17 changed files with 101 additions and 85 deletions

View File

@ -87,6 +87,7 @@ public:
friend class Button;
void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme);
void destroy() {}
};
~Button() {closeMenu({});}

View File

@ -58,8 +58,7 @@ class FontAtlas
{
friend class FontCache;
FT_Face m_face;
boo::ITextureSA* m_tex = nullptr;
boo::GraphicsDataToken m_token;
boo::ObjToken<boo::ITextureSA> 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<boo::ITextureSA>& texture() const {return m_tex;}
bool subpixel() const {return m_subpixel;}
const Glyph* lookupGlyph(atUint32 charcode) const

View File

@ -8,10 +8,10 @@ namespace specter
struct Icon
{
boo::ITexture* m_tex = nullptr;
boo::ObjToken<boo::ITexture> m_tex;
zeus::CVector2f m_uvCoords[4];
Icon() = default;
Icon(boo::ITexture* tex, float rect[4])
Icon(const boo::ObjToken<boo::ITexture>& tex, float rect[4])
: m_tex(tex)
{
m_uvCoords[0][0] = rect[0];
@ -31,25 +31,26 @@ struct Icon
template <size_t COLS, size_t ROWS>
class IconAtlas
{
boo::ITexture* m_tex = nullptr;
boo::ObjToken<boo::ITextureS> 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<boo::ITextureS>& tex)
{
m_tex = tex;
for (int c=0 ; c<COLS ; ++c)
for (int r=0 ; r<ROWS ; ++r)
m_icons[c][r] = MakeIcon(c, r);
}
void destroyAtlas() { m_tex.reset(); }
Icon& getIcon(size_t c, size_t r) {return m_icons[c][r];}
};

View File

@ -60,8 +60,6 @@ private:
m_vertsBinding.load<decltype(_m_verts)>(_m_verts);
}
boo::GraphicsDataToken m_windowGfxData;
std::unique_ptr<TextView> m_cornersOutline[4];
std::unique_ptr<TextView> m_cornersFilled[4];

View File

@ -19,7 +19,7 @@ namespace specter
class RootView : public View
{
boo::IWindow* m_window = nullptr;
boo::ITextureR* m_renderTex = nullptr;
boo::ObjToken<boo::ITextureR> 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<boo::ITextureR>& renderTex() const {return m_renderTex;}
std::vector<View*>& accessContentViews() {return m_views;}

View File

@ -16,9 +16,10 @@ public:
{
friend class ViewResources;
friend class SplitView;
boo::ITextureS* m_shadingTex;
boo::ObjToken<boo::ITextureS> m_shadingTex;
void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme);
void destroy() { m_shadingTex.reset(); }
};
enum class ArrowDir

View File

@ -61,8 +61,8 @@ public:
private:
size_t m_capacity;
hecl::VertexBufferPool<RenderGlyph>::Token m_glyphBuf;
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_shaderBinding;
boo::ObjToken<boo::IVertexFormat> m_vtxFmt; /* OpenGL only */
boo::ObjToken<boo::IShaderDataBinding> 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<boo::IShaderPipeline> m_regular;
boo::ObjToken<boo::IShaderPipeline> m_subpixel;
boo::ObjToken<boo::IVertexFormat> 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);

View File

@ -14,9 +14,10 @@ public:
{
friend class ViewResources;
friend class Toolbar;
boo::ITextureS* m_shadingTex;
boo::ObjToken<boo::ITextureS> m_shadingTex;
void init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme);
void destroy() { m_shadingTex.reset(); }
};
enum class Position

View File

@ -111,8 +111,8 @@ public:
struct VertexBufferBinding
{
typename hecl::VertexBufferPool<VertStruct>::Token m_vertsBuf;
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_shaderBinding = nullptr;
boo::ObjToken<boo::IVertexFormat> m_vtxFmt; /* OpenGL only */
boo::ObjToken<boo::IShaderDataBinding> 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<boo::IShaderDataBinding>&() { return m_shaderBinding; }
};
struct VertexBufferBindingSolid : VertexBufferBinding<SolidShaderVert>
{
@ -150,7 +150,7 @@ public:
void init(boo::IGraphicsDataFactory::Context& ctx,
ViewResources& res, size_t count,
const hecl::UniformBufferPool<ViewBlock>::Token& viewBlockBuf,
boo::ITexture* texture);
const boo::ObjToken<boo::ITexture>& 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<boo::IShaderPipeline> m_solidShader;
boo::ObjToken<boo::IVertexFormat> m_solidVtxFmt; /* Not OpenGL */
boo::IShaderPipeline* m_texShader = nullptr;
boo::IVertexFormat* m_texVtxFmt = nullptr; /* Not OpenGL */
boo::ObjToken<boo::IShaderPipeline> m_texShader;
boo::ObjToken<boo::IVertexFormat> 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:

View File

@ -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;}

View File

@ -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,

View File

@ -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);

View File

@ -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;
});
}

View File

@ -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<boo::IShaderPipeline> 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<boo::IGraphicsBuffer> uBufs[] = {uBufInfo.first.get()};
size_t uBufOffs[] = {size_t(uBufInfo.second)};
size_t uBufSizes[] = {sizeof(ViewBlock)};
boo::ITexture* texs[] = {m_fontAtlas.texture()};
boo::ObjToken<boo::ITexture> 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);
}

View File

@ -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());

View File

@ -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<boo::IGraphicsBuffer> 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<ViewBlock>::Token& viewBlockBuf,
boo::ITexture* texture)
const boo::ObjToken<boo::ITexture>& 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<boo::IGraphicsBuffer> bufs[] = {uBufInfo.first.get()};
size_t bufOffs[] = {size_t(uBufInfo.second)};
size_t bufSizes[] = {sizeof(ViewBlock)};
boo::ITexture* tex[] = {texture};
boo::ObjToken<boo::ITexture> 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);
}

View File

@ -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;