mirror of https://github.com/xqemu/xqemu.git
nv2a: Handle alignment padding between cubemap faces
This commit is contained in:
parent
4a608b307c
commit
e1236e1b62
|
@ -3821,6 +3821,7 @@ static void pgraph_bind_textures(NV2AState *d)
|
||||||
}
|
}
|
||||||
if (cubemap) {
|
if (cubemap) {
|
||||||
assert(dimensionality == 2);
|
assert(dimensionality == 2);
|
||||||
|
length = (length + NV2A_CUBEMAP_FACE_ALIGNMENT - 1) & ~(NV2A_CUBEMAP_FACE_ALIGNMENT - 1);
|
||||||
length *= 6;
|
length *= 6;
|
||||||
}
|
}
|
||||||
if (dimensionality >= 3) {
|
if (dimensionality >= 3) {
|
||||||
|
@ -4413,16 +4414,30 @@ static TextureBinding* generate_texture(const TextureShape s,
|
||||||
|
|
||||||
if (gl_target == GL_TEXTURE_CUBE_MAP) {
|
if (gl_target == GL_TEXTURE_CUBE_MAP) {
|
||||||
|
|
||||||
|
ColorFormatInfo f = kelvin_color_format_map[s.color_format];
|
||||||
|
unsigned int block_size;
|
||||||
|
if (f.gl_internal_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
|
||||||
|
block_size = 8;
|
||||||
|
} else {
|
||||||
|
block_size = 16;
|
||||||
|
}
|
||||||
|
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
unsigned int w = s.width, h = s.height;
|
unsigned int w = s.width, h = s.height;
|
||||||
int level;
|
int level;
|
||||||
for (level = 0; level < s.levels; level++) {
|
for (level = 0; level < s.levels; level++) {
|
||||||
/* FIXME: This is wrong for compressed textures and textures with 1x? non-square mipmaps */
|
if (f.gl_format == 0) {
|
||||||
|
length += w/4 * h/4 * block_size;
|
||||||
|
} else {
|
||||||
length += w * h * f.bytes_per_pixel;
|
length += w * h * f.bytes_per_pixel;
|
||||||
|
}
|
||||||
|
|
||||||
w /= 2;
|
w /= 2;
|
||||||
h /= 2;
|
h /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
length = (length + NV2A_CUBEMAP_FACE_ALIGNMENT - 1) & ~(NV2A_CUBEMAP_FACE_ALIGNMENT - 1);
|
||||||
|
|
||||||
upload_gl_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
upload_gl_texture(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||||
s, texture_data + 0 * length, palette_data);
|
s, texture_data + 0 * length, palette_data);
|
||||||
upload_gl_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
upload_gl_texture(GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
|
|
|
@ -1343,4 +1343,6 @@
|
||||||
#define NV2A_LTCTXB_COUNT 52
|
#define NV2A_LTCTXB_COUNT 52
|
||||||
#define NV2A_LTC1_COUNT 20
|
#define NV2A_LTC1_COUNT 20
|
||||||
|
|
||||||
|
#define NV2A_CUBEMAP_FACE_ALIGNMENT 128
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue