6bebc39d3da52151596d54538b8c9f6b215f3a1d
[mesa.git] / src / gallium / drivers / swr / rasterizer / core / api.h
1 /****************************************************************************
2 * Copyright (C) 2014-2016 Intel Corporation. All Rights Reserved.
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 *
23 * @file api.h
24 *
25 * @brief API definitions
26 *
27 ******************************************************************************/
28
29 #ifndef __SWR_API_H__
30 #define __SWR_API_H__
31
32 #include "common/os.h"
33
34 #include <assert.h>
35 #include <algorithm>
36
37 #include "common/simdintrin.h"
38 #include "common/formats.h"
39 #include "core/state.h"
40
41 typedef void(SWR_API *PFN_CALLBACK_FUNC)(uint64_t data, uint64_t data2, uint64_t data3);
42
43 //////////////////////////////////////////////////////////////////////////
44 /// @brief Rectangle structure
45 struct SWR_RECT
46 {
47 int32_t xmin; ///< inclusive
48 int32_t ymin; ///< inclusive
49 int32_t xmax; ///< exclusive
50 int32_t ymax; ///< exclusive
51
52 bool operator == (const SWR_RECT& rhs)
53 {
54 return (this->ymin == rhs.ymin &&
55 this->ymax == rhs.ymax &&
56 this->xmin == rhs.xmin &&
57 this->xmax == rhs.xmax);
58 }
59
60 bool operator != (const SWR_RECT& rhs)
61 {
62 return !(*this == rhs);
63 }
64
65 SWR_RECT& Intersect(const SWR_RECT& other)
66 {
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);
71
72 if (xmax - xmin < 0 ||
73 ymax - ymin < 0)
74 {
75 // Zero area
76 ymin = ymax = xmin = xmax = 0;
77 }
78
79 return *this;
80 }
81 SWR_RECT& operator &= (const SWR_RECT& other)
82 {
83 return Intersect(other);
84 }
85
86 SWR_RECT& Union(const SWR_RECT& other)
87 {
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);
92
93 return *this;
94 }
95
96 SWR_RECT& operator |= (const SWR_RECT& other)
97 {
98 return Union(other);
99 }
100
101 void Translate(int32_t x, int32_t y)
102 {
103 xmin += x;
104 ymin += y;
105 xmax += x;
106 ymax += y;
107 }
108 };
109
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);
121
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);
133
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 pClearColor - pointer to the hot tile's clear value
141 typedef void(SWR_API *PFN_CLEAR_TILE)(HANDLE hPrivateContext,
142 SWR_RENDERTARGET_ATTACHMENT rtIndex,
143 uint32_t x, uint32_t y, const float* pClearColor);
144
145 //////////////////////////////////////////////////////////////////////////
146 /// @brief Callback to allow driver to update their copy of streamout write offset.
147 /// This is call is made for any draw operation that has streamout enabled
148 /// and has updated the write offset.
149 /// @param hPrivateContext - handle to private data
150 /// @param soBufferSlot - buffer slot for write offset
151 /// @param soWriteOffset - update value for so write offset.
152 typedef void(SWR_API *PFN_UPDATE_SO_WRITE_OFFSET)(HANDLE hPrivateContext,
153 uint32_t soBufferSlot, uint32_t soWriteOffset);
154
155 //////////////////////////////////////////////////////////////////////////
156 /// @brief Callback to allow driver to update their copy of stats.
157 /// @param hPrivateContext - handle to private data
158 /// @param pStats - pointer to draw stats
159 typedef void(SWR_API *PFN_UPDATE_STATS)(HANDLE hPrivateContext,
160 const SWR_STATS* pStats);
161
162 //////////////////////////////////////////////////////////////////////////
163 /// @brief Callback to allow driver to update their copy of FE stats.
164 /// @note Its optimal to have a separate callback for FE stats since
165 /// there is only one DC per FE thread. This means we do not have
166 /// to sum up the stats across all of the workers.
167 /// @param hPrivateContext - handle to private data
168 /// @param pStats - pointer to draw stats
169 typedef void(SWR_API *PFN_UPDATE_STATS_FE)(HANDLE hPrivateContext,
170 const SWR_STATS_FE* pStats);
171
172 //////////////////////////////////////////////////////////////////////////
173 /// BucketManager
174 /// Forward Declaration (see rdtsc_buckets.h for full definition)
175 /////////////////////////////////////////////////////////////////////////
176 class BucketManager;
177
178 //////////////////////////////////////////////////////////////////////////
179 /// SWR_THREADING_INFO
180 /////////////////////////////////////////////////////////////////////////
181 struct SWR_THREADING_INFO
182 {
183 uint32_t MAX_WORKER_THREADS;
184 uint32_t MAX_NUMA_NODES;
185 uint32_t MAX_CORES_PER_NUMA_NODE;
186 uint32_t MAX_THREADS_PER_CORE;
187 bool SINGLE_THREADED;
188 };
189
190 //////////////////////////////////////////////////////////////////////////
191 /// SWR_CREATECONTEXT_INFO
192 /////////////////////////////////////////////////////////////////////////
193 struct SWR_CREATECONTEXT_INFO
194 {
195 // External functions (e.g. sampler) need per draw context state.
196 // Use SwrGetPrivateContextState() to access private state.
197 uint32_t privateStateSize;
198
199 // Callback functions
200 PFN_LOAD_TILE pfnLoadTile;
201 PFN_STORE_TILE pfnStoreTile;
202 PFN_CLEAR_TILE pfnClearTile;
203 PFN_UPDATE_SO_WRITE_OFFSET pfnUpdateSoWriteOffset;
204 PFN_UPDATE_STATS pfnUpdateStats;
205 PFN_UPDATE_STATS_FE pfnUpdateStatsFE;
206
207
208 // Pointer to rdtsc buckets mgr returned to the caller.
209 // Only populated when KNOB_ENABLE_RDTSC is set
210 BucketManager* pBucketMgr;
211
212 // Output: size required memory passed to for SwrSaveState / SwrRestoreState
213 size_t contextSaveSize;
214
215 // Input (optional): Threading info that overrides any set KNOB values.
216 SWR_THREADING_INFO* pThreadInfo;
217 };
218
219 //////////////////////////////////////////////////////////////////////////
220 /// @brief Create SWR Context.
221 /// @param pCreateInfo - pointer to creation info.
222 HANDLE SWR_API SwrCreateContext(
223 SWR_CREATECONTEXT_INFO* pCreateInfo);
224
225 //////////////////////////////////////////////////////////////////////////
226 /// @brief Destroys SWR Context.
227 /// @param hContext - Handle passed back from SwrCreateContext
228 void SWR_API SwrDestroyContext(
229 HANDLE hContext);
230
231 //////////////////////////////////////////////////////////////////////////
232 /// @brief Saves API state associated with hContext
233 /// @param hContext - Handle passed back from SwrCreateContext
234 /// @param pOutputStateBlock - Memory block to receive API state data
235 /// @param memSize - Size of memory pointed to by pOutputStateBlock
236 void SWR_API SwrSaveState(
237 HANDLE hContext,
238 void* pOutputStateBlock,
239 size_t memSize);
240
241 //////////////////////////////////////////////////////////////////////////
242 /// @brief Restores API state to hContext previously saved with SwrSaveState
243 /// @param hContext - Handle passed back from SwrCreateContext
244 /// @param pStateBlock - Memory block to read API state data from
245 /// @param memSize - Size of memory pointed to by pStateBlock
246 void SWR_API SwrRestoreState(
247 HANDLE hContext,
248 const void* pStateBlock,
249 size_t memSize);
250
251 //////////////////////////////////////////////////////////////////////////
252 /// @brief Sync cmd. Executes the callback func when all rendering up to this sync
253 /// has been completed
254 /// @param hContext - Handle passed back from SwrCreateContext
255 /// @param pfnFunc - pointer to callback function,
256 /// @param userData - user data to pass back
257 void SWR_API SwrSync(
258 HANDLE hContext,
259 PFN_CALLBACK_FUNC pfnFunc,
260 uint64_t userData,
261 uint64_t userData2,
262 uint64_t userData3 = 0);
263
264 //////////////////////////////////////////////////////////////////////////
265 /// @brief Blocks until all rendering has been completed.
266 /// @param hContext - Handle passed back from SwrCreateContext
267 void SWR_API SwrWaitForIdle(
268 HANDLE hContext);
269
270 //////////////////////////////////////////////////////////////////////////
271 /// @brief Blocks until all FE rendering has been completed.
272 /// @param hContext - Handle passed back from SwrCreateContext
273 void SWR_API SwrWaitForIdleFE(
274 HANDLE hContext);
275
276 //////////////////////////////////////////////////////////////////////////
277 /// @brief Set vertex buffer state.
278 /// @param hContext - Handle passed back from SwrCreateContext
279 /// @param numBuffers - Number of vertex buffer state descriptors.
280 /// @param pVertexBuffers - Array of vertex buffer state descriptors.
281 void SWR_API SwrSetVertexBuffers(
282 HANDLE hContext,
283 uint32_t numBuffers,
284 const SWR_VERTEX_BUFFER_STATE* pVertexBuffers);
285
286 //////////////////////////////////////////////////////////////////////////
287 /// @brief Set index buffer
288 /// @param hContext - Handle passed back from SwrCreateContext
289 /// @param pIndexBuffer - Index buffer.
290 void SWR_API SwrSetIndexBuffer(
291 HANDLE hContext,
292 const SWR_INDEX_BUFFER_STATE* pIndexBuffer);
293
294 //////////////////////////////////////////////////////////////////////////
295 /// @brief Set fetch shader pointer.
296 /// @param hContext - Handle passed back from SwrCreateContext
297 /// @param pfnFetchFunc - Pointer to shader.
298 void SWR_API SwrSetFetchFunc(
299 HANDLE hContext,
300 PFN_FETCH_FUNC pfnFetchFunc);
301
302 //////////////////////////////////////////////////////////////////////////
303 /// @brief Set streamout shader pointer.
304 /// @param hContext - Handle passed back from SwrCreateContext
305 /// @param pfnSoFunc - Pointer to shader.
306 /// @param streamIndex - specifies stream
307 void SWR_API SwrSetSoFunc(
308 HANDLE hContext,
309 PFN_SO_FUNC pfnSoFunc,
310 uint32_t streamIndex);
311
312 //////////////////////////////////////////////////////////////////////////
313 /// @brief Set streamout state
314 /// @param hContext - Handle passed back from SwrCreateContext
315 /// @param pSoState - Pointer to streamout state.
316 void SWR_API SwrSetSoState(
317 HANDLE hContext,
318 SWR_STREAMOUT_STATE* pSoState);
319
320 //////////////////////////////////////////////////////////////////////////
321 /// @brief Set streamout buffer state
322 /// @param hContext - Handle passed back from SwrCreateContext
323 /// @param pSoBuffer - Pointer to streamout buffer.
324 /// @param slot - Slot to bind SO buffer to.
325 void SWR_API SwrSetSoBuffers(
326 HANDLE hContext,
327 SWR_STREAMOUT_BUFFER* pSoBuffer,
328 uint32_t slot);
329
330 //////////////////////////////////////////////////////////////////////////
331 /// @brief Set vertex shader pointer.
332 /// @param hContext - Handle passed back from SwrCreateContext
333 /// @param pfnVertexFunc - Pointer to shader.
334 void SWR_API SwrSetVertexFunc(
335 HANDLE hContext,
336 PFN_VERTEX_FUNC pfnVertexFunc);
337
338 //////////////////////////////////////////////////////////////////////////
339 /// @brief Set frontend state.
340 /// @param hContext - Handle passed back from SwrCreateContext
341 /// @param pState - Pointer to state
342 void SWR_API SwrSetFrontendState(
343 HANDLE hContext,
344 SWR_FRONTEND_STATE *pState);
345
346 //////////////////////////////////////////////////////////////////////////
347 /// @brief Set geometry shader state.
348 /// @param hContext - Handle passed back from SwrCreateContext
349 /// @param pState - Pointer to state
350 void SWR_API SwrSetGsState(
351 HANDLE hContext,
352 SWR_GS_STATE *pState);
353
354 //////////////////////////////////////////////////////////////////////////
355 /// @brief Set geometry shader
356 /// @param hContext - Handle passed back from SwrCreateContext
357 /// @param pState - Pointer to geometry shader function
358 void SWR_API SwrSetGsFunc(
359 HANDLE hContext,
360 PFN_GS_FUNC pfnGsFunc);
361
362 //////////////////////////////////////////////////////////////////////////
363 /// @brief Set compute shader
364 /// @param hContext - Handle passed back from SwrCreateContext
365 /// @param pfnCsFunc - Pointer to compute shader function
366 /// @param totalThreadsInGroup - product of thread group dimensions.
367 /// @param totalSpillFillSize - size in bytes needed for spill/fill.
368 void SWR_API SwrSetCsFunc(
369 HANDLE hContext,
370 PFN_CS_FUNC pfnCsFunc,
371 uint32_t totalThreadsInGroup,
372 uint32_t totalSpillFillSize);
373
374 //////////////////////////////////////////////////////////////////////////
375 /// @brief Set tessellation state.
376 /// @param hContext - Handle passed back from SwrCreateContext
377 /// @param pState - Pointer to state
378 void SWR_API SwrSetTsState(
379 HANDLE hContext,
380 SWR_TS_STATE *pState);
381
382 //////////////////////////////////////////////////////////////////////////
383 /// @brief Set hull shader
384 /// @param hContext - Handle passed back from SwrCreateContext
385 /// @param pfnFunc - Pointer to shader function
386 void SWR_API SwrSetHsFunc(
387 HANDLE hContext,
388 PFN_HS_FUNC pfnFunc);
389
390 //////////////////////////////////////////////////////////////////////////
391 /// @brief Set domain shader
392 /// @param hContext - Handle passed back from SwrCreateContext
393 /// @param pfnFunc - Pointer to shader function
394 void SWR_API SwrSetDsFunc(
395 HANDLE hContext,
396 PFN_DS_FUNC pfnFunc);
397
398 //////////////////////////////////////////////////////////////////////////
399 /// @brief Set depth stencil state
400 /// @param hContext - Handle passed back from SwrCreateContext
401 /// @param pState - Pointer to state.
402 void SWR_API SwrSetDepthStencilState(
403 HANDLE hContext,
404 SWR_DEPTH_STENCIL_STATE *pState);
405
406 //////////////////////////////////////////////////////////////////////////
407 /// @brief Set backend state
408 /// @param hContext - Handle passed back from SwrCreateContext
409 /// @param pState - Pointer to state.
410 void SWR_API SwrSetBackendState(
411 HANDLE hContext,
412 SWR_BACKEND_STATE *pState);
413
414 //////////////////////////////////////////////////////////////////////////
415 /// @brief Set depth bounds state
416 /// @param hContext - Handle passed back from SwrCreateContext
417 /// @param pState - Pointer to state.
418 void SWR_API SwrSetDepthBoundsState(
419 HANDLE hContext,
420 SWR_DEPTH_BOUNDS_STATE *pState);
421
422 //////////////////////////////////////////////////////////////////////////
423 /// @brief Set pixel shader state
424 /// @param hContext - Handle passed back from SwrCreateContext
425 /// @param pState - Pointer to state.
426 void SWR_API SwrSetPixelShaderState(
427 HANDLE hContext,
428 SWR_PS_STATE *pState);
429
430 //////////////////////////////////////////////////////////////////////////
431 /// @brief Set blend state
432 /// @param hContext - Handle passed back from SwrCreateContext
433 /// @param pState - Pointer to state.
434 void SWR_API SwrSetBlendState(
435 HANDLE hContext,
436 SWR_BLEND_STATE *pState);
437
438 //////////////////////////////////////////////////////////////////////////
439 /// @brief Set blend function
440 /// @param hContext - Handle passed back from SwrCreateContext
441 /// @param renderTarget - render target index
442 /// @param pfnBlendFunc - function pointer
443 void SWR_API SwrSetBlendFunc(
444 HANDLE hContext,
445 uint32_t renderTarget,
446 PFN_BLEND_JIT_FUNC pfnBlendFunc);
447
448 //////////////////////////////////////////////////////////////////////////
449 /// @brief SwrDraw
450 /// @param hContext - Handle passed back from SwrCreateContext
451 /// @param topology - Specifies topology for draw.
452 /// @param startVertex - Specifies start vertex in vertex buffer for draw.
453 /// @param primCount - Number of vertices.
454 void SWR_API SwrDraw(
455 HANDLE hContext,
456 PRIMITIVE_TOPOLOGY topology,
457 uint32_t startVertex,
458 uint32_t primCount);
459
460 //////////////////////////////////////////////////////////////////////////
461 /// @brief SwrDrawInstanced
462 /// @param hContext - Handle passed back from SwrCreateContext
463 /// @param topology - Specifies topology for draw.
464 /// @param numVertsPerInstance - How many vertices to read sequentially from vertex data.
465 /// @param numInstances - How many instances to render.
466 /// @param startVertex - Specifies start vertex for draw. (vertex data)
467 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data)
468 void SWR_API SwrDrawInstanced(
469 HANDLE hContext,
470 PRIMITIVE_TOPOLOGY topology,
471 uint32_t numVertsPerInstance,
472 uint32_t numInstances,
473 uint32_t startVertex,
474 uint32_t startInstance);
475
476 //////////////////////////////////////////////////////////////////////////
477 /// @brief DrawIndexed
478 /// @param hContext - Handle passed back from SwrCreateContext
479 /// @param topology - Specifies topology for draw.
480 /// @param numIndices - Number of indices to read sequentially from index buffer.
481 /// @param indexOffset - Starting index into index buffer.
482 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed.
483 void SWR_API SwrDrawIndexed(
484 HANDLE hContext,
485 PRIMITIVE_TOPOLOGY topology,
486 uint32_t numIndices,
487 uint32_t indexOffset,
488 int32_t baseVertex);
489
490 //////////////////////////////////////////////////////////////////////////
491 /// @brief SwrDrawIndexedInstanced
492 /// @param hContext - Handle passed back from SwrCreateContext
493 /// @param topology - Specifies topology for draw.
494 /// @param numIndices - Number of indices to read sequentially from index buffer.
495 /// @param numInstances - Number of instances to render.
496 /// @param indexOffset - Starting index into index buffer.
497 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed.
498 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data)
499 void SWR_API SwrDrawIndexedInstanced(
500 HANDLE hContext,
501 PRIMITIVE_TOPOLOGY topology,
502 uint32_t numIndices,
503 uint32_t numInstances,
504 uint32_t indexOffset,
505 int32_t baseVertex,
506 uint32_t startInstance);
507
508 //////////////////////////////////////////////////////////////////////////
509 /// @brief SwrInvalidateTiles
510 /// @param hContext - Handle passed back from SwrCreateContext
511 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to invalidate.
512 /// @param invalidateRect - The pixel-coordinate rectangle to invalidate. This will be expanded to
513 /// be hottile size-aligned.
514 void SWR_API SwrInvalidateTiles(
515 HANDLE hContext,
516 uint32_t attachmentMask,
517 const SWR_RECT& invalidateRect);
518
519 //////////////////////////////////////////////////////////////////////////
520 /// @brief SwrDiscardRect
521 /// @param hContext - Handle passed back from SwrCreateContext
522 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to discard.
523 /// @param rect - The pixel-coordinate rectangle to discard. Only fully-covered hottiles will be
524 /// discarded.
525 void SWR_API SwrDiscardRect(
526 HANDLE hContext,
527 uint32_t attachmentMask,
528 const SWR_RECT& rect);
529
530 //////////////////////////////////////////////////////////////////////////
531 /// @brief SwrDispatch
532 /// @param hContext - Handle passed back from SwrCreateContext
533 /// @param threadGroupCountX - Number of thread groups dispatched in X direction
534 /// @param threadGroupCountY - Number of thread groups dispatched in Y direction
535 /// @param threadGroupCountZ - Number of thread groups dispatched in Z direction
536 void SWR_API SwrDispatch(
537 HANDLE hContext,
538 uint32_t threadGroupCountX,
539 uint32_t threadGroupCountY,
540 uint32_t threadGroupCountZ);
541
542
543 enum SWR_TILE_STATE
544 {
545 SWR_TILE_INVALID = 0, // tile is in unitialized state and should be loaded with surface contents before rendering
546 SWR_TILE_DIRTY = 2, // tile contains newer data than surface it represents
547 SWR_TILE_RESOLVED = 3, // is in sync with surface it represents
548 };
549
550 /// @todo Add a good description for what attachments are and when and why you would use the different SWR_TILE_STATEs.
551 void SWR_API SwrStoreTiles(
552 HANDLE hContext,
553 uint32_t attachmentMask,
554 SWR_TILE_STATE postStoreTileState,
555 const SWR_RECT& storeRect);
556
557
558 //////////////////////////////////////////////////////////////////////////
559 /// @brief SwrClearRenderTarget - Clear attached render targets / depth / stencil
560 /// @param hContext - Handle passed back from SwrCreateContext
561 /// @param clearMask - combination of SWR_CLEAR_COLOR / SWR_CLEAR_DEPTH / SWR_CLEAR_STENCIL flags (or SWR_CLEAR_NONE)
562 /// @param clearColor - color use for clearing render targets
563 /// @param z - depth value use for clearing depth buffer
564 /// @param stencil - stencil value used for clearing stencil buffer
565 /// @param clearRect - The pixel-coordinate rectangle to clear in all cleared buffers
566 void SWR_API SwrClearRenderTarget(
567 HANDLE hContext,
568 uint32_t clearMask,
569 const float clearColor[4],
570 float z,
571 uint8_t stencil,
572 const SWR_RECT& clearRect);
573
574 //////////////////////////////////////////////////////////////////////////
575 /// @brief SwrSetRastState
576 /// @param hContext - Handle passed back from SwrCreateContext
577 /// @param pRastState - New SWR_RASTSTATE used for SwrDraw* commands
578 void SWR_API SwrSetRastState(
579 HANDLE hContext,
580 const SWR_RASTSTATE *pRastState);
581
582 //////////////////////////////////////////////////////////////////////////
583 /// @brief SwrSetViewports
584 /// @param hContext - Handle passed back from SwrCreateContext
585 /// @param numViewports - number of viewports passed in
586 /// @param pViewports - Specifies extents of viewport.
587 /// @param pMatrices - If not specified then SWR computes a default one.
588 void SWR_API SwrSetViewports(
589 HANDLE hContext,
590 uint32_t numViewports,
591 const SWR_VIEWPORT* pViewports,
592 const SWR_VIEWPORT_MATRICES* pMatrices);
593
594 //////////////////////////////////////////////////////////////////////////
595 /// @brief SwrSetScissorRects
596 /// @param hContext - Handle passed back from SwrCreateContext
597 /// @param numScissors - number of scissors passed in
598 /// @param pScissors - array of scissors
599 void SWR_API SwrSetScissorRects(
600 HANDLE hContext,
601 uint32_t numScissors,
602 const SWR_RECT* pScissors);
603
604 //////////////////////////////////////////////////////////////////////////
605 /// @brief Returns a pointer to the private context state for the current
606 /// draw operation. This is used for external componets such as the
607 /// sampler.
608 ///
609 /// @note Client needs to resend private state prior to each draw call.
610 /// Also, SWR is responsible for the private state memory.
611 /// @param hContext - Handle passed back from SwrCreateContext
612 VOID* SWR_API SwrGetPrivateContextState(
613 HANDLE hContext);
614
615 //////////////////////////////////////////////////////////////////////////
616 /// @brief Clients can use this to allocate memory for draw/dispatch
617 /// operations. The memory will automatically be freed once operation
618 /// has completed. Client can use this to allocate binding tables,
619 /// etc. needed for shader execution.
620 /// @param hContext - Handle passed back from SwrCreateContext
621 /// @param size - Size of allocation
622 /// @param align - Alignment needed for allocation.
623 VOID* SWR_API SwrAllocDrawContextMemory(
624 HANDLE hContext,
625 uint32_t size,
626 uint32_t align);
627
628 //////////////////////////////////////////////////////////////////////////
629 /// @brief Enables stats counting
630 /// @param hContext - Handle passed back from SwrCreateContext
631 /// @param enable - If true then counts are incremented.
632 void SWR_API SwrEnableStatsFE(
633 HANDLE hContext,
634 bool enable);
635
636 //////////////////////////////////////////////////////////////////////////
637 /// @brief Enables stats counting
638 /// @param hContext - Handle passed back from SwrCreateContext
639 /// @param enable - If true then counts are incremented.
640 void SWR_API SwrEnableStatsBE(
641 HANDLE hContext,
642 bool enable);
643
644 //////////////////////////////////////////////////////////////////////////
645 /// @brief Mark end of frame - used for performance profiling
646 /// @param hContext - Handle passed back from SwrCreateContext
647 void SWR_API SwrEndFrame(
648 HANDLE hContext);
649
650
651 #endif