uint32_t i, j;
unsigned z_offset = 0;
- SVGA_DBG(DEBUG_PERF,
+ SVGA_DBG(DEBUG_PERF,
"svga: Create surface view: layer %d zslice %d mips %d..%d\n",
layer_pick, zslice_pick, start_mip, start_mip+num_mip-1);
if (key->sampleCount > 1) {
key->flags |= SVGA3D_SURFACE_MASKABLE_ANTIALIAS;
}
-
+
if (tex->b.b.target == PIPE_TEXTURE_CUBE && layer_pick < 0) {
key->flags |= SVGA3D_SURFACE_CUBEMAP;
key->numFaces = 6;
1);
svga_texture_copy_handle(svga,
- tex->handle,
- 0, 0, z_offset,
- i + start_mip,
+ 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),
unsigned nlayers = 1;
SVGA3dSurfaceFlags flags = 0;
SVGA3dSurfaceFormat format;
+ struct pipe_surface *retVal = NULL;
s = CALLOC_STRUCT(svga_surface);
if (!s)
return NULL;
+ SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_CREATESURFACEVIEW);
+
if (pt->target == PIPE_TEXTURE_CUBE) {
layer = surf_tmpl->u.tex.first_layer;
zslice = 0;
/* When we clone the surface view resource, use the format used in
* the creation of the original resource.
*/
- s->handle = svga_texture_view_surface(svga, tex, bind, flags, tex->key.format,
+ s->handle = svga_texture_view_surface(svga, tex, bind, flags,
+ tex->key.format,
surf_tmpl->u.tex.level, 1,
layer, nlayers, zslice, &s->key);
+ if (!s->handle) {
+ FREE(s);
+ goto done;
+ }
+
s->key.format = format;
s->real_layer = 0;
s->real_level = 0;
s->real_zslice = 0;
} else {
- SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, layer %u, z %u, %p\n",
+ SVGA_DBG(DEBUG_VIEWS,
+ "svga: Surface view: no %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);
s->real_level = surf_tmpl->u.tex.level;
}
- return &s->base;
+ svga->hud.num_surface_views++;
+ retVal = &s->base;
+
+done:
+ SVGA_STATS_TIME_POP(ss->sws);
+ return retVal;
}
{
struct svga_context *svga = svga_context(pipe);
struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *surf = NULL;
boolean view = FALSE;
+ SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_CREATESURFACE);
+
if (svga_screen(screen)->debug.force_surface_view)
view = TRUE;
if (svga_have_vgpu10(svga) || svga_screen(screen)->debug.no_surface_view)
view = FALSE;
- return svga_create_surface_view(pipe, pt, surf_tmpl, view);
+ surf = svga_create_surface_view(pipe, pt, surf_tmpl, view);
+
+ SVGA_STATS_TIME_POP(svga_sws(svga));
+
+ return surf;
}
{
struct svga_surface *bs = s->backed;
- if (bs == NULL) {
+ SVGA_STATS_TIME_PUSH(svga_sws(svga),
+ SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW);
+
+ if (!bs) {
struct svga_texture *tex = svga_texture(s->base.texture);
struct pipe_surface *backed_view;
&tex->b.b,
&s->base,
TRUE);
+ if (!backed_view)
+ return NULL;
bs = svga_surface(backed_view);
s->backed = bs;
svga_mark_surface_dirty(&bs->base);
+ SVGA_STATS_TIME_POP(svga_sws(svga));
+
return bs;
}
svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
{
enum pipe_error ret = PIPE_OK;
- int try;
unsigned shader;
+ struct pipe_surface *surf = NULL;
assert(svga_have_vgpu10(svga));
+ SVGA_STATS_TIME_PUSH(svga_sws(svga),
+ SVGA_STATS_TIME_VALIDATESURFACEVIEW);
+
/**
* DX spec explicitly specifies that no resource can be bound to a render
* target view and a shader resource view simultanously.
"same resource used in shaderResource and renderTarget 0x%x\n",
s->handle);
s = create_backed_surface_view(svga, s);
+ if (!s)
+ goto done;
+
break;
}
}
resType = SVGA3D_RESOURCE_TEXTURE2D;
}
- for (try = 0; try < 2; try++) {
- if (util_format_is_depth_or_stencil(s->base.format)) {
- ret = SVGA3D_vgpu10_DefineDepthStencilView(svga->swc,
- s->view_id,
- s->handle,
- s->key.format,
- resType,
- &desc);
- }
- else {
- ret = SVGA3D_vgpu10_DefineRenderTargetView(svga->swc,
- s->view_id,
- s->handle,
- s->key.format,
- resType,
- &desc);
+ if (util_format_is_depth_or_stencil(s->base.format)) {
+ ret = SVGA3D_vgpu10_DefineDepthStencilView(svga->swc,
+ s->view_id,
+ s->handle,
+ s->key.format,
+ resType,
+ &desc);
+ }
+ else {
+ SVGA3dSurfaceFormat view_format = s->key.format;
+ const struct svga_texture *stex = svga_texture(s->base.texture);
+
+ /* Can't create RGBA render target view of a RGBX surface so adjust
+ * the view format. We do something similar for texture samplers in
+ * svga_validate_pipe_sampler_view().
+ */
+ if (view_format == SVGA3D_B8G8R8A8_UNORM &&
+ stex->key.format == SVGA3D_B8G8R8X8_TYPELESS) {
+ view_format = SVGA3D_B8G8R8X8_UNORM;
}
- if (ret == PIPE_OK)
- break;
- svga_context_flush(svga, NULL);
+
+ ret = SVGA3D_vgpu10_DefineRenderTargetView(svga->swc,
+ s->view_id,
+ s->handle,
+ view_format,
+ resType,
+ &desc);
}
- assert(ret == PIPE_OK);
if (ret != PIPE_OK) {
util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
s->view_id = SVGA3D_INVALID_ID;
+ goto done;
}
}
- return &s->base;
+ surf = &s->base;
+
+done:
+ SVGA_STATS_TIME_POP(svga_sws(svga));
+
+ return surf;
}
struct svga_screen *ss = svga_screen(surf->texture->screen);
enum pipe_error ret = PIPE_OK;
+ SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_DESTROYSURFACE);
+
/* Destroy the backed view surface if it exists */
if (s->backed) {
svga_surface_destroy(pipe, &s->backed->base);
pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
+
+ svga->hud.num_surface_views--;
+ SVGA_STATS_TIME_POP(ss->sws);
}
-static void
+static void
svga_mark_surface_dirty(struct pipe_surface *surf)
{
struct svga_surface *s = svga_surface(surf);
void
svga_mark_surfaces_dirty(struct svga_context *svga)
{
- struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
unsigned i;
- for (i = 0; i < svgascreen->max_color_buffers; i++) {
+ for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) {
if (svga->curr.framebuffer.cbufs[i])
svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]);
}
if (!s->dirty)
return;
+ SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_PROPAGATESURFACE);
+
if (surf->texture->target == PIPE_TEXTURE_CUBE) {
zslice = 0;
layer = surf->u.tex.first_layer;
tex, surf->u.tex.level, surf);
for (i = 0; i < nlayers; i++) {
svga_texture_copy_handle(svga,
- s->handle, 0, 0, 0, s->real_level, s->real_layer + i,
- tex->handle, 0, 0, zslice, surf->u.tex.level, layer + i,
+ s->handle, 0, 0, 0, s->real_level,
+ s->real_layer + i,
+ tex->handle, 0, 0, zslice, surf->u.tex.level,
+ layer + i,
u_minify(tex->b.b.width0, surf->u.tex.level),
- u_minify(tex->b.b.height0, surf->u.tex.level), 1);
+ u_minify(tex->b.b.height0, surf->u.tex.level),
+ 1);
svga_define_texture_level(tex, layer + i, surf->u.tex.level);
}
}
+
+ SVGA_STATS_TIME_POP(ss->sws);
}