[Vulkan] Cube textures, now with mipmaps.

This commit is contained in:
gibbed
2018-05-13 08:31:33 -05:00
parent 9b64e67e14
commit ef924a8423
2 changed files with 92 additions and 18 deletions

View File

@@ -192,8 +192,8 @@ void TextureInfo::CalculateTextureSizes2D(uint32_t width, uint32_t height) {
size.input_width = texel_width;
size.input_height = size.block_height * format->block_height;
size.input_pitch = byte_pitch;
size.input_face_length = size.input_pitch * size.block_height;
input_length = size.input_face_length;
}
@@ -232,8 +232,8 @@ void TextureInfo::CalculateTextureSizes3D(uint32_t width, uint32_t height,
size.input_width = texel_width;
size.input_height = size.block_height * format->block_height;
size.input_pitch = byte_pitch;
size.input_face_length = size.input_pitch * size.block_height;
input_length = size.input_face_length * depth;
}
@@ -273,8 +273,8 @@ void TextureInfo::CalculateTextureSizesCube(uint32_t width, uint32_t height,
size.input_width = texel_width;
size.input_height = size.block_height * format->block_height;
size.input_pitch = byte_pitch;
size.input_face_length = size.input_pitch * size.block_height;
input_length = size.input_face_length * 6;
}
@@ -464,7 +464,24 @@ uint32_t TextureInfo::GetMipByteSize(const TextureInfo& src, uint32_t mip) {
byte_pitch = xe::round_up(byte_pitch, 256);
}
return byte_pitch * block_height;
uint32_t size = byte_pitch * block_height;
switch (src.dimension) {
case Dimension::k1D:
case Dimension::k2D:
break;
case Dimension::k3D:
size *= src.depth;
break;
case Dimension::kCube:
size *= 6;
break;
default:
assert_unhandled_case(src.dimension);
break;
}
return size;
}
uint32_t TextureInfo::GetMipLinearSize(const TextureInfo& src, uint32_t mip) {
@@ -474,7 +491,24 @@ uint32_t TextureInfo::GetMipLinearSize(const TextureInfo& src, uint32_t mip) {
uint32_t size = src.input_length >> (mip * 2);
// The size is a multiple of the block size.
return xe::round_up(size, bytes_per_block);
size = xe::round_up(size, bytes_per_block);
switch (src.dimension) {
case Dimension::k1D:
case Dimension::k2D:
break;
case Dimension::k3D:
size *= src.depth;
break;
case Dimension::kCube:
size *= 6;
break;
default:
assert_unhandled_case(src.dimension);
break;
}
return size;
}
bool TextureInfo::GetPackedTileOffset(uint32_t width, uint32_t height,