Buffer pool refactor

This commit is contained in:
Jack Andersen 2017-01-28 17:57:48 -10:00
parent 49e4446d4b
commit d618264e26
24 changed files with 56 additions and 56 deletions

View File

@ -122,7 +122,7 @@ public:
View::setMultiplyColor(color);
m_viewVertBlock.m_color = color;
if (m_viewVertBlockBuf)
m_viewVertBlockBuf->access() = m_viewVertBlock;
m_viewVertBlockBuf.access() = m_viewVertBlock;
m_text->setMultiplyColor(color);
if (m_icon)
m_icon->setMultiplyColor(color);

View File

@ -36,7 +36,7 @@ private:
zeus::CColor m_line2Clear;
ViewBlock m_viewBlock;
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_viewBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_viewBlockBuf;
union
{
struct

View File

@ -56,7 +56,7 @@ class RootView : public View
VertexBufferBindingSolid m_vertsBinding;
ViewBlock m_viewBlock;
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_viewVertBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_viewVertBlockBuf;
SolidShaderVert m_verts[32];
void setArrowVerts(const boo::SWindowRect& rect, SplitView::ArrowDir dir);
void setLineVerts(const boo::SWindowRect& rect, float split, SplitView::Axis axis);

View File

@ -43,7 +43,7 @@ private:
ViewChild<View*> m_views[2];
ViewBlock m_splitBlock;
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_splitBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_splitBlockBuf;
TexShaderVert m_splitVerts[4];
int m_clearanceA, m_clearanceB;
@ -104,7 +104,7 @@ public:
{
View::setMultiplyColor(color);
m_splitBlock.m_color = color;
m_splitBlockBuf->access() = m_splitBlock;
m_splitBlockBuf.access() = m_splitBlock;
if (m_views[0].m_view)
m_views[0].m_view->setMultiplyColor(color);

View File

@ -118,7 +118,7 @@ public:
View::setMultiplyColor(color);
m_viewVertBlock.m_color = color;
if (m_viewVertBlockBuf)
m_viewVertBlockBuf->access() = m_viewVertBlock;
m_viewVertBlockBuf.access() = m_viewVertBlock;
m_text->setMultiplyColor(color);
if (m_errText)
m_errText->setMultiplyColor(color);

View File

@ -44,7 +44,7 @@ public:
private:
size_t m_capacity;
std::experimental::optional<hecl::VertexBufferPool<RenderGlyph>::Token> m_glyphBuf;
hecl::VertexBufferPool<RenderGlyph>::Token m_glyphBuf;
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_shaderBinding;
const FontAtlas& m_fontAtlas;

View File

@ -31,7 +31,7 @@ private:
std::vector<std::vector<ViewChild<View*>>> m_children;
ViewBlock m_tbBlock;
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_tbBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_tbBlockBuf;
TexShaderVert m_tbVerts[10];
int m_nomGauge = 25;
int m_padding = 10;

View File

@ -10,7 +10,7 @@ namespace specter
class Tooltip : public View
{
ViewBlock m_ttBlock;
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_ttBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_ttBlockBuf;
SolidShaderVert m_ttVerts[16];
int m_nomWidth = 25;
int m_nomHeight = 25;

View File

@ -110,7 +110,7 @@ public:
template <typename VertStruct>
struct VertexBufferBinding
{
std::experimental::optional<typename hecl::VertexBufferPool<VertStruct>::Token> m_vertsBuf;
typename hecl::VertexBufferPool<VertStruct>::Token m_vertsBuf;
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_shaderBinding = nullptr;
@ -118,7 +118,7 @@ public:
{
if (m_vertsBuf)
{
VertStruct* out = m_vertsBuf->access();
VertStruct* out = m_vertsBuf.access();
for (size_t i=0; i<count; ++i)
out[i] = data[i];
}
@ -131,7 +131,7 @@ public:
if (m_vertsBuf)
{
constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct);
VertStruct* out = m_vertsBuf->access();
VertStruct* out = m_vertsBuf.access();
for (size_t i=0; i<count; ++i)
out[i] = data[i];
}
@ -184,7 +184,7 @@ protected:
" float4x4 mv;\n"\
" float4 mulColor;\n"\
"};\n"
std::experimental::optional<hecl::UniformBufferPool<ViewBlock>::Token> m_viewVertBlockBuf;
hecl::UniformBufferPool<ViewBlock>::Token m_viewVertBlockBuf;
public:
struct Resources
@ -249,7 +249,7 @@ public:
{
m_viewVertBlock.m_color = color;
if (m_viewVertBlockBuf)
m_viewVertBlockBuf->access() = m_viewVertBlock;
m_viewVertBlockBuf.access() = m_viewVertBlock;
}
virtual int nominalWidth() const {return 0;}

View File

@ -25,7 +25,7 @@ Button::Button(ViewResources& res, View& parentView,
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, 40, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, 40, m_viewVertBlockBuf);
return true;
});

View File

@ -394,7 +394,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_tex =
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1,
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1,
boo::TextureFormat::RGBA8, texmap.get(), bufSz);
return true;
});
@ -479,7 +479,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_tex =
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1,
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1,
boo::TextureFormat::I8, texmap.get(), bufSz);
return true;
});
@ -603,7 +603,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_tex =
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1,
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1,
boo::TextureFormat::RGBA8, texmap.get(), bufSz);
return false;
});
@ -688,7 +688,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
m_token = gf->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
m_tex =
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1,
ctx.newStaticArrayTexture(TEXMAP_DIM, finalHeight, fullTexmapLayers + 1, 1,
boo::TextureFormat::I8, texmap.get(), bufSz);
return true;
});

