nv2a: Add support for compressed 3D textures

This commit is contained in:
Wilhelm Kovatch 2020-10-27 02:17:44 +01:00 committed by mborgerson
parent 6f777e73e6
commit 518c9f38cd
1 changed files with 38 additions and 19 deletions

View File

@ -5346,11 +5346,29 @@ static void upload_gl_texture(GLenum gl_target,
unsigned int width = s.width, height = s.height, depth = s.depth;
assert(f.gl_format != 0); /* FIXME: compressed not supported yet */
assert(f.linear == false);
int level;
for (level = 0; level < s.levels; level++) {
if (f.gl_format == 0) { /* compressed */
width = MAX(width, 4); height = MAX(height, 4);
unsigned int block_size;
unsigned int depth_block_size = MIN(depth, 4);
if (f.gl_internal_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
block_size = 8 * depth_block_size;
} else {
block_size = 16 * depth_block_size;
}
glCompressedTexImage3D(gl_target, level, f.gl_internal_format,
width, height, depth, 0,
width/4 * height/4 * depth/depth_block_size * block_size,
texture_data);
texture_data += width/4 * height/4 * depth/4 * block_size;
} else {
unsigned int row_pitch = width * f.bytes_per_pixel;
unsigned int slice_pitch = row_pitch * height;
@ -5374,6 +5392,7 @@ static void upload_gl_texture(GLenum gl_target,
g_free(unswizzled);
texture_data += width * height * depth * f.bytes_per_pixel;
}
width /= 2;
height /= 2;