Fix texture errors on iOS Metal
Change-Id: I027b5e4a8ab737047e9fcd16be8b7597644c7dd6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307569 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
cfb130c662
commit
1788380a97
@ -277,6 +277,19 @@ size_t SkCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
size_t SkCompressedBlockSize(SkImage::CompressionType type) {
|
||||
switch (type) {
|
||||
case SkImage::CompressionType::kNone:
|
||||
return 0;
|
||||
case SkImage::CompressionType::kETC2_RGB8_UNORM:
|
||||
return sizeof(ETC1Block);
|
||||
case SkImage::CompressionType::kBC1_RGB8_UNORM:
|
||||
case SkImage::CompressionType::kBC1_RGBA8_UNORM:
|
||||
return sizeof(BC1Block);
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
size_t SkCompressedFormatDataSize(SkImage::CompressionType compressionType,
|
||||
SkISize dimensions, bool mipMapped) {
|
||||
return SkCompressedDataSize(compressionType, dimensions, nullptr, mipMapped);
|
||||
|
@ -29,7 +29,7 @@ static constexpr bool SkCompressionTypeIsOpaque(SkImage::CompressionType compres
|
||||
|
||||
size_t SkCompressedDataSize(SkImage::CompressionType, SkISize baseDimensions,
|
||||
SkTArray<size_t>* individualMipOffsets, bool mipMapped);
|
||||
|
||||
size_t SkCompressedBlockSize(SkImage::CompressionType type);
|
||||
|
||||
/**
|
||||
* Returns the data size for the given SkImage::CompressionType
|
||||
|
@ -337,13 +337,16 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex, int left, int top, int width,
|
||||
bpp, {width, height}, &individualMipOffsets, mipLevelCount);
|
||||
SkASSERT(combinedBufferSize);
|
||||
|
||||
|
||||
// offset value must be a multiple of the destination texture's pixel size in bytes
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
static const int kAlignment = 4;
|
||||
static const size_t kMinAlignment = 4;
|
||||
#else
|
||||
static const int kAlignment = 1;
|
||||
static const size_t kMinAlignment = 1;
|
||||
#endif
|
||||
size_t alignment = std::max(bpp, kMinAlignment);
|
||||
GrStagingBufferManager::Slice slice = fStagingBufferManager.allocateStagingBufferSlice(
|
||||
combinedBufferSize, kAlignment);
|
||||
combinedBufferSize, alignment);
|
||||
if (!slice.fBuffer) {
|
||||
return false;
|
||||
}
|
||||
@ -627,13 +630,11 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
|
||||
SkASSERT(individualMipOffsets.count() == numMipLevels);
|
||||
SkASSERT(dataSize == combinedBufferSize);
|
||||
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
static const int kAlignment = 4;
|
||||
#else
|
||||
static const int kAlignment = 1;
|
||||
#endif
|
||||
// offset value must be a multiple of the destination texture's pixel size in bytes
|
||||
// for compressed textures, this is the block size
|
||||
size_t alignment = SkCompressedBlockSize(compressionType);
|
||||
GrStagingBufferManager::Slice slice = fStagingBufferManager.allocateStagingBufferSlice(
|
||||
dataSize, kAlignment);
|
||||
dataSize, alignment);
|
||||
if (!slice.fBuffer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user