mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 16:18:06 +02:00
swr: [rasterizer archrast] fix double free issue
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
parent
dc8408920c
commit
2c697754a9
9 changed files with 41 additions and 24 deletions
|
|
@ -43,8 +43,8 @@ namespace ArchRast
|
|||
EventHandlerStatsFile(uint32_t id) : EventHandlerFile(id) {}
|
||||
|
||||
// These are events that we're not interested in saving in stats event files.
|
||||
virtual void handle(Start& event) {}
|
||||
virtual void handle(End& event) {}
|
||||
virtual void Handle(Start& event) {}
|
||||
virtual void Handle(End& event) {}
|
||||
};
|
||||
|
||||
static EventManager* FromHandle(HANDLE hThreadContext)
|
||||
|
|
@ -64,7 +64,7 @@ namespace ArchRast
|
|||
|
||||
if (pManager && pHandler)
|
||||
{
|
||||
pManager->attach(pHandler);
|
||||
pManager->Attach(pHandler);
|
||||
|
||||
return pManager;
|
||||
}
|
||||
|
|
@ -82,11 +82,11 @@ namespace ArchRast
|
|||
}
|
||||
|
||||
// Dispatch event for this thread.
|
||||
void dispatch(HANDLE hThreadContext, Event& event)
|
||||
void Dispatch(HANDLE hThreadContext, Event& event)
|
||||
{
|
||||
EventManager* pManager = FromHandle(hThreadContext);
|
||||
SWR_ASSERT(pManager != nullptr);
|
||||
|
||||
pManager->dispatch(event);
|
||||
pManager->Dispatch(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ namespace ArchRast
|
|||
void DestroyThreadContext(HANDLE hThreadContext);
|
||||
|
||||
// Dispatch event for this thread.
|
||||
void dispatch(HANDLE hThreadContext, Event& event);
|
||||
void Dispatch(HANDLE hThreadContext, Event& event);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,24 +43,36 @@ namespace ArchRast
|
|||
class EventManager
|
||||
{
|
||||
public:
|
||||
void attach(EventHandler* pHandler)
|
||||
EventManager() {}
|
||||
|
||||
~EventManager()
|
||||
{
|
||||
// Event manager owns destroying handler objects once attached.
|
||||
///@note See comment for Detach.
|
||||
for (auto pHandler : mHandlers)
|
||||
{
|
||||
delete pHandler;
|
||||
}
|
||||
}
|
||||
|
||||
void Attach(EventHandler* pHandler)
|
||||
{
|
||||
mHandlers.push_back(pHandler);
|
||||
}
|
||||
|
||||
void dispatch(Event& event)
|
||||
void Dispatch(Event& event)
|
||||
{
|
||||
///@todo Add event filter check here.
|
||||
|
||||
for (auto pHandler : mHandlers)
|
||||
{
|
||||
event.accept(pHandler);
|
||||
event.Accept(pHandler);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
// Handlers stay registered for life
|
||||
void detach(EventHandler* pHandler) { SWR_ASSERT(0); }
|
||||
void Detach(EventHandler* pHandler) { SWR_ASSERT(0); }
|
||||
|
||||
std::vector<EventHandler*> mHandlers;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -394,7 +394,6 @@ void SwrDestroyContext(HANDLE hContext)
|
|||
}
|
||||
|
||||
delete[] pContext->ppScratch;
|
||||
delete[] pContext->pArContext;
|
||||
delete[] pContext->pStats;
|
||||
|
||||
delete(pContext->pHotTileMgr);
|
||||
|
|
|
|||
|
|
@ -523,9 +523,9 @@ struct SWR_CONTEXT
|
|||
#define AR_API_CTX pContext->pArContext[pContext->NumWorkerThreads]
|
||||
|
||||
#ifdef KNOB_ENABLE_AR
|
||||
#define _AR_BEGIN(ctx, type, id) ArchRast::dispatch(ctx, ArchRast::Start(ArchRast::type, id))
|
||||
#define _AR_END(ctx, type, count) ArchRast::dispatch(ctx, ArchRast::End(ArchRast::type, count))
|
||||
#define _AR_EVENT(ctx, event) ArchRast::dispatch(ctx, ArchRast::event)
|
||||
#define _AR_BEGIN(ctx, type, id) ArchRast::Dispatch(ctx, ArchRast::Start(ArchRast::type, id))
|
||||
#define _AR_END(ctx, type, count) ArchRast::Dispatch(ctx, ArchRast::End(ArchRast::type, count))
|
||||
#define _AR_EVENT(ctx, event) ArchRast::Dispatch(ctx, ArchRast::event)
|
||||
#else
|
||||
#ifdef KNOB_ENABLE_RDTSC
|
||||
#define _AR_BEGIN(ctx, type, id) (void)ctx; RDTSC_START(type)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
using namespace ArchRast;
|
||||
% for name in protos['event_names']:
|
||||
|
||||
void ${name}::accept(EventHandler* pHandler)
|
||||
void ${name}::Accept(EventHandler* pHandler)
|
||||
{
|
||||
pHandler->handle(*this);
|
||||
pHandler->Handle(*this);
|
||||
}
|
||||
% endfor
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ namespace ArchRast
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
struct Event
|
||||
{
|
||||
virtual void accept(EventHandler* pHandler) = 0;
|
||||
Event() {}
|
||||
virtual ~Event() {}
|
||||
|
||||
virtual void Accept(EventHandler* pHandler) = 0;
|
||||
};
|
||||
% for name in protos['event_names']:
|
||||
|
||||
|
|
@ -96,7 +99,7 @@ namespace ArchRast
|
|||
% endfor
|
||||
}
|
||||
|
||||
virtual void accept(EventHandler* pHandler);
|
||||
virtual void Accept(EventHandler* pHandler);
|
||||
};
|
||||
% endfor
|
||||
}
|
||||
|
|
@ -39,8 +39,11 @@ namespace ArchRast
|
|||
class EventHandler
|
||||
{
|
||||
public:
|
||||
EventHandler() {}
|
||||
virtual ~EventHandler() {}
|
||||
|
||||
% for name in protos['event_names']:
|
||||
virtual void handle(${name}& event) {}
|
||||
virtual void Handle(${name}& event) {}
|
||||
% endfor
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,12 +69,12 @@ namespace ArchRast
|
|||
#endif
|
||||
}
|
||||
|
||||
~EventHandlerFile()
|
||||
virtual ~EventHandlerFile()
|
||||
{
|
||||
if (mFile.is_open()) mFile.close();
|
||||
}
|
||||
|
||||
void write(uint32_t eventId, const char* pBlock, uint32_t size)
|
||||
void Write(uint32_t eventId, const char* pBlock, uint32_t size)
|
||||
{
|
||||
if (!mFile.is_open())
|
||||
{
|
||||
|
|
@ -86,12 +86,12 @@ namespace ArchRast
|
|||
}
|
||||
|
||||
% for name in protos['event_names']:
|
||||
virtual void handle(${name}& event)
|
||||
virtual void Handle(${name}& event)
|
||||
{
|
||||
% if protos['events'][name]['num_fields'] == 0:
|
||||
write(${protos['events'][name]['event_id']}, (char*)&event.data, 0);
|
||||
Write(${protos['events'][name]['event_id']}, (char*)&event.data, 0);
|
||||
% else:
|
||||
write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data));
|
||||
Write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data));
|
||||
%endif
|
||||
}
|
||||
% endfor
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue