summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/identity/id_context.c
blob: bdbaae59875b3e94d4ca6ded65433c541fd47ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/**************************************************************************
 *
 * Copyright 2009 VMware, Inc.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/


#include "pipe/p_context.h"
#include "util/u_memory.h"

#include "id_public.h"
#include "id_context.h"
#include "id_objects.h"


static void
identity_destroy(struct pipe_context *_pipe)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->destroy(pipe);

   free(id_pipe);
}

static boolean
identity_draw_arrays(struct pipe_context *_pipe,
                     unsigned prim,
                     unsigned start,
                     unsigned count)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->draw_arrays(pipe,
                            prim,
                            start,
                            count);
}

static boolean
identity_draw_elements(struct pipe_context *_pipe,
                       struct pipe_buffer *_indexBuffer,
                       unsigned indexSize,
                       unsigned prim,
                       unsigned start,
                       unsigned count)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_buffer *id_buffer = identity_buffer(_indexBuffer);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_buffer *indexBuffer = id_buffer->buffer;

   return pipe->draw_elements(pipe,
                              indexBuffer,
                              indexSize,
                              prim,
                              start,
                              count);
}

static boolean
identity_draw_range_elements(struct pipe_context *_pipe,
                             struct pipe_buffer *_indexBuffer,
                             unsigned indexSize,
                             unsigned minIndex,
                             unsigned maxIndex,
                             unsigned mode,
                             unsigned start,
                             unsigned count)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_buffer *id_buffer = identity_buffer(_indexBuffer);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_buffer *indexBuffer = id_buffer->buffer;

   return pipe->draw_range_elements(pipe,
                                    indexBuffer,
                                    indexSize,
                                    minIndex,
                                    maxIndex,
                                    mode,
                                    start,
                                    count);
}

static struct pipe_query *
identity_create_query(struct pipe_context *_pipe,
                      unsigned query_type)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_query(pipe,
                             query_type);
}

static void
identity_destroy_query(struct pipe_context *_pipe,
                       struct pipe_query *query)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->destroy_query(pipe,
                       query);
}

static void
identity_begin_query(struct pipe_context *_pipe,
                     struct pipe_query *query)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->begin_query(pipe,
                     query);
}

static void
identity_end_query(struct pipe_context *_pipe,
                   struct pipe_query *query)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->end_query(pipe,
                   query);
}

static boolean
identity_get_query_result(struct pipe_context *_pipe,
                          struct pipe_query *query,
                          boolean wait,
                          uint64_t *result)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->get_query_result(pipe,
                                 query,
                                 wait,
                                 result);
}

static void *
identity_create_blend_state(struct pipe_context *_pipe,
                            const struct pipe_blend_state *blend)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_blend_state(pipe,
                                   blend);
}

static void
identity_bind_blend_state(struct pipe_context *_pipe,
                          void *blend)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_blend_state(pipe,
                              blend);
}

static void
identity_delete_blend_state(struct pipe_context *_pipe,
                            void *blend)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_blend_state(pipe,
                            blend);
}

static void *
identity_create_sampler_state(struct pipe_context *_pipe,
                              const struct pipe_sampler_state *sampler)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_sampler_state(pipe,
                                     sampler);
}

static void
identity_bind_fragment_sampler_states(struct pipe_context *_pipe,
                                      unsigned num_samplers,
                                      void **samplers)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_fragment_sampler_states(pipe,
                                      num_samplers,
                                      samplers);
}

static void
identity_bind_vertex_sampler_states(struct pipe_context *_pipe,
                                    unsigned num_samplers,
                                    void **samplers)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_vertex_sampler_states(pipe,
                                    num_samplers,
                                    samplers);
}

static void
identity_delete_sampler_state(struct pipe_context *_pipe,
                              void *sampler)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_sampler_state(pipe,
                              sampler);
}

static void *
identity_create_rasterizer_state(struct pipe_context *_pipe,
                                 const struct pipe_rasterizer_state *rasterizer)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_rasterizer_state(pipe,
                                        rasterizer);
}

static void
identity_bind_rasterizer_state(struct pipe_context *_pipe,
                               void *rasterizer)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_rasterizer_state(pipe,
                               rasterizer);
}

static void
identity_delete_rasterizer_state(struct pipe_context *_pipe,
                                 void *rasterizer)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_rasterizer_state(pipe,
                                 rasterizer);
}

static void *
identity_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
                                          const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_depth_stencil_alpha_state(pipe,
                                                 depth_stencil_alpha);
}

static void
identity_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
                                        void *depth_stencil_alpha)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_depth_stencil_alpha_state(pipe,
                                        depth_stencil_alpha);
}

static void
identity_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
                                          void *depth_stencil_alpha)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_depth_stencil_alpha_state(pipe,
                                          depth_stencil_alpha);
}

static void *
identity_create_fs_state(struct pipe_context *_pipe,
                         const struct pipe_shader_state *fs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_fs_state(pipe,
                                fs);
}

static void
identity_bind_fs_state(struct pipe_context *_pipe,
                       void *fs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_fs_state(pipe,
                       fs);
}

static void
identity_delete_fs_state(struct pipe_context *_pipe,
                         void *fs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_fs_state(pipe,
                         fs);
}

static void *
identity_create_vs_state(struct pipe_context *_pipe,
                         const struct pipe_shader_state *vs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   return pipe->create_vs_state(pipe,
                                vs);
}

static void
identity_bind_vs_state(struct pipe_context *_pipe,
                       void *vs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->bind_vs_state(pipe,
                       vs);
}

static void
identity_delete_vs_state(struct pipe_context *_pipe,
                         void *vs)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->delete_vs_state(pipe,
                         vs);
}

static void
identity_set_blend_color(struct pipe_context *_pipe,
                         const struct pipe_blend_color *blend_color)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_blend_color(pipe,
                         blend_color);
}

static void
identity_set_clip_state(struct pipe_context *_pipe,
                        const struct pipe_clip_state *clip)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_clip_state(pipe,
                        clip);
}

static void
identity_set_constant_buffer(struct pipe_context *_pipe,
                             uint shader,
                             uint index,
                             const struct pipe_constant_buffer *_buffer)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_constant_buffer unwrapped_buffer;
   struct pipe_constant_buffer *buffer = NULL;

   /* unwrap the input state */
   if (_buffer) {
      unwrapped_buffer.buffer = identity_buffer_unwrap(_buffer->buffer);
      buffer = &unwrapped_buffer;
   }

   pipe->set_constant_buffer(pipe,
                             shader,
                             index,
                             buffer);
}

static void
identity_set_framebuffer_state(struct pipe_context *_pipe,
                               const struct pipe_framebuffer_state *_state)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_framebuffer_state unwrapped_state;
   struct pipe_framebuffer_state *state = NULL;
   unsigned i;

   /* unwrap the input state */
   if (_state) {
      memcpy(&unwrapped_state, _state, sizeof(unwrapped_state));
      for(i = 0; i < _state->nr_cbufs; i++)
         unwrapped_state.cbufs[i] = identity_surface_unwrap(_state->cbufs[i]);
      for (; i < PIPE_MAX_COLOR_BUFS; i++)
         unwrapped_state.cbufs[i] = NULL;
      unwrapped_state.zsbuf = identity_surface_unwrap(_state->zsbuf);
      state = &unwrapped_state;
   }

   pipe->set_framebuffer_state(pipe,
                               state);
}

static void
identity_set_polygon_stipple(struct pipe_context *_pipe,
                             const struct pipe_poly_stipple *poly_stipple)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_polygon_stipple(pipe,
                             poly_stipple);
}

static void
identity_set_scissor_state(struct pipe_context *_pipe,
                           const struct pipe_scissor_state *scissor)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_scissor_state(pipe,
                           scissor);
}

static void
identity_set_viewport_state(struct pipe_context *_pipe,
                            const struct pipe_viewport_state *viewport)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_viewport_state(pipe,
                            viewport);
}

static void
identity_set_fragment_sampler_textures(struct pipe_context *_pipe,
                                       unsigned num_textures,
                                       struct pipe_texture **_textures)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
   struct pipe_texture **textures = NULL;
   unsigned i;

   if (_textures) {
      for (i = 0; i < num_textures; i++)
         unwrapped_textures[i] = identity_texture_unwrap(_textures[i]);
      for (; i < PIPE_MAX_SAMPLERS; i++)
         unwrapped_textures[i] = NULL;

      textures = unwrapped_textures;
   }

   pipe->set_fragment_sampler_textures(pipe,
                                       num_textures,
                                       textures);
}

static void
identity_set_vertex_sampler_textures(struct pipe_context *_pipe,
                                     unsigned num_textures,
                                     struct pipe_texture **_textures)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_texture *unwrapped_textures[PIPE_MAX_VERTEX_SAMPLERS];
   struct pipe_texture **textures = NULL;
   unsigned i;

   if (_textures) {
      for (i = 0; i < num_textures; i++)
         unwrapped_textures[i] = identity_texture_unwrap(_textures[i]);
      for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
         unwrapped_textures[i] = NULL;

      textures = unwrapped_textures;
   }

   pipe->set_vertex_sampler_textures(pipe,
                                     num_textures,
                                     textures);
}

static void
identity_set_vertex_buffers(struct pipe_context *_pipe,
                            unsigned num_buffers,
                            const struct pipe_vertex_buffer *_buffers)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS];
   struct pipe_vertex_buffer *buffers = NULL;
   unsigned i;

   if (num_buffers) {
      memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
      for (i = 0; i < num_buffers; i++)
         unwrapped_buffers[i].buffer = identity_buffer_unwrap(_buffers[i].buffer);
      buffers = unwrapped_buffers;
   }

   pipe->set_vertex_buffers(pipe,
                            num_buffers,
                            buffers);
}

static void
identity_set_vertex_elements(struct pipe_context *_pipe,
                             unsigned num_elements,
                             const struct pipe_vertex_element *vertex_elements)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->set_vertex_elements(pipe,
                             num_elements,
                             vertex_elements);
}

static void
identity_surface_copy(struct pipe_context *_pipe,
                      struct pipe_surface *_dst,
                      unsigned dstx,
                      unsigned dsty,
                      struct pipe_surface *_src,
                      unsigned srcx,
                      unsigned srcy,
                      unsigned width,
                      unsigned height)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_surface *id_surface_dst = identity_surface(_dst);
   struct identity_surface *id_surface_src = identity_surface(_src);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_surface *dst = id_surface_dst->surface;
   struct pipe_surface *src = id_surface_src->surface;

   pipe->surface_copy(pipe,
                      dst,
                      dstx,
                      dsty,
                      src,
                      srcx,
                      srcy,
                      width,
                      height);
}

static void
identity_surface_fill(struct pipe_context *_pipe,
                      struct pipe_surface *_dst,
                      unsigned dstx,
                      unsigned dsty,
                      unsigned width,
                      unsigned height,
                      unsigned value)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_surface *id_surface_dst = identity_surface(_dst);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_surface *dst = id_surface_dst->surface;

   pipe->surface_fill(pipe,
                      dst,
                      dstx,
                      dsty,
                      width,
                      height,
                      value);
}

static void
identity_clear(struct pipe_context *_pipe,
               unsigned buffers,
               const float *rgba,
               double depth,
               unsigned stencil)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->clear(pipe,
               buffers,
               rgba,
               depth,
               stencil);
}

static void
identity_flush(struct pipe_context *_pipe,
               unsigned flags,
               struct pipe_fence_handle **fence)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct pipe_context *pipe = id_pipe->pipe;

   pipe->flush(pipe,
               flags,
               fence);
}

static unsigned int
identity_is_texture_referenced(struct pipe_context *_pipe,
                               struct pipe_texture *_texture,
                               unsigned face,
                               unsigned level)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_texture *id_texture = identity_texture(_texture);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_texture *texture = id_texture->texture;

   return pipe->is_texture_referenced(pipe,
                                      texture,
                                      face,
                                      level);
}

