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
,
299 "New backed surface view: resource %p, level %u layer %u z %u, %p\n",
300 pt
, surf_tmpl
->u
.tex
.level
, layer
, zslice
, s
);
302 if (svga_have_vgpu10(svga
)) {
303 switch (pt
->target
) {
304 case PIPE_TEXTURE_1D
:
305 flags
|= SVGA3D_SURFACE_1D
;
307 case PIPE_TEXTURE_1D_ARRAY
:
308 flags
|= SVGA3D_SURFACE_1D
| SVGA3D_SURFACE_ARRAY
;
310 case PIPE_TEXTURE_2D_ARRAY
:
311 flags
|= SVGA3D_SURFACE_ARRAY
;
313 case PIPE_TEXTURE_3D
:
314 flags
|= SVGA3D_SURFACE_VOLUME
;
316 case PIPE_TEXTURE_CUBE
:
318 flags
|= SVGA3D_SURFACE_CUBEMAP
;
325 /* When we clone the surface view resource, use the format used in
326 * the creation of the original resource.
328 s
->handle
= svga_texture_view_surface(svga
, tex
, bind
, flags
,
330 surf_tmpl
->u
.tex
.level
, 1,
331 layer
, nlayers
, zslice
, &s
->key
);
337 s
->key
.format
= format
;
342 SVGA_DBG(DEBUG_VIEWS
,
343 "New surface view: resource %p, level %u, layer %u, z %u, %p\n",
344 pt
, surf_tmpl
->u
.tex
.level
, layer
, zslice
, s
);
346 memset(&s
->key
, 0, sizeof s
->key
);
347 s
->key
.format
= format
;
348 s
->handle
= tex
->handle
;
349 s
->real_layer
= layer
;
350 s
->real_zslice
= zslice
;
351 s
->real_level
= surf_tmpl
->u
.tex
.level
;
354 svga
->hud
.num_surface_views
++;
358 SVGA_STATS_TIME_POP(ss
->sws
);
363 static struct pipe_surface
*
364 svga_create_surface(struct pipe_context
*pipe
,
365 struct pipe_resource
*pt
,
366 const struct pipe_surface
*surf_tmpl
)
368 struct svga_context
*svga
= svga_context(pipe
);
369 struct pipe_screen
*screen
= pipe
->screen
;
370 struct pipe_surface
*surf
= NULL
;
371 boolean view
= FALSE
;
373 SVGA_STATS_TIME_PUSH(svga_sws(svga
), SVGA_STATS_TIME_CREATESURFACE
);
375 if (svga_screen(screen
)->debug
.force_surface_view
)
378 if (surf_tmpl
->u
.tex
.level
!= 0 &&
379 svga_screen(screen
)->debug
.force_level_surface_view
)
382 if (pt
->target
== PIPE_TEXTURE_3D
)
385 if (svga_have_vgpu10(svga
) || svga_screen(screen
)->debug
.no_surface_view
)
388 surf
= svga_create_surface_view(pipe
, pt
, surf_tmpl
, view
);
390 SVGA_STATS_TIME_POP(svga_sws(svga
));
397 * Clone the surface view and its associated resource.
399 static struct svga_surface
*
400 create_backed_surface_view(struct svga_context
*svga
, struct svga_surface
*s
)
402 struct svga_texture
*tex
= svga_texture(s
->base
.texture
);
404 SVGA_STATS_TIME_PUSH(svga_sws(svga
),
405 SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW
);
408 struct pipe_surface
*backed_view
;
410 backed_view
= svga_create_surface_view(&svga
->pipe
,
417 s
->backed
= svga_surface(backed_view
);
421 * There is already an existing backing surface, but we still need to
424 struct svga_surface
*bs
= s
->backed
;
425 unsigned int layer
, zslice
;
429 switch (tex
->b
.b
.target
) {
430 case PIPE_TEXTURE_CUBE
:
431 case PIPE_TEXTURE_1D_ARRAY
:
432 case PIPE_TEXTURE_2D_ARRAY
:
433 layer
= s
->base
.u
.tex
.first_layer
;
438 zslice
= s
->base
.u
.tex
.first_layer
;
441 svga_texture_copy_handle_resource(svga
, tex
, bs
->handle
,
442 bs
->key
.numMipLevels
,
443 bs
->key
.numFaces
* bs
->key
.arraySize
,
444 zslice
, s
->base
.u
.tex
.level
, layer
);
447 svga_mark_surface_dirty(&s
->backed
->base
);
449 SVGA_STATS_TIME_POP(svga_sws(svga
));
455 * Create a DX RenderTarget/DepthStencil View for the given surface,
458 struct pipe_surface
*
459 svga_validate_surface_view(struct svga_context
*svga
, struct svga_surface
*s
)
461 enum pipe_error ret
= PIPE_OK
;
462 enum pipe_shader_type shader
;
464 assert(svga_have_vgpu10(svga
));
467 SVGA_STATS_TIME_PUSH(svga_sws(svga
),
468 SVGA_STATS_TIME_VALIDATESURFACEVIEW
);
471 * DX spec explicitly specifies that no resource can be bound to a render
472 * target view and a shader resource view simultanously.
473 * So first check if the resource bound to this surface view collides with
474 * a sampler view. If so, then we will clone this surface view and its
475 * associated resource. We will then use the cloned surface view for
478 for (shader
= PIPE_SHADER_VERTEX
; shader
<= PIPE_SHADER_GEOMETRY
; shader
++) {
479 if (svga_check_sampler_view_resource_collision(svga
, s
->handle
, shader
)) {
480 SVGA_DBG(DEBUG_VIEWS
,
481 "same resource used in shaderResource and renderTarget 0x%x\n",
483 s
= create_backed_surface_view(svga
, s
);
486 svga
->state
.hw_draw
.has_backed_views
= TRUE
;
488 /* s may be null here if the function failed */
493 if (s
&& s
->view_id
== SVGA3D_INVALID_ID
) {
494 SVGA3dResourceType resType
;
495 SVGA3dRenderTargetViewDesc desc
;
496 struct svga_texture
*stex
= svga_texture(s
->base
.texture
);
498 if (stex
->validated
== FALSE
) {
499 assert(stex
->handle
);
501 /* We are about to render into a surface that has not been validated.
502 * First invalidate the surface so that the device does not
503 * need to update the host-side copy with the invalid
504 * content when the associated mob is first bound to the surface.
506 ret
= SVGA3D_InvalidateGBSurface(svga
->swc
, stex
->handle
);
507 if (ret
!= PIPE_OK
) {
511 stex
->validated
= TRUE
;
514 desc
.tex
.mipSlice
= s
->real_level
;
515 desc
.tex
.firstArraySlice
= s
->real_layer
+ s
->real_zslice
;
517 s
->base
.u
.tex
.last_layer
- s
->base
.u
.tex
.first_layer
+ 1;
519 s
->view_id
= util_bitmask_add(svga
->surface_view_id_bm
);
521 resType
= svga_resource_type(s
->base
.texture
->target
);
523 if (util_format_is_depth_or_stencil(s
->base
.format
)) {
524 ret
= SVGA3D_vgpu10_DefineDepthStencilView(svga
->swc
,
532 SVGA3dSurfaceFormat view_format
= s
->key
.format
;
533 const struct svga_texture
*stex
= svga_texture(s
->base
.texture
);
535 /* Can't create RGBA render target view of a RGBX surface so adjust
536 * the view format. We do something similar for texture samplers in
537 * svga_validate_pipe_sampler_view().
539 if (view_format
== SVGA3D_B8G8R8A8_UNORM
&&
540 (stex
->key
.format
== SVGA3D_B8G8R8X8_UNORM
||
541 stex
->key
.format
== SVGA3D_B8G8R8X8_TYPELESS
)) {
542 view_format
= SVGA3D_B8G8R8X8_UNORM
;
545 ret
= SVGA3D_vgpu10_DefineRenderTargetView(svga
->swc
,
553 if (ret
!= PIPE_OK
) {
554 util_bitmask_clear(svga
->surface_view_id_bm
, s
->view_id
);
555 s
->view_id
= SVGA3D_INVALID_ID
;
561 SVGA_STATS_TIME_POP(svga_sws(svga
));
563 return s
? &s
->base
: NULL
;
569 svga_surface_destroy(struct pipe_context
*pipe
,
570 struct pipe_surface
*surf
)
572 struct svga_context
*svga
= svga_context(pipe
);
573 struct svga_surface
*s
= svga_surface(surf
);
574 struct svga_texture
*t
= svga_texture(surf
->texture
);
575 struct svga_screen
*ss
= svga_screen(surf
->texture
->screen
);
576 enum pipe_error ret
= PIPE_OK
;
578 SVGA_STATS_TIME_PUSH(ss
->sws
, SVGA_STATS_TIME_DESTROYSURFACE
);
580 /* Destroy the backed view surface if it exists */
582 svga_surface_destroy(pipe
, &s
->backed
->base
);
586 if (s
->handle
!= t
->handle
) {
587 SVGA_DBG(DEBUG_DMA
, "unref sid %p (tex surface)\n", s
->handle
);
588 svga_screen_surface_destroy(ss
, &s
->key
, &s
->handle
);
591 if (s
->view_id
!= SVGA3D_INVALID_ID
) {
594 /* The SVGA3D device will generate a device error if the
595 * render target view or depth stencil view is destroyed from
596 * a context other than the one it was created with.
597 * Similar to shader resource view, in this case, we will skip
598 * the destroy for now.
600 if (surf
->context
!= pipe
) {
601 _debug_printf("context mismatch in %s\n", __func__
);
604 assert(svga_have_vgpu10(svga
));
605 for (try = 0; try < 2; try++) {
606 if (util_format_is_depth_or_stencil(s
->base
.format
)) {
607 ret
= SVGA3D_vgpu10_DestroyDepthStencilView(svga
->swc
, s
->view_id
);
610 ret
= SVGA3D_vgpu10_DestroyRenderTargetView(svga
->swc
, s
->view_id
);
614 svga_context_flush(svga
, NULL
);
616 assert(ret
== PIPE_OK
);
617 util_bitmask_clear(svga
->surface_view_id_bm
, s
->view_id
);
621 pipe_resource_reference(&surf
->texture
, NULL
);
624 svga
->hud
.num_surface_views
--;
625 SVGA_STATS_TIME_POP(ss
->sws
);
630 svga_mark_surface_dirty(struct pipe_surface
*surf
)
632 struct svga_surface
*s
= svga_surface(surf
);
633 struct svga_texture
*tex
= svga_texture(surf
->texture
);
638 if (s
->handle
== tex
->handle
) {
639 /* hmm so 3d textures always have all their slices marked ? */
640 svga_define_texture_level(tex
, surf
->u
.tex
.first_layer
,
644 /* this will happen later in svga_propagate_surface */
648 /* Increment the view_age and texture age for this surface's mipmap
649 * level so that any sampler views into the texture are re-validated too.
651 svga_age_texture_view(tex
, surf
->u
.tex
.level
);
656 svga_mark_surfaces_dirty(struct svga_context
*svga
)
660 for (i
= 0; i
< svga
->curr
.framebuffer
.nr_cbufs
; i
++) {
661 if (svga
->curr
.framebuffer
.cbufs
[i
])
662 svga_mark_surface_dirty(svga
->curr
.framebuffer
.cbufs
[i
]);
664 if (svga
->curr
.framebuffer
.zsbuf
)
665 svga_mark_surface_dirty(svga
->curr
.framebuffer
.zsbuf
);
670 * Progagate any changes from surfaces to texture.
671 * pipe is optional context to inline the blit command in.
674 svga_propagate_surface(struct svga_context
*svga
, struct pipe_surface
*surf
,
677 struct svga_surface
*s
= svga_surface(surf
);
678 struct svga_texture
*tex
= svga_texture(surf
->texture
);
679 struct svga_screen
*ss
= svga_screen(surf
->texture
->screen
);
684 SVGA_STATS_TIME_PUSH(ss
->sws
, SVGA_STATS_TIME_PROPAGATESURFACE
);
686 /* Reset the dirty flag if specified. This is to ensure that
687 * the dirty flag will not be reset and stay unset when the backing
688 * surface is still being bound and rendered to.
689 * The reset flag will be set to TRUE when the surface is propagated
690 * and will be unbound.
694 ss
->texture_timestamp
++;
695 svga_age_texture_view(tex
, surf
->u
.tex
.level
);
697 if (s
->handle
!= tex
->handle
) {
698 unsigned zslice
, layer
;
699 unsigned nlayers
= 1;
702 if (surf
->texture
->target
== PIPE_TEXTURE_CUBE
) {
704 layer
= surf
->u
.tex
.first_layer
;
706 else if (surf
->texture
->target
== PIPE_TEXTURE_1D_ARRAY
||
707 surf
->texture
->target
== PIPE_TEXTURE_2D_ARRAY
) {
709 layer
= surf
->u
.tex
.first_layer
;
710 nlayers
= surf
->u
.tex
.last_layer
- surf
->u
.tex
.first_layer
+ 1;
713 zslice
= surf
->u
.tex
.first_layer
;
717 SVGA_DBG(DEBUG_VIEWS
,
718 "Propagate surface %p to resource %p, level %u\n",
719 surf
, tex
, surf
->u
.tex
.level
);
720 for (i
= 0; i
< nlayers
; i
++) {
721 svga_texture_copy_handle(svga
,
722 s
->handle
, 0, 0, 0, s
->real_level
,
724 tex
->handle
, 0, 0, zslice
, surf
->u
.tex
.level
,
726 u_minify(tex
->b
.b
.width0
, surf
->u
.tex
.level
),
727 u_minify(tex
->b
.b
.height0
, surf
->u
.tex
.level
),
729 svga_define_texture_level(tex
, layer
+ i
, surf
->u
.tex
.level
);
733 SVGA_STATS_TIME_POP(ss
->sws
);
738 * If any of the render targets are in backing texture views, propagate any
739 * changes to them back to the original texture.
742 svga_propagate_rendertargets(struct svga_context
*svga
)
746 /* Early exit if there is no backing texture views in use */
747 if (!svga
->state
.hw_draw
.has_backed_views
)
750 /* Note that we examine the svga->state.hw_draw.framebuffer surfaces,
751 * not the svga->curr.framebuffer surfaces, because it's the former
752 * surfaces which may be backing surface views (the actual render targets).
754 for (i
= 0; i
< svga
->state
.hw_draw
.num_rendertargets
; i
++) {
755 struct pipe_surface
*s
= svga
->state
.hw_draw
.rtv
[i
];
757 svga_propagate_surface(svga
, s
, FALSE
);
761 if (svga
->state
.hw_draw
.dsv
) {
762 svga_propagate_surface(svga
, svga
->state
.hw_draw
.dsv
, FALSE
);
768 * Check if we should call svga_propagate_surface on the surface.
771 svga_surface_needs_propagation(const struct pipe_surface
*surf
)
773 const struct svga_surface
*s
= svga_surface_const(surf
);
774 struct svga_texture
*tex
= svga_texture(surf
->texture
);
776 return s
->dirty
&& s
->handle
!= tex
->handle
;
781 svga_get_sample_position(struct pipe_context
*context
,
782 unsigned sample_count
, unsigned sample_index
,
785 /* We can't actually query the device to learn the sample positions.
786 * These were grabbed from nvidia's driver.
788 static const float pos1
[1][2] = {
791 static const float pos4
[4][2] = {
792 { 0.375000, 0.125000 },
793 { 0.875000, 0.375000 },
794 { 0.125000, 0.625000 },
795 { 0.625000, 0.875000 }
797 static const float pos8
[8][2] = {
798 { 0.562500, 0.312500 },
799 { 0.437500, 0.687500 },
800 { 0.812500, 0.562500 },
801 { 0.312500, 0.187500 },
802 { 0.187500, 0.812500 },
803 { 0.062500, 0.437500 },
804 { 0.687500, 0.937500 },
805 { 0.937500, 0.062500 }
807 static const float pos16
[16][2] = {
808 { 0.187500, 0.062500 },
809 { 0.437500, 0.187500 },
810 { 0.062500, 0.312500 },
811 { 0.312500, 0.437500 },
812 { 0.687500, 0.062500 },
813 { 0.937500, 0.187500 },
814 { 0.562500, 0.312500 },
815 { 0.812500, 0.437500 },
816 { 0.187500, 0.562500 },
817 { 0.437500, 0.687500 },
818 { 0.062500, 0.812500 },
819 { 0.312500, 0.937500 },
820 { 0.687500, 0.562500 },
821 { 0.937500, 0.687500 },
822 { 0.562500, 0.812500 },
823 { 0.812500, 0.937500 }
825 const float (*positions
)[2];
827 switch (sample_count
) {
841 pos_out
[0] = positions
[sample_index
][0];
842 pos_out
[1] = positions
[sample_index
][1];
847 svga_init_surface_functions(struct svga_context
*svga
)
849 svga
->pipe
.create_surface
= svga_create_surface
;
850 svga
->pipe
.surface_destroy
= svga_surface_destroy
;
851 svga
->pipe
.get_sample_position
= svga_get_sample_position
;