mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 15:20:17 +01:00
swr/rast: Refactor api and worker event handlers.
In the API event handler we want to share information between the core layer and the API. Specifically, around associating various ids with different kinds of events. For example, associate render pass id with draw ids, or command buffer ids with draw ids. Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
parent
cfdd35beaf
commit
714093203e
2 changed files with 52 additions and 35 deletions
|
|
@ -74,12 +74,52 @@ namespace ArchRast
|
|||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Event handler that saves stat events to event files. This
|
||||
/// handler filters out unwanted events.
|
||||
class EventHandlerStatsFile : public EventHandlerFile
|
||||
/// @brief Event handler that handles API thread events. This is shared
|
||||
/// between the API and its caller (e.g. driver shim) but typically
|
||||
/// there is only a single API thread per context. So you can save
|
||||
/// information in the class to be used for other events.
|
||||
class EventHandlerApiStats : public EventHandlerFile
|
||||
{
|
||||
public:
|
||||
EventHandlerStatsFile(uint32_t id) : EventHandlerFile(id), mNeedFlush(false) {}
|
||||
EventHandlerApiStats(uint32_t id) : EventHandlerFile(id) {}
|
||||
|
||||
virtual void Handle(const DrawInstancedEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::Instanced, event.data.topology, event.data.numVertices, 0, 0, event.data.startVertex, event.data.numInstances, event.data.startInstance);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawIndexedInstancedEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::IndexedInstanced, event.data.topology, 0, event.data.numIndices, event.data.indexOffset, event.data.baseVertex, event.data.numInstances, event.data.startInstance);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawInstancedSplitEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::InstancedSplit, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawIndexedInstancedSplitEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::IndexedInstancedSplit, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Event handler that handles worker thread events. There is one
|
||||
/// event handler per thread. The python script will need to sum
|
||||
/// up counters across all of the threads.
|
||||
class EventHandlerWorkerStats : public EventHandlerFile
|
||||
{
|
||||
public:
|
||||
EventHandlerWorkerStats(uint32_t id) : EventHandlerFile(id), mNeedFlush(false) {}
|
||||
|
||||
virtual void Handle(const EarlyDepthStencilInfoSingleSample& event)
|
||||
{
|
||||
|
|
@ -215,34 +255,6 @@ namespace ArchRast
|
|||
mClipper.trivialAcceptCount += _mm_popcnt_u32(event.data.validMask & ~event.data.clipMask);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawInstancedEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::Instanced, event.data.topology, event.data.numVertices, 0, 0, event.data.startVertex, event.data.numInstances, event.data.startInstance);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawIndexedInstancedEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::IndexedInstanced, event.data.topology, 0, event.data.numIndices, event.data.indexOffset, event.data.baseVertex, event.data.numInstances, event.data.startInstance);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawInstancedSplitEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::InstancedSplit, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
virtual void Handle(const DrawIndexedInstancedSplitEvent& event)
|
||||
{
|
||||
DrawInfoEvent e(event.data.drawId, ArchRast::IndexedInstancedSplit, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
EventHandlerFile::Handle(e);
|
||||
}
|
||||
|
||||
// Flush cached events for this draw
|
||||
virtual void FlushDraw(uint32_t drawId)
|
||||
{
|
||||
|
|
@ -354,20 +366,24 @@ namespace ArchRast
|
|||
uint32_t id = counter.fetch_add(1);
|
||||
|
||||
EventManager* pManager = new EventManager();
|
||||
EventHandlerFile* pHandler = new EventHandlerStatsFile(id);
|
||||
|
||||
if (pManager && pHandler)
|
||||
if (pManager)
|
||||
{
|
||||
pManager->Attach(pHandler);
|
||||
EventHandlerFile* pHandler = nullptr;
|
||||
|
||||
if (type == AR_THREAD::API)
|
||||
{
|
||||
pHandler = new EventHandlerApiStats(id);
|
||||
pManager->Attach(pHandler);
|
||||
pHandler->Handle(ThreadStartApiEvent());
|
||||
}
|
||||
else
|
||||
{
|
||||
pHandler = new EventHandlerWorkerStats(id);
|
||||
pManager->Attach(pHandler);
|
||||
pHandler->Handle(ThreadStartWorkerEvent());
|
||||
}
|
||||
|
||||
pHandler->MarkHeader();
|
||||
|
||||
return pManager;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ namespace ArchRast
|
|||
|
||||
void Attach(EventHandler* pHandler)
|
||||
{
|
||||
SWR_ASSERT(pHandler != nullptr);
|
||||
mHandlers.push_back(pHandler);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue