本帖最後由 ati16800 於 2018-1-14 23:59 編輯
static void st_UnmapTextureImage(struct gl_context *ctx, struct gl_texture_image *texImage, GLuint slice)
{
struct st_context *st = st_context(ctx);
struct st_texture_image *stImage = st_texture_image(texImage);
if (st_etc_fallback(st, texImage)) {
/* Decompress the ETC texture to the mapped one. */
unsigned z = slice + stImage->base.Face;
struct st_texture_image_transfer *itransfer = &stImage->transfer[z];
struct pipe_transfer *transfer = itransfer->transfer;
assert(z == transfer->box.z);
if (transfer->usage & PIPE_TRANSFER_WRITE) {
if (texImage->TexFormat == MESA_FORMAT_ETC1_RGB8) {
........
}
else {
if (itransfer!=NULL) {
_mesa_unpack_etc2_format(itransfer->map, transfer->stride,
itransfer->temp_data, <-------這裡的temp_data=0 ??
itransfer->temp_stride,
transfer->box.width, transfer->box.height,
texImage->TexFormat);
}
}
}
itransfer->temp_data = NULL;
itransfer->temp_stride = 0;
itransfer->map = 0;
}
st_texture_image_unmap(st, stImage, slice);
}
static void
etc2_unpack_rgb8(uint8_t *dst_row,
unsigned dst_stride,
const uint8_t *src_row, <-------這裡的src_row 來自temp_data=0
unsigned src_stride,
unsigned width,
unsigned height)
{
const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
struct etc2_block block;
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row; <-------這裡的src 來自src_row=0
/*
* Destination texture may not be a multiple of four texels in
* height. Compute a safe height to avoid writing outside the texture.
*/
const unsigned h = MIN2(bh, height - y);
for (x = 0; x < width; x+= bw) {
/*
* Destination texture may not be a multiple of four texels in
* width. Compute a safe width to avoid writing outside the texture.
*/
const unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src, <-------這裡的src = 0
false /* punchthrough_alpha */);
for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
dst[3] = 255;
dst += comps;
}
}
src += bs;
}
src_row += src_stride;
}
}
static void
etc2_rgb8_parse_block(struct etc2_block *block,
const uint8_t *src,
GLboolean punchthrough_alpha)
{
unsigned i;
GLboolean diffbit = false;
static const int lookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
const int R_plus_dR = (src[0] >> 3) + lookup[src[0] & 0x7]; <-------這裡的src=0, 0[0]即死。 |