svga: Fix surface view error handling
[mesa.git] / src / gallium / drivers / svga / svga_surface.c
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26 #include "svga_cmd.h"
27
28 #include "pipe/p_state.h"
29 #include "pipe/p_defines.h"
30 #include "util/u_inlines.h"
31 #include "os/os_thread.h"
32 #include "util/u_bitmask.h"
33 #include "util/u_format.h"
34 #include "util/u_math.h"
35 #include "util/u_memory.h"
36
37 #include "svga_format.h"
38 #include "svga_screen.h"
39 #include "svga_context.h"
40 #include "svga_sampler_view.h"
41 #include "svga_resource_texture.h"
42 #include "svga_surface.h"
43 #include "svga_debug.h"
44
45 static void svga_mark_surface_dirty(struct pipe_surface *surf);
46
47 void
48 svga_texture_copy_handle(struct svga_context *svga,
49 struct svga_winsys_surface *src_handle,
50 unsigned src_x, unsigned src_y, unsigned src_z,
51 unsigned src_level, unsigned src_layer,
52 struct svga_winsys_surface *dst_handle,
53 unsigned dst_x, unsigned dst_y, unsigned dst_z,
54 unsigned dst_level, unsigned dst_layer,
55 unsigned width, unsigned height, unsigned depth)
56 {
57 struct svga_surface dst, src;
58 enum pipe_error ret;
59 SVGA3dCopyBox box, *boxes;
60
61 assert(svga);
62
63 src.handle = src_handle;
64 src.real_level = src_level;
65 src.real_layer = src_layer;
66 src.real_zslice = 0;
67
68 dst.handle = dst_handle;
69 dst.real_level = dst_level;
70 dst.real_layer = dst_layer;
71 dst.real_zslice = 0;
72
73 box.x = dst_x;
74 box.y = dst_y;
75 box.z = dst_z;
76 box.w = width;
77 box.h = height;
78 box.d = depth;
79 box.srcx = src_x;
80 box.srcy = src_y;
81 box.srcz = src_z;
82
83 /*
84 SVGA_DBG(DEBUG_VIEWS, "mipcopy src: %p %u (%ux%ux%u), dst: %p %u (%ux%ux%u)\n",
85 src_handle, src_level, src_x, src_y, src_z,
86 dst_handle, dst_level, dst_x, dst_y, dst_z);
87 */
88
89 ret = SVGA3D_BeginSurfaceCopy(svga->swc,
90 &src.base,
91 &dst.base,
92 &boxes, 1);
93 if (ret != PIPE_OK) {
94 svga_context_flush(svga, NULL);
95 ret = SVGA3D_BeginSurfaceCopy(svga->swc,
96 &src.base,
97 &dst.base,
98 &boxes, 1);
99 assert(ret == PIPE_OK);
100 }
101 *boxes = box;
102 SVGA_FIFOCommitAll(svga->swc);
103 }
104
105
106 struct svga_winsys_surface *
107 svga_texture_view_surface(struct svga_context *svga,
108 struct svga_texture *tex,
109 unsigned bind_flags,
110 SVGA3dSurfaceFlags flags,
111 SVGA3dSurfaceFormat format,
112 unsigned start_mip,
113 unsigned num_mip,
114 int layer_pick,
115 unsigned num_layers,
116 int zslice_pick,
117 struct svga_host_surface_cache_key *key) /* OUT */
118 {
119 struct svga_screen *ss = svga_screen(svga->pipe.screen);
120 struct svga_winsys_surface *handle;
121 uint32_t i, j;
122 unsigned z_offset = 0;
123
124 SVGA_DBG(DEBUG_PERF,
125 "svga: Create surface view: layer %d zslice %d mips %d..%d\n",
126 layer_pick, zslice_pick, start_mip, start_mip+num_mip-1);
127
128 key->flags = flags;
129 key->format = format;
130 key->numMipLevels = num_mip;
131 key->size.width = u_minify(tex->b.b.width0, start_mip);
132 key->size.height = u_minify(tex->b.b.height0, start_mip);
133 key->size.depth = zslice_pick < 0 ? u_minify(tex->b.b.depth0, start_mip) : 1;
134 key->cachable = 1;
135 key->arraySize = 1;
136 key->numFaces = 1;
137 key->sampleCount = tex->b.b.nr_samples;
138
139 if (key->sampleCount > 1) {
140 key->flags |= SVGA3D_SURFACE_MASKABLE_ANTIALIAS;
141 }
142
143 if (tex->b.b.target == PIPE_TEXTURE_CUBE && layer_pick < 0) {
144 key->flags |= SVGA3D_SURFACE_CUBEMAP;
145 key->numFaces = 6;
146 } else if (tex->b.b.target == PIPE_TEXTURE_1D_ARRAY ||
147 tex->b.b.target == PIPE_TEXTURE_2D_ARRAY) {
148 key->arraySize = num_layers;
149 }
150
151 if (key->format == SVGA3D_FORMAT_INVALID) {
152 key->cachable = 0;
153 return NULL;
154 }
155
156 SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
157 handle = svga_screen_surface_create(ss, bind_flags, PIPE_USAGE_DEFAULT, key);
158 if (!handle) {
159 key->cachable = 0;
160 return NULL;
161 }
162
163 SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
164
165 if (layer_pick < 0)
166 layer_pick = 0;
167
168 if (zslice_pick >= 0)
169 z_offset = zslice_pick;
170
171 for (i = 0; i < key->numMipLevels; i++) {
172 for (j = 0; j < key->numFaces * key->arraySize; j++) {
173 if (svga_is_texture_level_defined(tex, j + layer_pick, i + start_mip)) {
174 unsigned depth = (zslice_pick < 0 ?
175 u_minify(tex->b.b.depth0, i + start_mip) :
176 1);
177
178 svga_texture_copy_handle(svga,
179 tex->handle,
180 0, 0, z_offset,
181 i + start_mip,
182 j + layer_pick,
183 handle, 0, 0, 0, i, j,
184 u_minify(tex->b.b.width0, i + start_mip),
185 u_minify(tex->b.b.height0, i + start_mip),
186 depth);
187 }
188 }
189 }
190
191 return handle;
192 }
193
194
195 /**
196 * A helper function to create a surface view.
197 * The view boolean flag specifies whether svga_texture_view_surface()
198 * will be called to create a cloned surface and resource for the view.
199 */
200 static struct pipe_surface *
201 svga_create_surface_view(struct pipe_context *pipe,
202 struct pipe_resource *pt,
203 const struct pipe_surface *surf_tmpl,
204 boolean view)
205 {
206 struct svga_context *svga = svga_context(pipe);
207 struct svga_texture *tex = svga_texture(pt);
208 struct pipe_screen *screen = pipe->screen;
209 struct svga_screen *ss = svga_screen(screen);
210 struct svga_surface *s;
211 unsigned layer, zslice, bind;
212 unsigned nlayers = 1;
213 SVGA3dSurfaceFlags flags = 0;
214 SVGA3dSurfaceFormat format;
215
216 s = CALLOC_STRUCT(svga_surface);
217 if (!s)
218 return NULL;
219
220 if (pt->target == PIPE_TEXTURE_CUBE) {
221 layer = surf_tmpl->u.tex.first_layer;
222 zslice = 0;
223 }
224 else if (pt->target == PIPE_TEXTURE_1D_ARRAY ||
225 pt->target == PIPE_TEXTURE_2D_ARRAY) {
226 layer = surf_tmpl->u.tex.first_layer;
227 zslice = 0;
228 nlayers = surf_tmpl->u.tex.last_layer - surf_tmpl->u.tex.first_layer + 1;
229 }
230 else {
231 layer = 0;
232 zslice = surf_tmpl->u.tex.first_layer;
233 }
234
235 pipe_reference_init(&s->base.reference, 1);
236 pipe_resource_reference(&s->base.texture, pt);
237 s->base.context = pipe;
238 s->base.format = surf_tmpl->format;
239 s->base.width = u_minify(pt->width0, surf_tmpl->u.tex.level);
240 s->base.height = u_minify(pt->height0, surf_tmpl->u.tex.level);
241 s->base.u.tex.level = surf_tmpl->u.tex.level;
242 s->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer;
243 s->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer;
244 s->view_id = SVGA3D_INVALID_ID;
245
246 s->backed = NULL;
247
248 if (util_format_is_depth_or_stencil(surf_tmpl->format)) {
249 flags = SVGA3D_SURFACE_HINT_DEPTHSTENCIL |
250 SVGA3D_SURFACE_BIND_DEPTH_STENCIL;
251 bind = PIPE_BIND_DEPTH_STENCIL;
252 }
253 else {
254 flags = SVGA3D_SURFACE_HINT_RENDERTARGET |
255 SVGA3D_SURFACE_BIND_RENDER_TARGET;
256 bind = PIPE_BIND_RENDER_TARGET;
257 }
258
259 if (tex->imported)
260 format = tex->key.format;
261 else
262 format = svga_translate_format(ss, surf_tmpl->format, bind);
263
264 assert(format != SVGA3D_FORMAT_INVALID);
265
266 if (view) {
267 SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u layer %u z %u, %p\n",
268 pt, surf_tmpl->u.tex.level, layer, zslice, s);
269
270 if (svga_have_vgpu10(svga)) {
271 switch (pt->target) {
272 case PIPE_TEXTURE_1D:
273 flags |= SVGA3D_SURFACE_1D;
274 break;
275 case PIPE_TEXTURE_1D_ARRAY:
276 flags |= SVGA3D_SURFACE_1D | SVGA3D_SURFACE_ARRAY;
277 break;
278 case PIPE_TEXTURE_2D_ARRAY:
279 flags |= SVGA3D_SURFACE_ARRAY;
280 break;
281 case PIPE_TEXTURE_3D:
282 flags |= SVGA3D_SURFACE_VOLUME;
283 break;
284 case PIPE_TEXTURE_CUBE:
285 if (nlayers == 6)
286 flags |= SVGA3D_SURFACE_CUBEMAP;
287 break;
288 default:
289 break;
290 }
291 }
292
293 /* When we clone the surface view resource, use the format used in
294 * the creation of the original resource.
295 */
296 s->handle = svga_texture_view_surface(svga, tex, bind, flags, tex->key.format,
297 surf_tmpl->u.tex.level, 1,
298 layer, nlayers, zslice, &s->key);
299 if (!s->handle) {
300 FREE(s);
301 return NULL;
302 }
303
304 s->key.format = format;
305 s->real_layer = 0;
306 s->real_level = 0;
307 s->real_zslice = 0;
308 } else {
309 SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, layer %u, z %u, %p\n",
310 pt, surf_tmpl->u.tex.level, layer, zslice, s);
311
312 memset(&s->key, 0, sizeof s->key);
313 s->key.format = format;
314 s->handle = tex->handle;
315 s->real_layer = layer;
316 s->real_zslice = zslice;
317 s->real_level = surf_tmpl->u.tex.level;
318 }
319
320 return &s->base;
321 }
322
323
324 static struct pipe_surface *
325 svga_create_surface(struct pipe_context *pipe,
326 struct pipe_resource *pt,
327 const struct pipe_surface *surf_tmpl)
328 {
329 struct svga_context *svga = svga_context(pipe);
330 struct pipe_screen *screen = pipe->screen;
331 boolean view = FALSE;
332
333 if (svga_screen(screen)->debug.force_surface_view)
334 view = TRUE;
335
336 if (surf_tmpl->u.tex.level != 0 &&
337 svga_screen(screen)->debug.force_level_surface_view)
338 view = TRUE;
339
340 if (pt->target == PIPE_TEXTURE_3D)
341 view = TRUE;
342
343 if (svga_have_vgpu10(svga) || svga_screen(screen)->debug.no_surface_view)
344 view = FALSE;
345
346 return svga_create_surface_view(pipe, pt, surf_tmpl, view);
347 }
348
349
350 /**
351 * Clone the surface view and its associated resource.
352 */
353 static struct svga_surface *
354 create_backed_surface_view(struct svga_context *svga, struct svga_surface *s)
355 {
356 struct svga_surface *bs = s->backed;
357
358 if (bs == NULL) {
359 struct svga_texture *tex = svga_texture(s->base.texture);
360 struct pipe_surface *backed_view;
361
362 backed_view = svga_create_surface_view(&svga->pipe,
363 &tex->b.b,
364 &s->base,
365 TRUE);
366 if (!backed_view)
367 return NULL;
368
369 bs = svga_surface(backed_view);
370 s->backed = bs;
371 }
372
373 svga_mark_surface_dirty(&bs->base);
374
375 return bs;
376 }
377
378 /**
379 * Create a DX RenderTarget/DepthStencil View for the given surface,
380 * if needed.
381 */
382 struct pipe_surface *
383 svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
384 {
385 enum pipe_error ret = PIPE_OK;
386 unsigned shader;
387
388 assert(svga_have_vgpu10(svga));
389
390 /**
391 * DX spec explicitly specifies that no resource can be bound to a render
392 * target view and a shader resource view simultanously.
393 * So first check if the resource bound to this surface view collides with
394 * a sampler view. If so, then we will clone this surface view and its
395 * associated resource. We will then use the cloned surface view for
396 * render target.
397 */
398 for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) {
399 if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
400 SVGA_DBG(DEBUG_VIEWS,
401 "same resource used in shaderResource and renderTarget 0x%x\n",
402 s->handle);
403 s = create_backed_surface_view(svga, s);
404 if (!s)
405 return NULL;
406
407 break;
408 }
409 }
410
411 if (s->view_id == SVGA3D_INVALID_ID) {
412 SVGA3dResourceType resType;
413 SVGA3dRenderTargetViewDesc desc;
414
415 desc.tex.mipSlice = s->real_level;
416 desc.tex.firstArraySlice = s->real_layer + s->real_zslice;
417 desc.tex.arraySize =
418 s->base.u.tex.last_layer - s->base.u.tex.first_layer + 1;
419
420 s->view_id = util_bitmask_add(svga->surface_view_id_bm);
421
422 switch (s->base.texture->target) {
423 case PIPE_TEXTURE_1D:
424 case PIPE_TEXTURE_1D_ARRAY:
425 resType = SVGA3D_RESOURCE_TEXTURE1D;
426 break;
427 case PIPE_TEXTURE_RECT:
428 case PIPE_TEXTURE_2D:
429 case PIPE_TEXTURE_2D_ARRAY:
430 case PIPE_TEXTURE_CUBE:
431 /* drawing to cube map is treated as drawing to 2D array */
432 resType = SVGA3D_RESOURCE_TEXTURE2D;
433 break;
434 case PIPE_TEXTURE_3D:
435 resType = SVGA3D_RESOURCE_TEXTURE3D;
436 break;
437 default:
438 assert(!"Unexpected texture target");
439 resType = SVGA3D_RESOURCE_TEXTURE2D;
440 }
441
442 if (util_format_is_depth_or_stencil(s->base.format)) {
443 ret = SVGA3D_vgpu10_DefineDepthStencilView(svga->swc,
444 s->view_id,
445 s->handle,
446 s->key.format,
447 resType,
448 &desc);
449 }
450 else {
451 ret = SVGA3D_vgpu10_DefineRenderTargetView(svga->swc,
452 s->view_id,
453 s->handle,
454 s->key.format,
455 resType,
456 &desc);
457 }
458
459 if (ret != PIPE_OK) {
460 util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
461 s->view_id = SVGA3D_INVALID_ID;
462 return NULL;
463 }
464 }
465 return &s->base;
466 }
467
468
469
470 static void
471 svga_surface_destroy(struct pipe_context *pipe,
472 struct pipe_surface *surf)
473 {
474 struct svga_context *svga = svga_context(pipe);
475 struct svga_surface *s = svga_surface(surf);
476 struct svga_texture *t = svga_texture(surf->texture);
477 struct svga_screen *ss = svga_screen(surf->texture->screen);
478 enum pipe_error ret = PIPE_OK;
479
480 /* Destroy the backed view surface if it exists */
481 if (s->backed) {
482 svga_surface_destroy(pipe, &s->backed->base);
483 s->backed = NULL;
484 }
485
486 if (s->handle != t->handle) {
487 SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
488 svga_screen_surface_destroy(ss, &s->key, &s->handle);
489 }
490
491 if (s->view_id != SVGA3D_INVALID_ID) {
492 unsigned try;
493
494 assert(svga_have_vgpu10(svga));
495 for (try = 0; try < 2; try++) {
496 if (util_format_is_depth_or_stencil(s->base.format)) {
497 ret = SVGA3D_vgpu10_DestroyDepthStencilView(svga->swc, s->view_id);
498 }
499 else {
500 ret = SVGA3D_vgpu10_DestroyRenderTargetView(svga->swc, s->view_id);
501 }
502 if (ret == PIPE_OK)
503 break;
504 svga_context_flush(svga, NULL);
505 }
506 assert(ret == PIPE_OK);
507 util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
508 }
509
510 pipe_resource_reference(&surf->texture, NULL);
511 FREE(surf);
512 }
513
514
515 static void
516 svga_mark_surface_dirty(struct pipe_surface *surf)
517 {
518 struct svga_surface *s = svga_surface(surf);
519 struct svga_texture *tex = svga_texture(surf->texture);
520
521 if (!s->dirty) {
522 s->dirty = TRUE;
523
524 if (s->handle == tex->handle) {
525 /* hmm so 3d textures always have all their slices marked ? */
526 svga_define_texture_level(tex, surf->u.tex.first_layer,
527 surf->u.tex.level);
528 }
529 else {
530 /* this will happen later in svga_propagate_surface */
531 }
532 }
533
534 /* Increment the view_age and texture age for this surface's mipmap
535 * level so that any sampler views into the texture are re-validated too.
536 */
537 svga_age_texture_view(tex, surf->u.tex.level);
538 }
539
540
541 void
542 svga_mark_surfaces_dirty(struct svga_context *svga)
543 {
544 struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
545 unsigned i;
546
547 for (i = 0; i < svgascreen->max_color_buffers; i++) {
548 if (svga->curr.framebuffer.cbufs[i])
549 svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]);
550 }
551 if (svga->curr.framebuffer.zsbuf)
552 svga_mark_surface_dirty(svga->curr.framebuffer.zsbuf);
553 }
554
555
556 /**
557 * Progagate any changes from surfaces to texture.
558 * pipe is optional context to inline the blit command in.
559 */
560 void
561 svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf)
562 {
563 struct svga_surface *s = svga_surface(surf);
564 struct svga_texture *tex = svga_texture(surf->texture);
565 struct svga_screen *ss = svga_screen(surf->texture->screen);
566 unsigned zslice, layer;
567 unsigned nlayers = 1;
568 unsigned i;
569
570 if (!s->dirty)
571 return;
572
573 if (surf->texture->target == PIPE_TEXTURE_CUBE) {
574 zslice = 0;
575 layer = surf->u.tex.first_layer;
576 }
577 else if (surf->texture->target == PIPE_TEXTURE_1D_ARRAY ||
578 surf->texture->target == PIPE_TEXTURE_2D_ARRAY) {
579 zslice = 0;
580 layer = surf->u.tex.first_layer;
581 nlayers = surf->u.tex.last_layer - surf->u.tex.first_layer + 1;
582 }
583 else {
584 zslice = surf->u.tex.first_layer;
585 layer = 0;
586 }
587
588 s->dirty = FALSE;
589 ss->texture_timestamp++;
590 svga_age_texture_view(tex, surf->u.tex.level);
591
592 if (s->handle != tex->handle) {
593 SVGA_DBG(DEBUG_VIEWS,
594 "svga: Surface propagate: tex %p, level %u, from %p\n",
595 tex, surf->u.tex.level, surf);
596 for (i = 0; i < nlayers; i++) {
597 svga_texture_copy_handle(svga,
598 s->handle, 0, 0, 0, s->real_level, s->real_layer + i,
599 tex->handle, 0, 0, zslice, surf->u.tex.level, layer + i,
600 u_minify(tex->b.b.width0, surf->u.tex.level),
601 u_minify(tex->b.b.height0, surf->u.tex.level), 1);
602 svga_define_texture_level(tex, layer + i, surf->u.tex.level);
603 }
604 }
605 }
606
607
608 /**
609 * Check if we should call svga_propagate_surface on the surface.
610 */
611 boolean
612 svga_surface_needs_propagation(const struct pipe_surface *surf)
613 {
614 const struct svga_surface *s = svga_surface_const(surf);
615 struct svga_texture *tex = svga_texture(surf->texture);
616
617 return s->dirty && s->handle != tex->handle;
618 }
619
620
621 static void
622 svga_get_sample_position(struct pipe_context *context,
623 unsigned sample_count, unsigned sample_index,
624 float *pos_out)
625 {
626 /* We can't actually query the device to learn the sample positions.
627 * These were grabbed from nvidia's driver.
628 */
629 static const float pos1[1][2] = {
630 { 0.5, 0.5 }
631 };
632 static const float pos4[4][2] = {
633 { 0.375000, 0.125000 },
634 { 0.875000, 0.375000 },
635 { 0.125000, 0.625000 },
636 { 0.625000, 0.875000 }
637 };
638 static const float pos8[8][2] = {
639 { 0.562500, 0.312500 },
640 { 0.437500, 0.687500 },
641 { 0.812500, 0.562500 },
642 { 0.312500, 0.187500 },
643 { 0.187500, 0.812500 },
644 { 0.062500, 0.437500 },
645 { 0.687500, 0.937500 },
646 { 0.937500, 0.062500 }
647 };
648 static const float pos16[16][2] = {
649 { 0.187500, 0.062500 },
650 { 0.437500, 0.187500 },
651 { 0.062500, 0.312500 },
652 { 0.312500, 0.437500 },
653 { 0.687500, 0.062500 },
654 { 0.937500, 0.187500 },
655 { 0.562500, 0.312500 },
656 { 0.812500, 0.437500 },
657 { 0.187500, 0.562500 },
658 { 0.437500, 0.687500 },
659 { 0.062500, 0.812500 },
660 { 0.312500, 0.937500 },
661 { 0.687500, 0.562500 },
662 { 0.937500, 0.687500 },
663 { 0.562500, 0.812500 },
664 { 0.812500, 0.937500 }
665 };
666 const float (*positions)[2];
667
668 switch (sample_count) {
669 case 4:
670 positions = pos4;
671 break;
672 case 8:
673 positions = pos8;
674 break;
675 case 16:
676 positions = pos16;
677 break;
678 default:
679 positions = pos1;
680 }
681
682 pos_out[0] = positions[sample_index][0];
683 pos_out[1] = positions[sample_index][1];
684 }
685
686
687 void
688 svga_init_surface_functions(struct svga_context *svga)
689 {
690 svga->pipe.create_surface = svga_create_surface;
691 svga->pipe.surface_destroy = svga_surface_destroy;
692 svga->pipe.get_sample_position = svga_get_sample_position;
693 }