View File

@ -10,7 +10,7 @@ IconView::IconView(ViewResources& res, View& parentView, Icon& icon)
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertexBinding.init(ctx, res, 4, *m_viewVertBlockBuf, icon.m_tex);
m_vertexBinding.init(ctx, res, 4, m_viewVertBlockBuf, icon.m_tex);
return true;
});
TexShaderVert verts[] =

View File

@ -14,7 +14,7 @@ Menu::Menu(ViewResources& res, View& parentView, IMenuNode* rootNode)
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, 8, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, 8, m_viewVertBlockBuf);
return true;
});
m_headText.reset(new TextView(res, *this, res.m_mainFont));
@ -75,7 +75,7 @@ Menu::Menu(ViewResources& res, View& parentView, IMenuNode* rootNode, IMenuNode*
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, 8, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, 8, m_viewVertBlockBuf);
return true;
});
m_headText.reset(new TextView(res, *this, res.m_mainFont));
@ -90,7 +90,7 @@ Menu::ContentView::ContentView(ViewResources& res, Menu& menu)
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_hlVertsBinding.init(ctx, res, 4, *m_viewVertBlockBuf);
m_hlVertsBinding.init(ctx, res, 4, m_viewVertBlockBuf);
return true;
});

View File

@ -295,8 +295,8 @@ ModalWindow::ModalWindow(ViewResources& res, View& parentView,
m_windowGfxData = res.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_viewBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_vertsBinding.init(ctx, res, 38, *m_viewBlockBuf);
m_viewBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_vertsBinding.init(ctx, res, 38, m_viewBlockBuf);
return true;
});
@ -453,7 +453,7 @@ void ModalWindow::resized(const boo::SWindowRect& root, const boo::SWindowRect&
centerRect.location[1] = root.size[1] / 2 - m_height / 2.0;
View::resized(root, centerRect);
m_viewBlock.setViewRect(root, centerRect);
m_viewBlockBuf->access() = m_viewBlock;
m_viewBlockBuf.access() = m_viewBlock;
setLineVerts(m_width, m_height, pf, m_lineTime);
setFillVerts(m_width, m_height, pf);

View File

@ -27,8 +27,8 @@ RootView::SplitMenuSystem::SplitMenuSystem(RootView& rv, boo::IGraphicsDataFacto
m_splitActionNode(*this), m_joinActionNode(*this)
{
ViewResources& res = *rv.m_viewRes;
m_viewVertBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_vertsBinding.init(ctx, res, 32, *m_viewVertBlockBuf);
m_viewVertBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_vertsBinding.init(ctx, res, 32, m_viewVertBlockBuf);
zeus::CColor col = {0.0,0.0,0.0,0.5};
for (int i=0 ; i<32 ; ++i)
@ -106,7 +106,7 @@ void RootView::SplitMenuSystem::setArrowVerts(const boo::SWindowRect& rect, Spli
m_viewBlock.m_mv[3][1] = 2.0f * (rect.location[1] + (dir == SplitView::ArrowDir::Down ? rect.size[1] : 0)) /
float(root.size[1]) - 1.0f;
}
m_viewVertBlockBuf->access() = m_viewBlock;
m_viewVertBlockBuf.access() = m_viewBlock;
}
void RootView::SplitMenuSystem::setLineVerts(const boo::SWindowRect& rect, float split, SplitView::Axis axis)
@ -130,7 +130,7 @@ void RootView::SplitMenuSystem::setLineVerts(const boo::SWindowRect& rect, float
m_viewBlock.m_mv[3][0] = (rect.location[0] + split * rect.size[0]) * m_viewBlock.m_mv[0][0] - 1.0f;
m_viewBlock.m_mv[3][1] = 2.0f * (rect.location[1] + rect.size[1] / 2.0f) / float(root.size[1]) - 1.0f;
}
m_viewVertBlockBuf->access() = m_viewBlock;
m_viewVertBlockBuf.access() = m_viewBlock;
}
void RootView::destroyed()

View File

@ -13,7 +13,7 @@ ScrollView::ScrollView(ViewResources& res, View& parentView, Style style)
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, 4, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, 4, m_viewVertBlockBuf);
return true;
});