static unsigned int
identity_is_buffer_referenced(struct pipe_context *_pipe,
                              struct pipe_buffer *_buffer)
{
   struct identity_context *id_pipe = identity_context(_pipe);
   struct identity_buffer *id_buffer = identity_buffer(_buffer);
   struct pipe_context *pipe = id_pipe->pipe;
   struct pipe_buffer *buffer = id_buffer->buffer;

   return pipe->is_buffer_referenced(pipe,
                                     buffer);
}

struct pipe_context *
identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
{
   struct identity_context *id_pipe;
   (void)identity_screen(_screen);

   id_pipe = CALLOC_STRUCT(identity_context);
   if (!id_pipe) {
      return NULL;
   }

   id_pipe->base.winsys = NULL;
   id_pipe->base.screen = _screen;
   id_pipe->base.priv = pipe->priv;
   id_pipe->base.draw = NULL;

   id_pipe->base.destroy = identity_destroy;
   id_pipe->base.draw_arrays = identity_draw_arrays;
   id_pipe->base.draw_elements = identity_draw_elements;
   id_pipe->base.draw_range_elements = identity_draw_range_elements;
   id_pipe->base.create_query = identity_create_query;
   id_pipe->base.destroy_query = identity_destroy_query;
   id_pipe->base.begin_query = identity_begin_query;
   id_pipe->base.end_query = identity_end_query;
   id_pipe->base.get_query_result = identity_get_query_result;
   id_pipe->base.create_blend_state = identity_create_blend_state;
   id_pipe->base.bind_blend_state = identity_bind_blend_state;
   id_pipe->base.delete_blend_state = identity_delete_blend_state;
   id_pipe->base.create_sampler_state = identity_create_sampler_state;
   id_pipe->base.bind_fragment_sampler_states = identity_bind_fragment_sampler_states;
   id_pipe->base.bind_vertex_sampler_states = identity_bind_vertex_sampler_states;
   id_pipe->base.delete_sampler_state = identity_delete_sampler_state;
   id_pipe->base.create_rasterizer_state = identity_create_rasterizer_state;
   id_pipe->base.bind_rasterizer_state = identity_bind_rasterizer_state;
   id_pipe->base.delete_rasterizer_state = identity_delete_rasterizer_state;
   id_pipe->base.create_depth_stencil_alpha_state = identity_create_depth_stencil_alpha_state;
   id_pipe->base.bind_depth_stencil_alpha_state = identity_bind_depth_stencil_alpha_state;
   id_pipe->base.delete_depth_stencil_alpha_state = identity_delete_depth_stencil_alpha_state;
   id_pipe->base.create_fs_state = identity_create_fs_state;
   id_pipe->base.bind_fs_state = identity_bind_fs_state;
   id_pipe->base.delete_fs_state = identity_delete_fs_state;
   id_pipe->base.create_vs_state = identity_create_vs_state;
   id_pipe->base.bind_vs_state = identity_bind_vs_state;
   id_pipe->base.delete_vs_state = identity_delete_vs_state;
   id_pipe->base.set_blend_color = identity_set_blend_color;
   id_pipe->base.set_clip_state = identity_set_clip_state;
   id_pipe->base.set_constant_buffer = identity_set_constant_buffer;
   id_pipe->base.set_framebuffer_state = identity_set_framebuffer_state;
   id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple;
   id_pipe->base.set_scissor_state = identity_set_scissor_state;
   id_pipe->base.set_viewport_state = identity_set_viewport_state;
   id_pipe->base.set_fragment_sampler_textures = identity_set_fragment_sampler_textures;
   id_pipe->base.set_vertex_sampler_textures = identity_set_vertex_sampler_textures;
   id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers;
   id_pipe->base.set_vertex_elements = identity_set_vertex_elements;
   id_pipe->base.surface_copy = identity_surface_copy;
   id_pipe->base.surface_fill = identity_surface_fill;
   id_pipe->base.clear = identity_clear;
   id_pipe->base.flush = identity_flush;
   id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
   id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced;

   id_pipe->pipe = pipe;

   return &id_pipe->base;
}