mirror of https://github.com/AxioDL/boo.git
OpenGL and Vulkan resource tracing
This commit is contained in:
parent
7eb10885ad
commit
578432eb2f
|
@ -72,6 +72,22 @@ namespace boo
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define __BooTraceArgs , const char* file, int line
|
||||
#define __BooTraceArgsUse , file, line
|
||||
#define __BooTraceInitializer , m_file(file), m_line(line)
|
||||
#define __BooTraceFields const char* m_file; int m_line;
|
||||
#define BooCommitTransaction(...) commitTransaction(__VA_ARGS__, __FILE__, __LINE__)
|
||||
#define BooNewPoolBuffer(...) newPoolBuffer(__VA_ARGS__, __FILE__, __LINE__)
|
||||
#else
|
||||
#define __BooTraceArgs
|
||||
#define __BooTraceArgsUse
|
||||
#define __BooTraceInitializer
|
||||
#define __BooTraceFields
|
||||
#define BooCommitTransaction(...) commitTransaction(__VA_ARGS__)
|
||||
#define BooNewPoolBuffer(...) newPoolBuffer(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
friend class GLDataFactoryImpl;
|
||||
GLDataFactory& m_parent;
|
||||
ObjToken<BaseGraphicsData> m_data;
|
||||
Context(GLDataFactory& parent);
|
||||
Context(GLDataFactory& parent __BooTraceArgs);
|
||||
~Context();
|
||||
public:
|
||||
Platform platform() const { return Platform::OpenGL; }
|
||||
|
|
|
@ -293,9 +293,9 @@ struct IGraphicsDataFactory
|
|||
}
|
||||
};
|
||||
|
||||
virtual void commitTransaction(const std::function<bool(Context& ctx)>&)=0;
|
||||
virtual void commitTransaction(const std::function<bool(Context& ctx)>& __BooTraceArgs)=0;
|
||||
|
||||
virtual ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count)=0;
|
||||
virtual ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs)=0;
|
||||
|
||||
virtual void setDisplayGamma(float gamma)=0;
|
||||
};
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
friend class VulkanDataFactoryImpl;
|
||||
VulkanDataFactory& m_parent;
|
||||
boo::ObjToken<BaseGraphicsData> m_data;
|
||||
Context(VulkanDataFactory& parent);
|
||||
Context(VulkanDataFactory& parent __BooTraceArgs);
|
||||
~Context();
|
||||
public:
|
||||
Platform platform() const {return Platform::Vulkan;}
|
||||
|
|
|
@ -43,6 +43,8 @@ struct BaseGraphicsData : ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>
|
|||
static std::unique_lock<std::recursive_mutex> _getHeadLock(GraphicsDataFactoryHead* head)
|
||||
{ return std::unique_lock<std::recursive_mutex>{head->m_dataMutex}; }
|
||||
|
||||
__BooTraceFields
|
||||
|
||||
GraphicsDataNode<IShaderPipeline, BaseGraphicsData>* m_SPs = nullptr;
|
||||
GraphicsDataNode<IShaderDataBinding, BaseGraphicsData>* m_SBinds = nullptr;
|
||||
GraphicsDataNode<IGraphicsBufferS, BaseGraphicsData>* m_SBufs = nullptr;
|
||||
|
@ -58,8 +60,8 @@ struct BaseGraphicsData : ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>
|
|||
std::unique_lock<std::recursive_mutex> destructorLock() override
|
||||
{ return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex}; }
|
||||
|
||||
explicit BaseGraphicsData(GraphicsDataFactoryHead& head)
|
||||
: ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>(&head)
|
||||
explicit BaseGraphicsData(GraphicsDataFactoryHead& head __BooTraceArgs)
|
||||
: ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -91,6 +93,8 @@ struct BaseGraphicsPool : ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>
|
|||
static std::unique_lock<std::recursive_mutex> _getHeadLock(GraphicsDataFactoryHead* head)
|
||||
{ return std::unique_lock<std::recursive_mutex>{head->m_dataMutex}; }
|
||||
|
||||
__BooTraceFields
|
||||
|
||||
GraphicsDataNode<IGraphicsBufferD, BaseGraphicsPool>* m_DBufs = nullptr;
|
||||
template<class T> GraphicsDataNode<T, BaseGraphicsPool>*& getHead();
|
||||
template<class T> size_t countForward()
|
||||
|
@ -98,8 +102,8 @@ struct BaseGraphicsPool : ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>
|
|||
std::unique_lock<std::recursive_mutex> destructorLock() override
|
||||
{ return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex}; }
|
||||
|
||||
explicit BaseGraphicsPool(GraphicsDataFactoryHead& head)
|
||||
: ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>(&head)
|
||||
explicit BaseGraphicsPool(GraphicsDataFactoryHead& head __BooTraceArgs)
|
||||
: ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class GLDataFactoryImpl : public GLDataFactory, public GraphicsDataFactoryHead
|
|||
ObjToken<IVertexFormat> m_gammaVFMT;
|
||||
void SetupGammaResources()
|
||||
{
|
||||
commitTransaction([this](IGraphicsDataFactory::Context& ctx)
|
||||
BooCommitTransaction([this](IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
const char* texNames[] = {"screenTex", "gammaLUT"};
|
||||
m_gammaShader = static_cast<Context&>(ctx).newShaderPipeline(GammaVS, GammaFS,
|
||||
|
@ -115,8 +115,8 @@ public:
|
|||
|
||||
Platform platform() const { return Platform::OpenGL; }
|
||||
const SystemChar* platformName() const { return _S("OpenGL"); }
|
||||
void commitTransaction(const FactoryCommitFunc&);
|
||||
ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count);
|
||||
void commitTransaction(const FactoryCommitFunc& trans __BooTraceArgs);
|
||||
ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs);
|
||||
void _unregisterShareableShader(uint64_t srcKey, uint64_t binKey) { m_sharedShaders.erase(srcKey); }
|
||||
|
||||
void setDisplayGamma(float gamma)
|
||||
|
@ -1084,15 +1084,15 @@ GLDataFactory::Context::newShaderDataBinding(const ObjToken<IShaderPipeline>& pi
|
|||
ubufOffs, ubufSizes, texCount, texs, texBindIdx, depthBind)};
|
||||
}
|
||||
|
||||
GLDataFactory::Context::Context(GLDataFactory& parent)
|
||||
: m_parent(parent), m_data(new BaseGraphicsData(static_cast<GLDataFactoryImpl&>(parent)))
|
||||
GLDataFactory::Context::Context(GLDataFactory& parent __BooTraceArgs)
|
||||
: m_parent(parent), m_data(new BaseGraphicsData(static_cast<GLDataFactoryImpl&>(parent) __BooTraceArgsUse))
|
||||
{}
|
||||
|
||||
GLDataFactory::Context::~Context() {}
|
||||
|
||||
void GLDataFactoryImpl::commitTransaction(const FactoryCommitFunc& trans)
|
||||
void GLDataFactoryImpl::commitTransaction(const FactoryCommitFunc& trans __BooTraceArgs)
|
||||
{
|
||||
GLDataFactory::Context ctx(*this);
|
||||
GLDataFactory::Context ctx(*this __BooTraceArgsUse);
|
||||
if (!trans(ctx))
|
||||
return;
|
||||
|
||||
|
@ -1102,9 +1102,9 @@ void GLDataFactoryImpl::commitTransaction(const FactoryCommitFunc& trans)
|
|||
//glFlush();
|
||||
}
|
||||
|
||||
ObjToken<IGraphicsBufferD> GLDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count)
|
||||
ObjToken<IGraphicsBufferD> GLDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs)
|
||||
{
|
||||
ObjToken<BaseGraphicsPool> pool(new BaseGraphicsPool(*this));
|
||||
ObjToken<BaseGraphicsPool> pool(new BaseGraphicsPool(*this __BooTraceArgsUse));
|
||||
return {new GLGraphicsBufferD<BaseGraphicsPool>(pool, use, stride * count)};
|
||||
}
|
||||
|
||||
|
@ -1888,14 +1888,14 @@ ObjToken<IVertexFormat> GLDataFactory::Context::newVertexFormat
|
|||
return {new GLVertexFormat(m_data, q, elementCount, elements, baseVert, baseInst)};
|
||||
}
|
||||
|
||||
IGraphicsCommandQueue* _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx)
|
||||
std::unique_ptr<IGraphicsCommandQueue> _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx)
|
||||
{
|
||||
return new struct GLCommandQueue(parent, glCtx);
|
||||
return std::make_unique<GLCommandQueue>(parent, glCtx);
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx)
|
||||
std::unique_ptr<IGraphicsDataFactory> _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx)
|
||||
{
|
||||
return new class GLDataFactoryImpl(parent, glCtx);
|
||||
return std::make_unique<GLDataFactoryImpl>(parent, glCtx);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class VulkanDataFactoryImpl : public VulkanDataFactory, public GraphicsDataFacto
|
|||
ObjToken<IShaderDataBinding> m_gammaBinding;
|
||||
void SetupGammaResources()
|
||||
{
|
||||
commitTransaction([this](IGraphicsDataFactory::Context& ctx)
|
||||
BooCommitTransaction([this](IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
const VertexElementDescriptor vfmt[] = {
|
||||
{nullptr, nullptr, VertexSemantic::Position4},
|
||||
|
@ -124,9 +124,9 @@ public:
|
|||
Platform platform() const {return Platform::Vulkan;}
|
||||
const SystemChar* platformName() const {return _S("Vulkan");}
|
||||
|
||||
void commitTransaction(const FactoryCommitFunc&);
|
||||
void commitTransaction(const FactoryCommitFunc& __BooTraceArgs);
|
||||
|
||||
boo::ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count);
|
||||
boo::ObjToken<IGraphicsBufferD> newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs);
|
||||
|
||||
void _unregisterShareableShader(uint64_t srcKey, uint64_t binKey)
|
||||
{
|
||||
|
@ -957,8 +957,8 @@ struct VulkanData : BaseGraphicsData
|
|||
VkDeviceMemory m_bufMem = VK_NULL_HANDLE;
|
||||
VkDeviceMemory m_texMem = VK_NULL_HANDLE;
|
||||
|
||||
explicit VulkanData(VulkanDataFactoryImpl& head)
|
||||
: BaseGraphicsData(head), m_ctx(head.m_ctx) {}
|
||||
explicit VulkanData(VulkanDataFactoryImpl& head __BooTraceArgs)
|
||||
: BaseGraphicsData(head __BooTraceArgsUse), m_ctx(head.m_ctx) {}
|
||||
~VulkanData()
|
||||
{
|
||||
if (m_bufMem)
|
||||
|
@ -972,8 +972,8 @@ struct VulkanPool : BaseGraphicsPool
|
|||
{
|
||||
VulkanContext* m_ctx;
|
||||
VkDeviceMemory m_bufMem = VK_NULL_HANDLE;
|
||||
explicit VulkanPool(VulkanDataFactoryImpl& head)
|
||||
: BaseGraphicsPool(head), m_ctx(head.m_ctx) {}
|
||||
explicit VulkanPool(VulkanDataFactoryImpl& head __BooTraceArgs)
|
||||
: BaseGraphicsPool(head __BooTraceArgsUse), m_ctx(head.m_ctx) {}
|
||||
~VulkanPool()
|
||||
{
|
||||
if (m_bufMem)
|
||||
|
@ -3736,8 +3736,8 @@ boo::ObjToken<IShaderPipeline> VulkanDataFactory::Context::newShaderPipeline
|
|||
return {retval};
|
||||
}
|
||||
|
||||
VulkanDataFactory::Context::Context(VulkanDataFactory& parent)
|
||||
: m_parent(parent), m_data(new VulkanData(static_cast<VulkanDataFactoryImpl&>(parent))) {}
|
||||
VulkanDataFactory::Context::Context(VulkanDataFactory& parent __BooTraceArgs)
|
||||
: m_parent(parent), m_data(new VulkanData(static_cast<VulkanDataFactoryImpl&>(parent) __BooTraceArgsUse)) {}
|
||||
VulkanDataFactory::Context::~Context() {}
|
||||
|
||||
boo::ObjToken<IGraphicsBufferS>
|
||||
|
@ -3820,9 +3820,9 @@ VulkanDataFactory::Context::newShaderDataBinding(
|
|||
}
|
||||
|
||||
void VulkanDataFactoryImpl::commitTransaction
|
||||
(const std::function<bool(IGraphicsDataFactory::Context&)>& trans)
|
||||
(const std::function<bool(IGraphicsDataFactory::Context&)>& trans __BooTraceArgs)
|
||||
{
|
||||
Context ctx(*this);
|
||||
Context ctx(*this __BooTraceArgsUse);
|
||||
if (!trans(ctx))
|
||||
return;
|
||||
|
||||
|
@ -3944,10 +3944,10 @@ void VulkanDataFactoryImpl::commitTransaction
|
|||
}
|
||||
|
||||
boo::ObjToken<IGraphicsBufferD>
|
||||
VulkanDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count)
|
||||
VulkanDataFactoryImpl::newPoolBuffer(BufferUse use, size_t stride, size_t count __BooTraceArgs)
|
||||
{
|
||||
VulkanCommandQueue* q = static_cast<VulkanCommandQueue*>(m_parent->getCommandQueue());
|
||||
boo::ObjToken<BaseGraphicsPool> pool(new VulkanPool(*this));
|
||||
boo::ObjToken<BaseGraphicsPool> pool(new VulkanPool(*this __BooTraceArgsUse));
|
||||
VulkanPool* cpool = pool.cast<VulkanPool>();
|
||||
VulkanGraphicsBufferD<BaseGraphicsPool>* retval =
|
||||
new VulkanGraphicsBufferD<BaseGraphicsPool>(pool, q, use, m_ctx, stride, count);
|
||||
|
@ -4112,15 +4112,15 @@ void VulkanCommandQueue::execute()
|
|||
resetDynamicCommandBuffer();
|
||||
}
|
||||
|
||||
IGraphicsCommandQueue* _NewVulkanCommandQueue(VulkanContext* ctx, VulkanContext::Window* windowCtx,
|
||||
IGraphicsContext* parent)
|
||||
std::unique_ptr<IGraphicsCommandQueue> _NewVulkanCommandQueue(VulkanContext* ctx, VulkanContext::Window* windowCtx,
|
||||
IGraphicsContext* parent)
|
||||
{
|
||||
return new struct VulkanCommandQueue(ctx, windowCtx, parent);
|
||||
return std::make_unique<VulkanCommandQueue>(ctx, windowCtx, parent);
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* _NewVulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx)
|
||||
std::unique_ptr<IGraphicsDataFactory> _NewVulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx)
|
||||
{
|
||||
return new class VulkanDataFactoryImpl(parent, ctx);
|
||||
return std::make_unique<VulkanDataFactoryImpl>(parent, ctx);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ DBusConnection* RegisterDBus(const char* appName, bool& isFirst)
|
|||
namespace boo
|
||||
{
|
||||
|
||||
IApplication* APP = NULL;
|
||||
IApplication* APP = nullptr;
|
||||
int ApplicationRun(IApplication::EPlatformType platform,
|
||||
IApplicationCallback& cb,
|
||||
std::string_view uniqueName,
|
||||
|
@ -75,7 +75,10 @@ int ApplicationRun(IApplication::EPlatformType platform,
|
|||
APP = new ApplicationXlib(cb, uniqueName, friendlyName, pname, args, gfxApi, samples, anisotropy, deepColor, singleInstance);
|
||||
else
|
||||
return 1;
|
||||
return APP->run();
|
||||
int ret = APP->run();
|
||||
delete APP;
|
||||
APP = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ class ApplicationXlib final : public IApplication
|
|||
|
||||
Display* m_xDisp = nullptr;
|
||||
XIM m_xIM = nullptr;
|
||||
XFontSet m_fontset;
|
||||
XFontSet m_fontset = nullptr;
|
||||
XIMStyle m_bestStyle = 0;
|
||||
int m_xDefaultScreen = 0;
|
||||
int m_x11Fd, m_dbusFd, m_maxFd;
|
||||
|
@ -408,6 +408,10 @@ public:
|
|||
|
||||
~ApplicationXlib()
|
||||
{
|
||||
if (m_fontset)
|
||||
XFreeFontSet(m_xDisp, m_fontset);
|
||||
if (m_xIM)
|
||||
XCloseIM(m_xIM);
|
||||
XCloseDisplay(m_xDisp);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,13 +111,13 @@ extern "C" const size_t MAINICON_NETWM_SZ;
|
|||
namespace boo
|
||||
{
|
||||
static logvisor::Module Log("boo::WindowXlib");
|
||||
IGraphicsCommandQueue* _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx);
|
||||
IGraphicsDataFactory* _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx);
|
||||
std::unique_ptr<IGraphicsCommandQueue> _NewGLCommandQueue(IGraphicsContext* parent, GLContext* glCtx);
|
||||
std::unique_ptr<IGraphicsDataFactory> _NewGLDataFactory(IGraphicsContext* parent, GLContext* glCtx);
|
||||
#if BOO_HAS_VULKAN
|
||||
IGraphicsCommandQueue* _NewVulkanCommandQueue(VulkanContext* ctx,
|
||||
VulkanContext::Window* windowCtx,
|
||||
IGraphicsContext* parent);
|
||||
IGraphicsDataFactory* _NewVulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx);
|
||||
std::unique_ptr<IGraphicsCommandQueue> _NewVulkanCommandQueue(VulkanContext* ctx,
|
||||
VulkanContext::Window* windowCtx,
|
||||
IGraphicsContext* parent);
|
||||
std::unique_ptr<IGraphicsDataFactory> _NewVulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx);
|
||||
#endif
|
||||
void _XlibUpdateLastGlxCtx(GLXContext lastGlxCtx);
|
||||
void GLXExtensionCheck();
|
||||
|
@ -321,8 +321,8 @@ struct GraphicsContextXlibGLX : GraphicsContextXlib
|
|||
GLXWindow m_glxWindow = 0;
|
||||
GLXContext m_glxCtx = 0;
|
||||
|
||||
IGraphicsCommandQueue* m_commandQueue = nullptr;
|
||||
IGraphicsDataFactory* m_dataFactory = nullptr;
|
||||
std::unique_ptr<IGraphicsDataFactory> m_dataFactory;
|
||||
std::unique_ptr<IGraphicsCommandQueue> m_commandQueue;
|
||||
GLXContext m_mainCtx = 0;
|
||||
GLXContext m_loadCtx = 0;
|
||||
|
||||
|
@ -577,12 +577,12 @@ public:
|
|||
|
||||
IGraphicsCommandQueue* getCommandQueue()
|
||||
{
|
||||
return m_commandQueue;
|
||||
return m_commandQueue.get();
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* getDataFactory()
|
||||
{
|
||||
return m_dataFactory;
|
||||
return m_dataFactory.get();
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* getMainContextDataFactory()
|
||||
|
@ -638,8 +638,8 @@ struct GraphicsContextXlibVulkan : GraphicsContextXlib
|
|||
GLXFBConfig m_fbconfig = 0;
|
||||
int m_visualid = 0;
|
||||
|
||||
IGraphicsCommandQueue* m_commandQueue = nullptr;
|
||||
IGraphicsDataFactory* m_dataFactory = nullptr;
|
||||
std::unique_ptr<IGraphicsDataFactory> m_dataFactory;
|
||||
std::unique_ptr<IGraphicsCommandQueue> m_commandQueue;
|
||||
|
||||
std::thread m_vsyncThread;
|
||||
bool m_vsyncRunning;
|
||||
|
@ -888,12 +888,12 @@ public:
|
|||
|
||||
IGraphicsCommandQueue* getCommandQueue()
|
||||
{
|
||||
return m_commandQueue;
|
||||
return m_commandQueue.get();
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* getDataFactory()
|
||||
{
|
||||
return m_dataFactory;
|
||||
return m_dataFactory.get();
|
||||
}
|
||||
|
||||
IGraphicsDataFactory* getMainContextDataFactory()
|
||||
|
|
Loading…
Reference in New Issue