#include "util/u_inlines.h"
#include "os/os_thread.h"
#include "util/u_bitmask.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
static void svga_mark_surface_dirty(struct pipe_surface *surf);
+void
+svga_texture_copy_region(struct svga_context *svga,
+ struct svga_winsys_surface *src_handle,
+ unsigned srcSubResource,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ struct svga_winsys_surface *dst_handle,
+ unsigned dstSubResource,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned width, unsigned height, unsigned depth)
+{
+ SVGA3dCopyBox box;
+
+ assert(svga_have_vgpu10(svga));
+
+ box.x = dst_x;
+ box.y = dst_y;
+ box.z = dst_z;
+ box.w = width;
+ box.h = height;
+ box.d = depth;
+ box.srcx = src_x;
+ box.srcy = src_y;
+ box.srcz = src_z;
+
+ SVGA_RETRY(svga, SVGA3D_vgpu10_PredCopyRegion
+ (svga->swc, dst_handle, dstSubResource,
+ src_handle, srcSubResource, &box));
+}
+
+
void
svga_texture_copy_handle(struct svga_context *svga,
struct svga_winsys_surface *src_handle,
unsigned width, unsigned height, unsigned depth)
{
struct svga_surface dst, src;
- enum pipe_error ret;
SVGA3dCopyBox box, *boxes;
assert(svga);
dst_handle, dst_level, dst_x, dst_y, dst_z);
*/
- ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- if (ret != PIPE_OK) {
- svga_context_flush(svga, NULL);
- ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- assert(ret == PIPE_OK);
- }
+ SVGA_RETRY(svga, SVGA3D_BeginSurfaceCopy(svga->swc,
+ &src.base,
+ &dst.base,
+ &boxes, 1));
+
*boxes = box;
SVGA_FIFOCommitAll(svga->swc);
}
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);
+ if (src_tex->b.b.nr_samples > 1) {
+ unsigned subResource = j * numMipLevels + i;
+ svga_texture_copy_region(svga, src_tex->handle,
+ subResource, 0, 0, zoffset,
+ dst, subResource, 0, 0, 0,
+ src_tex->b.b.width0, src_tex->b.b.height0, depth);
+ }
+ else {
+ 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);
+ }
}
}
}
flags |= SVGA3D_SURFACE_CUBEMAP;
break;
case PIPE_TEXTURE_CUBE_ARRAY:
- flags |= SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_ARRAY;
+ if (nlayers % 6 == 0)
+ flags |= SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_ARRAY;
break;
default:
break;
switch (tex->b.b.target) {
case PIPE_TEXTURE_CUBE:
+ case PIPE_TEXTURE_CUBE_ARRAY:
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
layer = s->base.u.tex.first_layer;
* associated resource. We will then use the cloned surface view for
* render target.
*/
- for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) {
+ for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_TESS_EVAL; shader++) {
if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
SVGA_DBG(DEBUG_VIEWS,
"same resource used in shaderResource and renderTarget 0x%x\n",
}
}
+ /**
+ * Create an alternate surface view for the specified context if the
+ * view was created for another context.
+ */
+ if (s && s->base.context != &svga->pipe) {
+ struct pipe_surface *surf;
+ surf = svga_create_surface_view(&svga->pipe, s->base.texture, &s->base, FALSE);
+ s = svga_surface(surf);
+ }
+
if (s && s->view_id == SVGA3D_INVALID_ID) {
SVGA3dResourceType resType;
SVGA3dRenderTargetViewDesc desc;
* need to update the host-side copy with the invalid
* content when the associated mob is first bound to the surface.
*/
- if (svga->swc->surface_invalidate(svga->swc, stex->handle) != PIPE_OK) {
- svga_context_flush(svga, NULL);
- ret = svga->swc->surface_invalidate(svga->swc, stex->handle);
- assert(ret == PIPE_OK);
- }
+ SVGA_RETRY(svga, SVGA3D_InvalidateGBSurface(svga->swc, stex->handle));
stex->validated = TRUE;
}
struct svga_surface *s = svga_surface(surf);
struct svga_texture *t = svga_texture(surf->texture);
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);
}
if (s->view_id != SVGA3D_INVALID_ID) {
- unsigned try;
-
/* The SVGA3D device will generate a device error if the
* render target view or depth stencil view is destroyed from
* a context other than the one it was created with.
}
else {
assert(svga_have_vgpu10(svga));
- for (try = 0; try < 2; try++) {
- if (util_format_is_depth_or_stencil(s->base.format)) {
- ret = SVGA3D_vgpu10_DestroyDepthStencilView(svga->swc, s->view_id);
- }
- else {
- ret = SVGA3D_vgpu10_DestroyRenderTargetView(svga->swc, s->view_id);
- }
- if (ret == PIPE_OK)
- break;
- svga_context_flush(svga, NULL);
+ if (util_format_is_depth_or_stencil(s->base.format)) {
+ SVGA_RETRY(svga, SVGA3D_vgpu10_DestroyDepthStencilView(svga->swc,
+ s->view_id));
+ }
+ else {
+ SVGA_RETRY(svga, SVGA3D_vgpu10_DestroyRenderTargetView(svga->swc,
+ s->view_id));
}
- assert(ret == PIPE_OK);
util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
}
}
unsigned zslice, layer;
unsigned nlayers = 1;
unsigned i;
+ unsigned numMipLevels = tex->b.b.last_level + 1;
+ unsigned srcLevel = s->real_level;
+ unsigned dstLevel = surf->u.tex.level;
+ unsigned width = u_minify(tex->b.b.width0, dstLevel);
+ unsigned height = u_minify(tex->b.b.height0, dstLevel);
if (surf->texture->target == PIPE_TEXTURE_CUBE) {
zslice = 0;
layer = surf->u.tex.first_layer;
}
else if (surf->texture->target == PIPE_TEXTURE_1D_ARRAY ||
- surf->texture->target == PIPE_TEXTURE_2D_ARRAY) {
+ surf->texture->target == PIPE_TEXTURE_2D_ARRAY ||
+ surf->texture->target == PIPE_TEXTURE_CUBE_ARRAY) {
zslice = 0;
layer = surf->u.tex.first_layer;
nlayers = surf->u.tex.last_layer - surf->u.tex.first_layer + 1;
SVGA_DBG(DEBUG_VIEWS,
"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,
- 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);
- svga_define_texture_level(tex, layer + i, surf->u.tex.level);
+
+ if (svga_have_vgpu10(svga)) {
+ unsigned srcSubResource, dstSubResource;
+
+ for (i = 0; i < nlayers; i++) {
+ srcSubResource = (s->real_layer + i) * numMipLevels + srcLevel;
+ dstSubResource = (layer + i) * numMipLevels + dstLevel;
+
+ svga_texture_copy_region(svga,
+ s->handle, srcSubResource, 0, 0, 0,
+ tex->handle, dstSubResource, 0, 0, zslice,
+ width, height, 1);
+ svga_define_texture_level(tex, layer + i, dstLevel);
+ }
+ }
+ else {
+ for (i = 0; i < nlayers; i++) {
+ svga_texture_copy_handle(svga,
+ s->handle, 0, 0, 0, srcLevel,
+ s->real_layer + i,
+ tex->handle, 0, 0, zslice, dstLevel,
+ layer + i,
+ width, height, 1);
+
+ svga_define_texture_level(tex, layer + i, dstLevel);
+ }
}
/* Sync the surface view age with the texture age */
static const float pos1[1][2] = {
{ 0.5, 0.5 }
};
+ static const float pos2[2][2] = {
+ { 0.75, 0.75 },
+ { 0.25, 0.25 }
+ };
static const float pos4[4][2] = {
{ 0.375000, 0.125000 },
{ 0.875000, 0.375000 },
const float (*positions)[2];
switch (sample_count) {
+ case 2:
+ positions = pos2;
+ break;
case 4:
positions = pos4;
break;