1 /****************************************************************************
2 * Copyright (C) 2014-2016 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 API definitions
27 ******************************************************************************/
32 #include "common/os.h"
37 #include "common/intrin.h"
38 #include "common/formats.h"
39 #include "core/state.h"
41 typedef void(SWR_API
*PFN_CALLBACK_FUNC
)(uint64_t data
, uint64_t data2
, uint64_t data3
);
43 //////////////////////////////////////////////////////////////////////////
44 /// @brief Rectangle structure
47 int32_t xmin
; ///< inclusive
48 int32_t ymin
; ///< inclusive
49 int32_t xmax
; ///< exclusive
50 int32_t ymax
; ///< exclusive
52 bool operator == (const SWR_RECT
& rhs
)
54 return (this->ymin
== rhs
.ymin
&&
55 this->ymax
== rhs
.ymax
&&
56 this->xmin
== rhs
.xmin
&&
57 this->xmax
== rhs
.xmax
);
60 bool operator != (const SWR_RECT
& rhs
)
62 return !(*this == rhs
);
65 SWR_RECT
& Intersect(const SWR_RECT
& other
)
67 this->xmin
= std::max(this->xmin
, other
.xmin
);
68 this->ymin
= std::max(this->ymin
, other
.ymin
);
69 this->xmax
= std::min(this->xmax
, other
.xmax
);
70 this->ymax
= std::min(this->ymax
, other
.ymax
);
72 if (xmax
- xmin
< 0 ||
76 ymin
= ymax
= xmin
= xmax
= 0;
81 SWR_RECT
& operator &= (const SWR_RECT
& other
)
83 return Intersect(other
);
86 SWR_RECT
& Union(const SWR_RECT
& other
)
88 this->xmin
= std::min(this->xmin
, other
.xmin
);
89 this->ymin
= std::min(this->ymin
, other
.ymin
);
90 this->xmax
= std::max(this->xmax
, other
.xmax
);
91 this->ymax
= std::max(this->ymax
, other
.ymax
);
96 SWR_RECT
& operator |= (const SWR_RECT
& other
)
101 void Translate(int32_t x
, int32_t y
)
110 //////////////////////////////////////////////////////////////////////////
111 /// @brief Function signature for load hot tiles
112 /// @param hPrivateContext - handle to private data
113 /// @param dstFormat - format of the hot tile
114 /// @param renderTargetIndex - render target to store, can be color, depth or stencil
115 /// @param x - destination x coordinate
116 /// @param y - destination y coordinate
117 /// @param pDstHotTile - pointer to the hot tile surface
118 typedef void(SWR_API
*PFN_LOAD_TILE
)(HANDLE hPrivateContext
, SWR_FORMAT dstFormat
,
119 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex
,
120 uint32_t x
, uint32_t y
, uint32_t renderTargetArrayIndex
, uint8_t *pDstHotTile
);
122 //////////////////////////////////////////////////////////////////////////
123 /// @brief Function signature for store hot tiles
124 /// @param hPrivateContext - handle to private data
125 /// @param srcFormat - format of the hot tile
126 /// @param renderTargetIndex - render target to store, can be color, depth or stencil
127 /// @param x - destination x coordinate
128 /// @param y - destination y coordinate
129 /// @param pSrcHotTile - pointer to the hot tile surface
130 typedef void(SWR_API
*PFN_STORE_TILE
)(HANDLE hPrivateContext
, SWR_FORMAT srcFormat
,
131 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex
,
132 uint32_t x
, uint32_t y
, uint32_t renderTargetArrayIndex
, uint8_t *pSrcHotTile
);
134 //////////////////////////////////////////////////////////////////////////
135 /// @brief Function signature for clearing from the hot tiles clear value
136 /// @param hPrivateContext - handle to private data
137 /// @param renderTargetIndex - render target to store, can be color, depth or stencil
138 /// @param x - destination x coordinate
139 /// @param y - destination y coordinate
140 /// @param renderTargetArrayIndex - render target array offset from arrayIndex
141 /// @param pClearColor - pointer to the hot tile's clear value
142 typedef void(SWR_API
*PFN_CLEAR_TILE
)(HANDLE hPrivateContext
,
143 SWR_RENDERTARGET_ATTACHMENT rtIndex
,
144 uint32_t x
, uint32_t y
, uint32_t renderTargetArrayIndex
, const float* pClearColor
);
146 //////////////////////////////////////////////////////////////////////////
147 /// @brief Callback to allow driver to update their copy of streamout write offset.
148 /// This is call is made for any draw operation that has streamout enabled
149 /// and has updated the write offset.
150 /// @param hPrivateContext - handle to private data
151 /// @param soBufferSlot - buffer slot for write offset
152 /// @param soWriteOffset - update value for so write offset.
153 typedef void(SWR_API
*PFN_UPDATE_SO_WRITE_OFFSET
)(HANDLE hPrivateContext
,
154 uint32_t soBufferSlot
, uint32_t soWriteOffset
);
156 //////////////////////////////////////////////////////////////////////////
157 /// @brief Callback to allow driver to update their copy of stats.
158 /// @param hPrivateContext - handle to private data
159 /// @param pStats - pointer to draw stats
160 typedef void(SWR_API
*PFN_UPDATE_STATS
)(HANDLE hPrivateContext
,
161 const SWR_STATS
* pStats
);
163 //////////////////////////////////////////////////////////////////////////
164 /// @brief Callback to allow driver to update their copy of FE stats.
165 /// @note Its optimal to have a separate callback for FE stats since
166 /// there is only one DC per FE thread. This means we do not have
167 /// to sum up the stats across all of the workers.
168 /// @param hPrivateContext - handle to private data
169 /// @param pStats - pointer to draw stats
170 typedef void(SWR_API
*PFN_UPDATE_STATS_FE
)(HANDLE hPrivateContext
,
171 const SWR_STATS_FE
* pStats
);
173 //////////////////////////////////////////////////////////////////////////
175 /// Forward Declaration (see rdtsc_buckets.h for full definition)
176 /////////////////////////////////////////////////////////////////////////
179 //////////////////////////////////////////////////////////////////////////
180 /// SWR_THREADING_INFO
181 /////////////////////////////////////////////////////////////////////////
182 struct SWR_THREADING_INFO
184 uint32_t MAX_WORKER_THREADS
;
185 uint32_t MAX_NUMA_NODES
;
186 uint32_t MAX_CORES_PER_NUMA_NODE
;
187 uint32_t MAX_THREADS_PER_CORE
;
188 bool SINGLE_THREADED
;
191 //////////////////////////////////////////////////////////////////////////
192 /// SWR_CREATECONTEXT_INFO
193 /////////////////////////////////////////////////////////////////////////
194 struct SWR_CREATECONTEXT_INFO
196 // External functions (e.g. sampler) need per draw context state.
197 // Use SwrGetPrivateContextState() to access private state.
198 uint32_t privateStateSize
;
200 // Callback functions
201 PFN_LOAD_TILE pfnLoadTile
;
202 PFN_STORE_TILE pfnStoreTile
;
203 PFN_CLEAR_TILE pfnClearTile
;
204 PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset
;
205 PFN_UPDATE_STATS pfnUpdateStats
;
206 PFN_UPDATE_STATS_FE pfnUpdateStatsFE
;
209 // Pointer to rdtsc buckets mgr returned to the caller.
210 // Only populated when KNOB_ENABLE_RDTSC is set
211 BucketManager
* pBucketMgr
;
213 // Output: size required memory passed to for SwrSaveState / SwrRestoreState
214 size_t contextSaveSize
;
216 // Input (optional): Threading info that overrides any set KNOB values.
217 SWR_THREADING_INFO
* pThreadInfo
;
220 //////////////////////////////////////////////////////////////////////////
221 /// @brief Create SWR Context.
222 /// @param pCreateInfo - pointer to creation info.
223 SWR_FUNC(HANDLE
, SwrCreateContext
,
224 SWR_CREATECONTEXT_INFO
* pCreateInfo
);
226 //////////////////////////////////////////////////////////////////////////
227 /// @brief Destroys SWR Context.
228 /// @param hContext - Handle passed back from SwrCreateContext
229 SWR_FUNC(void, SwrDestroyContext
,
232 //////////////////////////////////////////////////////////////////////////
233 /// @brief Saves API state associated with hContext
234 /// @param hContext - Handle passed back from SwrCreateContext
235 /// @param pOutputStateBlock - Memory block to receive API state data
236 /// @param memSize - Size of memory pointed to by pOutputStateBlock
237 SWR_FUNC(void, SwrSaveState
,
239 void* pOutputStateBlock
,
242 //////////////////////////////////////////////////////////////////////////
243 /// @brief Restores API state to hContext previously saved with SwrSaveState
244 /// @param hContext - Handle passed back from SwrCreateContext
245 /// @param pStateBlock - Memory block to read API state data from
246 /// @param memSize - Size of memory pointed to by pStateBlock
247 SWR_FUNC(void, SwrRestoreState
,
249 const void* pStateBlock
,
252 //////////////////////////////////////////////////////////////////////////
253 /// @brief Sync cmd. Executes the callback func when all rendering up to this sync
254 /// has been completed
255 /// @param hContext - Handle passed back from SwrCreateContext
256 /// @param pfnFunc - pointer to callback function,
257 /// @param userData - user data to pass back
258 SWR_FUNC(void, SwrSync
,
260 PFN_CALLBACK_FUNC pfnFunc
,
265 //////////////////////////////////////////////////////////////////////////
266 /// @brief Blocks until all rendering has been completed.
267 /// @param hContext - Handle passed back from SwrCreateContext
268 SWR_FUNC(void, SwrWaitForIdle
,
271 //////////////////////////////////////////////////////////////////////////
272 /// @brief Blocks until all FE rendering has been completed.
273 /// @param hContext - Handle passed back from SwrCreateContext
274 SWR_FUNC(void, SwrWaitForIdleFE
,
277 //////////////////////////////////////////////////////////////////////////
278 /// @brief Set vertex buffer state.
279 /// @param hContext - Handle passed back from SwrCreateContext
280 /// @param numBuffers - Number of vertex buffer state descriptors.
281 /// @param pVertexBuffers - Array of vertex buffer state descriptors.
282 SWR_FUNC(void, SwrSetVertexBuffers
,
285 const SWR_VERTEX_BUFFER_STATE
* pVertexBuffers
);
287 //////////////////////////////////////////////////////////////////////////
288 /// @brief Set index buffer
289 /// @param hContext - Handle passed back from SwrCreateContext
290 /// @param pIndexBuffer - Index buffer.
291 SWR_FUNC(void, SwrSetIndexBuffer
,
293 const SWR_INDEX_BUFFER_STATE
* pIndexBuffer
);
295 //////////////////////////////////////////////////////////////////////////
296 /// @brief Set fetch shader pointer.
297 /// @param hContext - Handle passed back from SwrCreateContext
298 /// @param pfnFetchFunc - Pointer to shader.
299 SWR_FUNC(void, SwrSetFetchFunc
,
301 PFN_FETCH_FUNC pfnFetchFunc
);
303 //////////////////////////////////////////////////////////////////////////
304 /// @brief Set streamout shader pointer.
305 /// @param hContext - Handle passed back from SwrCreateContext
306 /// @param pfnSoFunc - Pointer to shader.
307 /// @param streamIndex - specifies stream
308 SWR_FUNC(void, SwrSetSoFunc
,
310 PFN_SO_FUNC pfnSoFunc
,
311 uint32_t streamIndex
);
313 //////////////////////////////////////////////////////////////////////////
314 /// @brief Set streamout state
315 /// @param hContext - Handle passed back from SwrCreateContext
316 /// @param pSoState - Pointer to streamout state.
317 SWR_FUNC(void, SwrSetSoState
,
319 SWR_STREAMOUT_STATE
* pSoState
);
321 //////////////////////////////////////////////////////////////////////////
322 /// @brief Set streamout buffer state
323 /// @param hContext - Handle passed back from SwrCreateContext
324 /// @param pSoBuffer - Pointer to streamout buffer.
325 /// @param slot - Slot to bind SO buffer to.
326 SWR_FUNC(void, SwrSetSoBuffers
,
328 SWR_STREAMOUT_BUFFER
* pSoBuffer
,
331 //////////////////////////////////////////////////////////////////////////
332 /// @brief Set vertex shader pointer.
333 /// @param hContext - Handle passed back from SwrCreateContext
334 /// @param pfnVertexFunc - Pointer to shader.
335 SWR_FUNC(void, SwrSetVertexFunc
,
337 PFN_VERTEX_FUNC pfnVertexFunc
);
339 //////////////////////////////////////////////////////////////////////////
340 /// @brief Set frontend state.
341 /// @param hContext - Handle passed back from SwrCreateContext
342 /// @param pState - Pointer to state
343 SWR_FUNC(void, SwrSetFrontendState
,
345 SWR_FRONTEND_STATE
*pState
);
347 //////////////////////////////////////////////////////////////////////////
348 /// @brief Set geometry shader state.
349 /// @param hContext - Handle passed back from SwrCreateContext
350 /// @param pState - Pointer to state
351 SWR_FUNC(void, SwrSetGsState
,
353 SWR_GS_STATE
*pState
);
355 //////////////////////////////////////////////////////////////////////////
356 /// @brief Set geometry shader
357 /// @param hContext - Handle passed back from SwrCreateContext
358 /// @param pState - Pointer to geometry shader function
359 SWR_FUNC(void, SwrSetGsFunc
,
361 PFN_GS_FUNC pfnGsFunc
);
363 //////////////////////////////////////////////////////////////////////////
364 /// @brief Set compute shader
365 /// @param hContext - Handle passed back from SwrCreateContext
366 /// @param pfnCsFunc - Pointer to compute shader function
367 /// @param totalThreadsInGroup - product of thread group dimensions.
368 /// @param totalSpillFillSize - size in bytes needed for spill/fill.
369 /// @param scratchSpaceSizePerInstance - size of the scratch space needed per simd instance
370 /// @param numInstances - number of simd instances that are run per execution of the shader
371 SWR_FUNC(void, SwrSetCsFunc
,
373 PFN_CS_FUNC pfnCsFunc
,
374 uint32_t totalThreadsInGroup
,
375 uint32_t totalSpillFillSize
,
376 uint32_t scratchSpaceSizePerInstance
,
377 uint32_t numInstances
380 //////////////////////////////////////////////////////////////////////////
381 /// @brief Set tessellation state.
382 /// @param hContext - Handle passed back from SwrCreateContext
383 /// @param pState - Pointer to state
384 SWR_FUNC(void, SwrSetTsState
,
386 SWR_TS_STATE
*pState
);
388 //////////////////////////////////////////////////////////////////////////
389 /// @brief Set hull shader
390 /// @param hContext - Handle passed back from SwrCreateContext
391 /// @param pfnFunc - Pointer to shader function
392 SWR_FUNC(void, SwrSetHsFunc
,
394 PFN_HS_FUNC pfnFunc
);
396 //////////////////////////////////////////////////////////////////////////
397 /// @brief Set domain shader
398 /// @param hContext - Handle passed back from SwrCreateContext
399 /// @param pfnFunc - Pointer to shader function
400 SWR_FUNC(void, SwrSetDsFunc
,
402 PFN_DS_FUNC pfnFunc
);
404 //////////////////////////////////////////////////////////////////////////
405 /// @brief Set depth stencil state
406 /// @param hContext - Handle passed back from SwrCreateContext
407 /// @param pState - Pointer to state.
408 SWR_FUNC(void, SwrSetDepthStencilState
,
410 SWR_DEPTH_STENCIL_STATE
*pState
);
412 //////////////////////////////////////////////////////////////////////////
413 /// @brief Set backend state
414 /// @param hContext - Handle passed back from SwrCreateContext
415 /// @param pState - Pointer to state.
416 SWR_FUNC(void, SwrSetBackendState
,
418 SWR_BACKEND_STATE
*pState
);
420 //////////////////////////////////////////////////////////////////////////
421 /// @brief Set depth bounds state
422 /// @param hContext - Handle passed back from SwrCreateContext
423 /// @param pState - Pointer to state.
424 SWR_FUNC(void, SwrSetDepthBoundsState
,
426 SWR_DEPTH_BOUNDS_STATE
*pState
);
428 //////////////////////////////////////////////////////////////////////////
429 /// @brief Set pixel shader state
430 /// @param hContext - Handle passed back from SwrCreateContext
431 /// @param pState - Pointer to state.
432 SWR_FUNC(void, SwrSetPixelShaderState
,
434 SWR_PS_STATE
*pState
);
436 //////////////////////////////////////////////////////////////////////////
437 /// @brief Set blend state
438 /// @param hContext - Handle passed back from SwrCreateContext
439 /// @param pState - Pointer to state.
440 SWR_FUNC(void, SwrSetBlendState
,
442 SWR_BLEND_STATE
*pState
);
444 //////////////////////////////////////////////////////////////////////////
445 /// @brief Set blend function
446 /// @param hContext - Handle passed back from SwrCreateContext
447 /// @param renderTarget - render target index
448 /// @param pfnBlendFunc - function pointer
449 SWR_FUNC(void, SwrSetBlendFunc
,
451 uint32_t renderTarget
,
452 PFN_BLEND_JIT_FUNC pfnBlendFunc
);
454 //////////////////////////////////////////////////////////////////////////
456 /// @param hContext - Handle passed back from SwrCreateContext
457 /// @param topology - Specifies topology for draw.
458 /// @param startVertex - Specifies start vertex in vertex buffer for draw.
459 /// @param primCount - Number of vertices.
460 SWR_FUNC(void, SwrDraw
,
462 PRIMITIVE_TOPOLOGY topology
,
463 uint32_t startVertex
,
466 //////////////////////////////////////////////////////////////////////////
467 /// @brief SwrDrawInstanced
468 /// @param hContext - Handle passed back from SwrCreateContext
469 /// @param topology - Specifies topology for draw.
470 /// @param numVertsPerInstance - How many vertices to read sequentially from vertex data.
471 /// @param numInstances - How many instances to render.
472 /// @param startVertex - Specifies start vertex for draw. (vertex data)
473 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data)
474 SWR_FUNC(void, SwrDrawInstanced
,
476 PRIMITIVE_TOPOLOGY topology
,
477 uint32_t numVertsPerInstance
,
478 uint32_t numInstances
,
479 uint32_t startVertex
,
480 uint32_t startInstance
);
482 //////////////////////////////////////////////////////////////////////////
483 /// @brief DrawIndexed
484 /// @param hContext - Handle passed back from SwrCreateContext
485 /// @param topology - Specifies topology for draw.
486 /// @param numIndices - Number of indices to read sequentially from index buffer.
487 /// @param indexOffset - Starting index into index buffer.
488 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed.
489 SWR_FUNC(void, SwrDrawIndexed
,
491 PRIMITIVE_TOPOLOGY topology
,
493 uint32_t indexOffset
,
496 //////////////////////////////////////////////////////////////////////////
497 /// @brief SwrDrawIndexedInstanced
498 /// @param hContext - Handle passed back from SwrCreateContext
499 /// @param topology - Specifies topology for draw.
500 /// @param numIndices - Number of indices to read sequentially from index buffer.
501 /// @param numInstances - Number of instances to render.
502 /// @param indexOffset - Starting index into index buffer.
503 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed.
504 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data)
505 SWR_FUNC(void, SwrDrawIndexedInstanced
,
507 PRIMITIVE_TOPOLOGY topology
,
509 uint32_t numInstances
,
510 uint32_t indexOffset
,
512 uint32_t startInstance
);
514 //////////////////////////////////////////////////////////////////////////
515 /// @brief SwrInvalidateTiles
516 /// @param hContext - Handle passed back from SwrCreateContext
517 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to invalidate.
518 /// @param invalidateRect - The pixel-coordinate rectangle to invalidate. This will be expanded to
519 /// be hottile size-aligned.
520 SWR_FUNC(void, SwrInvalidateTiles
,
522 uint32_t attachmentMask
,
523 const SWR_RECT
& invalidateRect
);
525 //////////////////////////////////////////////////////////////////////////
526 /// @brief SwrDiscardRect
527 /// @param hContext - Handle passed back from SwrCreateContext
528 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to discard.
529 /// @param rect - The pixel-coordinate rectangle to discard. Only fully-covered hottiles will be
531 SWR_FUNC(void, SwrDiscardRect
,
533 uint32_t attachmentMask
,
534 const SWR_RECT
& rect
);
536 //////////////////////////////////////////////////////////////////////////
537 /// @brief SwrDispatch
538 /// @param hContext - Handle passed back from SwrCreateContext
539 /// @param threadGroupCountX - Number of thread groups dispatched in X direction
540 /// @param threadGroupCountY - Number of thread groups dispatched in Y direction
541 /// @param threadGroupCountZ - Number of thread groups dispatched in Z direction
542 SWR_FUNC(void, SwrDispatch
,
544 uint32_t threadGroupCountX
,
545 uint32_t threadGroupCountY
,
546 uint32_t threadGroupCountZ
);
551 SWR_TILE_INVALID
= 0, // tile is in unitialized state and should be loaded with surface contents before rendering
552 SWR_TILE_DIRTY
= 2, // tile contains newer data than surface it represents
553 SWR_TILE_RESOLVED
= 3, // is in sync with surface it represents
556 /// @todo Add a good description for what attachments are and when and why you would use the different SWR_TILE_STATEs.
557 SWR_FUNC(void, SwrStoreTiles
,
559 uint32_t attachmentMask
,
560 SWR_TILE_STATE postStoreTileState
,
561 const SWR_RECT
& storeRect
);
564 //////////////////////////////////////////////////////////////////////////
565 /// @brief SwrClearRenderTarget - Clear attached render targets / depth / stencil
566 /// @param hContext - Handle passed back from SwrCreateContext
567 /// @param attachmentMask - combination of SWR_ATTACHMENT_*_BIT attachments to clear
568 /// @param renderTargetArrayIndex - the RT array index to clear
569 /// @param clearColor - color use for clearing render targets
570 /// @param z - depth value use for clearing depth buffer
571 /// @param stencil - stencil value used for clearing stencil buffer
572 /// @param clearRect - The pixel-coordinate rectangle to clear in all cleared buffers
573 SWR_FUNC(void, SwrClearRenderTarget
,
575 uint32_t attachmentMask
,
576 uint32_t renderTargetArrayIndex
,
577 const float clearColor
[4],
580 const SWR_RECT
& clearRect
);
582 //////////////////////////////////////////////////////////////////////////
583 /// @brief SwrSetRastState
584 /// @param hContext - Handle passed back from SwrCreateContext
585 /// @param pRastState - New SWR_RASTSTATE used for SwrDraw* commands
586 SWR_FUNC(void, SwrSetRastState
,
588 const SWR_RASTSTATE
*pRastState
);
590 //////////////////////////////////////////////////////////////////////////
591 /// @brief SwrSetViewports
592 /// @param hContext - Handle passed back from SwrCreateContext
593 /// @param numViewports - number of viewports passed in
594 /// @param pViewports - Specifies extents of viewport.
595 /// @param pMatrices - If not specified then SWR computes a default one.
596 SWR_FUNC(void, SwrSetViewports
,
598 uint32_t numViewports
,
599 const SWR_VIEWPORT
* pViewports
,
600 const SWR_VIEWPORT_MATRICES
* pMatrices
);
602 //////////////////////////////////////////////////////////////////////////
603 /// @brief SwrSetScissorRects
604 /// @param hContext - Handle passed back from SwrCreateContext
605 /// @param numScissors - number of scissors passed in
606 /// @param pScissors - array of scissors
607 SWR_FUNC(void, SwrSetScissorRects
,
609 uint32_t numScissors
,
610 const SWR_RECT
* pScissors
);
612 //////////////////////////////////////////////////////////////////////////
613 /// @brief Returns a pointer to the private context state for the current
614 /// draw operation. This is used for external componets such as the
617 /// @note Client needs to resend private state prior to each draw call.
618 /// Also, SWR is responsible for the private state memory.
619 /// @param hContext - Handle passed back from SwrCreateContext
620 SWR_FUNC(void*, SwrGetPrivateContextState
,
623 //////////////////////////////////////////////////////////////////////////
624 /// @brief Clients can use this to allocate memory for draw/dispatch
625 /// operations. The memory will automatically be freed once operation
626 /// has completed. Client can use this to allocate binding tables,
627 /// etc. needed for shader execution.
628 /// @param hContext - Handle passed back from SwrCreateContext
629 /// @param size - Size of allocation
630 /// @param align - Alignment needed for allocation.
631 SWR_FUNC(void*, SwrAllocDrawContextMemory
,
636 //////////////////////////////////////////////////////////////////////////
637 /// @brief Enables stats counting
638 /// @param hContext - Handle passed back from SwrCreateContext
639 /// @param enable - If true then counts are incremented.
640 SWR_FUNC(void, SwrEnableStatsFE
,
644 //////////////////////////////////////////////////////////////////////////
645 /// @brief Enables stats counting
646 /// @param hContext - Handle passed back from SwrCreateContext
647 /// @param enable - If true then counts are incremented.
648 SWR_FUNC(void, SwrEnableStatsBE
,
652 //////////////////////////////////////////////////////////////////////////
653 /// @brief Mark end of frame - used for performance profiling
654 /// @param hContext - Handle passed back from SwrCreateContext
655 SWR_FUNC(void, SwrEndFrame
,
658 //////////////////////////////////////////////////////////////////////////
659 /// @brief Initialize swr backend and memory internal tables
660 SWR_FUNC(void, SwrInit
);
663 //////////////////////////////////////////////////////////////////////////
664 /// @brief Loads a full hottile from a render surface
665 /// @param hPrivateContext - Handle to private DC
666 /// @param dstFormat - Format for hot tile.
667 /// @param renderTargetIndex - Index to src render target
668 /// @param x, y - Coordinates to raster tile.
669 /// @param pDstHotTile - Pointer to Hot Tile
670 SWR_FUNC(void, SwrLoadHotTile
,
671 const SWR_SURFACE_STATE
*pSrcSurface
,
672 SWR_FORMAT dstFormat
,
673 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex
,
674 uint32_t x
, uint32_t y
, uint32_t renderTargetArrayIndex
,
675 uint8_t *pDstHotTile
);
677 //////////////////////////////////////////////////////////////////////////
678 /// @brief Deswizzles and stores a full hottile to a render surface
679 /// @param hPrivateContext - Handle to private DC
680 /// @param srcFormat - Format for hot tile.
681 /// @param renderTargetIndex - Index to destination render target
682 /// @param x, y - Coordinates to raster tile.
683 /// @param pSrcHotTile - Pointer to Hot Tile
684 SWR_FUNC(void, SwrStoreHotTileToSurface
,
685 SWR_SURFACE_STATE
*pDstSurface
,
686 SWR_FORMAT srcFormat
,
687 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex
,
688 uint32_t x
, uint32_t y
, uint32_t renderTargetArrayIndex
,
689 uint8_t *pSrcHotTile
);
691 //////////////////////////////////////////////////////////////////////////
692 /// @brief Writes clear color to every pixel of a render surface
693 /// @param hPrivateContext - Handle to private DC
694 /// @param renderTargetIndex - Index to destination render target
695 /// @param x, y - Coordinates to raster tile.
696 /// @param pClearColor - Pointer to clear color
697 SWR_FUNC(void, SwrStoreHotTileClear
,
698 SWR_SURFACE_STATE
*pDstSurface
,
699 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex
,
702 uint32_t renderTargetArrayIndex
,
703 const float* pClearColor
);
707 PFNSwrCreateContext pfnSwrCreateContext
;
708 PFNSwrDestroyContext pfnSwrDestroyContext
;
709 PFNSwrSaveState pfnSwrSaveState
;
710 PFNSwrRestoreState pfnSwrRestoreState
;
711 PFNSwrSync pfnSwrSync
;
712 PFNSwrWaitForIdle pfnSwrWaitForIdle
;
713 PFNSwrWaitForIdleFE pfnSwrWaitForIdleFE
;
714 PFNSwrSetVertexBuffers pfnSwrSetVertexBuffers
;
715 PFNSwrSetIndexBuffer pfnSwrSetIndexBuffer
;
716 PFNSwrSetFetchFunc pfnSwrSetFetchFunc
;
717 PFNSwrSetSoFunc pfnSwrSetSoFunc
;
718 PFNSwrSetSoState pfnSwrSetSoState
;
719 PFNSwrSetSoBuffers pfnSwrSetSoBuffers
;
720 PFNSwrSetVertexFunc pfnSwrSetVertexFunc
;
721 PFNSwrSetFrontendState pfnSwrSetFrontendState
;
722 PFNSwrSetGsState pfnSwrSetGsState
;
723 PFNSwrSetGsFunc pfnSwrSetGsFunc
;
724 PFNSwrSetCsFunc pfnSwrSetCsFunc
;
725 PFNSwrSetTsState pfnSwrSetTsState
;
726 PFNSwrSetHsFunc pfnSwrSetHsFunc
;
727 PFNSwrSetDsFunc pfnSwrSetDsFunc
;
728 PFNSwrSetDepthStencilState pfnSwrSetDepthStencilState
;
729 PFNSwrSetBackendState pfnSwrSetBackendState
;
730 PFNSwrSetDepthBoundsState pfnSwrSetDepthBoundsState
;
731 PFNSwrSetPixelShaderState pfnSwrSetPixelShaderState
;
732 PFNSwrSetBlendState pfnSwrSetBlendState
;
733 PFNSwrSetBlendFunc pfnSwrSetBlendFunc
;
734 PFNSwrDraw pfnSwrDraw
;
735 PFNSwrDrawInstanced pfnSwrDrawInstanced
;
736 PFNSwrDrawIndexed pfnSwrDrawIndexed
;
737 PFNSwrDrawIndexedInstanced pfnSwrDrawIndexedInstanced
;
738 PFNSwrInvalidateTiles pfnSwrInvalidateTiles
;
739 PFNSwrDiscardRect pfnSwrDiscardRect
;
740 PFNSwrDispatch pfnSwrDispatch
;
741 PFNSwrStoreTiles pfnSwrStoreTiles
;
742 PFNSwrClearRenderTarget pfnSwrClearRenderTarget
;
743 PFNSwrSetRastState pfnSwrSetRastState
;
744 PFNSwrSetViewports pfnSwrSetViewports
;
745 PFNSwrSetScissorRects pfnSwrSetScissorRects
;
746 PFNSwrGetPrivateContextState pfnSwrGetPrivateContextState
;
747 PFNSwrAllocDrawContextMemory pfnSwrAllocDrawContextMemory
;
748 PFNSwrEnableStatsFE pfnSwrEnableStatsFE
;
749 PFNSwrEnableStatsBE pfnSwrEnableStatsBE
;
750 PFNSwrEndFrame pfnSwrEndFrame
;
751 PFNSwrInit pfnSwrInit
;
752 PFNSwrLoadHotTile pfnSwrLoadHotTile
;
753 PFNSwrStoreHotTileToSurface pfnSwrStoreHotTileToSurface
;
754 PFNSwrStoreHotTileClear pfnSwrStoreHotTileClear
;
758 typedef void (SWR_API
* PFNSwrGetInterface
)(SWR_INTERFACE
&out_funcs
);
759 SWR_VISIBLE
void SWR_API
SwrGetInterface(SWR_INTERFACE
&out_funcs
);