1aa1a5c0c9e0de71ecd15e7190c121d6dd98471a6Ian Romanick/*
2877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Copyright 2003 VMware, Inc.
33dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * All Rights Reserved.
4a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke *
53dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * Permission is hereby granted, free of charge, to any person obtaining a
63dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * copy of this software and associated documentation files (the
73dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * "Software"), to deal in the Software without restriction, including
83dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * without limitation the rights to use, copy, modify, merge, publish,
9284dcad20a9a55278c1d3dd98f53e45650b22896Ian Romanick * distribute, sublicense, and/or sell copies of the Software, and to
103dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * permit persons to whom the Software is furnished to do so, subject to
113dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * the following conditions:
12a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke *
133dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * The above copyright notice and this permission notice (including the
143dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * next paragraph) shall be included in all copies or substantial portions
153dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * of the Software.
16a7bdd4cba8ddcab8dff59ecaaa7efbd436c6c307Kenneth Graunke *
173dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
183dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19284dcad20a9a55278c1d3dd98f53e45650b22896Ian Romanick * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
213dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
223dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
233dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24aa1a5c0c9e0de71ecd15e7190c121d6dd98471a6Ian Romanick */
253dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
263dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/bufferobj.h"
27c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace#include "main/image.h"
283dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/macros.h"
293dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/mtypes.h"
303dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/pbo.h"
313dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/texobj.h"
323dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/texstore.h"
333dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/texcompress.h"
343dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "main/enums.h"
35d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand#include "drivers/common/meta.h"
363dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
37a69274454b6bde265a910ca5bd3199217431f5b5Kenneth Graunke#include "brw_context.h"
383dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "intel_batchbuffer.h"
393dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "intel_tex.h"
403dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "intel_mipmap_tree.h"
413dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#include "intel_blit.h"
42009be40b7d9e882ce95f6f76523f8f6d1c21238cSisinty Sasmita Patra#include "intel_tiled_memcpy.h"
4383649587c6a10a99d00a01eb72a6563a61aaf8a7Matt Turner
443dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt#define FILE_DEBUG_FLAG DEBUG_TEXTURE
453dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
463dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt/**
473dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * \brief A fast path for glTexImage and glTexSubImage.
483dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt *
493dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * \param for_glTexImage Was this called from glTexImage or glTexSubImage?
503dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt *
5149ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * This fast path is taken when the texture format is BGRA, RGBA,
5249ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * A or L and when the texture memory is X- or Y-tiled.  It uploads
533dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * the texture data by mapping the texture memory without a GTT fence, thus
5449ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * acquiring a tiled view of the memory, and then copying sucessive
5549ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * spans within each tile.
563dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt *
573dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * This is a performance win over the conventional texture upload path because
583dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * it avoids the performance penalty of writing through the write-combine
593dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * buffer. In the conventional texture upload path,
603dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * texstore.c:store_texsubimage(), the texture memory is mapped through a GTT
613dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * fence, thus acquiring a linear view of the memory, then each row in the
6249ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * image is memcpy'd. In this fast path, we replace each row's copy with
6349ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * a sequence of copies over each linear span in tile.
643dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt *
6549ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman * One use case is Google Chrome's paint rectangles.  Chrome (as
663dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * of version 21) renders each page as a tiling of 256x256 GL_BGRA textures.
673dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * Each page's content is initially uploaded with glTexImage2D and damaged
683dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * regions are updated with glTexSubImage2D. On some workloads, the
693dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt * performance gain of this fastpath on Sandybridge is over 5x.
703dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt */
713dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholtbool
723dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholtintel_texsubimage_tiled_memcpy(struct gl_context * ctx,
733dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               GLuint dims,
743dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               struct gl_texture_image *texImage,
753dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               GLint xoffset, GLint yoffset, GLint zoffset,
763dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               GLsizei width, GLsizei height, GLsizei depth,
773dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               GLenum format, GLenum type,
783dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               const GLvoid *pixels,
793dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               const struct gl_pixelstore_attrib *packing,
803dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                               bool for_glTexImage)
813dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt{
82ca437579b3974b91a5298707c459908a628c1098Kenneth Graunke   struct brw_context *brw = brw_context(ctx);
833dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   struct intel_texture_image *image = intel_texture_image(texImage);
84c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace   int src_pitch;
853dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
863dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   /* The miptree's buffer. */
873dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   drm_intel_bo *bo;
883dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
893dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   int error = 0;
903dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
9149ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman   uint32_t cpp;
9249ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman   mem_copy_fn mem_copy = NULL;
9349ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman
945a51c1b01a16d3256f9769a76d8293fea5853b1fCourtney Goeltzenleuchter   /* This fastpath is restricted to specific texture types:
9549ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman    * a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support
9649ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman    * more types.
97c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace    *
98c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace    * FINISHME: The restrictions below on packing alignment and packing row
99c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace    * length are likely unneeded now because we calculate the source stride
100c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace    * with _mesa_image_row_stride. However, before removing the restrictions
101c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace    * we need tests.
1023dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt    */
1032e26afb37b83effe44b218d5b2a305020b8ad22fKenneth Graunke   if (!brw->has_llc ||
1046bac86cd85bf85dd03df7e788232059dc63b9f65Jason Ekstrand       !(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) ||
105f883aac06ee9f609273722772b7dd15debaf4f11Jason Ekstrand       !(texImage->TexObject->Target == GL_TEXTURE_2D ||
106f883aac06ee9f609273722772b7dd15debaf4f11Jason Ekstrand         texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
1073dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       pixels == NULL ||
1083dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       _mesa_is_bufferobj(packing->BufferObj) ||
1093dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->Alignment > 4 ||
1103dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->SkipPixels > 0 ||
1113dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->SkipRows > 0 ||
1123dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       (packing->RowLength != 0 && packing->RowLength != width) ||
1133dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->SwapBytes ||
1143dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->LsbFirst ||
1153dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt       packing->Invert)
1163dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt      return false;
1173dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
118099f5b3a62be1919add02a4cb887841c9f0f2fe4Chris Wilson   /* Only a simple blit, no scale, bias or other mapping. */
119099f5b3a62be1919add02a4cb887841c9f0f2fe4Chris Wilson   if (ctx->_ImageTransferState)
120099f5b3a62be1919add02a4cb887841c9f0f2fe4Chris Wilson      return false;
121099f5b3a62be1919add02a4cb887841c9f0f2fe4Chris Wilson
1226cc7aec5b05ff19d9bdf2b33c993257625d7c9fcJason Ekstrand   if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp))
12349ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      return false;
12449ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman
125ca1d1b2fc1d1f7fb5dbbc0719c6c899b97bc9e6bChris Forbes   /* If this is a nontrivial texture view, let another path handle it instead. */
12624f490fb37f5a5b3ab0098aac6e4f6144f4f7029Chris Forbes   if (texImage->TexObject->MinLayer)
127ca1d1b2fc1d1f7fb5dbbc0719c6c899b97bc9e6bChris Forbes      return false;
128ca1d1b2fc1d1f7fb5dbbc0719c6c899b97bc9e6bChris Forbes
1293dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   if (for_glTexImage)
1303dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt      ctx->Driver.AllocTextureImageBuffer(ctx, texImage);
1313dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
1323dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   if (!image->mt ||
133e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt       (image->mt->tiling != I915_TILING_X &&
134e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt       image->mt->tiling != I915_TILING_Y)) {
13549ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      /* The algorithm is written only for X- or Y-tiled memory. */
1363dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt      return false;
1373dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   }
1383dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
1393dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   /* Since we are going to write raw data to the miptree, we need to resolve
1403dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt    * any pending fast color clears before we start.
1413dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt    */
14212010b92263dd63a6cef785c730ff877f7912cc8Topi Pohjolainen   intel_miptree_all_slices_resolve_color(brw, image->mt, 0);
1433dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
144e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt   bo = image->mt->bo;
1453dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
146329779a0b45b63be17627f026533c80b2c8f7991Kenneth Graunke   if (drm_intel_bo_references(brw->batch.bo, bo)) {
1473dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt      perf_debug("Flushing before mapping a referenced bo.\n");
148ca437579b3974b91a5298707c459908a628c1098Kenneth Graunke      intel_batchbuffer_flush(brw);
1493dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   }
1503dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
151e396674d5fb06ef467c7b66cf14ff89df64f2101Kenneth Graunke   error = brw_bo_map(brw, bo, true /* write enable */, "miptree");
1523dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   if (error || bo->virtual == NULL) {
15328d9e90428282a5e0a6aa31ad858a5cf514d1264Marius Predut      DBG("%s: failed to map bo\n", __func__);
1543dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt      return false;
1553dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   }
1563dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
157c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace   src_pitch = _mesa_image_row_stride(packing, width, format, type);
158c4205590e731c2e6de6ecc6d13897740df9a7b5fChad Versace
1593dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   /* We postponed printing this message until having committed to executing
1603dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt    * the function.
1613dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt    */
1622f6a31508505744e5f1b3e4c35c2a1b305a813a8Chad Versace   DBG("%s: level=%d offset=(%d,%d) (w,h)=(%d,%d) format=0x%x type=0x%x "
16371fe9437169cfdafda8814aa814bb85429fb6cfcMark Mueller       "mesa_format=0x%x tiling=%d "
1642f6a31508505744e5f1b3e4c35c2a1b305a813a8Chad Versace       "packing=(alignment=%d row_length=%d skip_pixels=%d skip_rows=%d) "
1652f6a31508505744e5f1b3e4c35c2a1b305a813a8Chad Versace       "for_glTexImage=%d\n",
16628d9e90428282a5e0a6aa31ad858a5cf514d1264Marius Predut       __func__, texImage->Level, xoffset, yoffset, width, height,
167e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt       format, type, texImage->TexFormat, image->mt->tiling,
1682f6a31508505744e5f1b3e4c35c2a1b305a813a8Chad Versace       packing->Alignment, packing->RowLength, packing->SkipPixels,
1692f6a31508505744e5f1b3e4c35c2a1b305a813a8Chad Versace       packing->SkipRows, for_glTexImage);
1703dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
1715de52541e52d0a14d70ef7472d08cdc650d4a222Chris Forbes   int level = texImage->Level + texImage->TexObject->MinLevel;
1725de52541e52d0a14d70ef7472d08cdc650d4a222Chris Forbes
1735a51c1b01a16d3256f9769a76d8293fea5853b1fCourtney Goeltzenleuchter   /* Adjust x and y offset based on miplevel */
1745de52541e52d0a14d70ef7472d08cdc650d4a222Chris Forbes   xoffset += image->mt->level[level].level_x;
1755de52541e52d0a14d70ef7472d08cdc650d4a222Chris Forbes   yoffset += image->mt->level[level].level_y;
1765a51c1b01a16d3256f9769a76d8293fea5853b1fCourtney Goeltzenleuchter
17749ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman   linear_to_tiled(
17849ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      xoffset * cpp, (xoffset + width) * cpp,
17949ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      yoffset, yoffset + height,
180225a09790da0b1605a0b68acbbe1e0f30eee3e6fChad Versace      bo->virtual,
181225a09790da0b1605a0b68acbbe1e0f30eee3e6fChad Versace      pixels - (ptrdiff_t) yoffset * src_pitch - (ptrdiff_t) xoffset * cpp,
182e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt      image->mt->pitch, src_pitch,
18349ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      brw->has_swizzling,
184e16c5c906316c58c0633e9bba02339ef981e5ef3Eric Anholt      image->mt->tiling,
18549ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman      mem_copy
18649ed5991ee002762f963104facdc6b291f14a9b5Frank Henigman   );
1873dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
1883dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   drm_intel_bo_unmap(bo);
1893dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   return true;
1903dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt}
1913dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
1923dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholtstatic void
1933dbba95b72262344b82fba018b7c2c1208754cd2Eric AnholtintelTexSubImage(struct gl_context * ctx,
1943dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 GLuint dims,
1953dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 struct gl_texture_image *texImage,
1963dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 GLint xoffset, GLint yoffset, GLint zoffset,
1973dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 GLsizei width, GLsizei height, GLsizei depth,
1983dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 GLenum format, GLenum type,
1993dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 const GLvoid * pixels,
2003dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                 const struct gl_pixelstore_attrib *packing)
2013dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt{
202c8194dc737464d19521c948aa555d936f47f381aJordan Justen   struct intel_mipmap_tree *mt = intel_texture_image(texImage)->mt;
2033dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   bool ok;
2043dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
205c8194dc737464d19521c948aa555d936f47f381aJordan Justen   bool tex_busy = mt && drm_intel_bo_busy(mt->bo);
206c8194dc737464d19521c948aa555d936f47f381aJordan Justen
207c8194dc737464d19521c948aa555d936f47f381aJordan Justen   if (mt && mt->format == MESA_FORMAT_S_UINT8)
208c8194dc737464d19521c948aa555d936f47f381aJordan Justen      mt->r8stencil_needs_update = true;
209d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand
210765f4b8c046dc01f7141097e9335360f2ad6a24fJason Ekstrand   DBG("%s mesa_format %s target %s format %s type %s level %d %dx%dx%d\n",
21128d9e90428282a5e0a6aa31ad858a5cf514d1264Marius Predut       __func__, _mesa_get_format_name(texImage->TexFormat),
2122f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke       _mesa_enum_to_string(texImage->TexObject->Target),
2132f11e92cef51c88a09bc778e2ceca4ab50cf0017Kenneth Graunke       _mesa_enum_to_string(format), _mesa_enum_to_string(type),
214765f4b8c046dc01f7141097e9335360f2ad6a24fJason Ekstrand       texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
215765f4b8c046dc01f7141097e9335360f2ad6a24fJason Ekstrand
216d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand   ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage,
217d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand                                   xoffset, yoffset, zoffset,
218d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand                                   width, height, depth, format, type,
219de61849994dec48496a81540c384159da0e8371eAnuj Phogat                                   pixels, tex_busy, packing);
220d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand   if (ok)
221d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand      return;
222d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand
2233dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
2243dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                                       xoffset, yoffset, zoffset,
2253dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                                       width, height, depth,
2263dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                                       format, type, pixels, packing,
2273dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt                                       false /*for_glTexImage*/);
2283dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   if (ok)
2293dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt     return;
2303dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
231d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand   _mesa_store_texsubimage(ctx, dims, texImage,
232d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand                           xoffset, yoffset, zoffset,
233d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand                           width, height, depth,
234d5d4ba9139a5bae6fdec992ddb9437bdb92e3790Jason Ekstrand                           format, type, pixels, packing);
2353dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt}
2363dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt
2373dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholtvoid
2383dbba95b72262344b82fba018b7c2c1208754cd2Eric AnholtintelInitTextureSubImageFuncs(struct dd_function_table *functions)
2393dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt{
2403dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt   functions->TexSubImage = intelTexSubImage;
2413dbba95b72262344b82fba018b7c2c1208754cd2Eric Anholt}
242