1 /****************************************************************************
2 * Copyright (C) 2014-2018 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * @brief Definitions for SWR threading model.
27 ******************************************************************************/
32 #include <unordered_set>
34 typedef std::thread
* THREAD_PTR
;
38 struct SWR_WORKER_PRIVATE_STATE
;
42 void* pWorkerPrivateData
; // Pointer to per-worker private data
43 uint32_t procGroupId
; // Will always be 0 for non-Windows OS
44 uint32_t threadId
; // within the procGroup for Windows
45 uint32_t numaId
; // NUMA node id
46 uint32_t coreId
; // Core id
47 uint32_t htId
; // Hyperthread id
48 uint32_t workerId
; // index of worker in total thread data
49 void* clipperData
; // pointer to hang clipper-private data on
50 SWR_CONTEXT
* pContext
;
51 bool forceBindProcGroup
; // Only useful when MAX_WORKER_THREADS is set.
59 THREAD_DATA
* pThreadData
;
60 void* pWorkerPrivateDataArray
; // All memory for worker private data
61 uint32_t numReservedThreads
; // Number of threads reserved for API use
62 THREAD_DATA
* pApiThreadData
;
67 void CreateThreadPool(SWR_CONTEXT
* pContext
, THREAD_POOL
* pPool
);
68 void StartThreadPool(SWR_CONTEXT
* pContext
, THREAD_POOL
* pPool
);
69 void DestroyThreadPool(SWR_CONTEXT
* pContext
, THREAD_POOL
* pPool
);
71 // Expose FE and BE worker functions to the API thread if single threaded
72 void WorkOnFifoFE(SWR_CONTEXT
* pContext
, uint32_t workerId
, uint32_t& curDrawFE
);
73 bool WorkOnFifoBE(SWR_CONTEXT
* pContext
,
79 void WorkOnCompute(SWR_CONTEXT
* pContext
, uint32_t workerId
, uint32_t& curDrawBE
);
80 int32_t CompleteDrawContext(SWR_CONTEXT
* pContext
, DRAW_CONTEXT
* pDC
);
82 void BindApiThread(SWR_CONTEXT
* pContext
, uint32_t apiThreadId
);