Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/driver_rbug/rbug_context.c
4561 views
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
bool 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
unsigned _drawid_offset,
119
const struct pipe_draw_indirect_info *_indirect,
120
const struct pipe_draw_start_count_bias *draws,
121
unsigned num_draws)
122
{
123
struct rbug_context *rb_pipe = rbug_context(_pipe);
124
struct pipe_context *pipe = rb_pipe->pipe;
125
struct pipe_draw_info info;
126
127
info = *_info;
128
if(_info->index_size && !_info->has_user_indices)
129
info.index.resource = rbug_resource_unwrap(_info->index.resource);
130
131
mtx_lock(&rb_pipe->draw_mutex);
132
rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE);
133
134
mtx_lock(&rb_pipe->call_mutex);
135
/* XXX loop over PIPE_SHADER_x here */
136
if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) &&
137
!(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) &&
138
!(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled))
139
pipe->draw_vbo(pipe, &info, _drawid_offset, _indirect, draws, num_draws);
140
mtx_unlock(&rb_pipe->call_mutex);
141
142
rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER);
143
mtx_unlock(&rb_pipe->draw_mutex);
144
}
145
146
static struct pipe_query *
147
rbug_create_query(struct pipe_context *_pipe,
148
unsigned query_type,
149
unsigned index)
150
{
151
struct rbug_context *rb_pipe = rbug_context(_pipe);
152
struct pipe_context *pipe = rb_pipe->pipe;
153
struct pipe_query *query;
154
155
mtx_lock(&rb_pipe->call_mutex);
156
query = pipe->create_query(pipe,
157
query_type,
158
index);
159
mtx_unlock(&rb_pipe->call_mutex);
160
return query;
161
}
162
163
static void
164
rbug_destroy_query(struct pipe_context *_pipe,
165
struct pipe_query *query)
166
{
167
struct rbug_context *rb_pipe = rbug_context(_pipe);
168
struct pipe_context *pipe = rb_pipe->pipe;
169
170
mtx_lock(&rb_pipe->call_mutex);
171
pipe->destroy_query(pipe,
172
query);
173
mtx_unlock(&rb_pipe->call_mutex);
174
}
175
176
static bool
177
rbug_begin_query(struct pipe_context *_pipe,
178
struct pipe_query *query)
179
{
180
struct rbug_context *rb_pipe = rbug_context(_pipe);
181
struct pipe_context *pipe = rb_pipe->pipe;
182
bool ret;
183
184
mtx_lock(&rb_pipe->call_mutex);
185
ret = pipe->begin_query(pipe, query);
186
mtx_unlock(&rb_pipe->call_mutex);
187
return ret;
188
}
189
190
static bool
191
rbug_end_query(struct pipe_context *_pipe,
192
struct pipe_query *query)
193
{
194
struct rbug_context *rb_pipe = rbug_context(_pipe);
195
struct pipe_context *pipe = rb_pipe->pipe;
196
bool ret;
197
198
mtx_lock(&rb_pipe->call_mutex);
199
ret = pipe->end_query(pipe,
200
query);
201
mtx_unlock(&rb_pipe->call_mutex);
202
203
return ret;
204
}
205
206
static bool
207
rbug_get_query_result(struct pipe_context *_pipe,
208
struct pipe_query *query,
209
bool wait,
210
union pipe_query_result *result)
211
{
212
struct rbug_context *rb_pipe = rbug_context(_pipe);
213
struct pipe_context *pipe = rb_pipe->pipe;
214
bool ret;
215
216
mtx_lock(&rb_pipe->call_mutex);
217
ret = pipe->get_query_result(pipe,
218
query,
219
wait,
220
result);
221
mtx_unlock(&rb_pipe->call_mutex);
222
223
return ret;
224
}
225
226
static void
227
rbug_set_active_query_state(struct pipe_context *_pipe, bool enable)
228
{
229
struct rbug_context *rb_pipe = rbug_context(_pipe);
230
struct pipe_context *pipe = rb_pipe->pipe;
231
232
mtx_lock(&rb_pipe->call_mutex);
233
pipe->set_active_query_state(pipe, enable);
234
mtx_unlock(&rb_pipe->call_mutex);
235
}
236
237
static void *
238
rbug_create_blend_state(struct pipe_context *_pipe,
239
const struct pipe_blend_state *blend)
240
{
241
struct rbug_context *rb_pipe = rbug_context(_pipe);
242
struct pipe_context *pipe = rb_pipe->pipe;
243
void *ret;
244
245
mtx_lock(&rb_pipe->call_mutex);
246
ret = pipe->create_blend_state(pipe,
247
blend);
248
mtx_unlock(&rb_pipe->call_mutex);
249
250
return ret;
251
}
252
253
static void
254
rbug_bind_blend_state(struct pipe_context *_pipe,
255
void *blend)
256
{
257
struct rbug_context *rb_pipe = rbug_context(_pipe);
258
struct pipe_context *pipe = rb_pipe->pipe;
259
260
mtx_lock(&rb_pipe->call_mutex);
261
pipe->bind_blend_state(pipe,
262
blend);
263
mtx_unlock(&rb_pipe->call_mutex);
264
}
265
266
static void
267
rbug_delete_blend_state(struct pipe_context *_pipe,
268
void *blend)
269
{
270
struct rbug_context *rb_pipe = rbug_context(_pipe);
271
struct pipe_context *pipe = rb_pipe->pipe;
272
273
mtx_lock(&rb_pipe->call_mutex);
274
pipe->delete_blend_state(pipe,
275
blend);
276
mtx_unlock(&rb_pipe->call_mutex);
277
}
278
279
static void *
280
rbug_create_sampler_state(struct pipe_context *_pipe,
281
const struct pipe_sampler_state *sampler)
282
{
283
struct rbug_context *rb_pipe = rbug_context(_pipe);
284
struct pipe_context *pipe = rb_pipe->pipe;
285
void *ret;
286
287
mtx_lock(&rb_pipe->call_mutex);
288
ret = pipe->create_sampler_state(pipe,
289
sampler);
290
mtx_unlock(&rb_pipe->call_mutex);
291
292
return ret;
293
}
294
295
static void
296
rbug_bind_sampler_states(struct pipe_context *_pipe,
297
enum pipe_shader_type shader,
298
unsigned start, unsigned count,
299
void **samplers)
300
{
301
struct rbug_context *rb_pipe = rbug_context(_pipe);
302
struct pipe_context *pipe = rb_pipe->pipe;
303
304
mtx_lock(&rb_pipe->call_mutex);
305
pipe->bind_sampler_states(pipe, shader, start, count, samplers);
306
mtx_unlock(&rb_pipe->call_mutex);
307
}
308
309
static void
310
rbug_delete_sampler_state(struct pipe_context *_pipe,
311
void *sampler)
312
{
313
struct rbug_context *rb_pipe = rbug_context(_pipe);
314
struct pipe_context *pipe = rb_pipe->pipe;
315
316
mtx_lock(&rb_pipe->call_mutex);
317
pipe->delete_sampler_state(pipe,
318
sampler);
319
mtx_unlock(&rb_pipe->call_mutex);
320
}
321
322
static void *
323
rbug_create_rasterizer_state(struct pipe_context *_pipe,
324
const struct pipe_rasterizer_state *rasterizer)
325
{
326
struct rbug_context *rb_pipe = rbug_context(_pipe);
327
struct pipe_context *pipe = rb_pipe->pipe;
328
void *ret;
329
330
mtx_lock(&rb_pipe->call_mutex);
331
ret = pipe->create_rasterizer_state(pipe,
332
rasterizer);
333
mtx_unlock(&rb_pipe->call_mutex);
334
335
return ret;
336
}
337
338
static void
339
rbug_bind_rasterizer_state(struct pipe_context *_pipe,
340
void *rasterizer)
341
{
342
struct rbug_context *rb_pipe = rbug_context(_pipe);
343
struct pipe_context *pipe = rb_pipe->pipe;
344
345
mtx_lock(&rb_pipe->call_mutex);
346
pipe->bind_rasterizer_state(pipe,
347
rasterizer);
348
mtx_unlock(&rb_pipe->call_mutex);
349
}
350
351
static void
352
rbug_delete_rasterizer_state(struct pipe_context *_pipe,
353
void *rasterizer)
354
{
355
struct rbug_context *rb_pipe = rbug_context(_pipe);
356
struct pipe_context *pipe = rb_pipe->pipe;
357
358
mtx_lock(&rb_pipe->call_mutex);
359
pipe->delete_rasterizer_state(pipe,
360
rasterizer);
361
mtx_unlock(&rb_pipe->call_mutex);
362
}
363
364
static void *
365
rbug_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
366
const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha)
367
{
368
struct rbug_context *rb_pipe = rbug_context(_pipe);
369
struct pipe_context *pipe = rb_pipe->pipe;
370
void *ret;
371
372
mtx_lock(&rb_pipe->call_mutex);
373
ret = pipe->create_depth_stencil_alpha_state(pipe,
374
depth_stencil_alpha);
375
mtx_unlock(&rb_pipe->call_mutex);
376
377
return ret;
378
}
379
380
static void
381
rbug_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
382
void *depth_stencil_alpha)
383
{
384
struct rbug_context *rb_pipe = rbug_context(_pipe);
385
struct pipe_context *pipe = rb_pipe->pipe;
386
387
mtx_lock(&rb_pipe->call_mutex);
388
pipe->bind_depth_stencil_alpha_state(pipe,
389
depth_stencil_alpha);
390
mtx_unlock(&rb_pipe->call_mutex);
391
}
392
393
static void
394
rbug_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
395
void *depth_stencil_alpha)
396
{
397
struct rbug_context *rb_pipe = rbug_context(_pipe);
398
struct pipe_context *pipe = rb_pipe->pipe;
399
400
mtx_lock(&rb_pipe->call_mutex);
401
pipe->delete_depth_stencil_alpha_state(pipe,
402
depth_stencil_alpha);
403
mtx_unlock(&rb_pipe->call_mutex);
404
}
405
406
static void *
407
rbug_create_fs_state(struct pipe_context *_pipe,
408
const struct pipe_shader_state *state)
409
{
410
struct rbug_context *rb_pipe = rbug_context(_pipe);
411
struct pipe_context *pipe = rb_pipe->pipe;
412
void *result;
413
414
mtx_lock(&rb_pipe->call_mutex);
415
result = pipe->create_fs_state(pipe, state);
416
mtx_unlock(&rb_pipe->call_mutex);
417
418
if (!result)
419
return NULL;
420
421
return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_FRAGMENT);
422
}
423
424
static void
425
rbug_bind_fs_state(struct pipe_context *_pipe,
426
void *_fs)
427
{
428
struct rbug_context *rb_pipe = rbug_context(_pipe);
429
struct pipe_context *pipe = rb_pipe->pipe;
430
void *fs;
431
432
mtx_lock(&rb_pipe->call_mutex);
433
434
fs = rbug_shader_unwrap(_fs);
435
rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] = rbug_shader(_fs);
436
pipe->bind_fs_state(pipe,
437
fs);
438
439
mtx_unlock(&rb_pipe->call_mutex);
440
}
441
442
static void
443
rbug_delete_fs_state(struct pipe_context *_pipe,
444
void *_fs)
445
{
446
struct rbug_context *rb_pipe = rbug_context(_pipe);
447
struct rbug_shader *rb_shader = rbug_shader(_fs);
448
449
mtx_lock(&rb_pipe->call_mutex);
450
rbug_shader_destroy(rb_pipe, rb_shader);
451
mtx_unlock(&rb_pipe->call_mutex);
452
}
453
454
static void *
455
rbug_create_vs_state(struct pipe_context *_pipe,
456
const struct pipe_shader_state *state)
457
{
458
struct rbug_context *rb_pipe = rbug_context(_pipe);
459
struct pipe_context *pipe = rb_pipe->pipe;
460
void *result;
461
462
mtx_lock(&rb_pipe->call_mutex);
463
result = pipe->create_vs_state(pipe, state);
464
mtx_unlock(&rb_pipe->call_mutex);
465
466
if (!result)
467
return NULL;
468
469
return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_VERTEX);
470
}
471
472
static void
473
rbug_bind_vs_state(struct pipe_context *_pipe,
474
void *_vs)
475
{
476
struct rbug_context *rb_pipe = rbug_context(_pipe);
477
struct pipe_context *pipe = rb_pipe->pipe;
478
void *vs;
479
480
mtx_lock(&rb_pipe->call_mutex);
481
482
vs = rbug_shader_unwrap(_vs);
483
rb_pipe->curr.shader[PIPE_SHADER_VERTEX] = rbug_shader(_vs);
484
pipe->bind_vs_state(pipe,
485
vs);
486
487
mtx_unlock(&rb_pipe->call_mutex);
488
}
489
490
static void
491
rbug_delete_vs_state(struct pipe_context *_pipe,
492
void *_vs)
493
{
494
struct rbug_context *rb_pipe = rbug_context(_pipe);
495
struct rbug_shader *rb_shader = rbug_shader(_vs);
496
497
mtx_lock(&rb_pipe->call_mutex);
498
rbug_shader_destroy(rb_pipe, rb_shader);
499
mtx_unlock(&rb_pipe->call_mutex);
500
}
501
502
static void *
503
rbug_create_gs_state(struct pipe_context *_pipe,
504
const struct pipe_shader_state *state)
505
{
506
struct rbug_context *rb_pipe = rbug_context(_pipe);
507
struct pipe_context *pipe = rb_pipe->pipe;
508
void *result;
509
510
mtx_lock(&rb_pipe->call_mutex);
511
result = pipe->create_gs_state(pipe, state);
512
mtx_unlock(&rb_pipe->call_mutex);
513
514
if (!result)
515
return NULL;
516
517
return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_GEOM);
518
}
519
520
static void
521
rbug_bind_gs_state(struct pipe_context *_pipe,
522
void *_gs)
523
{
524
struct rbug_context *rb_pipe = rbug_context(_pipe);
525
struct pipe_context *pipe = rb_pipe->pipe;
526
void *gs;
527
528
mtx_lock(&rb_pipe->call_mutex);
529
530
gs = rbug_shader_unwrap(_gs);
531
rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] = rbug_shader(_gs);
532
pipe->bind_gs_state(pipe,
533
gs);
534
535
mtx_unlock(&rb_pipe->call_mutex);
536
}
537
538
static void
539
rbug_delete_gs_state(struct pipe_context *_pipe,
540
void *_gs)
541
{
542
struct rbug_context *rb_pipe = rbug_context(_pipe);
543
struct rbug_shader *rb_shader = rbug_shader(_gs);
544
545
mtx_lock(&rb_pipe->call_mutex);
546
rbug_shader_destroy(rb_pipe, rb_shader);
547
mtx_unlock(&rb_pipe->call_mutex);
548
}
549
550
static void *
551
rbug_create_vertex_elements_state(struct pipe_context *_pipe,
552
unsigned num_elements,
553
const struct pipe_vertex_element *vertex_elements)
554
{
555
struct rbug_context *rb_pipe = rbug_context(_pipe);
556
struct pipe_context *pipe = rb_pipe->pipe;
557
void *ret;
558
559
mtx_lock(&rb_pipe->call_mutex);
560
ret = pipe->create_vertex_elements_state(pipe,
561
num_elements,
562
vertex_elements);
563
mtx_unlock(&rb_pipe->call_mutex);
564
565
return ret;
566
}
567
568
static void
569
rbug_bind_vertex_elements_state(struct pipe_context *_pipe,
570
void *velems)
571
{
572
struct rbug_context *rb_pipe = rbug_context(_pipe);
573
struct pipe_context *pipe = rb_pipe->pipe;
574
575
mtx_lock(&rb_pipe->call_mutex);
576
pipe->bind_vertex_elements_state(pipe,
577
velems);
578
mtx_unlock(&rb_pipe->call_mutex);
579
}
580
581
static void
582
rbug_delete_vertex_elements_state(struct pipe_context *_pipe,
583
void *velems)
584
{
585
struct rbug_context *rb_pipe = rbug_context(_pipe);
586
struct pipe_context *pipe = rb_pipe->pipe;
587
588
mtx_lock(&rb_pipe->call_mutex);
589
pipe->delete_vertex_elements_state(pipe,
590
velems);
591
mtx_unlock(&rb_pipe->call_mutex);
592
}
593
594
static void
595
rbug_set_blend_color(struct pipe_context *_pipe,
596
const struct pipe_blend_color *blend_color)
597
{
598
struct rbug_context *rb_pipe = rbug_context(_pipe);
599
struct pipe_context *pipe = rb_pipe->pipe;
600
601
mtx_lock(&rb_pipe->call_mutex);
602
pipe->set_blend_color(pipe,
603
blend_color);
604
mtx_unlock(&rb_pipe->call_mutex);
605
}
606
607
static void
608
rbug_set_stencil_ref(struct pipe_context *_pipe,
609
const struct pipe_stencil_ref stencil_ref)
610
{
611
struct rbug_context *rb_pipe = rbug_context(_pipe);
612
struct pipe_context *pipe = rb_pipe->pipe;
613
614
mtx_lock(&rb_pipe->call_mutex);
615
pipe->set_stencil_ref(pipe,
616
stencil_ref);
617
mtx_unlock(&rb_pipe->call_mutex);
618
}
619
620
static void
621
rbug_set_clip_state(struct pipe_context *_pipe,
622
const struct pipe_clip_state *clip)
623
{
624
struct rbug_context *rb_pipe = rbug_context(_pipe);
625
struct pipe_context *pipe = rb_pipe->pipe;
626
627
mtx_lock(&rb_pipe->call_mutex);
628
pipe->set_clip_state(pipe,
629
clip);
630
mtx_unlock(&rb_pipe->call_mutex);
631
}
632
633
static void
634
rbug_set_constant_buffer(struct pipe_context *_pipe,
635
enum pipe_shader_type shader,
636
uint index, bool take_ownership,
637
const struct pipe_constant_buffer *_cb)
638
{
639
struct rbug_context *rb_pipe = rbug_context(_pipe);
640
struct pipe_context *pipe = rb_pipe->pipe;
641
struct pipe_constant_buffer cb;
642
643
/* XXX hmm? unwrap the input state */
644
if (_cb) {
645
cb = *_cb;
646
cb.buffer = rbug_resource_unwrap(_cb->buffer);
647
}
648
649
mtx_lock(&rb_pipe->call_mutex);
650
pipe->set_constant_buffer(pipe,
651
shader,
652
index, take_ownership,
653
_cb ? &cb : NULL);
654
mtx_unlock(&rb_pipe->call_mutex);
655
}
656
657
static void
658
rbug_set_framebuffer_state(struct pipe_context *_pipe,
659
const struct pipe_framebuffer_state *_state)
660
{
661
struct rbug_context *rb_pipe = rbug_context(_pipe);
662
struct pipe_context *pipe = rb_pipe->pipe;
663
struct pipe_framebuffer_state unwrapped_state;
664
struct pipe_framebuffer_state *state = NULL;
665
unsigned i;
666
667
/* must protect curr status */
668
mtx_lock(&rb_pipe->call_mutex);
669
670
rb_pipe->curr.nr_cbufs = 0;
671
memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs));
672
rb_pipe->curr.zsbuf = NULL;
673
674
/* unwrap the input state */
675
if (_state) {
676
memcpy(&unwrapped_state, _state, sizeof(unwrapped_state));
677
678
rb_pipe->curr.nr_cbufs = _state->nr_cbufs;
679
for(i = 0; i < _state->nr_cbufs; i++) {
680
unwrapped_state.cbufs[i] = rbug_surface_unwrap(_state->cbufs[i]);
681
if (_state->cbufs[i])
682
rb_pipe->curr.cbufs[i] = rbug_resource(_state->cbufs[i]->texture);
683
}
684
unwrapped_state.zsbuf = rbug_surface_unwrap(_state->zsbuf);
685
if (_state->zsbuf)
686
rb_pipe->curr.zsbuf = rbug_resource(_state->zsbuf->texture);
687
state = &unwrapped_state;
688
}
689
690
pipe->set_framebuffer_state(pipe,
691
state);
692
693
mtx_unlock(&rb_pipe->call_mutex);
694
}
695
696
static void
697
rbug_set_polygon_stipple(struct pipe_context *_pipe,
698
const struct pipe_poly_stipple *poly_stipple)
699
{
700
struct rbug_context *rb_pipe = rbug_context(_pipe);
701
struct pipe_context *pipe = rb_pipe->pipe;
702
703
mtx_lock(&rb_pipe->call_mutex);
704
pipe->set_polygon_stipple(pipe,
705
poly_stipple);
706
mtx_unlock(&rb_pipe->call_mutex);
707
}
708
709
static void
710
rbug_set_scissor_states(struct pipe_context *_pipe,
711
unsigned start_slot,
712
unsigned num_scissors,
713
const struct pipe_scissor_state *scissor)
714
{
715
struct rbug_context *rb_pipe = rbug_context(_pipe);
716
struct pipe_context *pipe = rb_pipe->pipe;
717
718
mtx_lock(&rb_pipe->call_mutex);
719
pipe->set_scissor_states(pipe, start_slot, num_scissors, scissor);
720
mtx_unlock(&rb_pipe->call_mutex);
721
}
722
723
static void
724
rbug_set_viewport_states(struct pipe_context *_pipe,
725
unsigned start_slot,
726
unsigned num_viewports,
727
const struct pipe_viewport_state *viewport)
728
{
729
struct rbug_context *rb_pipe = rbug_context(_pipe);
730
struct pipe_context *pipe = rb_pipe->pipe;
731
732
mtx_lock(&rb_pipe->call_mutex);
733
pipe->set_viewport_states(pipe, start_slot, num_viewports, viewport);
734
mtx_unlock(&rb_pipe->call_mutex);
735
}
736
737
static void
738
rbug_set_sampler_views(struct pipe_context *_pipe,
739
enum pipe_shader_type shader,
740
unsigned start,
741
unsigned num,
742
unsigned unbind_num_trailing_slots,
743
struct pipe_sampler_view **_views)
744
{
745
struct rbug_context *rb_pipe = rbug_context(_pipe);
746
struct pipe_context *pipe = rb_pipe->pipe;
747
struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
748
struct pipe_sampler_view **views = NULL;
749
unsigned i;
750
751
assert(start == 0); /* XXX fix */
752
753
/* must protect curr status */
754
mtx_lock(&rb_pipe->call_mutex);
755
756
rb_pipe->curr.num_views[shader] = 0;
757
memset(rb_pipe->curr.views[shader], 0, sizeof(rb_pipe->curr.views[shader]));
758
memset(rb_pipe->curr.texs[shader], 0, sizeof(rb_pipe->curr.texs[shader]));
759
memset(unwrapped_views, 0, sizeof(unwrapped_views));
760
761
if (_views) {
762
rb_pipe->curr.num_views[shader] = num;
763
for (i = 0; i < num; i++) {
764
rb_pipe->curr.views[shader][i] = rbug_sampler_view(_views[i]);
765
rb_pipe->curr.texs[shader][i] = rbug_resource(_views[i] ? _views[i]->texture : NULL);
766
unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]);
767
}
768
views = unwrapped_views;
769
}
770
771
pipe->set_sampler_views(pipe, shader, start, num,
772
unbind_num_trailing_slots, views);
773
774
mtx_unlock(&rb_pipe->call_mutex);
775
}
776
777
static void
778
rbug_set_vertex_buffers(struct pipe_context *_pipe,
779
unsigned start_slot, unsigned num_buffers,
780
unsigned unbind_num_trailing_slots,
781
bool take_ownership,
782
const struct pipe_vertex_buffer *_buffers)
783
{
784
struct rbug_context *rb_pipe = rbug_context(_pipe);
785
struct pipe_context *pipe = rb_pipe->pipe;
786
struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS];
787
struct pipe_vertex_buffer *buffers = NULL;
788
unsigned i;
789
790
mtx_lock(&rb_pipe->call_mutex);
791
792
if (num_buffers && _buffers) {
793
memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
794
for (i = 0; i < num_buffers; i++) {
795
if (!_buffers[i].is_user_buffer)
796
unwrapped_buffers[i].buffer.resource =
797
rbug_resource_unwrap(_buffers[i].buffer.resource);
798
}
799
buffers = unwrapped_buffers;
800
}
801
802
pipe->set_vertex_buffers(pipe, start_slot,
803
num_buffers, unbind_num_trailing_slots,
804
take_ownership, buffers);
805
806
mtx_unlock(&rb_pipe->call_mutex);
807
}
808
809
static void
810
rbug_set_sample_mask(struct pipe_context *_pipe,
811
unsigned sample_mask)
812
{
813
struct rbug_context *rb_pipe = rbug_context(_pipe);
814
struct pipe_context *pipe = rb_pipe->pipe;
815
816
mtx_lock(&rb_pipe->call_mutex);
817
pipe->set_sample_mask(pipe, sample_mask);
818
mtx_unlock(&rb_pipe->call_mutex);
819
}
820
821
static struct pipe_stream_output_target *
822
rbug_create_stream_output_target(struct pipe_context *_pipe,
823
struct pipe_resource *_res,
824
unsigned buffer_offset, unsigned buffer_size)
825
{
826
struct rbug_context *rb_pipe = rbug_context(_pipe);
827
struct pipe_context *pipe = rb_pipe->pipe;
828
struct pipe_resource *res = rbug_resource_unwrap(_res);
829
struct pipe_stream_output_target *target;
830
831
mtx_lock(&rb_pipe->call_mutex);
832
target = pipe->create_stream_output_target(pipe, res, buffer_offset,
833
buffer_size);
834
mtx_unlock(&rb_pipe->call_mutex);
835
return target;
836
}
837
838
static void
839
rbug_stream_output_target_destroy(struct pipe_context *_pipe,
840
struct pipe_stream_output_target *target)
841
{
842
struct rbug_context *rb_pipe = rbug_context(_pipe);
843
struct pipe_context *pipe = rb_pipe->pipe;
844
845
mtx_lock(&rb_pipe->call_mutex);
846
pipe->stream_output_target_destroy(pipe, target);
847
mtx_unlock(&rb_pipe->call_mutex);
848
}
849
850
static void
851
rbug_set_stream_output_targets(struct pipe_context *_pipe,
852
unsigned num_targets,
853
struct pipe_stream_output_target **targets,
854
const unsigned *offsets)
855
{
856
struct rbug_context *rb_pipe = rbug_context(_pipe);
857
struct pipe_context *pipe = rb_pipe->pipe;
858
859
mtx_lock(&rb_pipe->call_mutex);
860
pipe->set_stream_output_targets(pipe, num_targets, targets, offsets);
861
mtx_unlock(&rb_pipe->call_mutex);
862
}
863
864
static void
865
rbug_resource_copy_region(struct pipe_context *_pipe,
866
struct pipe_resource *_dst,
867
unsigned dst_level,
868
unsigned dstx,
869
unsigned dsty,
870
unsigned dstz,
871
struct pipe_resource *_src,
872
unsigned src_level,
873
const struct pipe_box *src_box)
874
{
875
struct rbug_context *rb_pipe = rbug_context(_pipe);
876
struct rbug_resource *rb_resource_dst = rbug_resource(_dst);
877
struct rbug_resource *rb_resource_src = rbug_resource(_src);
878
struct pipe_context *pipe = rb_pipe->pipe;
879
struct pipe_resource *dst = rb_resource_dst->resource;
880
struct pipe_resource *src = rb_resource_src->resource;
881
882
mtx_lock(&rb_pipe->call_mutex);
883
pipe->resource_copy_region(pipe,
884
dst,
885
dst_level,
886
dstx,
887
dsty,
888
dstz,
889
src,
890
src_level,
891
src_box);
892
mtx_unlock(&rb_pipe->call_mutex);
893
}
894
895
static void
896
rbug_blit(struct pipe_context *_pipe, const struct pipe_blit_info *_blit_info)
897
{
898
struct rbug_context *rb_pipe = rbug_context(_pipe);
899
struct rbug_resource *rb_resource_dst = rbug_resource(_blit_info->dst.resource);
900
struct rbug_resource *rb_resource_src = rbug_resource(_blit_info->src.resource);
901
struct pipe_context *pipe = rb_pipe->pipe;
902
struct pipe_resource *dst = rb_resource_dst->resource;
903
struct pipe_resource *src = rb_resource_src->resource;
904
struct pipe_blit_info blit_info;
905
906
blit_info = *_blit_info;
907
blit_info.dst.resource = dst;
908
blit_info.src.resource = src;
909
910
mtx_lock(&rb_pipe->call_mutex);
911
pipe->blit(pipe, &blit_info);
912
mtx_unlock(&rb_pipe->call_mutex);
913
}
914
915
static void
916
rbug_flush_resource(struct pipe_context *_pipe,
917
struct pipe_resource *_res)
918
{
919
struct rbug_context *rb_pipe = rbug_context(_pipe);
920
struct rbug_resource *rb_resource_res = rbug_resource(_res);
921
struct pipe_context *pipe = rb_pipe->pipe;
922
struct pipe_resource *res = rb_resource_res->resource;
923
924
mtx_lock(&rb_pipe->call_mutex);
925
pipe->flush_resource(pipe, res);
926
mtx_unlock(&rb_pipe->call_mutex);
927
}
928
929
static void
930
rbug_clear(struct pipe_context *_pipe,
931
unsigned buffers,
932
const struct pipe_scissor_state *scissor_state,
933
const union pipe_color_union *color,
934
double depth,
935
unsigned stencil)
936
{
937
struct rbug_context *rb_pipe = rbug_context(_pipe);
938
struct pipe_context *pipe = rb_pipe->pipe;
939
940
mtx_lock(&rb_pipe->call_mutex);
941
pipe->clear(pipe,
942
buffers,
943
scissor_state,
944
color,
945
depth,
946
stencil);
947
mtx_unlock(&rb_pipe->call_mutex);
948
}
949
950
static void
951
rbug_clear_render_target(struct pipe_context *_pipe,
952
struct pipe_surface *_dst,
953
const union pipe_color_union *color,
954
unsigned dstx, unsigned dsty,
955
unsigned width, unsigned height,
956
bool render_condition_enabled)
957
{
958
struct rbug_context *rb_pipe = rbug_context(_pipe);
959
struct rbug_surface *rb_surface_dst = rbug_surface(_dst);
960
struct pipe_context *pipe = rb_pipe->pipe;
961
struct pipe_surface *dst = rb_surface_dst->surface;
962
963
mtx_lock(&rb_pipe->call_mutex);
964
pipe->clear_render_target(pipe,
965
dst,
966
color,
967
dstx,
968
dsty,
969
width,
970
height,
971
render_condition_enabled);
972
mtx_unlock(&rb_pipe->call_mutex);
973
}
974
975
static void
976
rbug_clear_depth_stencil(struct pipe_context *_pipe,
977
struct pipe_surface *_dst,
978
unsigned clear_flags,
979
double depth,
980
unsigned stencil,
981
unsigned dstx, unsigned dsty,
982
unsigned width, unsigned height,
983
bool render_condition_enabled)
984
{
985
struct rbug_context *rb_pipe = rbug_context(_pipe);
986
struct rbug_surface *rb_surface_dst = rbug_surface(_dst);
987
struct pipe_context *pipe = rb_pipe->pipe;
988
struct pipe_surface *dst = rb_surface_dst->surface;
989
990
mtx_lock(&rb_pipe->call_mutex);
991
pipe->clear_depth_stencil(pipe,
992
dst,
993
clear_flags,
994
depth,
995
stencil,
996
dstx,
997
dsty,
998
width,
999
height,
1000
render_condition_enabled);
1001
mtx_unlock(&rb_pipe->call_mutex);
1002
}
1003
1004
static void
1005
rbug_flush(struct pipe_context *_pipe,
1006
struct pipe_fence_handle **fence,
1007
unsigned flags)
1008
{
1009
struct rbug_context *rb_pipe = rbug_context(_pipe);
1010
struct pipe_context *pipe = rb_pipe->pipe;
1011
1012
mtx_lock(&rb_pipe->call_mutex);
1013
pipe->flush(pipe, fence, flags);
1014
mtx_unlock(&rb_pipe->call_mutex);
1015
}
1016
1017
static void
1018
rbug_create_fence_fd(struct pipe_context *_pipe,
1019
struct pipe_fence_handle **fence, int fd,
1020
enum pipe_fd_type type)
1021
{
1022
struct rbug_context *rb_pipe = rbug_context(_pipe);
1023
struct pipe_context *pipe = rb_pipe->pipe;
1024
1025
mtx_lock(&rb_pipe->call_mutex);
1026
pipe->create_fence_fd(pipe, fence, fd, type);
1027
mtx_unlock(&rb_pipe->call_mutex);
1028
}
1029
1030
static void
1031
rbug_fence_server_sync(struct pipe_context *_pipe,
1032
struct pipe_fence_handle *fence)
1033
{
1034
struct rbug_context *rb_pipe = rbug_context(_pipe);
1035
struct pipe_context *pipe = rb_pipe->pipe;
1036
1037
mtx_lock(&rb_pipe->call_mutex);
1038
pipe->fence_server_sync(pipe, fence);
1039
mtx_unlock(&rb_pipe->call_mutex);
1040
}
1041
1042
static struct pipe_sampler_view *
1043
rbug_context_create_sampler_view(struct pipe_context *_pipe,
1044
struct pipe_resource *_resource,
1045
const struct pipe_sampler_view *templ)
1046
{
1047
struct rbug_context *rb_pipe = rbug_context(_pipe);
1048
struct rbug_resource *rb_resource = rbug_resource(_resource);
1049
struct pipe_context *pipe = rb_pipe->pipe;
1050
struct pipe_resource *resource = rb_resource->resource;
1051
struct pipe_sampler_view *result;
1052
1053
mtx_lock(&rb_pipe->call_mutex);
1054
result = pipe->create_sampler_view(pipe,
1055
resource,
1056
templ);
1057
mtx_unlock(&rb_pipe->call_mutex);
1058
1059
if (result)
1060
return rbug_sampler_view_create(rb_pipe, rb_resource, result);
1061
return NULL;
1062
}
1063
1064
static void
1065
rbug_context_sampler_view_destroy(struct pipe_context *_pipe,
1066
struct pipe_sampler_view *_view)
1067
{
1068
rbug_sampler_view_destroy(rbug_context(_pipe),
1069
rbug_sampler_view(_view));
1070
}
1071
1072
static struct pipe_surface *
1073
rbug_context_create_surface(struct pipe_context *_pipe,
1074
struct pipe_resource *_resource,
1075
const struct pipe_surface *surf_tmpl)
1076
{
1077
struct rbug_context *rb_pipe = rbug_context(_pipe);
1078
struct rbug_resource *rb_resource = rbug_resource(_resource);
1079
struct pipe_context *pipe = rb_pipe->pipe;
1080
struct pipe_resource *resource = rb_resource->resource;
1081
struct pipe_surface *result;
1082
1083
mtx_lock(&rb_pipe->call_mutex);
1084
result = pipe->create_surface(pipe,
1085
resource,
1086
surf_tmpl);
1087
mtx_unlock(&rb_pipe->call_mutex);
1088
1089
if (result)
1090
return rbug_surface_create(rb_pipe, rb_resource, result);
1091
return NULL;
1092
}
1093
1094
static void
1095
rbug_context_surface_destroy(struct pipe_context *_pipe,
1096
struct pipe_surface *_surface)
1097
{
1098
struct rbug_context *rb_pipe = rbug_context(_pipe);
1099
struct rbug_surface *rb_surface = rbug_surface(_surface);
1100
1101
mtx_lock(&rb_pipe->call_mutex);
1102
rbug_surface_destroy(rb_pipe,
1103
rb_surface);
1104
mtx_unlock(&rb_pipe->call_mutex);
1105
}
1106
1107
1108
1109
static void *
1110
rbug_context_buffer_map(struct pipe_context *_context,
1111
struct pipe_resource *_resource,
1112
unsigned level,
1113
unsigned usage,
1114
const struct pipe_box *box,
1115
struct pipe_transfer **transfer)
1116
{
1117
struct rbug_context *rb_pipe = rbug_context(_context);
1118
struct rbug_resource *rb_resource = rbug_resource(_resource);
1119
struct pipe_context *context = rb_pipe->pipe;
1120
struct pipe_resource *resource = rb_resource->resource;
1121
struct pipe_transfer *result;
1122
void *map;
1123
1124
mtx_lock(&rb_pipe->call_mutex);
1125
map = context->buffer_map(context,
1126
resource,
1127
level,
1128
usage,
1129
box, &result);
1130
mtx_unlock(&rb_pipe->call_mutex);
1131
1132
*transfer = rbug_transfer_create(rb_pipe, rb_resource, result);
1133
return *transfer ? map : NULL;
1134
}
1135
1136
static void *
1137
rbug_context_texture_map(struct pipe_context *_context,
1138
struct pipe_resource *_resource,
1139
unsigned level,
1140
unsigned usage,
1141
const struct pipe_box *box,
1142
struct pipe_transfer **transfer)
1143
{
1144
struct rbug_context *rb_pipe = rbug_context(_context);
1145
struct rbug_resource *rb_resource = rbug_resource(_resource);
1146
struct pipe_context *context = rb_pipe->pipe;
1147
struct pipe_resource *resource = rb_resource->resource;
1148
struct pipe_transfer *result;
1149
void *map;
1150
1151
mtx_lock(&rb_pipe->call_mutex);
1152
map = context->texture_map(context,
1153
resource,
1154
level,
1155
usage,
1156
box, &result);
1157
mtx_unlock(&rb_pipe->call_mutex);
1158
1159
*transfer = rbug_transfer_create(rb_pipe, rb_resource, result);
1160
return *transfer ? map : NULL;
1161
}
1162
1163
static void
1164
rbug_context_transfer_flush_region(struct pipe_context *_context,
1165
struct pipe_transfer *_transfer,
1166
const struct pipe_box *box)
1167
{
1168
struct rbug_context *rb_pipe = rbug_context(_context);
1169
struct rbug_transfer *rb_transfer = rbug_transfer(_transfer);
1170
struct pipe_context *context = rb_pipe->pipe;
1171
struct pipe_transfer *transfer = rb_transfer->transfer;
1172
1173
mtx_lock(&rb_pipe->call_mutex);
1174
context->transfer_flush_region(context,
1175
transfer,
1176
box);
1177
mtx_unlock(&rb_pipe->call_mutex);
1178
}
1179
1180
1181
static void
1182
rbug_context_buffer_unmap(struct pipe_context *_context,
1183
struct pipe_transfer *_transfer)
1184
{
1185
struct rbug_context *rb_pipe = rbug_context(_context);
1186
struct rbug_transfer *rb_transfer = rbug_transfer(_transfer);
1187
struct pipe_context *context = rb_pipe->pipe;
1188
struct pipe_transfer *transfer = rb_transfer->transfer;
1189
1190
mtx_lock(&rb_pipe->call_mutex);
1191
context->buffer_unmap(context,
1192
transfer);
1193
rbug_transfer_destroy(rb_pipe,
1194
rb_transfer);
1195
mtx_unlock(&rb_pipe->call_mutex);
1196
}
1197
1198
static void
1199
rbug_context_texture_unmap(struct pipe_context *_context,
1200
struct pipe_transfer *_transfer)
1201
{
1202
struct rbug_context *rb_pipe = rbug_context(_context);
1203
struct rbug_transfer *rb_transfer = rbug_transfer(_transfer);
1204
struct pipe_context *context = rb_pipe->pipe;
1205
struct pipe_transfer *transfer = rb_transfer->transfer;
1206
1207
mtx_lock(&rb_pipe->call_mutex);
1208
context->texture_unmap(context,
1209
transfer);
1210
rbug_transfer_destroy(rb_pipe,
1211
rb_transfer);
1212
mtx_unlock(&rb_pipe->call_mutex);
1213
}
1214
1215
1216
static void
1217
rbug_context_buffer_subdata(struct pipe_context *_context,
1218
struct pipe_resource *_resource,
1219
unsigned usage, unsigned offset,
1220
unsigned size, const void *data)
1221
{
1222
struct rbug_context *rb_pipe = rbug_context(_context);
1223
struct rbug_resource *rb_resource = rbug_resource(_resource);
1224
struct pipe_context *context = rb_pipe->pipe;
1225
struct pipe_resource *resource = rb_resource->resource;
1226
1227
mtx_lock(&rb_pipe->call_mutex);
1228
context->buffer_subdata(context, resource, usage, offset, size, data);
1229
mtx_unlock(&rb_pipe->call_mutex);
1230
}
1231
1232
1233
static void
1234
rbug_context_texture_subdata(struct pipe_context *_context,
1235
struct pipe_resource *_resource,
1236
unsigned level,
1237
unsigned usage,
1238
const struct pipe_box *box,
1239
const void *data,
1240
unsigned stride,
1241
unsigned layer_stride)
1242
{
1243
struct rbug_context *rb_pipe = rbug_context(_context);
1244
struct rbug_resource *rb_resource = rbug_resource(_resource);
1245
struct pipe_context *context = rb_pipe->pipe;
1246
struct pipe_resource *resource = rb_resource->resource;
1247
1248
mtx_lock(&rb_pipe->call_mutex);
1249
context->texture_subdata(context,
1250
resource,
1251
level,
1252
usage,
1253
box,
1254
data,
1255
stride,
1256
layer_stride);
1257
mtx_unlock(&rb_pipe->call_mutex);
1258
}
1259
1260
static void
1261
rbug_context_texture_barrier(struct pipe_context *_context, unsigned flags)
1262
{
1263
struct rbug_context *rb_pipe = rbug_context(_context);
1264
struct pipe_context *context = rb_pipe->pipe;
1265
1266
mtx_lock(&rb_pipe->call_mutex);
1267
context->texture_barrier(context,
1268
flags);
1269
mtx_unlock(&rb_pipe->call_mutex);
1270
}
1271
1272
struct pipe_context *
1273
rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
1274
{
1275
struct rbug_context *rb_pipe;
1276
struct rbug_screen *rb_screen = rbug_screen(_screen);
1277
1278
if (!rb_screen)
1279
return NULL;
1280
1281
rb_pipe = CALLOC_STRUCT(rbug_context);
1282
if (!rb_pipe)
1283
return NULL;
1284
1285
(void) mtx_init(&rb_pipe->draw_mutex, mtx_plain);
1286
cnd_init(&rb_pipe->draw_cond);
1287
(void) mtx_init(&rb_pipe->call_mutex, mtx_plain);
1288
(void) mtx_init(&rb_pipe->list_mutex, mtx_plain);
1289
make_empty_list(&rb_pipe->shaders);
1290
1291
rb_pipe->base.screen = _screen;
1292
rb_pipe->base.priv = pipe->priv; /* expose wrapped data */
1293
rb_pipe->base.draw = NULL;
1294
rb_pipe->base.stream_uploader = pipe->stream_uploader;
1295
rb_pipe->base.const_uploader = pipe->const_uploader;
1296
1297
rb_pipe->base.destroy = rbug_destroy;
1298
rb_pipe->base.draw_vbo = rbug_draw_vbo;
1299
rb_pipe->base.create_query = rbug_create_query;
1300
rb_pipe->base.destroy_query = rbug_destroy_query;
1301
rb_pipe->base.begin_query = rbug_begin_query;
1302
rb_pipe->base.end_query = rbug_end_query;
1303
rb_pipe->base.get_query_result = rbug_get_query_result;
1304
rb_pipe->base.set_active_query_state = rbug_set_active_query_state;
1305
rb_pipe->base.create_blend_state = rbug_create_blend_state;
1306
rb_pipe->base.bind_blend_state = rbug_bind_blend_state;
1307
rb_pipe->base.delete_blend_state = rbug_delete_blend_state;
1308
rb_pipe->base.create_sampler_state = rbug_create_sampler_state;
1309
rb_pipe->base.bind_sampler_states = rbug_bind_sampler_states;
1310
rb_pipe->base.delete_sampler_state = rbug_delete_sampler_state;
1311
rb_pipe->base.create_rasterizer_state = rbug_create_rasterizer_state;
1312
rb_pipe->base.bind_rasterizer_state = rbug_bind_rasterizer_state;
1313
rb_pipe->base.delete_rasterizer_state = rbug_delete_rasterizer_state;
1314
rb_pipe->base.create_depth_stencil_alpha_state = rbug_create_depth_stencil_alpha_state;
1315
rb_pipe->base.bind_depth_stencil_alpha_state = rbug_bind_depth_stencil_alpha_state;
1316
rb_pipe->base.delete_depth_stencil_alpha_state = rbug_delete_depth_stencil_alpha_state;
1317
rb_pipe->base.create_fs_state = rbug_create_fs_state;
1318
rb_pipe->base.bind_fs_state = rbug_bind_fs_state;
1319
rb_pipe->base.delete_fs_state = rbug_delete_fs_state;
1320
rb_pipe->base.create_vs_state = rbug_create_vs_state;
1321
rb_pipe->base.bind_vs_state = rbug_bind_vs_state;
1322
rb_pipe->base.delete_vs_state = rbug_delete_vs_state;
1323
rb_pipe->base.create_gs_state = rbug_create_gs_state;
1324
rb_pipe->base.bind_gs_state = rbug_bind_gs_state;
1325
rb_pipe->base.delete_gs_state = rbug_delete_gs_state;
1326
rb_pipe->base.create_vertex_elements_state = rbug_create_vertex_elements_state;
1327
rb_pipe->base.bind_vertex_elements_state = rbug_bind_vertex_elements_state;
1328
rb_pipe->base.delete_vertex_elements_state = rbug_delete_vertex_elements_state;
1329
rb_pipe->base.set_blend_color = rbug_set_blend_color;
1330
rb_pipe->base.set_stencil_ref = rbug_set_stencil_ref;
1331
rb_pipe->base.set_clip_state = rbug_set_clip_state;
1332
rb_pipe->base.set_constant_buffer = rbug_set_constant_buffer;
1333
rb_pipe->base.set_framebuffer_state = rbug_set_framebuffer_state;
1334
rb_pipe->base.set_polygon_stipple = rbug_set_polygon_stipple;
1335
rb_pipe->base.set_scissor_states = rbug_set_scissor_states;
1336
rb_pipe->base.set_viewport_states = rbug_set_viewport_states;
1337
rb_pipe->base.set_sampler_views = rbug_set_sampler_views;
1338
rb_pipe->base.set_vertex_buffers = rbug_set_vertex_buffers;
1339
rb_pipe->base.set_sample_mask = rbug_set_sample_mask;
1340
rb_pipe->base.create_stream_output_target = rbug_create_stream_output_target;
1341
rb_pipe->base.stream_output_target_destroy = rbug_stream_output_target_destroy;
1342
rb_pipe->base.set_stream_output_targets = rbug_set_stream_output_targets;
1343
rb_pipe->base.resource_copy_region = rbug_resource_copy_region;
1344
rb_pipe->base.blit = rbug_blit;
1345
rb_pipe->base.clear = rbug_clear;
1346
rb_pipe->base.clear_render_target = rbug_clear_render_target;
1347
rb_pipe->base.clear_depth_stencil = rbug_clear_depth_stencil;
1348
rb_pipe->base.flush = rbug_flush;
1349
rb_pipe->base.create_fence_fd = rbug_create_fence_fd;
1350
rb_pipe->base.fence_server_sync = rbug_fence_server_sync;
1351
rb_pipe->base.create_sampler_view = rbug_context_create_sampler_view;
1352
rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy;
1353
rb_pipe->base.create_surface = rbug_context_create_surface;
1354
rb_pipe->base.surface_destroy = rbug_context_surface_destroy;
1355
rb_pipe->base.buffer_map = rbug_context_buffer_map;
1356
rb_pipe->base.buffer_unmap = rbug_context_buffer_unmap;
1357
rb_pipe->base.texture_map = rbug_context_texture_map;
1358
rb_pipe->base.texture_unmap = rbug_context_texture_unmap;
1359
rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region;
1360
rb_pipe->base.buffer_subdata = rbug_context_buffer_subdata;
1361
rb_pipe->base.texture_subdata = rbug_context_texture_subdata;
1362
rb_pipe->base.texture_barrier = rbug_context_texture_barrier;
1363
rb_pipe->base.flush_resource = rbug_flush_resource;
1364
1365
rb_pipe->pipe = pipe;
1366
1367
rbug_screen_add_to_list(rb_screen, contexts, rb_pipe);
1368
1369
if (debug_get_bool_option("GALLIUM_RBUG_START_BLOCKED", false)) {
1370
rb_pipe->draw_blocked = RBUG_BLOCK_BEFORE;
1371
}
1372
1373
return &rb_pipe->base;
1374
}
1375
1376