mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
swrast: Replace ImageOffsets with an ImageSlices pointer.
This is a step toward allowing drivers to use their normal mapping paths, instead of requiring that all slice mappings come from an aligned offset from the first slice's map. This incidentally fixes missing slice handling in FXT1 swrast. v2: Use slice height helper function. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
e7ecc11311
commit
0c883e46d8
13 changed files with 122 additions and 184 deletions
|
|
@ -163,34 +163,19 @@ intel_tex_map_image_for_swrast(struct intel_context *intel,
|
|||
for (int i = 0; i < mt->level[level].depth; i++)
|
||||
intel_miptree_slice_resolve_depth(intel, mt, level, i);
|
||||
|
||||
if (mt->target == GL_TEXTURE_3D ||
|
||||
mt->target == GL_TEXTURE_2D_ARRAY ||
|
||||
mt->target == GL_TEXTURE_1D_ARRAY) {
|
||||
int i;
|
||||
void *map = intel_miptree_map_raw(intel, mt);
|
||||
|
||||
/* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't
|
||||
* share code with the normal path.
|
||||
*/
|
||||
for (i = 0; i < mt->level[level].depth; i++) {
|
||||
intel_miptree_get_image_offset(mt, level, i, &x, &y);
|
||||
intel_image->base.ImageOffsets[i] = x + y * (mt->region->pitch /
|
||||
mt->region->cpp);
|
||||
}
|
||||
|
||||
DBG("%s \n", __FUNCTION__);
|
||||
|
||||
intel_image->base.Map = intel_miptree_map_raw(intel, mt);
|
||||
} else {
|
||||
assert(intel_image->base.Base.Depth == 1);
|
||||
intel_miptree_get_image_offset(mt, level, face, &x, &y);
|
||||
|
||||
DBG("%s: (%d,%d) -> (%d, %d)/%d\n",
|
||||
__FUNCTION__, face, level, x, y, mt->region->pitch);
|
||||
|
||||
intel_image->base.Map = intel_miptree_map_raw(intel, mt) +
|
||||
x * mt->cpp + y * mt->region->pitch;
|
||||
for (int i = 0; i < mt->level[level].depth; i++) {
|
||||
intel_miptree_get_image_offset(mt, level, i, &x, &y);
|
||||
intel_image->base.ImageSlices[i] = (map +
|
||||
y * mt->region->pitch +
|
||||
x * mt->cpp);
|
||||
DBG("%s: (%d,%d,%d) -> (%d, %d)/%d\n",
|
||||
__FUNCTION__, face, level, i, x, y, mt->region->pitch);
|
||||
}
|
||||
|
||||
intel_image->base.Map = intel_image->base.ImageSlices[0];
|
||||
|
||||
assert(mt->region->pitch % mt->region->cpp == 0);
|
||||
intel_image->base.RowStride = mt->region->pitch / mt->region->cpp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -638,7 +638,6 @@ radeon_swrast_map_image(radeonContextPtr rmesa,
|
|||
radeon_mipmap_tree *mt;
|
||||
GLuint texel_size;
|
||||
radeon_mipmap_level *lvl;
|
||||
int rs;
|
||||
|
||||
if (!image || !image->mt)
|
||||
return;
|
||||
|
|
@ -650,18 +649,16 @@ radeon_swrast_map_image(radeonContextPtr rmesa,
|
|||
|
||||
lvl = &image->mt->levels[level];
|
||||
|
||||
rs = lvl->rowstride / texel_size;
|
||||
|
||||
radeon_bo_map(mt->bo, 1);
|
||||
|
||||
image->base.Map = mt->bo->ptr + lvl->faces[face].offset;
|
||||
if (mt->target == GL_TEXTURE_3D) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mt->levels[level].depth; i++)
|
||||
image->base.ImageOffsets[i] = rs * lvl->height * i;
|
||||
for (int i = 0; i < mt->levels[level].depth; i++) {
|
||||
image->base.ImageSlices[i] =
|
||||
image->base.Map + (lvl->rowstride * lvl->height * i);
|
||||
}
|
||||
image->base.RowStride = rs;
|
||||
|
||||
image->base.RowStride = lvl->rowstride / texel_size;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
|
|||
|
||||
for (j = 0; j < height; j++) {
|
||||
for (i = 0; i < width; i++) {
|
||||
fetch(src, NULL, stride, i, j, 0, dest);
|
||||
fetch(src, stride, i, j, dest);
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,8 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
|
|||
|
||||
/** A function to fetch one texel from a compressed texture */
|
||||
typedef void (*compressed_fetch_func)(const GLubyte *map,
|
||||
const GLuint imageOffsets[],
|
||||
GLint rowStride,
|
||||
GLint i, GLint j, GLint k,
|
||||
GLint i, GLint j,
|
||||
GLfloat *texel);
|
||||
|
||||
extern compressed_fetch_func
|
||||
|
|
|
|||
|
|
@ -1222,8 +1222,8 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
|
|||
|
||||
|
||||
static void
|
||||
fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
fetch_etc1_rgb8(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j,
|
||||
GLfloat *texel)
|
||||
{
|
||||
struct etc1_block block;
|
||||
|
|
@ -1243,9 +1243,8 @@ fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
|
||||
static void
|
||||
fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_rgb8(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
uint8_t dst[3];
|
||||
|
|
@ -1265,9 +1264,8 @@ fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_srgb8(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
uint8_t dst[3];
|
||||
|
|
@ -1287,9 +1285,8 @@ fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_rgba8_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
uint8_t dst[4];
|
||||
|
|
@ -1307,9 +1304,8 @@ fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
uint8_t dst[4];
|
||||
|
|
@ -1327,9 +1323,8 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_r11_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
GLushort dst;
|
||||
|
|
@ -1347,9 +1342,8 @@ fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_rg11_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
GLushort dst[2];
|
||||
|
|
@ -1372,9 +1366,8 @@ fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_signed_r11_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
GLushort dst;
|
||||
|
|
@ -1392,9 +1385,8 @@ fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_etc2_signed_rg11_eac(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
GLushort dst[2];
|
||||
|
|
@ -1418,8 +1410,7 @@ fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
static void
|
||||
fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
|
||||
const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLint rowStride, GLint i, GLint j,
|
||||
GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
|
|
@ -1440,10 +1431,8 @@ fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
|
|||
|
||||
static void
|
||||
fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
|
||||
const GLuint imageOffsets[],
|
||||
GLint rowStride,
|
||||
GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
struct etc2_block block;
|
||||
uint8_t dst[4];
|
||||
|
|
|
|||
|
|
@ -1616,8 +1616,8 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
|
|||
|
||||
|
||||
static void
|
||||
fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgb_fxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte rgba[4];
|
||||
fxt1_decode_1(map, rowStride, i, j, rgba);
|
||||
|
|
@ -1629,8 +1629,8 @@ fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
|
||||
static void
|
||||
fetch_rgba_fxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgba_fxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte rgba[4];
|
||||
fxt1_decode_1(map, rowStride, i, j, rgba);
|
||||
|
|
|
|||
|
|
@ -318,12 +318,11 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
|
|||
|
||||
|
||||
static void
|
||||
fetch_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_red_rgtc1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte red;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1);
|
||||
unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(red);
|
||||
texel[GCOMP] = 0.0;
|
||||
texel[BCOMP] = 0.0;
|
||||
|
|
@ -331,12 +330,11 @@ fetch_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_l_latc1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte red;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1);
|
||||
unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
|
||||
texel[RCOMP] =
|
||||
texel[GCOMP] =
|
||||
texel[BCOMP] = UBYTE_TO_FLOAT(red);
|
||||
|
|
@ -344,13 +342,11 @@ fetch_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_signed_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_signed_red_rgtc1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLbyte red;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map + sliceOffset,
|
||||
signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map,
|
||||
i, j, &red, 1);
|
||||
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
|
||||
texel[GCOMP] = 0.0;
|
||||
|
|
@ -359,13 +355,11 @@ fetch_signed_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_signed_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_signed_l_latc1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLbyte red;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
signed_fetch_texel_rgtc(rowStride, (GLbyte *) map + sliceOffset,
|
||||
signed_fetch_texel_rgtc(rowStride, (GLbyte *) map,
|
||||
i, j, &red, 1);
|
||||
texel[RCOMP] =
|
||||
texel[GCOMP] =
|
||||
|
|
@ -374,17 +368,15 @@ fetch_signed_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_rg_rgtc2(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte red, green;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
unsigned_fetch_texel_rgtc(rowStride,
|
||||
map + sliceOffset,
|
||||
map,
|
||||
i, j, &red, 2);
|
||||
unsigned_fetch_texel_rgtc(rowStride,
|
||||
map + sliceOffset + 8,
|
||||
map + 8,
|
||||
i, j, &green, 2);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(red);
|
||||
texel[GCOMP] = UBYTE_TO_FLOAT(green);
|
||||
|
|
@ -393,17 +385,15 @@ fetch_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_la_latc2(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_la_latc2(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLubyte red, green;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
unsigned_fetch_texel_rgtc(rowStride,
|
||||
map + sliceOffset,
|
||||
map,
|
||||
i, j, &red, 2);
|
||||
unsigned_fetch_texel_rgtc(rowStride,
|
||||
map + sliceOffset + 8,
|
||||
map + 8,
|
||||
i, j, &green, 2);
|
||||
texel[RCOMP] =
|
||||
texel[GCOMP] =
|
||||
|
|
@ -413,17 +403,15 @@ fetch_la_latc2(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
|
||||
static void
|
||||
fetch_signed_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_signed_rg_rgtc2(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLbyte red, green;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
signed_fetch_texel_rgtc(rowStride,
|
||||
(GLbyte *) map + sliceOffset,
|
||||
(GLbyte *) map,
|
||||
i, j, &red, 2);
|
||||
signed_fetch_texel_rgtc(rowStride,
|
||||
(GLbyte *) map + sliceOffset + 8,
|
||||
(GLbyte *) map + 8,
|
||||
i, j, &green, 2);
|
||||
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
|
||||
texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
|
||||
|
|
@ -433,17 +421,15 @@ fetch_signed_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
|
||||
static void
|
||||
fetch_signed_la_latc2(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k,
|
||||
GLfloat *texel)
|
||||
fetch_signed_la_latc2(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
GLbyte red, green;
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
signed_fetch_texel_rgtc(rowStride,
|
||||
(GLbyte *) map + sliceOffset,
|
||||
(GLbyte *) map,
|
||||
i, j, &red, 2);
|
||||
signed_fetch_texel_rgtc(rowStride,
|
||||
(GLbyte *) map + sliceOffset + 8,
|
||||
(GLbyte *) map + 8,
|
||||
i, j, &green, 2);
|
||||
texel[RCOMP] =
|
||||
texel[GCOMP] =
|
||||
|
|
|
|||
|
|
@ -345,13 +345,12 @@ problem(const char *func)
|
|||
|
||||
|
||||
static void
|
||||
fetch_rgb_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgb_dxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgb_dxt1) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgb_dxt1(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgb_dxt1(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
|
||||
texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
|
||||
texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
|
||||
|
|
@ -363,13 +362,12 @@ fetch_rgb_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_rgba_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgba_dxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt1) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt1(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt1(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
|
||||
texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
|
||||
texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
|
||||
|
|
@ -381,13 +379,12 @@ fetch_rgba_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_rgba_dxt3(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgba_dxt3(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt3) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt3(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt3(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
|
||||
texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
|
||||
texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
|
||||
|
|
@ -399,13 +396,12 @@ fetch_rgba_dxt3(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_rgba_dxt5(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_rgba_dxt5(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt5) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt5(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt5(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
|
||||
texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
|
||||
texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
|
||||
|
|
@ -418,13 +414,12 @@ fetch_rgba_dxt5(const GLubyte *map, const GLuint imageOffsets[],
|
|||
|
||||
|
||||
static void
|
||||
fetch_srgb_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_srgb_dxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgb_dxt1) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgb_dxt1(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgb_dxt1(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
|
||||
texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
|
||||
texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
|
||||
|
|
@ -436,13 +431,12 @@ fetch_srgb_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_srgba_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_srgba_dxt1(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt1) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt1(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt1(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
|
||||
texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
|
||||
texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
|
||||
|
|
@ -454,13 +448,12 @@ fetch_srgba_dxt1(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_srgba_dxt3(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_srgba_dxt3(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt3) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt3(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt3(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
|
||||
texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
|
||||
texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
|
||||
|
|
@ -472,13 +465,12 @@ fetch_srgba_dxt3(const GLubyte *map, const GLuint imageOffsets[],
|
|||
}
|
||||
|
||||
static void
|
||||
fetch_srgba_dxt5(const GLubyte *map, const GLuint imageOffsets[],
|
||||
GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
fetch_srgba_dxt5(const GLubyte *map,
|
||||
GLint rowStride, GLint i, GLint j, GLfloat *texel)
|
||||
{
|
||||
if (fetch_ext_rgba_dxt5) {
|
||||
GLuint sliceOffset = k ? imageOffsets[k] : 0;
|
||||
GLubyte tex[4];
|
||||
fetch_ext_rgba_dxt5(rowStride, map + sliceOffset, i, j, tex);
|
||||
fetch_ext_rgba_dxt5(rowStride, map, i, j, tex);
|
||||
texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
|
||||
texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
|
||||
texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ struct swrast_texture_image
|
|||
|
||||
/** These fields only valid when texture memory is mapped */
|
||||
GLint RowStride; /**< Padded width in units of texels */
|
||||
GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
|
||||
void **ImageSlices; /**< if 3D texture: array [Depth] of offsets to
|
||||
each 2D slice in 'Data', in texels */
|
||||
GLubyte *Map; /**< Pointer to mapped image memory */
|
||||
|
||||
|
|
|
|||
|
|
@ -98,10 +98,9 @@ static void
|
|||
fetch_compressed(const struct swrast_texture_image *swImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel)
|
||||
{
|
||||
swImage->FetchCompressedTexel(swImage->Map,
|
||||
swImage->ImageOffsets,
|
||||
swImage->FetchCompressedTexel(swImage->ImageSlices[k],
|
||||
swImage->RowStride,
|
||||
i, j, k, texel);
|
||||
i, j, texel);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@
|
|||
#elif DIM == 3
|
||||
|
||||
#define TEXEL_ADDR( type, image, i, j, k, size ) \
|
||||
((type *)(image)->Map + ((image)->ImageOffsets[k] \
|
||||
+ (image)->RowStride * (j) + (i)) * (size))
|
||||
((type *)(image)->ImageSlices[k] + \
|
||||
((image)->RowStride * (j) + (i)) * (size))
|
||||
|
||||
#define FETCH(x) fetch_texel_3d_##x
|
||||
|
||||
|
|
|
|||
|
|
@ -88,18 +88,8 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
|
|||
|
||||
/* Want to store linear values, not sRGB */
|
||||
rb->Format = _mesa_get_srgb_format_linear(format);
|
||||
|
||||
/* Set the gl_renderbuffer::Buffer field so that mapping the buffer
|
||||
* succeeds.
|
||||
*/
|
||||
if (att->Texture->Target == GL_TEXTURE_3D ||
|
||||
att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) {
|
||||
srb->Buffer = swImage->Buffer +
|
||||
swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format);
|
||||
}
|
||||
else {
|
||||
srb->Buffer = swImage->Buffer;
|
||||
}
|
||||
|
||||
srb->Buffer = swImage->ImageSlices[zOffset];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -88,23 +88,26 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct swrast_texture_image *swImg = swrast_texture_image(texImage);
|
||||
GLuint bytes = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
|
||||
texImage->Height, texImage->Depth);
|
||||
GLuint bytesPerSlice;
|
||||
GLuint slices = texture_slices(texImage);
|
||||
GLuint i;
|
||||
|
||||
if (!_swrast_init_texture_image(texImage))
|
||||
return GL_FALSE;
|
||||
|
||||
bytesPerSlice = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
|
||||
_swrast_teximage_slice_height(texImage), 1);
|
||||
|
||||
assert(!swImg->Buffer);
|
||||
swImg->Buffer = _mesa_align_malloc(bytes, 512);
|
||||
swImg->Buffer = _mesa_align_malloc(bytesPerSlice * slices, 512);
|
||||
if (!swImg->Buffer)
|
||||
return GL_FALSE;
|
||||
|
||||
/* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
|
||||
/* RowStride and ImageSlices[] describe how to address texels in 'Data' */
|
||||
swImg->RowStride = texImage->Width;
|
||||
|
||||
for (i = 0; i < texture_slices(texImage); i++) {
|
||||
swImg->ImageOffsets[i] = i * texImage->Width * texImage->Height;
|
||||
for (i = 0; i < slices; i++) {
|
||||
swImg->ImageSlices[i] = swImg->Buffer + bytesPerSlice * i;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
|
|
@ -114,7 +117,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
|
|||
/**
|
||||
* Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to
|
||||
* initialize the fields of swrast_texture_image without allocating the image
|
||||
* buffer or initializing RowStride or the contents of ImageOffsets.
|
||||
* buffer or initializing RowStride or the contents of ImageSlices.
|
||||
*
|
||||
* Returns GL_TRUE on success, GL_FALSE on memory allocation failure.
|
||||
*/
|
||||
|
|
@ -143,9 +146,9 @@ _swrast_init_texture_image(struct gl_texture_image *texImage)
|
|||
swImg->DepthScale = (GLfloat) texImage->Depth;
|
||||
}
|
||||
|
||||
assert(!swImg->ImageOffsets);
|
||||
swImg->ImageOffsets = malloc(texture_slices(texImage) * sizeof(GLuint));
|
||||
if (!swImg->ImageOffsets)
|
||||
assert(!swImg->ImageSlices);
|
||||
swImg->ImageSlices = calloc(texture_slices(texImage), sizeof(void *));
|
||||
if (!swImg->ImageSlices)
|
||||
return GL_FALSE;
|
||||
|
||||
return GL_TRUE;
|
||||
|
|
@ -165,8 +168,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
|
|||
swImage->Buffer = NULL;
|
||||
}
|
||||
|
||||
free(swImage->ImageOffsets);
|
||||
swImage->ImageOffsets = NULL;
|
||||
free(swImage->ImageSlices);
|
||||
swImage->ImageSlices = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -227,17 +230,15 @@ _swrast_map_teximage(struct gl_context *ctx,
|
|||
*mapOut = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
map = swImage->Buffer;
|
||||
|
||||
/* This function can only be used with a swrast-allocated buffer, in which
|
||||
* case ImageSlices is populated with pointers into Buffer.
|
||||
*/
|
||||
assert(swImage->Buffer);
|
||||
assert(swImage->Buffer == swImage->ImageSlices[0]);
|
||||
|
||||
assert(slice < texture_slices(texImage));
|
||||
if (slice != 0) {
|
||||
GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat,
|
||||
texImage->Width,
|
||||
_swrast_teximage_slice_height(texImage),
|
||||
1);
|
||||
map += slice * sliceSize;
|
||||
}
|
||||
map = swImage->ImageSlices[slice];
|
||||
|
||||
/* apply x/y offset to map address */
|
||||
map += stride * (y / bh) + texelSize * (x / bw);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue