static uint64_t g_alloc_count = 0;
static uint64_t g_free_count = 0;
#endif
-
+#define MAX_TID 513
+static loader_platform_thread_id tidMapping[MAX_TID] = {0};
+static uint32_t g_maxTID = 0;
+// Map actual TID to an index value and return that index
+// This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs
+static uint32_t getTIDIndex() {
+ loader_platform_thread_id tid = loader_platform_get_thread_id();
+ for (uint32_t i = 0; i < g_maxTID; i++) {
+ if (tid == tidMapping[i])
+ return i;
+ }
+ // Don't yet have mapping, set it and return newly set index
+ uint32_t retVal = (uint32_t) g_maxTID;
+ tidMapping[g_maxTID++] = tid;
+ assert(g_maxTID < MAX_TID);
+ return retVal;
+}
// Return the size of the underlying struct based on struct type
static size_t sTypeStructSize(XGL_STRUCTURE_TYPE sType)
{
static IMAGE_NODE* g_pImageHead = NULL;
static BUFFER_NODE* g_pBufferHead = NULL;
static GLOBAL_CB_NODE* g_pCmdBufferHead = NULL;
-static XGL_CMD_BUFFER g_lastCmdBuffer = NULL;
+static XGL_CMD_BUFFER g_lastCmdBuffer[MAX_TID] = {NULL};
#define MAX_BINDING 0xFFFFFFFF // Default vtxBinding value in CB Node to identify if no vtxBinding set
static DYNAMIC_STATE_NODE* g_pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0};
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
loader_platform_thread_lock_mutex(&globalLock);
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BINDDYNAMICSTATEOBJECT);
DYNAMIC_STATE_NODE* pTrav = g_pDynamicStateHead[sType];
while (pTrav && (state != pTrav->stateObj)) {
pCB->flags = pCreateInfo->flags;
pCB->queueType = pCreateInfo->queueType;
pCB->lastVtxBinding = MAX_BINDING;
- g_lastCmdBuffer = *pCmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = *pCmdBuffer;
loader_platform_thread_unlock_mutex(&globalLock);
}
return result;
layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
loader_platform_thread_lock_mutex(&globalLock);
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
loader_platform_thread_unlock_mutex(&globalLock);
}
return result;
layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
loader_platform_thread_lock_mutex(&globalLock);
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
loader_platform_thread_unlock_mutex(&globalLock);
}
return result;
if (XGL_SUCCESS == result) {
resetCB(cmdBuffer);
loader_platform_thread_lock_mutex(&globalLock);
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
loader_platform_thread_unlock_mutex(&globalLock);
}
return result;
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BINDPIPELINE);
if (getPipeline(pipeline)) {
pCB->lastBoundPipeline = pipeline;
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
// TODO : Handle storing Pipeline Deltas to cmd buffer here
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
synchAndDumpDot(cmdBuffer);
addCmd(pCB, CMD_BINDPIPELINEDELTA);
}
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BINDDESCRIPTORSET);
if (getSetNode(descriptorSet)) {
if (dsUpdateActive(descriptorSet)) {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BINDINDEXBUFFER);
// TODO : Track idxBuffer binding
}
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BINDVERTEXBUFFER);
pCB->lastVtxBinding = binding;
}
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DRAW);
pCB->drawCount[DRAW]++;
char str[1024];
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DRAWINDEXED);
pCB->drawCount[DRAW_INDEXED]++;
char str[1024];
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DRAWINDIRECT);
pCB->drawCount[DRAW_INDIRECT]++;
char str[1024];
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DRAWINDEXEDINDIRECT);
pCB->drawCount[DRAW_INDEXED_INDIRECT]++;
char str[1024];
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DISPATCH);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_DISPATCHINDIRECT);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_COPYBUFFER);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_COPYIMAGE);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_COPYBUFFERTOIMAGE);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_COPYIMAGETOBUFFER);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_CLONEIMAGEDATA);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_UPDATEBUFFER);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_FILLBUFFER);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_CLEARCOLORIMAGE);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_CLEARCOLORIMAGERAW);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_CLEARDEPTHSTENCIL);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_RESOLVEIMAGE);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_SETEVENT);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_RESETEVENT);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_WAITEVENTS);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_PIPELINEBARRIER);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BEGINQUERY);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_ENDQUERY);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_RESETQUERYPOOL);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_WRITETIMESTAMP);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_INITATOMICCOUNTERS);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_LOADATOMICCOUNTERS);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_SAVEATOMICCOUNTERS);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_BEGINRENDERPASS);
}
else {
{
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
- g_lastCmdBuffer = cmdBuffer;
+ g_lastCmdBuffer[getTIDIndex()] = cmdBuffer;
addCmd(pCB, CMD_ENDRENDERPASS);
}
else {
void drawStateDumpDotFile(char* outFileName)
{
// TODO : Currently just setting cmdBuffer based on global var
- dumpDotFile(g_lastCmdBuffer, outFileName);
+ dumpDotFile(g_lastCmdBuffer[getTIDIndex()], outFileName);
}
void drawStateDumpPngFile(char* outFileName)
#else // WIN32
char dotExe[32] = "/usr/bin/dot";
if( access(dotExe, X_OK) != -1) {
- dumpDotFile(g_lastCmdBuffer, "/tmp/tmp.dot");
+ dumpDotFile(g_lastCmdBuffer[getTIDIndex()], "/tmp/tmp.dot");
char dotCmd[1024];
sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName);
system(dotCmd);