View File

@ -40,7 +40,7 @@ Space::CornerView::CornerView(ViewResources& res, Space& space, const zeus::CCol
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertexBinding.init(ctx, res, 34, *m_viewVertBlockBuf);
m_vertexBinding.init(ctx, res, 34, m_viewVertBlockBuf);
return true;
});
float pf = res.pixelFactor();

View File

@ -28,8 +28,8 @@ SplitView::SplitView(ViewResources& res, View& parentView, ISplitSpaceController
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_splitBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_splitVertsBinding.init(ctx, res, 4, *m_splitBlockBuf, res.m_splitRes.m_shadingTex);
m_splitBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_splitVertsBinding.init(ctx, res, 4, m_splitBlockBuf, res.m_splitRes.m_shadingTex);
return true;
});
}
@ -476,7 +476,7 @@ void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& su
m_splitBlock.setViewRect(root, ssub);
setVerticalVerts(ssub.size[1]);
}
m_splitBlockBuf->access() = m_splitBlock;
m_splitBlockBuf.access() = m_splitBlock;
m_splitVertsBinding.load<decltype(m_splitVerts)>(m_splitVerts);
}

View File

@ -22,7 +22,7 @@ Table::Table(ViewResources& res, View& parentView, ITableDataBinding* data,
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, maxColumns * 6, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, maxColumns * 6, m_viewVertBlockBuf);
return true;
});
m_scroll.m_view->setContentView(&m_rowsView);
@ -36,7 +36,7 @@ Table::RowsView::RowsView(Table& t, ViewResources& res)
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, SPECTER_TABLE_MAX_ROWS * t.m_maxColumns * 6, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, SPECTER_TABLE_MAX_ROWS * t.m_maxColumns * 6, m_viewVertBlockBuf);
return true;
});
}

View File

@ -11,7 +11,7 @@ TextField::TextField(ViewResources& res, View& parentView, IStringBinding* strBi
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_vertsBinding.init(ctx, res, 41, *m_viewVertBlockBuf);
m_vertsBinding.init(ctx, res, 41, m_viewVertBlockBuf);
return true;
});

View File

