1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
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
24 **********************************************************/
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"
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"
45 static void svga_mark_surface_dirty(struct pipe_surface
*surf
);
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
)
57 struct svga_surface dst
, src
;
59 SVGA3dCopyBox box
, *boxes
;
63 src
.handle
= src_handle
;
64 src
.real_level
= src_level
;
65 src
.real_layer
= src_layer
;
68 dst
.handle
= dst_handle
;
69 dst
.real_level
= dst_level
;
70 dst
.real_layer
= dst_layer
;
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);
89 ret
= SVGA3D_BeginSurfaceCopy(svga
->swc
,
94 svga_context_flush(svga
, NULL
);
95 ret
= SVGA3D_BeginSurfaceCopy(svga
->swc
,
99 assert(ret
== PIPE_OK
);
102 SVGA_FIFOCommitAll(svga
->swc
);
106 /* A helper function to sync up the two surface handles.
109 svga_texture_copy_handle_resource(struct svga_context
*svga
,
110 struct svga_texture
*src_tex
,
111 struct svga_winsys_surface
*dst
,
112 unsigned int numMipLevels
,
113 unsigned int numLayers
,
115 unsigned int mipoffset
,
116 unsigned int layeroffset
)
119 unsigned int zoffset
= 0;
121 /* A negative zslice_pick implies zoffset at 0, and depth to copy is
122 * from the depth of the texture at the particular mipmap level.
124 if (zslice_pick
>= 0)
125 zoffset
= zslice_pick
;
127 for (i
= 0; i
< numMipLevels
; i
++) {
128 unsigned int miplevel
= i
+ mipoffset
;
130 for (j
= 0; j
< numLayers
; j
++) {
131 if (svga_is_texture_level_defined(src_tex
, j
+layeroffset
, miplevel
)) {
132 unsigned depth
= (zslice_pick
< 0 ?
133 u_minify(src_tex
->b
.b
.depth0
, miplevel
) : 1);
135 svga_texture_copy_handle(svga
,
141 u_minify(src_tex
->b
.b
.width0
, miplevel
),
142 u_minify(src_tex
->b
.b
.height0
, miplevel
),
150 struct svga_winsys_surface
*
151 svga_texture_view_surface(struct svga_context
*svga
,
152 struct svga_texture
*tex
,
154 SVGA3dSurfaceFlags flags
,
155 SVGA3dSurfaceFormat format
,
161 struct svga_host_surface_cache_key
*key
) /* OUT */
163 struct svga_screen
*ss
= svga_screen(svga
->pipe
.screen
);
164 struct svga_winsys_surface
*handle
;
168 "svga: Create surface view: layer %d zslice %d mips %d..%d\n",
169 layer_pick
, zslice_pick
, start_mip
, start_mip
+num_mip
-1);
172 key
->format
= format
;
173 key
->numMipLevels
= num_mip
;
174 key
->size
.width
= u_minify(tex
->b
.b
.width0
, start_mip
);
175 key
->size
.height
= u_minify(tex
->b
.b
.height0
, start_mip
);
176 key
->size
.depth
= zslice_pick
< 0 ? u_minify(tex
->b
.b
.depth0
, start_mip
) : 1;
181 /* single sample surface can be treated as non-multisamples surface */
182 key
->sampleCount
= tex
->b
.b
.nr_samples
> 1 ? tex
->b
.b
.nr_samples
: 0;
184 if (key
->sampleCount
> 1) {
185 key
->flags
|= SVGA3D_SURFACE_MASKABLE_ANTIALIAS
;
188 if (tex
->b
.b
.target
== PIPE_TEXTURE_CUBE
&& layer_pick
< 0) {
189 key
->flags
|= SVGA3D_SURFACE_CUBEMAP
;
191 } else if (tex
->b
.b
.target
== PIPE_TEXTURE_1D_ARRAY
||
192 tex
->b
.b
.target
== PIPE_TEXTURE_2D_ARRAY
) {
193 key
->arraySize
= num_layers
;
196 if (key
->format
== SVGA3D_FORMAT_INVALID
) {
201 SVGA_DBG(DEBUG_DMA
, "surface_create for texture view\n");
202 handle
= svga_screen_surface_create(ss
, bind_flags
, PIPE_USAGE_DEFAULT
,
209 SVGA_DBG(DEBUG_DMA
, " --> got sid %p (texture view)\n", handle
);
214 svga_texture_copy_handle_resource(svga
, tex
, handle
,
216 key
->numFaces
* key
->arraySize
,
217 zslice_pick
, start_mip
, layer_pick
);
224 * A helper function to create a surface view.
225 * The view boolean flag specifies whether svga_texture_view_surface()
226 * will be called to create a cloned surface and resource for the view.
228 static struct pipe_surface
*
229 svga_create_surface_view(struct pipe_context
*pipe
,
230 struct pipe_resource
*pt
,
231 const struct pipe_surface
*surf_tmpl
,
234 struct svga_context
*svga
= svga_context(pipe
);
235 struct svga_texture
*tex
= svga_texture(pt
);
236 struct pipe_screen
*screen
= pipe
->screen
;
237 struct svga_screen
*ss
= svga_screen(screen
);
238 struct svga_surface
*s
;
239 unsigned layer
, zslice
, bind
;
240 unsigned nlayers
= 1;
241 SVGA3dSurfaceFlags flags
= 0;
242 SVGA3dSurfaceFormat format
;
243 struct pipe_surface
*retVal
= NULL
;
245 s
= CALLOC_STRUCT(svga_surface
);
249 SVGA_STATS_TIME_PUSH(ss
->sws
, SVGA_STATS_TIME_CREATESURFACEVIEW
);
251 if (pt
->target
== PIPE_TEXTURE_CUBE
) {
252 layer
= surf_tmpl
->u
.tex
.first_layer
;
255 else if (pt
->target
== PIPE_TEXTURE_1D_ARRAY
||
256 pt
->target
== PIPE_TEXTURE_2D_ARRAY
) {
257 layer
= surf_tmpl
->u
.tex
.first_layer
;
259 nlayers
= surf_tmpl
->u
.tex
.last_layer
- surf_tmpl
->u
.tex
.first_layer
+ 1;
263 zslice
= surf_tmpl
->u
.tex
.first_layer
;
266 pipe_reference_init(&s
->base
.reference
, 1);
267 pipe_resource_reference(&s
->base
.texture
, pt
);
268 s
->base
.context
= pipe
;
269 s
->base
.format
= surf_tmpl
->format
;
270 s
->base
.width
= u_minify(pt
->width0
, surf_tmpl
->u
.tex
.level
);
271 s
->base
.height
= u_minify(pt
->height0
, surf_tmpl
->u
.tex
.level
);
272 s
->base
.u
.tex
.level
= surf_tmpl
->u
.tex
.level
;
273 s
->base
.u
.tex
.first_layer
= surf_tmpl
->u
.tex
.first_layer
;
274 s
->base
.u
.tex
.last_layer
= surf_tmpl
->u
.tex
.last_layer
;
275 s
->view_id
= SVGA3D_INVALID_ID
;
279 if (util_format_is_depth_or_stencil(surf_tmpl
->format
)) {
280 flags
= SVGA3D_SURFACE_HINT_DEPTHSTENCIL
|
281 SVGA3D_SURFACE_BIND_DEPTH_STENCIL
;
282 bind
= PIPE_BIND_DEPTH_STENCIL
;
285 flags
= SVGA3D_SURFACE_HINT_RENDERTARGET
|
286 SVGA3D_SURFACE_BIND_RENDER_TARGET
;
287 bind
= PIPE_BIND_RENDER_TARGET
;
291 format
= tex
->key
.format
;
293 format
= svga_translate_format(ss
, surf_tmpl
->format
, bind
);
295 assert(format
!= SVGA3D_FORMAT_INVALID
);
298 SVGA_DBG(DEBUG_VIEWS
, "svga: Surface view: yes %p, level %u layer %u z %u, %p\n",
299 pt
, surf_tmpl
->u
.tex
.level
, layer
, zslice
, s
);
301 if (svga_have_vgpu10(svga
)) {
302 switch (pt
->target
) {
303 case PIPE_TEXTURE_1D
:
304 flags
|= SVGA3D_SURFACE_1D
;
306 case PIPE_TEXTURE_1D_ARRAY
:
307 flags
|= SVGA3D_SURFACE_1D
| SVGA3D_SURFACE_ARRAY
;
309 case PIPE_TEXTURE_2D_ARRAY
:
310 flags
|= SVGA3D_SURFACE_ARRAY
;
312 case PIPE_TEXTURE_3D
:
313 flags
|= SVGA3D_SURFACE_VOLUME
;
315 case PIPE_TEXTURE_CUBE
:
317 flags
|= SVGA3D_SURFACE_CUBEMAP
;
324 /* When we clone the surface view resource, use the format used in
325 * the creation of the original resource.
327 s
->handle
= svga_texture_view_surface(svga
, tex
, bind
, flags
,
329 surf_tmpl
->u
.tex
.level
, 1,
330 layer
, nlayers
, zslice
, &s
->key
);
336 s
->key
.format
= format
;
341 SVGA_DBG(DEBUG_VIEWS
,
342 "svga: Surface view: no %p, level %u, layer %u, z %u, %p\n",
343 pt
, surf_tmpl
->u
.tex
.level
, layer
, zslice
, s
);
345 memset(&s
->key
, 0, sizeof s
->key
);
346 s
->key
.format
= format
;
347 s
->handle
= tex
->handle
;
348 s
->real_layer
= layer
;
349 s
->real_zslice
= zslice
;
350 s
->real_level
= surf_tmpl
->u
.tex
.level
;
353 svga
->hud
.num_surface_views
++;
357 SVGA_STATS_TIME_POP(ss
->sws
);
362 static struct pipe_surface
*
363 svga_create_surface(struct pipe_context
*pipe
,
364 struct pipe_resource
*pt
,
365 const struct pipe_surface
*surf_tmpl
)
367 struct svga_context
*svga
= svga_context(pipe
);
368 struct pipe_screen
*screen
= pipe
->screen
;
369 struct pipe_surface
*surf
= NULL
;
370 boolean view
= FALSE
;
372 SVGA_STATS_TIME_PUSH(svga_sws(svga
), SVGA_STATS_TIME_CREATESURFACE
);
374 if (svga_screen(screen
)->debug
.force_surface_view
)
377 if (surf_tmpl
->u
.tex
.level
!= 0 &&
378 svga_screen(screen
)->debug
.force_level_surface_view
)
381 if (pt
->target
== PIPE_TEXTURE_3D
)
384 if (svga_have_vgpu10(svga
) || svga_screen(screen
)->debug
.no_surface_view
)
387 surf
= svga_create_surface_view(pipe
, pt
, surf_tmpl
, view
);
389 SVGA_STATS_TIME_POP(svga_sws(svga
));
396 * Clone the surface view and its associated resource.
398 static struct svga_surface
*
399 create_backed_surface_view(struct svga_context
*svga
, struct svga_surface
*s
)
401 struct svga_texture
*tex
= svga_texture(s
->base
.texture
);
403 SVGA_STATS_TIME_PUSH(svga_sws(svga
),
404 SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW
);
407 struct pipe_surface
*backed_view
;
409 backed_view
= svga_create_surface_view(&svga
->pipe
,
416 s
->backed
= svga_surface(backed_view
);
420 * There is already an existing backing surface, but we still need to
423 struct svga_surface
*bs
= s
->backed
;
424 unsigned int layer
, zslice
;
428 switch (tex
->b
.b
.target
) {
429 case PIPE_TEXTURE_CUBE
:
430 case PIPE_TEXTURE_1D_ARRAY
:
431 case PIPE_TEXTURE_2D_ARRAY
:
432 layer
= s
->base
.u
.tex
.first_layer
;
437 zslice
= s
->base
.u
.tex
.first_layer
;
440 svga_texture_copy_handle_resource(svga
, tex
, bs
->handle
,
441 bs
->key
.numMipLevels
,
442 bs
->key
.numFaces
* bs
->key
.arraySize
,
443 zslice
, s
->base
.u
.tex
.level
, layer
);
446 svga_mark_surface_dirty(&s
->backed
->base
);
448 SVGA_STATS_TIME_POP(svga_sws(svga
));
454 * Create a DX RenderTarget/DepthStencil View for the given surface,
457 struct pipe_surface
*
458 svga_validate_surface_view(struct svga_context
*svga
, struct svga_surface
*s
)
460 enum pipe_error ret
= PIPE_OK
;
461 enum pipe_shader_type shader
;
463 assert(svga_have_vgpu10(svga
));
466 SVGA_STATS_TIME_PUSH(svga_sws(svga
),
467 SVGA_STATS_TIME_VALIDATESURFACEVIEW
);
470 * DX spec explicitly specifies that no resource can be bound to a render
471 * target view and a shader resource view simultanously.
472 * So first check if the resource bound to this surface view collides with
473 * a sampler view. If so, then we will clone this surface view and its
474 * associated resource. We will then use the cloned surface view for
477 for (shader
= PIPE_SHADER_VERTEX
; shader
<= PIPE_SHADER_GEOMETRY
; shader
++) {
478 if (svga_check_sampler_view_resource_collision(svga
, s
->handle
, shader
)) {
479 SVGA_DBG(DEBUG_VIEWS
,
480 "same resource used in shaderResource and renderTarget 0x%x\n",
482 s
= create_backed_surface_view(svga
, s
);
485 svga
->state
.hw_draw
.has_backed_views
= TRUE
;
487 /* s may be null here if the function failed */
492 if (s
&& s
->view_id
== SVGA3D_INVALID_ID
) {
493 SVGA3dResourceType resType
;
494 SVGA3dRenderTargetViewDesc desc
;
495 struct svga_texture
*stex
= svga_texture(s
->base
.texture
);
497 if (stex
->validated
== FALSE
) {
498 assert(stex
->handle
);
500 /* We are about to render into a surface that has not been validated.
501 * First invalidate the surface so that the device does not
502 * need to update the host-side copy with the invalid
503 * content when the associated mob is first bound to the surface.
505 ret
= SVGA3D_InvalidateGBSurface(svga
->swc
, stex
->handle
);
506 if (ret
!= PIPE_OK
) {
510 stex
->validated
= TRUE
;
513 desc
.tex
.mipSlice
= s
->real_level
;
514 desc
.tex
.firstArraySlice
= s
->real_layer
+ s
->real_zslice
;
516 s
->base
.u
.tex
.last_layer
- s
->base
.u
.tex
.first_layer
+ 1;
518 s
->view_id
= util_bitmask_add(svga
->surface_view_id_bm
);
520 resType
= svga_resource_type(s
->base
.texture
->target
);
522 if (util_format_is_depth_or_stencil(s
->base
.format
)) {
523 ret
= SVGA3D_vgpu10_DefineDepthStencilView(svga
->swc
,
531 SVGA3dSurfaceFormat view_format
= s
->key
.format
;
532 const struct svga_texture
*stex
= svga_texture(s
->base
.texture
);
534 /* Can't create RGBA render target view of a RGBX surface so adjust
535 * the view format. We do something similar for texture samplers in
536 * svga_validate_pipe_sampler_view().
538 if (view_format
== SVGA3D_B8G8R8A8_UNORM
&&
539 (stex
->key
.format
== SVGA3D_B8G8R8X8_UNORM
||
540 stex
->key
.format
== SVGA3D_B8G8R8X8_TYPELESS
)) {
541 view_format
= SVGA3D_B8G8R8X8_UNORM
;
544 ret
= SVGA3D_vgpu10_DefineRenderTargetView(svga
->swc
,
552 if (ret
!= PIPE_OK
) {
553 util_bitmask_clear(svga
->surface_view_id_bm
, s
->view_id
);
554 s
->view_id
= SVGA3D_INVALID_ID
;
560 SVGA_STATS_TIME_POP(svga_sws(svga
));
562 return s
? &s
->base
: NULL
;
568 svga_surface_destroy(struct pipe_context
*pipe
,
569 struct pipe_surface
*surf
)
571 struct svga_context
*svga
= svga_context(pipe
);
572 struct svga_surface
*s
= svga_surface(surf
);
573 struct svga_texture
*t
= svga_texture(surf
->texture
);
574 struct svga_screen
*ss
= svga_screen(surf
->texture
->screen
);
575 enum pipe_error ret
= PIPE_OK
;
577 SVGA_STATS_TIME_PUSH(ss
->sws
, SVGA_STATS_TIME_DESTROYSURFACE
);
579 /* Destroy the backed view surface if it exists */
581 svga_surface_destroy(pipe
, &s
->backed
->base
);
585 if (s
->handle
!= t
->handle
) {
586 SVGA_DBG(DEBUG_DMA
, "unref sid %p (tex surface)\n", s
->handle
);
587 svga_screen_surface_destroy(ss
, &s
->key
, &s
->handle
);
590 if (s
->view_id
!= SVGA3D_INVALID_ID
) {
593 /* The SVGA3D device will generate a device error if the
594 * render target view or depth stencil view is destroyed from
595 * a context other than the one it was created with.
596 * Similar to shader resource view, in this case, we will skip
597 * the destroy for now.
599 if (surf
->context
!= pipe
) {
600 _debug_printf("context mismatch in %s\n", __func__
);
603 assert(svga_have_vgpu10(svga
));
604 for (try = 0; try < 2; try++) {
605 if (util_format_is_depth_or_stencil(s
->base
.format
)) {
606 ret
= SVGA3D_vgpu10_DestroyDepthStencilView(svga
->swc
, s
->view_id
);
609 ret
= SVGA3D_vgpu10_DestroyRenderTargetView(svga
->swc
, s
->view_id
);
613 svga_context_flush(svga
, NULL
);
615 assert(ret
== PIPE_OK
);
616 util_bitmask_clear(svga
->surface_view_id_bm
, s
->view_id
);
620 pipe_resource_reference(&surf
->texture
, NULL
);
623 svga
->hud
.num_surface_views
--;
624 SVGA_STATS_TIME_POP(ss
->sws
);
629 svga_mark_surface_dirty(struct pipe_surface
*surf
)
631 struct svga_surface
*s
= svga_surface(surf
);
632 struct svga_texture
*tex
= svga_texture(surf
->texture
);
637 if (s
->handle
== tex
->handle
) {
638 /* hmm so 3d textures always have all their slices marked ? */
639 svga_define_texture_level(tex
, surf
->u
.tex
.first_layer
,
643 /* this will happen later in svga_propagate_surface */
647 /* Increment the view_age and texture age for this surface's mipmap
648 * level so that any sampler views into the texture are re-validated too.
650 svga_age_texture_view(tex
, surf
->u
.tex
.level
);
655 svga_mark_surfaces_dirty(struct svga_context
*svga
)
659 for (i
= 0; i
< svga
->curr
.framebuffer
.nr_cbufs
; i
++) {
660 if (svga
->curr
.framebuffer
.cbufs
[i
])
661 svga_mark_surface_dirty(svga
->curr
.framebuffer
.cbufs
[i
]);
663 if (svga
->curr
.framebuffer
.zsbuf
)
664 svga_mark_surface_dirty(svga
->curr
.framebuffer
.zsbuf
);
669 * Progagate any changes from surfaces to texture.
670 * pipe is optional context to inline the blit command in.
673 svga_propagate_surface(struct svga_context
*svga
, struct pipe_surface
*surf
,
676 struct svga_surface
*s
= svga_surface(surf
);
677 struct svga_texture
*tex
= svga_texture(surf
->texture
);
678 struct svga_screen
*ss
= svga_screen(surf
->texture
->screen
);
683 SVGA_STATS_TIME_PUSH(ss
->sws
, SVGA_STATS_TIME_PROPAGATESURFACE
);
685 /* Reset the dirty flag if specified. This is to ensure that
686 * the dirty flag will not be reset and stay unset when the backing
687 * surface is still being bound and rendered to.
688 * The reset flag will be set to TRUE when the surface is propagated
689 * and will be unbound.
693 ss
->texture_timestamp
++;
694 svga_age_texture_view(tex
, surf
->u
.tex
.level
);
696 if (s
->handle
!= tex
->handle
) {
697 unsigned zslice
, layer
;
698 unsigned nlayers
= 1;
701 if (surf
->texture
->target
== PIPE_TEXTURE_CUBE
) {
703 layer
= surf
->u
.tex
.first_layer
;
705 else if (surf
->texture
->target
== PIPE_TEXTURE_1D_ARRAY
||
706 surf
->texture
->target
== PIPE_TEXTURE_2D_ARRAY
) {
708 layer
= surf
->u
.tex
.first_layer
;
709 nlayers
= surf
->u
.tex
.last_layer
- surf
->u
.tex
.first_layer
+ 1;
712 zslice
= surf
->u
.tex
.first_layer
;
716 SVGA_DBG(DEBUG_VIEWS
,
717 "svga: Surface propagate: tex %p, level %u, from %p\n",
718 tex
, surf
->u
.tex
.level
, surf
);
719 for (i
= 0; i
< nlayers
; i
++) {
720 svga_texture_copy_handle(svga
,
721 s
->handle
, 0, 0, 0, s
->real_level
,
723 tex
->handle
, 0, 0, zslice
, surf
->u
.tex
.level
,
725 u_minify(tex
->b
.b
.width0
, surf
->u
.tex
.level
),
726 u_minify(tex
->b
.b
.height0
, surf
->u
.tex
.level
),
728 svga_define_texture_level(tex
, layer
+ i
, surf
->u
.tex
.level
);
732 SVGA_STATS_TIME_POP(ss
->sws
);
737 * If any of the render targets are in backing texture views, propagate any
738 * changes to them back to the original texture.
741 svga_propagate_rendertargets(struct svga_context
*svga
)
745 /* Early exit if there is no backing texture views in use */
746 if (!svga
->state
.hw_draw
.has_backed_views
)
749 /* Note that we examine the svga->state.hw_draw.framebuffer surfaces,
750 * not the svga->curr.framebuffer surfaces, because it's the former
751 * surfaces which may be backing surface views (the actual render targets).
753 for (i
= 0; i
< svga
->state
.hw_draw
.num_rendertargets
; i
++) {
754 struct pipe_surface
*s
= svga
->state
.hw_draw
.rtv
[i
];
756 svga_propagate_surface(svga
, s
, FALSE
);
760 if (svga
->state
.hw_draw
.dsv
) {
761 svga_propagate_surface(svga
, svga
->state
.hw_draw
.dsv
, FALSE
);
767 * Check if we should call svga_propagate_surface on the surface.
770 svga_surface_needs_propagation(const struct pipe_surface
*surf
)
772 const struct svga_surface
*s
= svga_surface_const(surf
);
773 struct svga_texture
*tex
= svga_texture(surf
->texture
);
775 return s
->dirty
&& s
->handle
!= tex
->handle
;
780 svga_get_sample_position(struct pipe_context
*context
,
781 unsigned sample_count
, unsigned sample_index
,
784 /* We can't actually query the device to learn the sample positions.
785 * These were grabbed from nvidia's driver.
787 static const float pos1
[1][2] = {
790 static const float pos4
[4][2] = {
791 { 0.375000, 0.125000 },
792 { 0.875000, 0.375000 },
793 { 0.125000, 0.625000 },
794 { 0.625000, 0.875000 }
796 static const float pos8
[8][2] = {
797 { 0.562500, 0.312500 },
798 { 0.437500, 0.687500 },
799 { 0.812500, 0.562500 },
800 { 0.312500, 0.187500 },
801 { 0.187500, 0.812500 },
802 { 0.062500, 0.437500 },
803 { 0.687500, 0.937500 },
804 { 0.937500, 0.062500 }
806 static const float pos16
[16][2] = {
807 { 0.187500, 0.062500 },
808 { 0.437500, 0.187500 },
809 { 0.062500, 0.312500 },
810 { 0.312500, 0.437500 },
811 { 0.687500, 0.062500 },
812 { 0.937500, 0.187500 },
813 { 0.562500, 0.312500 },
814 { 0.812500, 0.437500 },
815 { 0.187500, 0.562500 },
816 { 0.437500, 0.687500 },
817 { 0.062500, 0.812500 },
818 { 0.312500, 0.937500 },
819 { 0.687500, 0.562500 },
820 { 0.937500, 0.687500 },
821 { 0.562500, 0.812500 },
822 { 0.812500, 0.937500 }
824 const float (*positions
)[2];
826 switch (sample_count
) {
840 pos_out
[0] = positions
[sample_index
][0];
841 pos_out
[1] = positions
[sample_index
][1];
846 svga_init_surface_functions(struct svga_context
*svga
)
848 svga
->pipe
.create_surface
= svga_create_surface
;
849 svga
->pipe
.surface_destroy
= svga_surface_destroy
;
850 svga
->pipe
.get_sample_position
= svga_get_sample_position
;