static struct gl_texture_image *
st_NewTextureImage(struct gl_context * ctx)
{
- DBG("%s\n", __FUNCTION__);
+ DBG("%s\n", __func__);
(void) ctx;
return (struct gl_texture_image *) ST_CALLOC_STRUCT(st_texture_image);
}
{
struct st_texture_object *obj = ST_CALLOC_STRUCT(st_texture_object);
- DBG("%s\n", __FUNCTION__);
+ DBG("%s\n", __func__);
_mesa_initialize_texture_object(ctx, &obj->base, name, target);
return &obj->base;
{
struct st_texture_image *stImage = st_texture_image(texImage);
- DBG("%s\n", __FUNCTION__);
+ DBG("%s\n", __func__);
if (stImage->pt) {
pipe_resource_reference(&stImage->pt, NULL);
GLuint ptWidth, ptHeight, ptDepth, ptLayers;
enum pipe_format fmt;
- DBG("%s\n", __FUNCTION__);
+ DBG("%s\n", __func__);
assert(!stObj->pt);
stObj->lastLevel = lastLevel;
- DBG("%s returning %d\n", __FUNCTION__, (stObj->pt != NULL));
+ DBG("%s returning %d\n", __func__, (stObj->pt != NULL));
return stObj->pt != NULL;
}
GLuint height = texImage->Height;
GLuint depth = texImage->Depth;
- DBG("%s\n", __FUNCTION__);
+ DBG("%s\n", __func__);
assert(!stImage->pt); /* xxx this might be wrong */
* in which case the memcpy-based fast path will likely be used and
* we don't have to blit. */
if (_mesa_format_matches_format_and_type(texImage->TexFormat, format,
- type, unpack->SwapBytes)) {
+ type, unpack->SwapBytes, NULL)) {
goto fallback;
}
if (gl_target == GL_TEXTURE_CUBE_MAP) {
gl_target = GL_TEXTURE_2D;
}
+ /* TexSubImage can specify subsets of cube map array faces
+ * so we need to upload via 2D array instead */
+ if (gl_target == GL_TEXTURE_CUBE_MAP_ARRAY) {
+ gl_target = GL_TEXTURE_2D_ARRAY;
+ }
/* Initialize the source texture description. */
memset(&src_templ, 0, sizeof(src_templ));
/**
- * Called via ctx->Driver.GetTexImage()
+ * Called via ctx->Driver.GetTexSubImage()
*
* This uses a blit to copy the texture to a texture format which matches
* the format and type combo and then a fast read-back is done using memcpy.
* we do here should be free in such cases.
*/
static void
-st_GetTexImage(struct gl_context * ctx,
- GLenum format, GLenum type, GLvoid * pixels,
- struct gl_texture_image *texImage)
+st_GetTexSubImage(struct gl_context * ctx,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLint depth,
+ GLenum format, GLenum type, GLvoid * pixels,
+ struct gl_texture_image *texImage)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- GLuint width = texImage->Width;
- GLuint height = texImage->Height;
- GLuint depth = texImage->Depth;
struct st_texture_image *stImage = st_texture_image(texImage);
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
struct pipe_resource *src = stObj->pt;
/* XXX Fallback to _mesa_GetTexImage_sw for depth-stencil formats
* due to an incomplete stencil blit implementation in some drivers. */
- if (format == GL_DEPTH_STENCIL) {
+ if (format == GL_DEPTH_STENCIL || format == GL_STENCIL_INDEX) {
goto fallback;
}
/* See if the texture format already matches the format and type,
* in which case the memcpy-based fast path will be used. */
if (_mesa_format_matches_format_and_type(texImage->TexFormat, format,
- type, ctx->Pack.SwapBytes)) {
+ type, ctx->Pack.SwapBytes, NULL)) {
goto fallback;
}
}
}
- /* create the destination texture */
+ /* create the destination texture of size (width X height X depth) */
memset(&dst_templ, 0, sizeof(dst_templ));
dst_templ.target = pipe_target;
dst_templ.format = dst_format;
/* From now on, we need the gallium representation of dimensions. */
if (gl_target == GL_TEXTURE_1D_ARRAY) {
+ zoffset = yoffset;
+ yoffset = 0;
depth = height;
height = 1;
}
+ assert(texImage->Face == 0 ||
+ texImage->TexObject->MinLayer == 0 ||
+ zoffset == 0);
+
memset(&blit, 0, sizeof(blit));
blit.src.resource = src;
blit.src.level = texImage->Level + texImage->TexObject->MinLevel;
blit.dst.resource = dst;
blit.dst.level = 0;
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 = texImage->Face + texImage->TexObject->MinLayer;
+ blit.src.box.x = xoffset;
+ blit.dst.box.x = 0;
+ blit.src.box.y = yoffset;
+ blit.dst.box.y = 0;
+ blit.src.box.z = texImage->Face + texImage->TexObject->MinLayer + zoffset;
blit.dst.box.z = 0;
blit.src.box.width = blit.dst.box.width = width;
blit.src.box.height = blit.dst.box.height = height;
/* copy/pack data into user buffer */
if (_mesa_format_matches_format_and_type(mesa_format, format, type,
- ctx->Pack.SwapBytes)) {
+ ctx->Pack.SwapBytes, NULL)) {
/* memcpy */
const uint bytesPerRow = width * util_format_get_blocksize(dst_format);
GLuint row, slice;
}
if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback format translation\n", __FUNCTION__);
+ debug_printf("%s: fallback format translation\n", __func__);
dstMesaFormat = _mesa_format_from_format_and_type(format, type);
dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
fallback:
if (!done) {
- _mesa_GetTexImage_sw(ctx, format, type, pixels, texImage);
+ _mesa_GetTexSubImage_sw(ctx, xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, texImage);
}
}
struct pipe_transfer *transfer;
if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
+ debug_printf("%s: fallback processing\n", __func__);
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
srcY = strb->Base.Height - srcY - height;
texImage->TexFormat != MESA_FORMAT_ETC1_RGB8);
if (!strb || !strb->surface || !stImage->pt) {
- debug_printf("%s: null strb or stImage\n", __FUNCTION__);
+ debug_printf("%s: null strb or stImage\n", __func__);
return;
}
return GL_TRUE;
}
+/* HACK: this is only enough for the most basic uses of CopyImage. Must fix
+ * before actually exposing the extension.
+ */
+static void
+st_CopyImageSubData(struct gl_context *ctx,
+ struct gl_texture_image *src_image,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dst_image,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height)
+{
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
+ struct st_texture_image *src = st_texture_image(src_image);
+ struct st_texture_image *dst = st_texture_image(dst_image);
+
+ struct pipe_box box;
+
+ u_box_2d_zslice(src_x, src_y, src_z, src_width, src_height, &box);
+ pipe->resource_copy_region(pipe, dst->pt, dst_image->Level,
+ dst_x, dst_y, dst_z,
+ src->pt, src_image->Level,
+ &box);
+}
+
void
st_init_texture_functions(struct dd_function_table *functions)
functions->CopyTexSubImage = st_CopyTexSubImage;
functions->GenerateMipmap = st_generate_mipmap;
- functions->GetTexImage = st_GetTexImage;
+ functions->GetTexSubImage = st_GetTexSubImage;
/* compressed texture functions */
functions->CompressedTexImage = st_CompressedTexImage;
- functions->GetCompressedTexImage = _mesa_GetCompressedTexImage_sw;
+ functions->GetCompressedTexSubImage = _mesa_GetCompressedTexSubImage_sw;
functions->NewTextureObject = st_NewTextureObject;
functions->NewTextureImage = st_NewTextureImage;
functions->AllocTextureStorage = st_AllocTextureStorage;
functions->TextureView = st_TextureView;
+
+ functions->CopyImageSubData = st_CopyImageSubData;
}