1 /************************************************************************** 2 * 3 * Copyright 2010 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28 29 #include "pipe/p_context.h" 30 #include "util/u_memory.h" 31 #include "util/u_inlines.h" 32 #include "util/simple_list.h" 33 34 #include "rbug/rbug_context.h" 35 36 #include "rbug_context.h" 37 #include "rbug_objects.h" 38 39 40 static void 41 rbug_destroy(struct pipe_context *_pipe) 42 { 43 struct rbug_screen *rb_screen = rbug_screen(_pipe->screen); 44 struct rbug_context *rb_pipe = rbug_context(_pipe); 45 struct pipe_context *pipe = rb_pipe->pipe; 46 47 rbug_screen_remove_from_list(rb_screen, contexts, rb_pipe); 48 49 mtx_lock(&rb_pipe->call_mutex); 50 pipe->destroy(pipe); 51 rb_pipe->pipe = NULL; 52 mtx_unlock(&rb_pipe->call_mutex); 53 54 FREE(rb_pipe); 55 } 56 57 static void 58 rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag) 59 { 60 61 if (rb_pipe->draw_blocker & flag) { 62 rb_pipe->draw_blocked |= flag; 63 } else if ((rb_pipe->draw_rule.blocker & flag) && 64 (rb_pipe->draw_blocker & RBUG_BLOCK_RULE)) { 65 unsigned k; 66 boolean block = FALSE; 67 unsigned sh; 68 69 debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, 70 (void *) rb_pipe->draw_rule.shader[PIPE_SHADER_FRAGMENT], 71 (void *) rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT], 72 (void *) rb_pipe->draw_rule.shader[PIPE_SHADER_VERTEX], 73 (void *) rb_pipe->curr.shader[PIPE_SHADER_VERTEX], 74 (void *) rb_pipe->draw_rule.surf, 0, 75 (void *) rb_pipe->draw_rule.texture, 0); 76 for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { 77 if (rb_pipe->draw_rule.shader[sh] && 78 rb_pipe->draw_rule.shader[sh] == rb_pipe->curr.shader[sh]) 79 block = TRUE; 80 } 81 82 if (rb_pipe->draw_rule.surf && 83 rb_pipe->draw_rule.surf == rb_pipe->curr.zsbuf) 84 block = TRUE; 85 if (rb_pipe->draw_rule.surf) 86 for (k = 0; k < rb_pipe->curr.nr_cbufs; k++) 87 if (rb_pipe->draw_rule.surf == rb_pipe->curr.cbufs[k]) 88 block = TRUE; 89 if (rb_pipe->draw_rule.texture) { 90 for (sh = 0; sh < ARRAY_SIZE(rb_pipe->curr.num_views); sh++) { 91 for (k = 0; k < rb_pipe->curr.num_views[sh]; k++) { 92 if (rb_pipe->draw_rule.texture == rb_pipe->curr.texs[sh][k]) { 93 block = TRUE; 94 sh = PIPE_SHADER_TYPES; /* to break out of both loops */ 95 break; 96 } 97 } 98 } 99 } 100 101 if (block) 102 rb_pipe->draw_blocked |= (flag | RBUG_BLOCK_RULE); 103 } 104 105 if (rb_pipe->draw_blocked) 106 rbug_notify_draw_blocked(rb_pipe); 107 108 /* wait for rbug to clear the blocked flag */ 109 while (rb_pipe->draw_blocked & flag) { 110 rb_pipe->draw_blocked |= flag; 111 cnd_wait(&rb_pipe->draw_cond, &rb_pipe->draw_mutex); 112 } 113 114 } 115 116 static void 117 rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info) 118 { 119 struct rbug_context *rb_pipe = rbug_context(_pipe); 120 struct pipe_context *pipe = rb_pipe->pipe; 121 122 mtx_lock(&rb_pipe->draw_mutex); 123 rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); 124 125 mtx_lock(&rb_pipe->call_mutex); 126 /* XXX loop over PIPE_SHADER_x here */ 127 if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) && 128 !(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) && 129 !(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled)) 130 pipe->draw_vbo(pipe, info); 131 mtx_unlock(&rb_pipe->call_mutex); 132 133 rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); 134 mtx_unlock(&rb_pipe->draw_mutex); 135 } 136 137 static struct pipe_query * 138 rbug_create_query(struct pipe_context *_pipe, 139 unsigned query_type, 140 unsigned index) 141 { 142 struct rbug_context *rb_pipe = rbug_context(_pipe); 143 struct pipe_context *pipe = rb_pipe->pipe; 144 struct pipe_query *query; 145 146 mtx_lock(&rb_pipe->call_mutex); 147 query = pipe->create_query(pipe, 148 query_type, 149 index); 150 mtx_unlock(&rb_pipe->call_mutex); 151 return query; 152 } 153 154 static void 155 rbug_destroy_query(struct pipe_context *_pipe, 156 struct pipe_query *query) 157 { 158 struct rbug_context *rb_pipe = rbug_context(_pipe); 159 struct pipe_context *pipe = rb_pipe->pipe; 160 161 mtx_lock(&rb_pipe->call_mutex); 162 pipe->destroy_query(pipe, 163 query); 164 mtx_unlock(&rb_pipe->call_mutex); 165 } 166 167 static boolean 168 rbug_begin_query(struct pipe_context *_pipe, 169 struct pipe_query *query) 170 { 171 struct rbug_context *rb_pipe = rbug_context(_pipe); 172 struct pipe_context *pipe = rb_pipe->pipe; 173 boolean ret; 174 175 mtx_lock(&rb_pipe->call_mutex); 176 ret = pipe->begin_query(pipe, query); 177 mtx_unlock(&rb_pipe->call_mutex); 178 return ret; 179 } 180 181 static bool 182 rbug_end_query(struct pipe_context *_pipe, 183 struct pipe_query *query) 184 { 185 struct rbug_context *rb_pipe = rbug_context(_pipe); 186 struct pipe_context *pipe = rb_pipe->pipe; 187 bool ret; 188 189 mtx_lock(&rb_pipe->call_mutex); 190 ret = pipe->end_query(pipe, 191 query); 192 mtx_unlock(&rb_pipe->call_mutex); 193 194 return ret; 195 } 196 197 static boolean 198 rbug_get_query_result(struct pipe_context *_pipe, 199 struct pipe_query *query, 200 boolean wait, 201 union pipe_query_result *result) 202 { 203 struct rbug_context *rb_pipe = rbug_context(_pipe); 204 struct pipe_context *pipe = rb_pipe->pipe; 205 boolean ret; 206 207 mtx_lock(&rb_pipe->call_mutex); 208 ret = pipe->get_query_result(pipe, 209 query, 210 wait, 211 result); 212 mtx_unlock(&rb_pipe->call_mutex); 213 214 return ret; 215 } 216 217 static void 218 rbug_set_active_query_state(struct pipe_context *_pipe, boolean enable) 219 { 220 struct rbug_context *rb_pipe = rbug_context(_pipe); 221 struct pipe_context *pipe = rb_pipe->pipe; 222 223 mtx_lock(&rb_pipe->call_mutex); 224 pipe->set_active_query_state(pipe, enable); 225 mtx_unlock(&rb_pipe->call_mutex); 226 } 227 228 static void * 229 rbug_create_blend_state(struct pipe_context *_pipe, 230 const struct pipe_blend_state *blend) 231 { 232 struct rbug_context *rb_pipe = rbug_context(_pipe); 233 struct pipe_context *pipe = rb_pipe->pipe; 234 void *ret; 235 236 mtx_lock(&rb_pipe->call_mutex); 237 ret = pipe->create_blend_state(pipe, 238 blend); 239 mtx_unlock(&rb_pipe->call_mutex); 240 241 return ret; 242 } 243 244 static void 245 rbug_bind_blend_state(struct pipe_context *_pipe, 246 void *blend) 247 { 248 struct rbug_context *rb_pipe = rbug_context(_pipe); 249 struct pipe_context *pipe = rb_pipe->pipe; 250 251 mtx_lock(&rb_pipe->call_mutex); 252 pipe->bind_blend_state(pipe, 253 blend); 254 mtx_unlock(&rb_pipe->call_mutex); 255 } 256 257 static void 258 rbug_delete_blend_state(struct pipe_context *_pipe, 259 void *blend) 260 { 261 struct rbug_context *rb_pipe = rbug_context(_pipe); 262 struct pipe_context *pipe = rb_pipe->pipe; 263 264 mtx_lock(&rb_pipe->call_mutex); 265 pipe->delete_blend_state(pipe, 266 blend); 267 mtx_unlock(&rb_pipe->call_mutex); 268 } 269 270 static void * 271 rbug_create_sampler_state(struct pipe_context *_pipe, 272 const struct pipe_sampler_state *sampler) 273 { 274 struct rbug_context *rb_pipe = rbug_context(_pipe); 275 struct pipe_context *pipe = rb_pipe->pipe; 276 void *ret; 277 278 mtx_lock(&rb_pipe->call_mutex); 279 ret = pipe->create_sampler_state(pipe, 280 sampler); 281 mtx_unlock(&rb_pipe->call_mutex); 282 283 return ret; 284 } 285 286 static void 287 rbug_bind_sampler_states(struct pipe_context *_pipe, 288 enum pipe_shader_type shader, 289 unsigned start, unsigned count, 290 void **samplers) 291 { 292 struct rbug_context *rb_pipe = rbug_context(_pipe); 293 struct pipe_context *pipe = rb_pipe->pipe; 294 295 mtx_lock(&rb_pipe->call_mutex); 296 pipe->bind_sampler_states(pipe, shader, start, count, samplers); 297 mtx_unlock(&rb_pipe->call_mutex); 298 } 299 300 static void 301 rbug_delete_sampler_state(struct pipe_context *_pipe, 302 void *sampler) 303 { 304 struct rbug_context *rb_pipe = rbug_context(_pipe); 305 struct pipe_context *pipe = rb_pipe->pipe; 306 307 mtx_lock(&rb_pipe->call_mutex); 308 pipe->delete_sampler_state(pipe, 309 sampler); 310 mtx_unlock(&rb_pipe->call_mutex); 311 } 312 313 static void * 314 rbug_create_rasterizer_state(struct pipe_context *_pipe, 315 const struct pipe_rasterizer_state *rasterizer) 316 { 317 struct rbug_context *rb_pipe = rbug_context(_pipe); 318 struct pipe_context *pipe = rb_pipe->pipe; 319 void *ret; 320 321 mtx_lock(&rb_pipe->call_mutex); 322 ret = pipe->create_rasterizer_state(pipe, 323 rasterizer); 324 mtx_unlock(&rb_pipe->call_mutex); 325 326 return ret; 327 } 328 329 static void 330 rbug_bind_rasterizer_state(struct pipe_context *_pipe, 331 void *rasterizer) 332 { 333 struct rbug_context *rb_pipe = rbug_context(_pipe); 334 struct pipe_context *pipe = rb_pipe->pipe; 335 336 mtx_lock(&rb_pipe->call_mutex); 337 pipe->bind_rasterizer_state(pipe, 338 rasterizer); 339 mtx_unlock(&rb_pipe->call_mutex); 340 } 341 342 static void 343 rbug_delete_rasterizer_state(struct pipe_context *_pipe, 344 void *rasterizer) 345 { 346 struct rbug_context *rb_pipe = rbug_context(_pipe); 347 struct pipe_context *pipe = rb_pipe->pipe; 348 349 mtx_lock(&rb_pipe->call_mutex); 350 pipe->delete_rasterizer_state(pipe, 351 rasterizer); 352 mtx_unlock(&rb_pipe->call_mutex); 353 } 354 355 static void * 356 rbug_create_depth_stencil_alpha_state(struct pipe_context *_pipe, 357 const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha) 358 { 359 struct rbug_context *rb_pipe = rbug_context(_pipe); 360 struct pipe_context *pipe = rb_pipe->pipe; 361 void *ret; 362 363 mtx_lock(&rb_pipe->call_mutex); 364 ret = pipe->create_depth_stencil_alpha_state(pipe, 365 depth_stencil_alpha); 366 mtx_unlock(&rb_pipe->call_mutex); 367 368 return ret; 369 } 370 371 static void 372 rbug_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, 373 void *depth_stencil_alpha) 374 { 375 struct rbug_context *rb_pipe = rbug_context(_pipe); 376 struct pipe_context *pipe = rb_pipe->pipe; 377 378 mtx_lock(&rb_pipe->call_mutex); 379 pipe->bind_depth_stencil_alpha_state(pipe, 380 depth_stencil_alpha); 381 mtx_unlock(&rb_pipe->call_mutex); 382 } 383 384 static void 385 rbug_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, 386 void *depth_stencil_alpha) 387 { 388 struct rbug_context *rb_pipe = rbug_context(_pipe); 389 struct pipe_context *pipe = rb_pipe->pipe; 390 391 mtx_lock(&rb_pipe->call_mutex); 392 pipe->delete_depth_stencil_alpha_state(pipe, 393 depth_stencil_alpha); 394 mtx_unlock(&rb_pipe->call_mutex); 395 } 396 397 static void * 398 rbug_create_fs_state(struct pipe_context *_pipe, 399 const struct pipe_shader_state *state) 400 { 401 struct rbug_context *rb_pipe = rbug_context(_pipe); 402 struct pipe_context *pipe = rb_pipe->pipe; 403 void *result; 404 405 mtx_lock(&rb_pipe->call_mutex); 406 result = pipe->create_fs_state(pipe, state); 407 mtx_unlock(&rb_pipe->call_mutex); 408 409 if (!result) 410 return NULL; 411 412 return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_FRAGMENT); 413 } 414 415 static void 416 rbug_bind_fs_state(struct pipe_context *_pipe, 417 void *_fs) 418 { 419 struct rbug_context *rb_pipe = rbug_context(_pipe); 420 struct pipe_context *pipe = rb_pipe->pipe; 421 void *fs; 422 423 mtx_lock(&rb_pipe->call_mutex); 424 425 fs = rbug_shader_unwrap(_fs); 426 rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] = rbug_shader(_fs); 427 pipe->bind_fs_state(pipe, 428 fs); 429 430 mtx_unlock(&rb_pipe->call_mutex); 431 } 432 433 static void 434 rbug_delete_fs_state(struct pipe_context *_pipe, 435 void *_fs) 436 { 437 struct rbug_context *rb_pipe = rbug_context(_pipe); 438 struct rbug_shader *rb_shader = rbug_shader(_fs); 439 440 mtx_lock(&rb_pipe->call_mutex); 441 rbug_shader_destroy(rb_pipe, rb_shader); 442 mtx_unlock(&rb_pipe->call_mutex); 443 } 444 445 static void * 446 rbug_create_vs_state(struct pipe_context *_pipe, 447 const struct pipe_shader_state *state) 448 { 449 struct rbug_context *rb_pipe = rbug_context(_pipe); 450 struct pipe_context *pipe = rb_pipe->pipe; 451 void *result; 452 453 mtx_lock(&rb_pipe->call_mutex); 454 result = pipe->create_vs_state(pipe, state); 455 mtx_unlock(&rb_pipe->call_mutex); 456 457 if (!result) 458 return NULL; 459 460 return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_VERTEX); 461 } 462 463 static void 464 rbug_bind_vs_state(struct pipe_context *_pipe, 465 void *_vs) 466 { 467 struct rbug_context *rb_pipe = rbug_context(_pipe); 468 struct pipe_context *pipe = rb_pipe->pipe; 469 void *vs; 470 471 mtx_lock(&rb_pipe->call_mutex); 472 473 vs = rbug_shader_unwrap(_vs); 474 rb_pipe->curr.shader[PIPE_SHADER_VERTEX] = rbug_shader(_vs); 475 pipe->bind_vs_state(pipe, 476 vs); 477 478 mtx_unlock(&rb_pipe->call_mutex); 479 } 480 481 static void 482 rbug_delete_vs_state(struct pipe_context *_pipe, 483 void *_vs) 484 { 485 struct rbug_context *rb_pipe = rbug_context(_pipe); 486 struct rbug_shader *rb_shader = rbug_shader(_vs); 487 488 mtx_unlock(&rb_pipe->call_mutex); 489 rbug_shader_destroy(rb_pipe, rb_shader); 490 mtx_unlock(&rb_pipe->call_mutex); 491 } 492 493 static void * 494 rbug_create_gs_state(struct pipe_context *_pipe, 495 const struct pipe_shader_state *state) 496 { 497 struct rbug_context *rb_pipe = rbug_context(_pipe); 498 struct pipe_context *pipe = rb_pipe->pipe; 499 void *result; 500 501 mtx_lock(&rb_pipe->call_mutex); 502 result = pipe->create_gs_state(pipe, state); 503 mtx_unlock(&rb_pipe->call_mutex); 504 505 if (!result) 506 return NULL; 507 508 return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_GEOM); 509 } 510 511 static void 512 rbug_bind_gs_state(struct pipe_context *_pipe, 513 void *_gs) 514 { 515 struct rbug_context *rb_pipe = rbug_context(_pipe); 516 struct pipe_context *pipe = rb_pipe->pipe; 517 void *gs; 518 519 mtx_lock(&rb_pipe->call_mutex); 520 521 gs = rbug_shader_unwrap(_gs); 522 rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] = rbug_shader(_gs); 523 pipe->bind_gs_state(pipe, 524 gs); 525 526 mtx_unlock(&rb_pipe->call_mutex); 527 } 528 529 static void 530 rbug_delete_gs_state(struct pipe_context *_pipe, 531 void *_gs) 532 { 533 struct rbug_context *rb_pipe = rbug_context(_pipe); 534 struct rbug_shader *rb_shader = rbug_shader(_gs); 535 536 mtx_lock(&rb_pipe->call_mutex); 537 rbug_shader_destroy(rb_pipe, rb_shader); 538 mtx_unlock(&rb_pipe->call_mutex); 539 } 540 541 static void * 542 rbug_create_vertex_elements_state(struct pipe_context *_pipe, 543 unsigned num_elements, 544 const struct pipe_vertex_element *vertex_elements) 545 { 546 struct rbug_context *rb_pipe = rbug_context(_pipe); 547 struct pipe_context *pipe = rb_pipe->pipe; 548 void *ret; 549 550 mtx_lock(&rb_pipe->call_mutex); 551 ret = pipe->create_vertex_elements_state(pipe, 552 num_elements, 553 vertex_elements); 554 mtx_unlock(&rb_pipe->call_mutex); 555 556 return ret; 557 } 558 559 static void 560 rbug_bind_vertex_elements_state(struct pipe_context *_pipe, 561 void *velems) 562 { 563 struct rbug_context *rb_pipe = rbug_context(_pipe); 564 struct pipe_context *pipe = rb_pipe->pipe; 565 566 mtx_lock(&rb_pipe->call_mutex); 567 pipe->bind_vertex_elements_state(pipe, 568 velems); 569 mtx_unlock(&rb_pipe->call_mutex); 570 } 571 572 static void 573 rbug_delete_vertex_elements_state(struct pipe_context *_pipe, 574 void *velems) 575 { 576 struct rbug_context *rb_pipe = rbug_context(_pipe); 577 struct pipe_context *pipe = rb_pipe->pipe; 578 579 mtx_lock(&rb_pipe->call_mutex); 580 pipe->delete_vertex_elements_state(pipe, 581 velems); 582 mtx_unlock(&rb_pipe->call_mutex); 583 } 584 585 static void 586 rbug_set_blend_color(struct pipe_context *_pipe, 587 const struct pipe_blend_color *blend_color) 588 { 589 struct rbug_context *rb_pipe = rbug_context(_pipe); 590 struct pipe_context *pipe = rb_pipe->pipe; 591 592 mtx_lock(&rb_pipe->call_mutex); 593 pipe->set_blend_color(pipe, 594 blend_color); 595 mtx_unlock(&rb_pipe->call_mutex); 596 } 597 598 static void 599 rbug_set_stencil_ref(struct pipe_context *_pipe, 600 const struct pipe_stencil_ref *stencil_ref) 601 { 602 struct rbug_context *rb_pipe = rbug_context(_pipe); 603 struct pipe_context *pipe = rb_pipe->pipe; 604 605 mtx_lock(&rb_pipe->call_mutex); 606 pipe->set_stencil_ref(pipe, 607 stencil_ref); 608 mtx_unlock(&rb_pipe->call_mutex); 609 } 610 611 static void 612 rbug_set_clip_state(struct pipe_context *_pipe, 613 const struct pipe_clip_state *clip) 614 { 615 struct rbug_context *rb_pipe = rbug_context(_pipe); 616 struct pipe_context *pipe = rb_pipe->pipe; 617 618 mtx_lock(&rb_pipe->call_mutex); 619 pipe->set_clip_state(pipe, 620 clip); 621 mtx_unlock(&rb_pipe->call_mutex); 622 } 623 624 static void 625 rbug_set_constant_buffer(struct pipe_context *_pipe, 626 enum pipe_shader_type shader, 627 uint index, 628 const struct pipe_constant_buffer *_cb) 629 { 630 struct rbug_context *rb_pipe = rbug_context(_pipe); 631 struct pipe_context *pipe = rb_pipe->pipe; 632 struct pipe_constant_buffer cb; 633 634 /* XXX hmm? unwrap the input state */ 635 if (_cb) { 636 cb = *_cb; 637 cb.buffer = rbug_resource_unwrap(_cb->buffer); 638 } 639 640 mtx_lock(&rb_pipe->call_mutex); 641 pipe->set_constant_buffer(pipe, 642 shader, 643 index, 644 _cb ? &cb : NULL); 645 mtx_unlock(&rb_pipe->call_mutex); 646 } 647 648 static void 649 rbug_set_framebuffer_state(struct pipe_context *_pipe, 650 const struct pipe_framebuffer_state *_state) 651 { 652 struct rbug_context *rb_pipe = rbug_context(_pipe); 653 struct pipe_context *pipe = rb_pipe->pipe; 654 struct pipe_framebuffer_state unwrapped_state; 655 struct pipe_framebuffer_state *state = NULL; 656 unsigned i; 657 658 /* must protect curr status */ 659 mtx_lock(&rb_pipe->call_mutex); 660 661 rb_pipe->curr.nr_cbufs = 0; 662 memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs)); 663 rb_pipe->curr.zsbuf = NULL; 664 665 /* unwrap the input state */ 666 if (_state) { 667 memcpy(&unwrapped_state, _state, sizeof(unwrapped_state)); 668 669 rb_pipe->curr.nr_cbufs = _state->nr_cbufs; 670 for(i = 0; i < _state->nr_cbufs; i++) { 671 unwrapped_state.cbufs[i] = rbug_surface_unwrap(_state->cbufs[i]); 672 if (_state->cbufs[i]) 673 rb_pipe->curr.cbufs[i] = rbug_resource(_state->cbufs[i]->texture); 674 } 675 unwrapped_state.zsbuf = rbug_surface_unwrap(_state->zsbuf); 676 if (_state->zsbuf) 677 rb_pipe->curr.zsbuf = rbug_resource(_state->zsbuf->texture); 678 state = &unwrapped_state; 679 } 680 681 pipe->set_framebuffer_state(pipe, 682 state); 683 684 mtx_unlock(&rb_pipe->call_mutex); 685 } 686 687 static void 688 rbug_set_polygon_stipple(struct pipe_context *_pipe, 689 const struct pipe_poly_stipple *poly_stipple) 690 { 691 struct rbug_context *rb_pipe = rbug_context(_pipe); 692 struct pipe_context *pipe = rb_pipe->pipe; 693 694 mtx_lock(&rb_pipe->call_mutex); 695 pipe->set_polygon_stipple(pipe, 696 poly_stipple); 697 mtx_unlock(&rb_pipe->call_mutex); 698 } 699 700 static void 701 rbug_set_scissor_states(struct pipe_context *_pipe, 702 unsigned start_slot, 703 unsigned num_scissors, 704 const struct pipe_scissor_state *scissor) 705 { 706 struct rbug_context *rb_pipe = rbug_context(_pipe); 707 struct pipe_context *pipe = rb_pipe->pipe; 708 709 mtx_lock(&rb_pipe->call_mutex); 710 pipe->set_scissor_states(pipe, start_slot, num_scissors, scissor); 711 mtx_unlock(&rb_pipe->call_mutex); 712 } 713 714 static void 715 rbug_set_viewport_states(struct pipe_context *_pipe, 716 unsigned start_slot, 717 unsigned num_viewports, 718 const struct pipe_viewport_state *viewport) 719 { 720 struct rbug_context *rb_pipe = rbug_context(_pipe); 721 struct pipe_context *pipe = rb_pipe->pipe; 722 723 mtx_lock(&rb_pipe->call_mutex); 724 pipe->set_viewport_states(pipe, start_slot, num_viewports, viewport); 725 mtx_unlock(&rb_pipe->call_mutex); 726 } 727 728 static void 729 rbug_set_sampler_views(struct pipe_context *_pipe, 730 enum pipe_shader_type shader, 731 unsigned start, 732 unsigned num, 733 struct pipe_sampler_view **_views) 734 { 735 struct rbug_context *rb_pipe = rbug_context(_pipe); 736 struct pipe_context *pipe = rb_pipe->pipe; 737 struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 738 struct pipe_sampler_view **views = NULL; 739 unsigned i; 740 741 assert(start == 0); /* XXX fix */ 742 743 /* must protect curr status */ 744 mtx_lock(&rb_pipe->call_mutex); 745 746 rb_pipe->curr.num_views[shader] = 0; 747 memset(rb_pipe->curr.views[shader], 0, sizeof(rb_pipe->curr.views[shader])); 748 memset(rb_pipe->curr.texs[shader], 0, sizeof(rb_pipe->curr.texs[shader])); 749 memset(unwrapped_views, 0, sizeof(unwrapped_views)); 750 751 if (_views) { 752 rb_pipe->curr.num_views[shader] = num; 753 for (i = 0; i < num; i++) { 754 rb_pipe->curr.views[shader][i] = rbug_sampler_view(_views[i]); 755 rb_pipe->curr.texs[shader][i] = rbug_resource(_views[i] ? _views[i]->texture : NULL); 756 unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]); 757 } 758 views = unwrapped_views; 759 } 760 761 pipe->set_sampler_views(pipe, shader, start, num, views); 762 763 mtx_unlock(&rb_pipe->call_mutex); 764 } 765 766 static void 767 rbug_set_vertex_buffers(struct pipe_context *_pipe, 768 unsigned start_slot, unsigned num_buffers, 769 const struct pipe_vertex_buffer *_buffers) 770 { 771 struct rbug_context *rb_pipe = rbug_context(_pipe); 772 struct pipe_context *pipe = rb_pipe->pipe; 773 struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS]; 774 struct pipe_vertex_buffer *buffers = NULL; 775 unsigned i; 776 777 mtx_lock(&rb_pipe->call_mutex); 778 779 if (num_buffers && _buffers) { 780 memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers)); 781 for (i = 0; i < num_buffers; i++) { 782 if (!_buffers[i].is_user_buffer) 783 unwrapped_buffers[i].buffer.resource = 784 rbug_resource_unwrap(_buffers[i].buffer.resource); 785 } 786 buffers = unwrapped_buffers; 787 } 788 789 pipe->set_vertex_buffers(pipe, start_slot, 790 num_buffers, 791 buffers); 792 793 mtx_unlock(&rb_pipe->call_mutex); 794 } 795 796 static void 797 rbug_set_sample_mask(struct pipe_context *_pipe, 798 unsigned sample_mask) 799 { 800 struct rbug_context *rb_pipe = rbug_context(_pipe); 801 struct pipe_context *pipe = rb_pipe->pipe; 802 803 mtx_lock(&rb_pipe->call_mutex); 804 pipe->set_sample_mask(pipe, sample_mask); 805 mtx_unlock(&rb_pipe->call_mutex); 806 } 807 808 static struct pipe_stream_output_target * 809 rbug_create_stream_output_target(struct pipe_context *_pipe, 810 struct pipe_resource *_res, 811 unsigned buffer_offset, unsigned buffer_size) 812 { 813 struct rbug_context *rb_pipe = rbug_context(_pipe); 814 struct pipe_context *pipe = rb_pipe->pipe; 815 struct pipe_resource *res = rbug_resource_unwrap(_res); 816 struct pipe_stream_output_target *target; 817 818 mtx_lock(&rb_pipe->call_mutex); 819 target = pipe->create_stream_output_target(pipe, res, buffer_offset, 820 buffer_size); 821 mtx_unlock(&rb_pipe->call_mutex); 822 return target; 823 } 824 825 static void 826 rbug_stream_output_target_destroy(struct pipe_context *_pipe, 827 struct pipe_stream_output_target *target) 828 { 829 struct rbug_context *rb_pipe = rbug_context(_pipe); 830 struct pipe_context *pipe = rb_pipe->pipe; 831 832 mtx_lock(&rb_pipe->call_mutex); 833 pipe->stream_output_target_destroy(pipe, target); 834 mtx_unlock(&rb_pipe->call_mutex); 835 } 836 837 static void 838 rbug_set_stream_output_targets(struct pipe_context *_pipe, 839 unsigned num_targets, 840 struct pipe_stream_output_target **targets, 841 const unsigned *offsets) 842 { 843 struct rbug_context *rb_pipe = rbug_context(_pipe); 844 struct pipe_context *pipe = rb_pipe->pipe; 845 846 mtx_lock(&rb_pipe->call_mutex); 847 pipe->set_stream_output_targets(pipe, num_targets, targets, offsets); 848 mtx_unlock(&rb_pipe->call_mutex); 849 } 850 851 static void 852 rbug_resource_copy_region(struct pipe_context *_pipe, 853 struct pipe_resource *_dst, 854 unsigned dst_level, 855 unsigned dstx, 856 unsigned dsty, 857 unsigned dstz, 858 struct pipe_resource *_src, 859 unsigned src_level, 860 const struct pipe_box *src_box) 861 { 862 struct rbug_context *rb_pipe = rbug_context(_pipe); 863 struct rbug_resource *rb_resource_dst = rbug_resource(_dst); 864 struct rbug_resource *rb_resource_src = rbug_resource(_src); 865 struct pipe_context *pipe = rb_pipe->pipe; 866 struct pipe_resource *dst = rb_resource_dst->resource; 867 struct pipe_resource *src = rb_resource_src->resource; 868 869 mtx_lock(&rb_pipe->call_mutex); 870 pipe->resource_copy_region(pipe, 871 dst, 872 dst_level, 873 dstx, 874 dsty, 875 dstz, 876 src, 877 src_level, 878 src_box); 879 mtx_unlock(&rb_pipe->call_mutex); 880 } 881 882 static void 883 rbug_blit(struct pipe_context *_pipe, const struct pipe_blit_info *_blit_info) 884 { 885 struct rbug_context *rb_pipe = rbug_context(_pipe); 886 struct rbug_resource *rb_resource_dst = rbug_resource(_blit_info->dst.resource); 887 struct rbug_resource *rb_resource_src = rbug_resource(_blit_info->src.resource); 888 struct pipe_context *pipe = rb_pipe->pipe; 889 struct pipe_resource *dst = rb_resource_dst->resource; 890 struct pipe_resource *src = rb_resource_src->resource; 891 struct pipe_blit_info blit_info; 892 893 blit_info = *_blit_info; 894 blit_info.dst.resource = dst; 895 blit_info.src.resource = src; 896 897 mtx_lock(&rb_pipe->call_mutex); 898 pipe->blit(pipe, &blit_info); 899 mtx_unlock(&rb_pipe->call_mutex); 900 } 901 902 static void 903 rbug_flush_resource(struct pipe_context *_pipe, 904 struct pipe_resource *_res) 905 { 906 struct rbug_context *rb_pipe = rbug_context(_pipe); 907 struct rbug_resource *rb_resource_res = rbug_resource(_res); 908 struct pipe_context *pipe = rb_pipe->pipe; 909 struct pipe_resource *res = rb_resource_res->resource; 910 911 mtx_lock(&rb_pipe->call_mutex); 912 pipe->flush_resource(pipe, res); 913 mtx_unlock(&rb_pipe->call_mutex); 914 } 915 916 static void 917 rbug_clear(struct pipe_context *_pipe, 918 unsigned buffers, 919 const union pipe_color_union *color, 920 double depth, 921 unsigned stencil) 922 { 923 struct rbug_context *rb_pipe = rbug_context(_pipe); 924 struct pipe_context *pipe = rb_pipe->pipe; 925 926 mtx_lock(&rb_pipe->call_mutex); 927 pipe->clear(pipe, 928 buffers, 929 color, 930 depth, 931 stencil); 932 mtx_unlock(&rb_pipe->call_mutex); 933 } 934 935 static void 936 rbug_clear_render_target(struct pipe_context *_pipe, 937 struct pipe_surface *_dst, 938 const union pipe_color_union *color, 939 unsigned dstx, unsigned dsty, 940 unsigned width, unsigned height, 941 bool render_condition_enabled) 942 { 943 struct rbug_context *rb_pipe = rbug_context(_pipe); 944 struct rbug_surface *rb_surface_dst = rbug_surface(_dst); 945 struct pipe_context *pipe = rb_pipe->pipe; 946 struct pipe_surface *dst = rb_surface_dst->surface; 947 948 mtx_lock(&rb_pipe->call_mutex); 949 pipe->clear_render_target(pipe, 950 dst, 951 color, 952 dstx, 953 dsty, 954 width, 955 height, 956 render_condition_enabled); 957 mtx_unlock(&rb_pipe->call_mutex); 958 } 959 960 static void 961 rbug_clear_depth_stencil(struct pipe_context *_pipe, 962 struct pipe_surface *_dst, 963 unsigned clear_flags, 964 double depth, 965 unsigned stencil, 966 unsigned dstx, unsigned dsty, 967 unsigned width, unsigned height, 968 bool render_condition_enabled) 969 { 970 struct rbug_context *rb_pipe = rbug_context(_pipe); 971 struct rbug_surface *rb_surface_dst = rbug_surface(_dst); 972 struct pipe_context *pipe = rb_pipe->pipe; 973 struct pipe_surface *dst = rb_surface_dst->surface; 974 975 mtx_lock(&rb_pipe->call_mutex); 976 pipe->clear_depth_stencil(pipe, 977 dst, 978 clear_flags, 979 depth, 980 stencil, 981 dstx, 982 dsty, 983 width, 984 height, 985 render_condition_enabled); 986 mtx_unlock(&rb_pipe->call_mutex); 987 } 988 989 static void 990 rbug_flush(struct pipe_context *_pipe, 991 struct pipe_fence_handle **fence, 992 unsigned flags) 993 { 994 struct rbug_context *rb_pipe = rbug_context(_pipe); 995 struct pipe_context *pipe = rb_pipe->pipe; 996 997 mtx_lock(&rb_pipe->call_mutex); 998 pipe->flush(pipe, fence, flags); 999 mtx_unlock(&rb_pipe->call_mutex); 1000 } 1001 1002 static struct pipe_sampler_view * 1003 rbug_context_create_sampler_view(struct pipe_context *_pipe, 1004 struct pipe_resource *_resource, 1005 const struct pipe_sampler_view *templ) 1006 { 1007 struct rbug_context *rb_pipe = rbug_context(_pipe); 1008 struct rbug_resource *rb_resource = rbug_resource(_resource); 1009 struct pipe_context *pipe = rb_pipe->pipe; 1010 struct pipe_resource *resource = rb_resource->resource; 1011 struct pipe_sampler_view *result; 1012 1013 mtx_lock(&rb_pipe->call_mutex); 1014 result = pipe->create_sampler_view(pipe, 1015 resource, 1016 templ); 1017 mtx_unlock(&rb_pipe->call_mutex); 1018 1019 if (result) 1020 return rbug_sampler_view_create(rb_pipe, rb_resource, result); 1021 return NULL; 1022 } 1023 1024 static void 1025 rbug_context_sampler_view_destroy(struct pipe_context *_pipe, 1026 struct pipe_sampler_view *_view) 1027 { 1028 rbug_sampler_view_destroy(rbug_context(_pipe), 1029 rbug_sampler_view(_view)); 1030 } 1031 1032 static struct pipe_surface * 1033 rbug_context_create_surface(struct pipe_context *_pipe, 1034 struct pipe_resource *_resource, 1035 const struct pipe_surface *surf_tmpl) 1036 { 1037 struct rbug_context *rb_pipe = rbug_context(_pipe); 1038 struct rbug_resource *rb_resource = rbug_resource(_resource); 1039 struct pipe_context *pipe = rb_pipe->pipe; 1040 struct pipe_resource *resource = rb_resource->resource; 1041 struct pipe_surface *result; 1042 1043 mtx_lock(&rb_pipe->call_mutex); 1044 result = pipe->create_surface(pipe, 1045 resource, 1046 surf_tmpl); 1047 mtx_unlock(&rb_pipe->call_mutex); 1048 1049 if (result) 1050 return rbug_surface_create(rb_pipe, rb_resource, result); 1051 return NULL; 1052 } 1053 1054 static void 1055 rbug_context_surface_destroy(struct pipe_context *_pipe, 1056 struct pipe_surface *_surface) 1057 { 1058 struct rbug_context *rb_pipe = rbug_context(_pipe); 1059 struct rbug_surface *rb_surface = rbug_surface(_surface); 1060 1061 mtx_lock(&rb_pipe->call_mutex); 1062 rbug_surface_destroy(rb_pipe, 1063 rb_surface); 1064 mtx_unlock(&rb_pipe->call_mutex); 1065 } 1066 1067 1068 1069 static void * 1070 rbug_context_transfer_map(struct pipe_context *_context, 1071 struct pipe_resource *_resource, 1072 unsigned level, 1073 unsigned usage, 1074 const struct pipe_box *box, 1075 struct pipe_transfer **transfer) 1076 { 1077 struct rbug_context *rb_pipe = rbug_context(_context); 1078 struct rbug_resource *rb_resource = rbug_resource(_resource); 1079 struct pipe_context *context = rb_pipe->pipe; 1080 struct pipe_resource *resource = rb_resource->resource; 1081 struct pipe_transfer *result; 1082 void *map; 1083 1084 mtx_lock(&rb_pipe->call_mutex); 1085 map = context->transfer_map(context, 1086 resource, 1087 level, 1088 usage, 1089 box, &result); 1090 mtx_unlock(&rb_pipe->call_mutex); 1091 1092 *transfer = rbug_transfer_create(rb_pipe, rb_resource, result); 1093 return *transfer ? map : NULL; 1094 } 1095 1096 static void 1097 rbug_context_transfer_flush_region(struct pipe_context *_context, 1098 struct pipe_transfer *_transfer, 1099 const struct pipe_box *box) 1100 { 1101 struct rbug_context *rb_pipe = rbug_context(_context); 1102 struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); 1103 struct pipe_context *context = rb_pipe->pipe; 1104 struct pipe_transfer *transfer = rb_transfer->transfer; 1105 1106 mtx_lock(&rb_pipe->call_mutex); 1107 context->transfer_flush_region(context, 1108 transfer, 1109 box); 1110 mtx_unlock(&rb_pipe->call_mutex); 1111 } 1112 1113 1114 static void 1115 rbug_context_transfer_unmap(struct pipe_context *_context, 1116 struct pipe_transfer *_transfer) 1117 { 1118 struct rbug_context *rb_pipe = rbug_context(_context); 1119 struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); 1120 struct pipe_context *context = rb_pipe->pipe; 1121 struct pipe_transfer *transfer = rb_transfer->transfer; 1122 1123 mtx_lock(&rb_pipe->call_mutex); 1124 context->transfer_unmap(context, 1125 transfer); 1126 rbug_transfer_destroy(rb_pipe, 1127 rb_transfer); 1128 mtx_unlock(&rb_pipe->call_mutex); 1129 } 1130 1131 1132 static void 1133 rbug_context_buffer_subdata(struct pipe_context *_context, 1134 struct pipe_resource *_resource, 1135 unsigned usage, unsigned offset, 1136 unsigned size, const void *data) 1137 { 1138 struct rbug_context *rb_pipe = rbug_context(_context); 1139 struct rbug_resource *rb_resource = rbug_resource(_resource); 1140 struct pipe_context *context = rb_pipe->pipe; 1141 struct pipe_resource *resource = rb_resource->resource; 1142 1143 mtx_lock(&rb_pipe->call_mutex); 1144 context->buffer_subdata(context, resource, usage, offset, size, data); 1145 mtx_unlock(&rb_pipe->call_mutex); 1146 } 1147 1148 1149 static void 1150 rbug_context_texture_subdata(struct pipe_context *_context, 1151 struct pipe_resource *_resource, 1152 unsigned level, 1153 unsigned usage, 1154 const struct pipe_box *box, 1155 const void *data, 1156 unsigned stride, 1157 unsigned layer_stride) 1158 { 1159 struct rbug_context *rb_pipe = rbug_context(_context); 1160 struct rbug_resource *rb_resource = rbug_resource(_resource); 1161 struct pipe_context *context = rb_pipe->pipe; 1162 struct pipe_resource *resource = rb_resource->resource; 1163 1164 mtx_lock(&rb_pipe->call_mutex); 1165 context->texture_subdata(context, 1166 resource, 1167 level, 1168 usage, 1169 box, 1170 data, 1171 stride, 1172 layer_stride); 1173 mtx_unlock(&rb_pipe->call_mutex); 1174 } 1175 1176 1177 struct pipe_context * 1178 rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) 1179 { 1180 struct rbug_context *rb_pipe; 1181 struct rbug_screen *rb_screen = rbug_screen(_screen); 1182 1183 if (!rb_screen) 1184 return NULL; 1185 1186 rb_pipe = CALLOC_STRUCT(rbug_context); 1187 if (!rb_pipe) 1188 return NULL; 1189 1190 (void) mtx_init(&rb_pipe->draw_mutex, mtx_plain); 1191 cnd_init(&rb_pipe->draw_cond); 1192 (void) mtx_init(&rb_pipe->call_mutex, mtx_plain); 1193 (void) mtx_init(&rb_pipe->list_mutex, mtx_plain); 1194 make_empty_list(&rb_pipe->shaders); 1195 1196 rb_pipe->base.screen = _screen; 1197 rb_pipe->base.priv = pipe->priv; /* expose wrapped data */ 1198 rb_pipe->base.draw = NULL; 1199 rb_pipe->base.stream_uploader = pipe->stream_uploader; 1200 rb_pipe->base.const_uploader = pipe->const_uploader; 1201 1202 rb_pipe->base.destroy = rbug_destroy; 1203 rb_pipe->base.draw_vbo = rbug_draw_vbo; 1204 rb_pipe->base.create_query = rbug_create_query; 1205 rb_pipe->base.destroy_query = rbug_destroy_query; 1206 rb_pipe->base.begin_query = rbug_begin_query; 1207 rb_pipe->base.end_query = rbug_end_query; 1208 rb_pipe->base.get_query_result = rbug_get_query_result; 1209 rb_pipe->base.set_active_query_state = rbug_set_active_query_state; 1210 rb_pipe->base.create_blend_state = rbug_create_blend_state; 1211 rb_pipe->base.bind_blend_state = rbug_bind_blend_state; 1212 rb_pipe->base.delete_blend_state = rbug_delete_blend_state; 1213 rb_pipe->base.create_sampler_state = rbug_create_sampler_state; 1214 rb_pipe->base.bind_sampler_states = rbug_bind_sampler_states; 1215 rb_pipe->base.delete_sampler_state = rbug_delete_sampler_state; 1216 rb_pipe->base.create_rasterizer_state = rbug_create_rasterizer_state; 1217 rb_pipe->base.bind_rasterizer_state = rbug_bind_rasterizer_state; 1218 rb_pipe->base.delete_rasterizer_state = rbug_delete_rasterizer_state; 1219 rb_pipe->base.create_depth_stencil_alpha_state = rbug_create_depth_stencil_alpha_state; 1220 rb_pipe->base.bind_depth_stencil_alpha_state = rbug_bind_depth_stencil_alpha_state; 1221 rb_pipe->base.delete_depth_stencil_alpha_state = rbug_delete_depth_stencil_alpha_state; 1222 rb_pipe->base.create_fs_state = rbug_create_fs_state; 1223 rb_pipe->base.bind_fs_state = rbug_bind_fs_state; 1224 rb_pipe->base.delete_fs_state = rbug_delete_fs_state; 1225 rb_pipe->base.create_vs_state = rbug_create_vs_state; 1226 rb_pipe->base.bind_vs_state = rbug_bind_vs_state; 1227 rb_pipe->base.delete_vs_state = rbug_delete_vs_state; 1228 rb_pipe->base.create_gs_state = rbug_create_gs_state; 1229 rb_pipe->base.bind_gs_state = rbug_bind_gs_state; 1230 rb_pipe->base.delete_gs_state = rbug_delete_gs_state; 1231 rb_pipe->base.create_vertex_elements_state = rbug_create_vertex_elements_state; 1232 rb_pipe->base.bind_vertex_elements_state = rbug_bind_vertex_elements_state; 1233 rb_pipe->base.delete_vertex_elements_state = rbug_delete_vertex_elements_state; 1234 rb_pipe->base.set_blend_color = rbug_set_blend_color; 1235 rb_pipe->base.set_stencil_ref = rbug_set_stencil_ref; 1236 rb_pipe->base.set_clip_state = rbug_set_clip_state; 1237 rb_pipe->base.set_constant_buffer = rbug_set_constant_buffer; 1238 rb_pipe->base.set_framebuffer_state = rbug_set_framebuffer_state; 1239 rb_pipe->base.set_polygon_stipple = rbug_set_polygon_stipple; 1240 rb_pipe->base.set_scissor_states = rbug_set_scissor_states; 1241 rb_pipe->base.set_viewport_states = rbug_set_viewport_states; 1242 rb_pipe->base.set_sampler_views = rbug_set_sampler_views; 1243 rb_pipe->base.set_vertex_buffers = rbug_set_vertex_buffers; 1244 rb_pipe->base.set_sample_mask = rbug_set_sample_mask; 1245 rb_pipe->base.create_stream_output_target = rbug_create_stream_output_target; 1246 rb_pipe->base.stream_output_target_destroy = rbug_stream_output_target_destroy; 1247 rb_pipe->base.set_stream_output_targets = rbug_set_stream_output_targets; 1248 rb_pipe->base.resource_copy_region = rbug_resource_copy_region; 1249 rb_pipe->base.blit = rbug_blit; 1250 rb_pipe->base.flush_resource = rbug_flush_resource; 1251 rb_pipe->base.clear = rbug_clear; 1252 rb_pipe->base.clear_render_target = rbug_clear_render_target; 1253 rb_pipe->base.clear_depth_stencil = rbug_clear_depth_stencil; 1254 rb_pipe->base.flush = rbug_flush; 1255 rb_pipe->base.create_sampler_view = rbug_context_create_sampler_view; 1256 rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy; 1257 rb_pipe->base.create_surface = rbug_context_create_surface; 1258 rb_pipe->base.surface_destroy = rbug_context_surface_destroy; 1259 rb_pipe->base.transfer_map = rbug_context_transfer_map; 1260 rb_pipe->base.transfer_unmap = rbug_context_transfer_unmap; 1261 rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region; 1262 rb_pipe->base.buffer_subdata = rbug_context_buffer_subdata; 1263 rb_pipe->base.texture_subdata = rbug_context_texture_subdata; 1264 1265 rb_pipe->pipe = pipe; 1266 1267 rbug_screen_add_to_list(rb_screen, contexts, rb_pipe); 1268 1269 if (debug_get_bool_option("GALLIUM_RBUG_START_BLOCKED", FALSE)) { 1270 rb_pipe->draw_blocked = RBUG_BLOCK_BEFORE; 1271 } 1272 1273 return &rb_pipe->base; 1274 } 1275