From 62402be407845da97a5a542d640b04ac212b3ad1 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Wed, 4 Oct 2017 10:56:30 -0600 Subject: [PATCH] svga: add support for cubemap array This patch adds support for cubemap array for SM4_1. Fixes piglit test arb_texture_cube_map_array-cubemap Reviewed-by: Neha Bhende Reviewed-by: Brian Paul --- src/gallium/drivers/svga/svga_pipe_blit.c | 6 ++-- .../drivers/svga/svga_resource_texture.c | 35 ++++++++++++++----- src/gallium/drivers/svga/svga_screen.c | 4 ++- src/gallium/drivers/svga/svga_surface.c | 6 +++- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c index 9ab51831492..bb213ac92e8 100644 --- a/src/gallium/drivers/svga/svga_pipe_blit.c +++ b/src/gallium/drivers/svga/svga_pipe_blit.c @@ -191,8 +191,9 @@ static bool has_layer_face_index_in_z(enum pipe_texture_target target) { if (target == PIPE_TEXTURE_CUBE || + target == PIPE_TEXTURE_1D_ARRAY || target == PIPE_TEXTURE_2D_ARRAY || - target == PIPE_TEXTURE_1D_ARRAY) + target == PIPE_TEXTURE_CUBE_ARRAY) return true; else return false; @@ -209,8 +210,9 @@ adjust_z_layer(enum pipe_texture_target target, int z_in, unsigned *layer_out, unsigned *z_out) { if (target == PIPE_TEXTURE_CUBE || + target == PIPE_TEXTURE_1D_ARRAY || target == PIPE_TEXTURE_2D_ARRAY || - target == PIPE_TEXTURE_1D_ARRAY) { + target == PIPE_TEXTURE_CUBE_ARRAY) { *layer_out = z_in; *z_out = 0; } diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 068862bb780..aaf62534945 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -262,18 +262,22 @@ static inline boolean was_tex_rendered_to(struct pipe_resource *resource, const struct pipe_transfer *transfer) { - unsigned face; + unsigned layer_face; - if (resource->target == PIPE_TEXTURE_CUBE) { + switch (resource->target) { + case PIPE_TEXTURE_CUBE: assert(transfer->box.depth == 1); - face = transfer->box.z; - } - else { - face = 0; + case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + case PIPE_TEXTURE_CUBE_ARRAY: + layer_face = transfer->box.z; + break; + default: + layer_face = 0; } return svga_was_texture_rendered_to(svga_texture(resource), - face, transfer->level); + layer_face, transfer->level); } @@ -505,7 +509,8 @@ svga_texture_transfer_map_direct(struct svga_context *svga, baseLevelSize.depth = tex->b.b.depth0; if ((tex->b.b.target == PIPE_TEXTURE_1D_ARRAY) || - (tex->b.b.target == PIPE_TEXTURE_2D_ARRAY)) { + (tex->b.b.target == PIPE_TEXTURE_2D_ARRAY) || + (tex->b.b.target == PIPE_TEXTURE_CUBE_ARRAY)) { st->base.layer_stride = svga3dsurface_get_image_offset(tex->key.format, baseLevelSize, tex->b.b.last_level + 1, 1, 0); @@ -526,6 +531,7 @@ svga_texture_transfer_map_direct(struct svga_context *svga, st->base.box.x, st->base.box.y, st->base.box.z); + return (void *) (map + offset); } } @@ -578,8 +584,9 @@ svga_texture_transfer_map(struct pipe_context *pipe, st->slice = st->base.box.z; st->base.box.z = 0; /* so we don't apply double offsets below */ break; - case PIPE_TEXTURE_2D_ARRAY: case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + case PIPE_TEXTURE_CUBE_ARRAY: st->slice = st->base.box.z; st->base.box.z = 0; /* so we don't apply double offsets below */ @@ -727,6 +734,7 @@ update_image_vgpu10(struct svga_context *svga, unsigned subResource; subResource = slice * numMipLevels + level; + ret = SVGA3D_vgpu10_UpdateSubResource(svga->swc, surf, box, subResource); if (ret != PIPE_OK) { svga_context_flush(svga, NULL); @@ -801,6 +809,7 @@ svga_texture_transfer_unmap_direct(struct svga_context *svga, box.z = 0; break; case PIPE_TEXTURE_2D_ARRAY: + case PIPE_TEXTURE_CUBE_ARRAY: nlayers = box.d; box.z = 0; box.d = 1; @@ -823,6 +832,7 @@ svga_texture_transfer_unmap_direct(struct svga_context *svga, if (svga_have_vgpu10(svga)) { unsigned i; + for (i = 0; i < nlayers; i++) { ret = update_image_vgpu10(svga, surf, &box, st->slice + i, transfer->level, @@ -1014,6 +1024,12 @@ svga_texture_create(struct pipe_screen *screen, tex->key.flags |= (SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_ARRAY); tex->key.numFaces = 6; break; + case PIPE_TEXTURE_CUBE_ARRAY: + assert(svgascreen->sws->have_sm4_1); + tex->key.flags |= (SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_ARRAY); + tex->key.numFaces = 1; // arraySize already includes the 6 faces + tex->key.arraySize = template->array_size; + break; default: break; } @@ -1408,6 +1424,7 @@ svga_texture_transfer_map_upload(struct svga_context *svga, st->upload.box.z = 0; break; case PIPE_TEXTURE_2D_ARRAY: + case PIPE_TEXTURE_CUBE_ARRAY: st->upload.nlayers = st->base.box.depth; st->upload.box.z = 0; st->upload.box.d = 1; diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index be653bd4fe2..23b165c37e9 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -343,6 +343,9 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: return 1; + case PIPE_CAP_CUBE_MAP_ARRAY: + return sws->have_sm4_1; + /* Unsupported features */ case PIPE_CAP_TEXTURE_MIRROR_CLAMP: case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: @@ -354,7 +357,6 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: case PIPE_CAP_COMPUTE: case PIPE_CAP_START_INSTANCE: - case PIPE_CAP_CUBE_MAP_ARRAY: case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: case PIPE_CAP_QUERY_PIPELINE_STATISTICS: case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index cb74a00c1e0..6237999b75f 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -276,7 +276,8 @@ svga_create_surface_view(struct pipe_context *pipe, zslice = 0; } else if (pt->target == PIPE_TEXTURE_1D_ARRAY || - pt->target == PIPE_TEXTURE_2D_ARRAY) { + pt->target == PIPE_TEXTURE_2D_ARRAY || + pt->target == PIPE_TEXTURE_CUBE_ARRAY) { layer = surf_tmpl->u.tex.first_layer; zslice = 0; nlayers = surf_tmpl->u.tex.last_layer - surf_tmpl->u.tex.first_layer + 1; @@ -347,6 +348,9 @@ svga_create_surface_view(struct pipe_context *pipe, if (nlayers == 6) flags |= SVGA3D_SURFACE_CUBEMAP; break; + case PIPE_TEXTURE_CUBE_ARRAY: + flags |= SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_ARRAY; + break; default: break; } -- 2.30.2