/****************************************************************************
-* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
+* Copyright (C) 2014-2016 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
// initialize function pointer tables
InitClearTilesTable();
- // initialize store tiles function
+ // initialize callback functions
pContext->pfnLoadTile = pCreateInfo->pfnLoadTile;
pContext->pfnStoreTile = pCreateInfo->pfnStoreTile;
pContext->pfnClearTile = pCreateInfo->pfnClearTile;
+ pContext->pfnUpdateSoWriteOffset = pCreateInfo->pfnUpdateSoWriteOffset;
// pass pointer to bucket manager back to caller
#ifdef KNOB_ENABLE_RDTSC
pCurDrawContext->threadsDone = 0;
pCurDrawContext->retireCallback.pfnCallbackFunc = nullptr;
+ memset(&pCurDrawContext->dynState, 0, sizeof(pCurDrawContext->dynState));
+
// Assign unique drawId for this DC
pCurDrawContext->drawId = pContext->dcRing.GetHead();
/****************************************************************************
-* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
+* Copyright (C) 2014-2016 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex, uint8_t *pSrcHotTile);
+//////////////////////////////////////////////////////////////////////////
/// @brief Function signature for clearing from the hot tiles clear value
/// @param hPrivateContext - handle to private data
/// @param renderTargetIndex - render target to store, can be color, depth or stencil
SWR_RENDERTARGET_ATTACHMENT rtIndex,
uint32_t x, uint32_t y, const float* pClearColor);
+//////////////////////////////////////////////////////////////////////////
+/// @brief Callback to allow driver to update their copy of streamout write offset.
+/// This is call is made for any draw operation that has streamout enabled
+/// and has updated the write offset.
+/// @param hPrivateContext - handle to private data
+/// @param soBufferSlot - buffer slot for write offset
+/// @param soWriteOffset - update value for so write offset.
+typedef void(SWR_API *PFN_UPDATE_SO_WRITE_OFFSET)(HANDLE hPrivateContext,
+ uint32_t soBufferSlot, uint32_t soWriteOffset);
+
class BucketManager;
//////////////////////////////////////////////////////////////////////////
// Use SwrGetPrivateContextState() to access private state.
uint32_t privateStateSize;
- // Tile manipulation functions
+ // Callback functions
PFN_LOAD_TILE pfnLoadTile;
PFN_STORE_TILE pfnStoreTile;
PFN_CLEAR_TILE pfnClearTile;
+ PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset;
// Pointer to rdtsc buckets mgr returned to the caller.
// Only populated when KNOB_ENABLE_RDTSC is set
for (uint32_t stream = 0; stream < MAX_SO_STREAMS; ++stream)
{
- pStats->SoWriteOffset[stream] += pContext->stats[i].SoWriteOffset[stream];
-
- /// @note client is required to provide valid write offset before every draw, so we clear
- /// out the contents of the write offset when storing stats
- pContext->stats[i].SoWriteOffset[stream] = 0;
-
pStats->SoPrimStorageNeeded[stream] += pContext->stats[i].SoPrimStorageNeeded[stream];
pStats->SoNumPrimsWritten[stream] += pContext->stats[i].SoNumPrimsWritten[stream];
}
/****************************************************************************
-* Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
+* Copyright (C) 2014-2016 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
CachingArena* pArena; // This should only be used by API thread.
};
+struct DRAW_DYNAMIC_STATE
+{
+ ///@todo Currently assumes only a single FE can do stream output for a draw.
+ uint32_t SoWriteOffset[4];
+ bool SoWriteOffsetDirty[4];
+};
+
// Draw Context
// The api thread sets up a draw context that exists for the life of the draw.
// This draw context maintains all of the state needed for the draw operation.
MacroTileMgr* pTileMgr;
DispatchQueue* pDispatch; // Queue for thread groups. (isCompute)
};
- DRAW_STATE* pState;
+ DRAW_STATE* pState; // Read-only state. Core should not update this outside of API thread.
+ DRAW_DYNAMIC_STATE dynState;
+
CachingArena* pArena;
uint32_t drawId;
HotTileMgr *pHotTileMgr;
- // tile load/store functions, passed in at create context time
+ // Callback functions, passed in at create context time
PFN_LOAD_TILE pfnLoadTile;
PFN_STORE_TILE pfnStoreTile;
PFN_CLEAR_TILE pfnClearTile;
+ PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset;
// Global Stats
SWR_STATS stats[KNOB_MAX_NUM_THREADS];
void WakeAllThreads(SWR_CONTEXT *pContext);
#define UPDATE_STAT(name, count) if (GetApiState(pDC).enableStats) { pContext->stats[workerId].name += count; }
-#define SET_STAT(name, count) if (GetApiState(pDC).enableStats) { pContext->stats[workerId].name = count; }
if (state.soBuffer[i].pWriteOffset)
{
*state.soBuffer[i].pWriteOffset = soContext.pBuffer[i]->streamOffset * sizeof(uint32_t);
+ }
- // The SOS increments the existing write offset. So we don't want to increment
- // the SoWriteOffset stat using an absolute offset instead of relative.
- SET_STAT(SoWriteOffset[i], soContext.pBuffer[i]->streamOffset);
+ if (state.soBuffer[i].soWriteEnable)
+ {
+ pDC->dynState.SoWriteOffset[i] = soContext.pBuffer[i]->streamOffset * sizeof(uint32_t);
+ pDC->dynState.SoWriteOffsetDirty[i] = true;
}
}
if (HasStreamOutT::value)
{
pSoPrimData = (uint32_t*)pDC->pArena->AllocAligned(4096, 16);
-
- // update the
- for (uint32_t i = 0; i < 4; ++i)
- {
- SET_STAT(SoWriteOffset[i], state.soBuffer[i].streamOffset);
- }
-
}
// choose primitive assembler
uint64_t GsPrimitives; // Number of prims GS outputs.
// Streamout Stats
- uint32_t SoWriteOffset[4];
uint64_t SoPrimStorageNeeded[4];
uint64_t SoNumPrimsWritten[4];
};
/////////////////////////////////////////////////////////////////////////
#define MAX_SO_STREAMS 4
+#define MAX_SO_BUFFERS 4
#define MAX_ATTRIBUTES 32
struct SWR_STREAMOUT_BUFFER
{
bool enable;
+ bool soWriteEnable;
// Pointers to streamout buffers.
uint32_t* pBuffer;
return pDC->dependent && IDComparesLess(lastRetiredDraw, pDC->drawId - 1);
}
+INLINE void ExecuteCallbacks(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
+{
+ if (pContext->pfnUpdateSoWriteOffset)
+ {
+ for (uint32_t i = 0; i < MAX_SO_BUFFERS; ++i)
+ {
+ if ((pDC->dynState.SoWriteOffsetDirty[i]) &&
+ (pDC->pState->state.soBuffer[i].soWriteEnable))
+ {
+ pContext->pfnUpdateSoWriteOffset(GetPrivateState(pDC), i, pDC->dynState.SoWriteOffset[i]);
+ }
+ }
+ }
+
+ if (pDC->retireCallback.pfnCallbackFunc)
+ {
+ pDC->retireCallback.pfnCallbackFunc(pDC->retireCallback.userData,
+ pDC->retireCallback.userData2,
+ pDC->retireCallback.userData3);
+ }
+}
+
// inlined-only version
INLINE int64_t CompleteDrawContextInl(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
{
if (result == 0)
{
- if (pDC->retireCallback.pfnCallbackFunc)
- {
- pDC->retireCallback.pfnCallbackFunc(pDC->retireCallback.userData,
- pDC->retireCallback.userData2,
- pDC->retireCallback.userData3);
- }
+ ExecuteCallbacks(pContext, pDC);
// Cleanup memory allocations
pDC->pArena->Reset(true);
new std::unordered_map<BLEND_COMPILE_STATE, PFN_BLEND_JIT_FUNC>;
SWR_CREATECONTEXT_INFO createInfo;
+ memset(&createInfo, 0, sizeof(createInfo));
createInfo.driver = GL;
createInfo.privateStateSize = sizeof(swr_draw_context);
createInfo.pfnLoadTile = swr_LoadHotTile;