@ -306,7 +306,7 @@ void TextView::_commitResources(size_t capacity)
if (capacity)
{
m_glyphBuf.emplace(res.m_textRes.m_glyphPool.allocateBlock(res.m_factory, capacity));
m_glyphBuf = res.m_textRes.m_glyphPool.allocateBlock(res.m_factory, capacity);
boo::IShaderPipeline* shader;
if (m_fontAtlas.subpixel())
@ -314,8 +314,8 @@ void TextView::_commitResources(size_t capacity)
else
shader = res.m_textRes.m_regular;
auto vBufInfo = m_glyphBuf->getBufferInfo();
auto uBufInfo = m_viewVertBlockBuf->getBufferInfo();
auto vBufInfo = m_glyphBuf.getBufferInfo();
auto uBufInfo = m_viewVertBlockBuf.getBufferInfo();
boo::IGraphicsBuffer* uBufs[] = {uBufInfo.first};
size_t uBufOffs[] = {size_t(uBufInfo.second)};
size_t uBufSizes[] = {sizeof(ViewBlock)};
@ -550,7 +550,7 @@ void TextView::invalidateGlyphs()
{
if (m_glyphBuf)
{
RenderGlyph* out = m_glyphBuf->access();
RenderGlyph* out = m_glyphBuf.access();
size_t i = 0;
for (RenderGlyph& glyph : m_glyphs)
out[i++] = glyph;

View File

@ -33,8 +33,8 @@ Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_tbBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_vertsBinding.init(ctx, res, 10, *m_tbBlockBuf, res.m_toolbarRes.m_shadingTex);
m_tbBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_vertsBinding.init(ctx, res, 10, m_tbBlockBuf, res.m_toolbarRes.m_shadingTex);
return true;
});
setBackground(res.themeData().toolbarBackground());
@ -140,7 +140,7 @@ void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
setHorizontalVerts(sub.size[0]);
m_vertsBinding.load<decltype(m_tbVerts)>(m_tbVerts);
m_tbBlock.setViewRect(root, sub);
m_tbBlockBuf->access() = m_tbBlock;
m_tbBlockBuf.access() = m_tbBlock;
float gaugeUnit = rootView().viewRes().pixelFactor() * SPECTER_TOOLBAR_GAUGE;
float yOff = 0.0;

View File

@ -18,8 +18,8 @@ Tooltip::Tooltip(ViewResources& res, View& parentView, const std::string& title,
commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
buildResources(ctx, res);
m_ttBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_vertsBinding.init(ctx, res, 16, *m_ttBlockBuf);
m_ttBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_vertsBinding.init(ctx, res, 16, m_ttBlockBuf);
return true;
});
@ -84,7 +84,7 @@ void Tooltip::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
float pf = rootView().viewRes().pixelFactor();
setVerts(m_nomWidth, m_nomHeight, pf);
m_ttBlock.setViewRect(root, sub);
m_ttBlockBuf->access() = m_ttBlock;
m_ttBlockBuf.access() = m_ttBlock;
std::pair<int,int> margin = m_cornersFilled[0]->queryGlyphDimensions(0);

View File

@ -322,8 +322,8 @@ void View::Resources::init(boo::VulkanDataFactory::Context& ctx, const IThemeDat
void View::buildResources(boo::IGraphicsDataFactory::Context& ctx, ViewResources& res)
{
m_viewVertBlockBuf.emplace(res.m_viewRes.m_bufPool.allocateBlock(res.m_factory));
m_bgVertsBinding.init(ctx, res, 4, *m_viewVertBlockBuf);
m_viewVertBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory);
m_bgVertsBinding.init(ctx, res, 4, m_viewVertBlockBuf);
}
View::View(ViewResources& res)
@ -348,7 +348,7 @@ void View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
m_bgRect[2].m_pos.assign(sub.size[0], sub.size[1], 0.f);
m_bgRect[3].m_pos.assign(sub.size[0], 0.f, 0.f);
if (m_viewVertBlockBuf)
m_viewVertBlockBuf->access() = m_viewVertBlock;
m_viewVertBlockBuf.access() = m_viewVertBlock;
m_bgVertsBinding.load<decltype(m_bgRect)>(m_bgRect);
}
@ -360,7 +360,7 @@ void View::resized(const ViewBlock& vb, const boo::SWindowRect& sub)
m_bgRect[2].m_pos.assign(sub.size[0], sub.size[1], 0.f);
m_bgRect[3].m_pos.assign(sub.size[0], 0.f, 0.f);
if (m_viewVertBlockBuf)
m_viewVertBlockBuf->access() = vb;
m_viewVertBlockBuf.access() = vb;
m_bgVertsBinding.load<decltype(m_bgRect)>(m_bgRect);
}
@ -389,8 +389,8 @@ void View::VertexBufferBindingSolid::init(boo::IGraphicsDataFactory::Context& ct
ViewResources& res, size_t count,
const hecl::UniformBufferPool<ViewBlock>::Token& viewBlockBuf)
{
m_vertsBuf.emplace(res.m_viewRes.m_solidPool.allocateBlock(res.m_factory, count));
auto vBufInfo = m_vertsBuf->getBufferInfo();
m_vertsBuf = res.m_viewRes.m_solidPool.allocateBlock(res.m_factory, count);
auto vBufInfo = m_vertsBuf.getBufferInfo();
auto uBufInfo = viewBlockBuf.getBufferInfo();
boo::IGraphicsBuffer* bufs[] = {uBufInfo.first};
@ -425,8 +425,8 @@ void View::VertexBufferBindingTex::init(boo::IGraphicsDataFactory::Context& ctx,
const hecl::UniformBufferPool<ViewBlock>::Token& viewBlockBuf,
boo::ITexture* texture)
{
m_vertsBuf.emplace(res.m_viewRes.m_texPool.allocateBlock(res.m_factory, count));
auto vBufInfo = m_vertsBuf->getBufferInfo();
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};