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 IntersectSWR_RECT65 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 UnionSWR_RECT86 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 TranslateSWR_RECT101 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 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); 145 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); 155 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); 162 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); 172 173 ////////////////////////////////////////////////////////////////////////// 174 /// BucketManager 175 /// Forward Declaration (see rdtsc_buckets.h for full definition) 176 ///////////////////////////////////////////////////////////////////////// 177 class BucketManager; 178 179 ////////////////////////////////////////////////////////////////////////// 180 /// SWR_THREADING_INFO 181 ///////////////////////////////////////////////////////////////////////// 182 struct SWR_THREADING_INFO 183 { 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; 189 }; 190 191 ////////////////////////////////////////////////////////////////////////// 192 /// SWR_CREATECONTEXT_INFO 193 ///////////////////////////////////////////////////////////////////////// 194 struct SWR_CREATECONTEXT_INFO 195 { 196 // External functions (e.g. sampler) need per draw context state. 197 // Use SwrGetPrivateContextState() to access private state. 198 uint32_t privateStateSize; 199 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; 207 208 209 // Pointer to rdtsc buckets mgr returned to the caller. 210 // Only populated when KNOB_ENABLE_RDTSC is set 211 BucketManager* pBucketMgr; 212 213 // Output: size required memory passed to for SwrSaveState / SwrRestoreState 214 size_t contextSaveSize; 215 216 // Input (optional): Threading info that overrides any set KNOB values. 217 SWR_THREADING_INFO* pThreadInfo; 218 }; 219 220 ////////////////////////////////////////////////////////////////////////// 221 /// @brief Create SWR Context. 222 /// @param pCreateInfo - pointer to creation info. 223 HANDLE SWR_API SwrCreateContext( 224 SWR_CREATECONTEXT_INFO* pCreateInfo); 225 226 ////////////////////////////////////////////////////////////////////////// 227 /// @brief Destroys SWR Context. 228 /// @param hContext - Handle passed back from SwrCreateContext 229 void SWR_API SwrDestroyContext( 230 HANDLE hContext); 231 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 void SWR_API SwrSaveState( 238 HANDLE hContext, 239 void* pOutputStateBlock, 240 size_t memSize); 241 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 void SWR_API SwrRestoreState( 248 HANDLE hContext, 249 const void* pStateBlock, 250 size_t memSize); 251 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 void SWR_API SwrSync( 259 HANDLE hContext, 260 PFN_CALLBACK_FUNC pfnFunc, 261 uint64_t userData, 262 uint64_t userData2, 263 uint64_t userData3 = 0); 264 265 ////////////////////////////////////////////////////////////////////////// 266 /// @brief Blocks until all rendering has been completed. 267 /// @param hContext - Handle passed back from SwrCreateContext 268 void SWR_API SwrWaitForIdle( 269 HANDLE hContext); 270 271 ////////////////////////////////////////////////////////////////////////// 272 /// @brief Blocks until all FE rendering has been completed. 273 /// @param hContext - Handle passed back from SwrCreateContext 274 void SWR_API SwrWaitForIdleFE( 275 HANDLE hContext); 276 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 void SWR_API SwrSetVertexBuffers( 283 HANDLE hContext, 284 uint32_t numBuffers, 285 const SWR_VERTEX_BUFFER_STATE* pVertexBuffers); 286 287 ////////////////////////////////////////////////////////////////////////// 288 /// @brief Set index buffer 289 /// @param hContext - Handle passed back from SwrCreateContext 290 /// @param pIndexBuffer - Index buffer. 291 void SWR_API SwrSetIndexBuffer( 292 HANDLE hContext, 293 const SWR_INDEX_BUFFER_STATE* pIndexBuffer); 294 295 ////////////////////////////////////////////////////////////////////////// 296 /// @brief Set fetch shader pointer. 297 /// @param hContext - Handle passed back from SwrCreateContext 298 /// @param pfnFetchFunc - Pointer to shader. 299 void SWR_API SwrSetFetchFunc( 300 HANDLE hContext, 301 PFN_FETCH_FUNC pfnFetchFunc); 302 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 void SWR_API SwrSetSoFunc( 309 HANDLE hContext, 310 PFN_SO_FUNC pfnSoFunc, 311 uint32_t streamIndex); 312 313 ////////////////////////////////////////////////////////////////////////// 314 /// @brief Set streamout state 315 /// @param hContext - Handle passed back from SwrCreateContext 316 /// @param pSoState - Pointer to streamout state. 317 void SWR_API SwrSetSoState( 318 HANDLE hContext, 319 SWR_STREAMOUT_STATE* pSoState); 320 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 void SWR_API SwrSetSoBuffers( 327 HANDLE hContext, 328 SWR_STREAMOUT_BUFFER* pSoBuffer, 329 uint32_t slot); 330 331 ////////////////////////////////////////////////////////////////////////// 332 /// @brief Set vertex shader pointer. 333 /// @param hContext - Handle passed back from SwrCreateContext 334 /// @param pfnVertexFunc - Pointer to shader. 335 void SWR_API SwrSetVertexFunc( 336 HANDLE hContext, 337 PFN_VERTEX_FUNC pfnVertexFunc); 338 339 ////////////////////////////////////////////////////////////////////////// 340 /// @brief Set frontend state. 341 /// @param hContext - Handle passed back from SwrCreateContext 342 /// @param pState - Pointer to state 343 void SWR_API SwrSetFrontendState( 344 HANDLE hContext, 345 SWR_FRONTEND_STATE *pState); 346 347 ////////////////////////////////////////////////////////////////////////// 348 /// @brief Set geometry shader state. 349 /// @param hContext - Handle passed back from SwrCreateContext 350 /// @param pState - Pointer to state 351 void SWR_API SwrSetGsState( 352 HANDLE hContext, 353 SWR_GS_STATE *pState); 354 355 ////////////////////////////////////////////////////////////////////////// 356 /// @brief Set geometry shader 357 /// @param hContext - Handle passed back from SwrCreateContext 358 /// @param pState - Pointer to geometry shader function 359 void SWR_API SwrSetGsFunc( 360 HANDLE hContext, 361 PFN_GS_FUNC pfnGsFunc); 362 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 void SWR_API SwrSetCsFunc( 370 HANDLE hContext, 371 PFN_CS_FUNC pfnCsFunc, 372 uint32_t totalThreadsInGroup, 373 uint32_t totalSpillFillSize); 374 375 ////////////////////////////////////////////////////////////////////////// 376 /// @brief Set tessellation state. 377 /// @param hContext - Handle passed back from SwrCreateContext 378 /// @param pState - Pointer to state 379 void SWR_API SwrSetTsState( 380 HANDLE hContext, 381 SWR_TS_STATE *pState); 382 383 ////////////////////////////////////////////////////////////////////////// 384 /// @brief Set hull shader 385 /// @param hContext - Handle passed back from SwrCreateContext 386 /// @param pfnFunc - Pointer to shader function 387 void SWR_API SwrSetHsFunc( 388 HANDLE hContext, 389 PFN_HS_FUNC pfnFunc); 390 391 ////////////////////////////////////////////////////////////////////////// 392 /// @brief Set domain shader 393 /// @param hContext - Handle passed back from SwrCreateContext 394 /// @param pfnFunc - Pointer to shader function 395 void SWR_API SwrSetDsFunc( 396 HANDLE hContext, 397 PFN_DS_FUNC pfnFunc); 398 399 ////////////////////////////////////////////////////////////////////////// 400 /// @brief Set depth stencil state 401 /// @param hContext - Handle passed back from SwrCreateContext 402 /// @param pState - Pointer to state. 403 void SWR_API SwrSetDepthStencilState( 404 HANDLE hContext, 405 SWR_DEPTH_STENCIL_STATE *pState); 406 407 ////////////////////////////////////////////////////////////////////////// 408 /// @brief Set backend state 409 /// @param hContext - Handle passed back from SwrCreateContext 410 /// @param pState - Pointer to state. 411 void SWR_API SwrSetBackendState( 412 HANDLE hContext, 413 SWR_BACKEND_STATE *pState); 414 415 ////////////////////////////////////////////////////////////////////////// 416 /// @brief Set depth bounds state 417 /// @param hContext - Handle passed back from SwrCreateContext 418 /// @param pState - Pointer to state. 419 void SWR_API SwrSetDepthBoundsState( 420 HANDLE hContext, 421 SWR_DEPTH_BOUNDS_STATE *pState); 422 423 ////////////////////////////////////////////////////////////////////////// 424 /// @brief Set pixel shader state 425 /// @param hContext - Handle passed back from SwrCreateContext 426 /// @param pState - Pointer to state. 427 void SWR_API SwrSetPixelShaderState( 428 HANDLE hContext, 429 SWR_PS_STATE *pState); 430 431 ////////////////////////////////////////////////////////////////////////// 432 /// @brief Set blend state 433 /// @param hContext - Handle passed back from SwrCreateContext 434 /// @param pState - Pointer to state. 435 void SWR_API SwrSetBlendState( 436 HANDLE hContext, 437 SWR_BLEND_STATE *pState); 438 439 ////////////////////////////////////////////////////////////////////////// 440 /// @brief Set blend function 441 /// @param hContext - Handle passed back from SwrCreateContext 442 /// @param renderTarget - render target index 443 /// @param pfnBlendFunc - function pointer 444 void SWR_API SwrSetBlendFunc( 445 HANDLE hContext, 446 uint32_t renderTarget, 447 PFN_BLEND_JIT_FUNC pfnBlendFunc); 448 449 ////////////////////////////////////////////////////////////////////////// 450 /// @brief SwrDraw 451 /// @param hContext - Handle passed back from SwrCreateContext 452 /// @param topology - Specifies topology for draw. 453 /// @param startVertex - Specifies start vertex in vertex buffer for draw. 454 /// @param primCount - Number of vertices. 455 void SWR_API SwrDraw( 456 HANDLE hContext, 457 PRIMITIVE_TOPOLOGY topology, 458 uint32_t startVertex, 459 uint32_t primCount); 460 461 ////////////////////////////////////////////////////////////////////////// 462 /// @brief SwrDrawInstanced 463 /// @param hContext - Handle passed back from SwrCreateContext 464 /// @param topology - Specifies topology for draw. 465 /// @param numVertsPerInstance - How many vertices to read sequentially from vertex data. 466 /// @param numInstances - How many instances to render. 467 /// @param startVertex - Specifies start vertex for draw. (vertex data) 468 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data) 469 void SWR_API SwrDrawInstanced( 470 HANDLE hContext, 471 PRIMITIVE_TOPOLOGY topology, 472 uint32_t numVertsPerInstance, 473 uint32_t numInstances, 474 uint32_t startVertex, 475 uint32_t startInstance); 476 477 ////////////////////////////////////////////////////////////////////////// 478 /// @brief DrawIndexed 479 /// @param hContext - Handle passed back from SwrCreateContext 480 /// @param topology - Specifies topology for draw. 481 /// @param numIndices - Number of indices to read sequentially from index buffer. 482 /// @param indexOffset - Starting index into index buffer. 483 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed. 484 void SWR_API SwrDrawIndexed( 485 HANDLE hContext, 486 PRIMITIVE_TOPOLOGY topology, 487 uint32_t numIndices, 488 uint32_t indexOffset, 489 int32_t baseVertex); 490 491 ////////////////////////////////////////////////////////////////////////// 492 /// @brief SwrDrawIndexedInstanced 493 /// @param hContext - Handle passed back from SwrCreateContext 494 /// @param topology - Specifies topology for draw. 495 /// @param numIndices - Number of indices to read sequentially from index buffer. 496 /// @param numInstances - Number of instances to render. 497 /// @param indexOffset - Starting index into index buffer. 498 /// @param baseVertex - Vertex in vertex buffer to consider as index "0". Note value is signed. 499 /// @param startInstance - Which instance to start sequentially fetching from in each buffer (instanced data) 500 void SWR_API SwrDrawIndexedInstanced( 501 HANDLE hContext, 502 PRIMITIVE_TOPOLOGY topology, 503 uint32_t numIndices, 504 uint32_t numInstances, 505 uint32_t indexOffset, 506 int32_t baseVertex, 507 uint32_t startInstance); 508 509 ////////////////////////////////////////////////////////////////////////// 510 /// @brief SwrInvalidateTiles 511 /// @param hContext - Handle passed back from SwrCreateContext 512 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to invalidate. 513 /// @param invalidateRect - The pixel-coordinate rectangle to invalidate. This will be expanded to 514 /// be hottile size-aligned. 515 void SWR_API SwrInvalidateTiles( 516 HANDLE hContext, 517 uint32_t attachmentMask, 518 const SWR_RECT& invalidateRect); 519 520 ////////////////////////////////////////////////////////////////////////// 521 /// @brief SwrDiscardRect 522 /// @param hContext - Handle passed back from SwrCreateContext 523 /// @param attachmentMask - The mask specifies which surfaces attached to the hottiles to discard. 524 /// @param rect - The pixel-coordinate rectangle to discard. Only fully-covered hottiles will be 525 /// discarded. 526 void SWR_API SwrDiscardRect( 527 HANDLE hContext, 528 uint32_t attachmentMask, 529 const SWR_RECT& rect); 530 531 ////////////////////////////////////////////////////////////////////////// 532 /// @brief SwrDispatch 533 /// @param hContext - Handle passed back from SwrCreateContext 534 /// @param threadGroupCountX - Number of thread groups dispatched in X direction 535 /// @param threadGroupCountY - Number of thread groups dispatched in Y direction 536 /// @param threadGroupCountZ - Number of thread groups dispatched in Z direction 537 void SWR_API SwrDispatch( 538 HANDLE hContext, 539 uint32_t threadGroupCountX, 540 uint32_t threadGroupCountY, 541 uint32_t threadGroupCountZ); 542 543 544 enum SWR_TILE_STATE 545 { 546 SWR_TILE_INVALID = 0, // tile is in unitialized state and should be loaded with surface contents before rendering 547 SWR_TILE_DIRTY = 2, // tile contains newer data than surface it represents 548 SWR_TILE_RESOLVED = 3, // is in sync with surface it represents 549 }; 550 551 /// @todo Add a good description for what attachments are and when and why you would use the different SWR_TILE_STATEs. 552 void SWR_API SwrStoreTiles( 553 HANDLE hContext, 554 uint32_t attachmentMask, 555 SWR_TILE_STATE postStoreTileState, 556 const SWR_RECT& storeRect); 557 558 559 ////////////////////////////////////////////////////////////////////////// 560 /// @brief SwrClearRenderTarget - Clear attached render targets / depth / stencil 561 /// @param hContext - Handle passed back from SwrCreateContext 562 /// @param attachmentMask - combination of SWR_ATTACHMENT_*_BIT attachments to clear 563 /// @param renderTargetArrayIndex - the RT array index to clear 564 /// @param clearColor - color use for clearing render targets 565 /// @param z - depth value use for clearing depth buffer 566 /// @param stencil - stencil value used for clearing stencil buffer 567 /// @param clearRect - The pixel-coordinate rectangle to clear in all cleared buffers 568 void SWR_API SwrClearRenderTarget( 569 HANDLE hContext, 570 uint32_t attachmentMask, 571 uint32_t renderTargetArrayIndex, 572 const float clearColor[4], 573 float z, 574 uint8_t stencil, 575 const SWR_RECT& clearRect); 576 577 ////////////////////////////////////////////////////////////////////////// 578 /// @brief SwrSetRastState 579 /// @param hContext - Handle passed back from SwrCreateContext 580 /// @param pRastState - New SWR_RASTSTATE used for SwrDraw* commands 581 void SWR_API SwrSetRastState( 582 HANDLE hContext, 583 const SWR_RASTSTATE *pRastState); 584 585 ////////////////////////////////////////////////////////////////////////// 586 /// @brief SwrSetViewports 587 /// @param hContext - Handle passed back from SwrCreateContext 588 /// @param numViewports - number of viewports passed in 589 /// @param pViewports - Specifies extents of viewport. 590 /// @param pMatrices - If not specified then SWR computes a default one. 591 void SWR_API SwrSetViewports( 592 HANDLE hContext, 593 uint32_t numViewports, 594 const SWR_VIEWPORT* pViewports, 595 const SWR_VIEWPORT_MATRICES* pMatrices); 596 597 ////////////////////////////////////////////////////////////////////////// 598 /// @brief SwrSetScissorRects 599 /// @param hContext - Handle passed back from SwrCreateContext 600 /// @param numScissors - number of scissors passed in 601 /// @param pScissors - array of scissors 602 void SWR_API SwrSetScissorRects( 603 HANDLE hContext, 604 uint32_t numScissors, 605 const SWR_RECT* pScissors); 606 607 ////////////////////////////////////////////////////////////////////////// 608 /// @brief Returns a pointer to the private context state for the current 609 /// draw operation. This is used for external componets such as the 610 /// sampler. 611 /// 612 /// @note Client needs to resend private state prior to each draw call. 613 /// Also, SWR is responsible for the private state memory. 614 /// @param hContext - Handle passed back from SwrCreateContext 615 VOID* SWR_API SwrGetPrivateContextState( 616 HANDLE hContext); 617 618 ////////////////////////////////////////////////////////////////////////// 619 /// @brief Clients can use this to allocate memory for draw/dispatch 620 /// operations. The memory will automatically be freed once operation 621 /// has completed. Client can use this to allocate binding tables, 622 /// etc. needed for shader execution. 623 /// @param hContext - Handle passed back from SwrCreateContext 624 /// @param size - Size of allocation 625 /// @param align - Alignment needed for allocation. 626 VOID* SWR_API SwrAllocDrawContextMemory( 627 HANDLE hContext, 628 uint32_t size, 629 uint32_t align); 630 631 ////////////////////////////////////////////////////////////////////////// 632 /// @brief Enables stats counting 633 /// @param hContext - Handle passed back from SwrCreateContext 634 /// @param enable - If true then counts are incremented. 635 void SWR_API SwrEnableStatsFE( 636 HANDLE hContext, 637 bool enable); 638 639 ////////////////////////////////////////////////////////////////////////// 640 /// @brief Enables stats counting 641 /// @param hContext - Handle passed back from SwrCreateContext 642 /// @param enable - If true then counts are incremented. 643 void SWR_API SwrEnableStatsBE( 644 HANDLE hContext, 645 bool enable); 646 647 ////////////////////////////////////////////////////////////////////////// 648 /// @brief Mark end of frame - used for performance profiling 649 /// @param hContext - Handle passed back from SwrCreateContext 650 void SWR_API SwrEndFrame( 651 HANDLE hContext); 652 653 654 #endif 655