diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_array.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_flush.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_flush.h | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_queryobj.c | 85 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_queryobj.h | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_syncobj.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 256 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_manager.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.h | 8 |
12 files changed, 289 insertions, 118 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_array.c b/mesalib/src/mesa/state_tracker/st_atom_array.c index 15f5d1c95..2437245bd 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_array.c +++ b/mesalib/src/mesa/state_tracker/st_atom_array.c @@ -403,9 +403,9 @@ setup_interleaved_attribs(const struct st_vertex_program *vp, const GLuint mesaAttr = vp->index_to_input[attr]; const struct gl_client_array *array = arrays[mesaAttr]; unsigned src_offset = (unsigned) (array->Ptr - low_addr); - GLuint element_size = array->_ElementSize; - assert(element_size == array->Size * _mesa_sizeof_type(array->Type)); + assert(array->_ElementSize == + _mesa_bytes_per_vertex_attrib(array->Size, array->Type)); velements[attr].src_offset = src_offset; velements[attr].instance_divisor = array->InstanceDivisor; @@ -474,7 +474,8 @@ setup_non_interleaved_attribs(struct st_context *st, struct gl_buffer_object *bufobj = array->BufferObj; GLsizei stride = array->StrideB; - assert(array->_ElementSize == array->Size * _mesa_sizeof_type(array->Type)); + assert(array->_ElementSize == + _mesa_bytes_per_vertex_attrib(array->Size, array->Type)); if (_mesa_is_bufferobj(bufobj)) { /* Attribute data is in a VBO. diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c index 7c9f91f1b..b569e3b3c 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.c +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c @@ -76,15 +76,16 @@ display_front_buffer(struct st_context *st) } -void st_flush( struct st_context *st, - struct pipe_fence_handle **fence ) +void st_flush(struct st_context *st, + struct pipe_fence_handle **fence, + enum pipe_flush_flags flags) { FLUSH_VERTICES(st->ctx, 0); FLUSH_CURRENT(st->ctx, 0); st_flush_bitmap_cache(st); - st->pipe->flush( st->pipe, fence ); + st->pipe->flush(st->pipe, fence, flags); } @@ -95,7 +96,7 @@ void st_finish( struct st_context *st ) { struct pipe_fence_handle *fence = NULL; - st_flush(st, &fence); + st_flush(st, &fence, 0); if(fence) { st->pipe->screen->fence_finish(st->pipe->screen, fence, @@ -118,7 +119,7 @@ static void st_glFlush(struct gl_context *ctx) * synchronization issues. Calling finish() here will just hide * problems that need to be fixed elsewhere. */ - st_flush(st, NULL); + st_flush(st, NULL, 0); if (is_front_buffer_dirty(st)) { display_front_buffer(st); diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.h b/mesalib/src/mesa/state_tracker/st_cb_flush.h index 598536ba0..003e2a2a9 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.h +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.h @@ -41,7 +41,8 @@ st_init_flush_functions(struct dd_function_table *functions); extern void st_flush(struct st_context *st, - struct pipe_fence_handle **fence); + struct pipe_fence_handle **fence, + enum pipe_flush_flags flags); extern void st_finish(struct st_context *st); diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c index b10fd9335..98b61f576 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c @@ -72,6 +72,11 @@ st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q) stq->pq = NULL; } + if (stq->pq_begin) { + pipe->destroy_query(pipe, stq->pq_begin); + stq->pq_begin = NULL; + } + free(stq); } @@ -79,7 +84,8 @@ st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q) static void st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct st_query_object *stq = st_query_object(q); unsigned type; @@ -98,29 +104,46 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q) case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: type = PIPE_QUERY_PRIMITIVES_EMITTED; break; - case GL_TIME_ELAPSED_EXT: - type = PIPE_QUERY_TIME_ELAPSED; + case GL_TIME_ELAPSED: + if (st->has_time_elapsed) + type = PIPE_QUERY_TIME_ELAPSED; + else + type = PIPE_QUERY_TIMESTAMP; break; default: assert(0 && "unexpected query target in st_BeginQuery()"); return; } - if (stq->pq && stq->type != type) { + if (stq->type != type) { /* free old query of different type */ - pipe->destroy_query(pipe, stq->pq); - stq->pq = NULL; + if (stq->pq) { + pipe->destroy_query(pipe, stq->pq); + stq->pq = NULL; + } + if (stq->pq_begin) { + pipe->destroy_query(pipe, stq->pq_begin); + stq->pq_begin = NULL; + } stq->type = PIPE_QUERY_TYPES; /* an invalid value */ } - if (!stq->pq) { - stq->pq = pipe->create_query(pipe, type); - stq->type = type; + if (q->Target == GL_TIME_ELAPSED && + type == PIPE_QUERY_TIMESTAMP) { + /* Determine time elapsed by emitting two timestamp queries. */ + if (!stq->pq_begin) { + stq->pq_begin = pipe->create_query(pipe, type); + stq->type = type; + } + pipe->end_query(pipe, stq->pq_begin); + } else { + if (!stq->pq) { + stq->pq = pipe->create_query(pipe, type); + stq->type = type; + } + pipe->begin_query(pipe, stq->pq); } - assert(stq->type == type); - - pipe->begin_query(pipe, stq->pq); } @@ -132,7 +155,9 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q) st_flush_bitmap_cache(st_context(ctx)); - if (q->Target == GL_TIMESTAMP && !stq->pq) { + if ((q->Target == GL_TIMESTAMP || + q->Target == GL_TIME_ELAPSED) && + !stq->pq) { stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP); stq->type = PIPE_QUERY_TIMESTAMP; } @@ -141,6 +166,33 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q) } +static boolean +get_query_result(struct pipe_context *pipe, + struct st_query_object *stq, + boolean wait) +{ + if (!pipe->get_query_result(pipe, + stq->pq, + wait, + (void *)&stq->base.Result)) { + return FALSE; + } + + if (stq->base.Target == GL_TIME_ELAPSED && + stq->type == PIPE_QUERY_TIMESTAMP) { + /* Calculate the elapsed time from the two timestamp queries */ + GLuint64EXT Result0 = 0; + assert(stq->pq_begin); + pipe->get_query_result(pipe, stq->pq_begin, TRUE, (void *)&Result0); + stq->base.Result -= Result0; + } else { + assert(!stq->pq_begin); + } + + return TRUE; +} + + static void st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q) { @@ -151,10 +203,7 @@ st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q) assert(!stq->base.Ready); while (!stq->base.Ready && - !pipe->get_query_result(pipe, - stq->pq, - TRUE, - (void*)&q->Result)) + !get_query_result(pipe, stq, TRUE)) { /* nothing */ } @@ -169,7 +218,7 @@ st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q) struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); assert(!q->Ready); /* we should not get called if Ready is TRUE */ - q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, (void*)&q->Result); + q->Ready = get_query_result(pipe, stq, FALSE); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h index 03487b153..d5b107532 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h @@ -39,6 +39,10 @@ struct st_query_object { struct gl_query_object base; struct pipe_query *pq; + + /* Begin TIMESTAMP query for GL_TIME_ELAPSED_EXT queries */ + struct pipe_query *pq_begin; + unsigned type; /**< PIPE_QUERY_x */ }; diff --git a/mesalib/src/mesa/state_tracker/st_cb_syncobj.c b/mesalib/src/mesa/state_tracker/st_cb_syncobj.c index f9f2348a3..94bf4861d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_syncobj.c +++ b/mesalib/src/mesa/state_tracker/st_cb_syncobj.c @@ -72,7 +72,7 @@ static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj, assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0); assert(so->fence == NULL); - pipe->flush(pipe, &so->fence); + pipe->flush(pipe, &so->fence, 0); } static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj) diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index bf13526d2..02fc675ae 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -201,7 +201,7 @@ st_MapTextureImage(struct gl_context *ctx, if (mode & GL_MAP_INVALIDATE_RANGE_BIT) pipeMode |= PIPE_TRANSFER_DISCARD_RANGE; - map = st_texture_image_map(st, stImage, slice, pipeMode, x, y, w, h); + map = st_texture_image_map(st, stImage, pipeMode, x, y, slice, w, h, 1); if (map) { *mapOut = map; *rowStrideOut = stImage->transfer->stride; @@ -572,37 +572,68 @@ decompress_with_blit(struct gl_context * ctx, { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct st_texture_image *stImage = st_texture_image(texImage); - struct st_texture_object *stObj = st_texture_object(texImage->TexObject); + struct pipe_screen *screen = pipe->screen; const GLuint width = texImage->Width; const GLuint height = texImage->Height; - struct pipe_resource *dst_texture; + const GLuint depth = texImage->Depth; + struct pipe_resource *src = st_texture_object(texImage->TexObject)->pt; + struct pipe_resource *dst; + struct pipe_resource dst_templ; + enum pipe_format pipe_format; + gl_format mesa_format; + GLenum gl_target = texImage->TexObject->Target; + enum pipe_texture_target pipe_target; struct pipe_blit_info blit; unsigned bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_READ); struct pipe_transfer *tex_xfer; ubyte *map; - /* create temp / dest surface */ - if (!util_create_rgba_texture(pipe, width, height, bind, - &dst_texture)) { - _mesa_problem(ctx, "util_create_rgba_texture() failed " - "in decompress_with_blit()"); + /* GetTexImage only returns a single face for cubemaps. */ + if (gl_target == GL_TEXTURE_CUBE_MAP) { + gl_target = GL_TEXTURE_2D; + } + + pipe_target = gl_target_to_pipe(gl_target); + + /* Find the best match for the format+type combo. */ + pipe_format = st_choose_format(pipe->screen, GL_RGBA8, format, type, + pipe_target, 0, bind); + if (pipe_format == PIPE_FORMAT_NONE) { + /* unable to get an rgba format!?! */ + _mesa_problem(ctx, "%s: cannot find a supported format", __func__); return; } - blit.src.resource = stObj->pt; + /* create the destination texture */ + memset(&dst_templ, 0, sizeof(dst_templ)); + dst_templ.target = pipe_target; + dst_templ.format = pipe_format; + dst_templ.bind = bind; + dst_templ.usage = PIPE_USAGE_STAGING; + + st_gl_texture_dims_to_pipe_dims(gl_target, width, height, depth, + &dst_templ.width0, &dst_templ.height0, + &dst_templ.depth0, &dst_templ.array_size); + + dst = screen->resource_create(screen, &dst_templ); + if (!dst) { + _mesa_problem(ctx, "%s: cannot create a temporary texture", __func__); + return; + } + + blit.src.resource = src; blit.src.level = texImage->Level; - blit.src.format = util_format_linear(stObj->pt->format); - blit.dst.resource = dst_texture; + blit.src.format = util_format_linear(src->format); + blit.dst.resource = dst; blit.dst.level = 0; - blit.dst.format = dst_texture->format; + blit.dst.format = dst->format; blit.src.box.x = blit.dst.box.x = 0; blit.src.box.y = blit.dst.box.y = 0; - blit.src.box.z = 0; /* XXX compressed array textures? */ + blit.src.box.z = texImage->Face; blit.dst.box.z = 0; blit.src.box.width = blit.dst.box.width = width; blit.src.box.height = blit.dst.box.height = height; - blit.src.box.depth = blit.dst.box.depth = 1; + blit.src.box.depth = blit.dst.box.depth = depth; blit.mask = PIPE_MASK_RGBA; blit.filter = PIPE_TEX_FILTER_NEAREST; blit.scissor_enable = FALSE; @@ -612,33 +643,38 @@ decompress_with_blit(struct gl_context * ctx, pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels); - map = pipe_transfer_map(pipe, dst_texture, 0, 0, - PIPE_TRANSFER_READ, - 0, 0, width, height, &tex_xfer); + map = pipe_transfer_map_3d(pipe, dst, 0, PIPE_TRANSFER_READ, + 0, 0, 0, width, height, depth, &tex_xfer); if (!map) { goto end; } + mesa_format = st_pipe_format_to_mesa_format(pipe_format); + /* copy/pack data into user buffer */ - if (_mesa_format_matches_format_and_type(stImage->base.TexFormat, - format, type, + if (_mesa_format_matches_format_and_type(mesa_format, format, type, ctx->Pack.SwapBytes)) { /* memcpy */ - const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format); - /* map the dst_surface so we can read from it */ - GLuint row; - for (row = 0; row < height; row++) { - GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width, - height, format, type, row, 0); - memcpy(dest, map, bytesPerRow); - map += tex_xfer->stride; + const uint bytesPerRow = width * util_format_get_blocksize(pipe_format); + GLuint row, slice; + + for (slice = 0; slice < depth; slice++) { + ubyte *slice_map = map; + + for (row = 0; row < height; row++) { + GLvoid *dest = _mesa_image_address3d(&ctx->Pack, pixels, + width, height, format, + type, slice, row, 0); + memcpy(dest, slice_map, bytesPerRow); + slice_map += tex_xfer->stride; + } + map += tex_xfer->layer_stride; } - pipe_transfer_unmap(pipe, tex_xfer); } else { /* format translation via floats */ - GLuint row; - enum pipe_format pformat = util_format_linear(dst_texture->format); + GLuint row, slice; + enum pipe_format pformat = util_format_linear(dst->format); GLfloat *rgba; rgba = malloc(width * 4 * sizeof(GLfloat)); @@ -647,20 +683,24 @@ decompress_with_blit(struct gl_context * ctx, goto end; } - for (row = 0; row < height; row++) { - const GLbitfield transferOps = 0x0; /* bypassed for glGetTexImage() */ - GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width, - height, format, type, row, 0); + for (slice = 0; slice < depth; slice++) { + for (row = 0; row < height; row++) { + const GLbitfield transferOps = 0x0; /* bypassed for glGetTexImage() */ + GLvoid *dest = _mesa_image_address3d(&ctx->Pack, pixels, + width, height, format, + type, slice, row, 0); - if (ST_DEBUG & DEBUG_FALLBACK) - debug_printf("%s: fallback format translation\n", __FUNCTION__); + if (ST_DEBUG & DEBUG_FALLBACK) + debug_printf("%s: fallback format translation\n", __FUNCTION__); - /* get float[4] rgba row from surface */ - pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1, - pformat, rgba); + /* get float[4] rgba row from surface */ + pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1, + pformat, rgba); - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, - type, dest, &ctx->Pack, transferOps); + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, + type, dest, &ctx->Pack, transferOps); + } + map += tex_xfer->layer_stride; } free(rgba); @@ -671,7 +711,7 @@ end: pipe_transfer_unmap(pipe, tex_xfer); _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - pipe_resource_reference(&dst_texture, NULL); + pipe_resource_reference(&dst, NULL); } @@ -722,6 +762,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLvoid *texDest; enum pipe_transfer_usage transfer_usage; void *map; + unsigned dst_width = width; + unsigned dst_height = height; + unsigned dst_depth = 1; if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); @@ -730,6 +773,14 @@ fallback_copy_texsubimage(struct gl_context *ctx, srcY = strb->Base.Height - srcY - height; } + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + /* Move y/height to z/depth for 1D array textures. */ + destZ = destY; + destY = 0; + dst_depth = dst_height; + dst_height = 1; + } + map = pipe_transfer_map(pipe, strb->texture, strb->rtt_level, @@ -745,9 +796,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, else transfer_usage = PIPE_TRANSFER_WRITE; - /* XXX this used to ignore destZ param */ - texDest = st_texture_image_map(st, stImage, destZ, transfer_usage, - destX, destY, width, height); + texDest = st_texture_image_map(st, stImage, transfer_usage, + destX, destY, destZ, + dst_width, dst_height, dst_depth); if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) { @@ -775,8 +826,16 @@ fallback_copy_texsubimage(struct gl_context *ctx, if (scaleOrBias) { _mesa_scale_and_bias_depth_uint(ctx, width, data); } - pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1, - data); + + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + pipe_put_tile_z(stImage->transfer, + texDest + row*stImage->transfer->layer_stride, + 0, 0, width, 1, data); + } + else { + pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1, + data); + } } } else { @@ -792,7 +851,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, if (tempSrc && texDest) { const GLint dims = 2; - const GLint dstRowStride = stImage->transfer->stride; + GLint dstRowStride; struct gl_texture_image *texImage = &stImage->base; struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; @@ -800,6 +859,13 @@ fallback_copy_texsubimage(struct gl_context *ctx, unpack.Invert = GL_TRUE; } + if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { + dstRowStride = stImage->transfer->layer_stride; + } + else { + dstRowStride = stImage->transfer->stride; + } + /* get float/RGBA image from framebuffer */ /* XXX this usually involves a lot of int/float conversion. * try to avoid that someday. @@ -901,6 +967,43 @@ compatible_src_dst_formats(struct gl_context *ctx, } +/** + * Do pipe->blit. Return FALSE if the blitting is unsupported + * for the given formats. + */ +static GLboolean +st_pipe_blit(struct pipe_context *pipe, struct pipe_blit_info *blit) +{ + struct pipe_screen *screen = pipe->screen; + unsigned dst_usage; + + if (util_format_is_depth_or_stencil(blit->dst.format)) { + dst_usage = PIPE_BIND_DEPTH_STENCIL; + } + else { + dst_usage = PIPE_BIND_RENDER_TARGET; + } + + /* try resource_copy_region in case the format is not supported + * for rendering */ + if (util_try_blit_via_copy_region(pipe, blit)) { + return GL_TRUE; /* done */ + } + + /* check the format support */ + if (!screen->is_format_supported(screen, blit->src.format, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW) || + !screen->is_format_supported(screen, blit->dst.format, + PIPE_TEXTURE_2D, 0, + dst_usage)) { + return GL_FALSE; + } + + pipe->blit(pipe, blit); + return GL_TRUE; +} + /** * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible. @@ -929,7 +1032,7 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims, struct pipe_surface surf_tmpl; unsigned dst_usage; unsigned blit_mask; - GLint srcY0, srcY1; + GLint srcY0, srcY1, yStep; /* make sure finalize_textures has been called? */ @@ -950,10 +1053,12 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims, if (do_flip) { srcY1 = strb->Base.Height - srcY - height; srcY0 = srcY1 + height; + yStep = -1; } else { srcY0 = srcY; srcY1 = srcY0 + height; + yStep = 1; } if (ctx->_ImageTransferState) { @@ -965,16 +1070,6 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims, goto fallback; } - if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { - /* 1D arrays might be thought of as 2D images but the actual layout - * might not be that way. At some points, we convert OpenGL's 1D - * array 'height' into gallium 'layers' and that prevents the blit - * utility code from doing the right thing. Simpy use the memcpy-based - * fallback. - */ - goto fallback; - } - /* Set the blit writemask. */ switch (texBaseFormat) { case GL_DEPTH_STENCIL: @@ -1055,27 +1150,38 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims, blit.mask = blit_mask; blit.filter = PIPE_TEX_FILTER_NEAREST; - /* try resource_copy_region in case the format is not supported - * for rendering */ - if (util_try_blit_via_copy_region(pipe, &blit)) { - return; /* done */ - } + /* 1D array textures need special treatment. + * Blit rows from the source to layers in the destination. */ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + int y, layer; - /* check the format support */ - if (!screen->is_format_supported(screen, src_format, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW) || - !screen->is_format_supported(screen, dest_format, - PIPE_TEXTURE_2D, 0, - dst_usage)) { - goto fallback; - } + for (y = srcY0, layer = 0; layer < height; y += yStep, layer++) { + blit.src.box.y = y; + blit.src.box.height = 1; + blit.dst.box.y = 0; + blit.dst.box.height = 1; + blit.dst.box.z = destY + layer; - pipe->blit(pipe, &blit); + if (!st_pipe_blit(pipe, &blit)) { + goto fallback; + } + } + } + else { + /* All the other texture targets. */ + if (!st_pipe_blit(pipe, &blit)) { + goto fallback; + } + } return; } /* try u_blit */ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + /* u_blit cannot copy 1D array textures as required by CopyTexSubImage */ + goto fallback; + } + color_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage); if (!color_writemask || diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index eeb7f0c4f..2be74b452 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -83,6 +83,7 @@ struct st_context GLboolean clamp_frag_color_in_shader; GLboolean clamp_vert_color_in_shader; boolean has_stencil_export; /**< can do shader stencil export? */ + boolean has_time_elapsed; /* On old libGL's for linux we need to invalidate the drawables * on glViewpport calls, this is set via a option. diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 262cc3d6c..e7cf4f3bb 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -371,6 +371,7 @@ void st_init_extensions(struct st_context *st) { o(ARB_shader_texture_lod), PIPE_CAP_SM3 }, { o(ARB_shadow), PIPE_CAP_TEXTURE_SHADOW_MAP }, { o(ARB_texture_non_power_of_two), PIPE_CAP_NPOT_TEXTURES }, + { o(ARB_timer_query), PIPE_CAP_QUERY_TIMESTAMP }, { o(ARB_transform_feedback2), PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME }, { o(ARB_transform_feedback3), PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME }, @@ -382,7 +383,6 @@ void st_init_extensions(struct st_context *st) { o(EXT_texture_filter_anisotropic), PIPE_CAP_ANISOTROPIC_FILTER }, { o(EXT_texture_mirror_clamp), PIPE_CAP_TEXTURE_MIRROR_CLAMP }, { o(EXT_texture_swizzle), PIPE_CAP_TEXTURE_SWIZZLE }, - { o(EXT_timer_query), PIPE_CAP_TIMER_QUERY }, { o(EXT_transform_feedback), PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS }, { o(AMD_seamless_cubemap_per_texture), PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE }, @@ -652,9 +652,12 @@ void st_init_extensions(struct st_context *st) if (ctx->Const.MaxDualSourceDrawBuffers > 0) ctx->Extensions.ARB_blend_func_extended = GL_TRUE; - if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY) && - screen->get_param(screen, PIPE_CAP_QUERY_TIMESTAMP)) { - ctx->Extensions.ARB_timer_query = GL_TRUE; + st->has_time_elapsed = + screen->get_param(screen, PIPE_CAP_QUERY_TIME_ELAPSED); + + if (st->has_time_elapsed || + ctx->Extensions.ARB_timer_query) { + ctx->Extensions.EXT_timer_query = GL_TRUE; } if (ctx->Extensions.ARB_transform_feedback2 && diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 30f5ca5ed..a3a67712a 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -455,7 +455,13 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags, struct pipe_fence_handle **fence) { struct st_context *st = (struct st_context *) stctxi; - st_flush(st, fence); + enum pipe_flush_flags pipe_flags = 0; + + if (flags & ST_FLUSH_END_OF_FRAME) { + pipe_flags |= PIPE_FLUSH_END_OF_FRAME; + } + + st_flush(st, fence, pipe_flags); if (flags & ST_FLUSH_FRONT) st_manager_flush_frontbuffer(st); } diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index 5a4dcaab2..ee4d7622d 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -232,8 +232,9 @@ st_texture_match_image(const struct pipe_resource *pt, */ GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, - GLuint zoffset, enum pipe_transfer_usage usage, - GLuint x, GLuint y, GLuint w, GLuint h) + enum pipe_transfer_usage usage, + GLuint x, GLuint y, GLuint z, + GLuint w, GLuint h, GLuint d) { struct st_texture_object *stObj = st_texture_object(stImage->base.TexObject); @@ -249,9 +250,9 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, else level = stImage->base.Level; - return pipe_transfer_map(st->pipe, stImage->pt, level, - stImage->base.Face + zoffset, - usage, x, y, w, h, &stImage->transfer); + return pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage, + x, y, z + stImage->base.Face, + w, h, d, &stImage->transfer); } diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index 62e975bb4..8a701009a 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -176,12 +176,10 @@ st_texture_match_image(const struct pipe_resource *pt, * well. */ extern GLubyte * -st_texture_image_map(struct st_context *st, - struct st_texture_image *stImage, - GLuint zoffset, +st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h); + GLuint x, GLuint y, GLuint z, + GLuint w, GLuint h, GLuint d); extern void st_texture_image_unmap(struct st_context *st, |