}
+/* A helper function to sync up the two surface handles.
+ */
+static void
+svga_texture_copy_handle_resource(struct svga_context *svga,
+ struct svga_texture *src_tex,
+ struct svga_winsys_surface *dst,
+ unsigned int numMipLevels,
+ unsigned int numLayers,
+ int zslice_pick,
+ unsigned int mipoffset,
+ unsigned int layeroffset)
+{
+ unsigned int i, j;
+ unsigned int zoffset = 0;
+
+ /* A negative zslice_pick implies zoffset at 0, and depth to copy is
+ * from the depth of the texture at the particular mipmap level.
+ */
+ if (zslice_pick >= 0)
+ zoffset = zslice_pick;
+
+ for (i = 0; i < numMipLevels; i++) {
+ unsigned int miplevel = i + mipoffset;
+
+ for (j = 0; j < numLayers; j++) {
+ if (svga_is_texture_level_defined(src_tex, j+layeroffset, miplevel)) {
+ unsigned depth = (zslice_pick < 0 ?
+ u_minify(src_tex->b.b.depth0, miplevel) : 1);
+
+ svga_texture_copy_handle(svga,
+ src_tex->handle,
+ 0, 0, zoffset,
+ miplevel,
+ j + layeroffset,
+ dst, 0, 0, 0, i, j,
+ u_minify(src_tex->b.b.width0, miplevel),
+ u_minify(src_tex->b.b.height0, miplevel),
+ depth);
+ }
+ }
+ }
+}
+
+
struct svga_winsys_surface *
svga_texture_view_surface(struct svga_context *svga,
struct svga_texture *tex,
{
struct svga_screen *ss = svga_screen(svga->pipe.screen);
struct svga_winsys_surface *handle;
- uint32_t i, j;
- unsigned z_offset = 0;
boolean validated;
SVGA_DBG(DEBUG_PERF,
if (layer_pick < 0)
layer_pick = 0;
- if (zslice_pick >= 0)
- z_offset = zslice_pick;
-
- for (i = 0; i < key->numMipLevels; i++) {
- for (j = 0; j < key->numFaces * key->arraySize; j++) {
- if (svga_is_texture_level_defined(tex, j + layer_pick, i + start_mip)) {
- unsigned depth = (zslice_pick < 0 ?
- u_minify(tex->b.b.depth0, i + start_mip) :
- 1);
-
- svga_texture_copy_handle(svga,
- tex->handle,
- 0, 0, z_offset,
- i + start_mip,
- j + layer_pick,
- handle, 0, 0, 0, i, j,
- u_minify(tex->b.b.width0, i + start_mip),
- u_minify(tex->b.b.height0, i + start_mip),
- depth);
- }
- }
- }
+ svga_texture_copy_handle_resource(svga, tex, handle,
+ key->numMipLevels,
+ key->numFaces * key->arraySize,
+ zslice_pick, start_mip, layer_pick);
return handle;
}
assert(format != SVGA3D_FORMAT_INVALID);
if (view) {
- SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u layer %u z %u, %p\n",
+ SVGA_DBG(DEBUG_VIEWS,
+ "New backed surface view: resource %p, level %u layer %u z %u, %p\n",
pt, surf_tmpl->u.tex.level, layer, zslice, s);
if (svga_have_vgpu10(svga)) {
s->real_zslice = 0;
} else {
SVGA_DBG(DEBUG_VIEWS,
- "svga: Surface view: no %p, level %u, layer %u, z %u, %p\n",
+ "New surface view: resource %p, level %u, layer %u, z %u, %p\n",
pt, surf_tmpl->u.tex.level, layer, zslice, s);
memset(&s->key, 0, sizeof s->key);
static struct svga_surface *
create_backed_surface_view(struct svga_context *svga, struct svga_surface *s)
{
+ struct svga_texture *tex = svga_texture(s->base.texture);
+
SVGA_STATS_TIME_PUSH(svga_sws(svga),
SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW);
if (!s->backed) {
- struct svga_texture *tex = svga_texture(s->base.texture);
struct pipe_surface *backed_view;
backed_view = svga_create_surface_view(&svga->pipe,
s->backed = svga_surface(backed_view);
}
+ else {
+ /*
+ * There is already an existing backing surface, but we still need to
+ * sync the handles.
+ */
+ struct svga_surface *bs = s->backed;
+ unsigned int layer, zslice;
+
+ assert(bs->handle);
+
+ switch (tex->b.b.target) {
+ case PIPE_TEXTURE_CUBE:
+ case PIPE_TEXTURE_1D_ARRAY:
+ case PIPE_TEXTURE_2D_ARRAY:
+ layer = s->base.u.tex.first_layer;
+ zslice = 0;
+ break;
+ default:
+ layer = 0;
+ zslice = s->base.u.tex.first_layer;
+ }
+
+ svga_texture_copy_handle_resource(svga, tex, bs->handle,
+ bs->key.numMipLevels,
+ bs->key.numFaces * bs->key.arraySize,
+ zslice, s->base.u.tex.level, layer);
+ }
svga_mark_surface_dirty(&s->backed->base);
* pipe is optional context to inline the blit command in.
*/
void
-svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf)
+svga_propagate_surface(struct svga_context *svga, struct pipe_surface *surf,
+ boolean reset)
{
struct svga_surface *s = svga_surface(surf);
struct svga_texture *tex = svga_texture(surf->texture);
SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_PROPAGATESURFACE);
- s->dirty = FALSE;
+ /* Reset the dirty flag if specified. This is to ensure that
+ * the dirty flag will not be reset and stay unset when the backing
+ * surface is still being bound and rendered to.
+ * The reset flag will be set to TRUE when the surface is propagated
+ * and will be unbound.
+ */
+ s->dirty = !reset;
+
ss->texture_timestamp++;
svga_age_texture_view(tex, surf->u.tex.level);
}
SVGA_DBG(DEBUG_VIEWS,
- "svga: Surface propagate: tex %p, level %u, from %p\n",
- tex, surf->u.tex.level, surf);
+ "Propagate surface %p to resource %p, level %u\n",
+ surf, tex, surf->u.tex.level);
for (i = 0; i < nlayers; i++) {
svga_texture_copy_handle(svga,
s->handle, 0, 0, 0, s->real_level,
* not the svga->curr.framebuffer surfaces, because it's the former
* surfaces which may be backing surface views (the actual render targets).
*/
- for (i = 0; i < svga->state.hw_draw.num_rendertargets; i++) {
- struct pipe_surface *s = svga->state.hw_draw.rtv[i];
+ for (i = 0; i < svga->state.hw_clear.num_rendertargets; i++) {
+ struct pipe_surface *s = svga->state.hw_clear.rtv[i];
if (s) {
- svga_propagate_surface(svga, s);
+ svga_propagate_surface(svga, s, FALSE);
}
}
- if (svga->state.hw_draw.dsv) {
- svga_propagate_surface(svga, svga->state.hw_draw.dsv);
+ if (svga->state.hw_clear.dsv) {
+ svga_propagate_surface(svga, svga->state.hw_clear.dsv, FALSE);
}
}