Backed out changeset 4a679b76e51b (bug 1674592) for causing failures in test_conformance__extensions__ext-texture-compression-rgtc.html CLOSED TREE

This commit is contained in:
Noemi Erli 2020-11-09 13:16:26 +02:00
Родитель a15f3e2f6d
Коммит 9c91fa69af
4 изменённых файлов: 6 добавлений и 89 удалений

Просмотреть файл

@ -3873,20 +3873,6 @@ Maybe<webgl::TexUnpackBlobDesc> FromDomElem(const ClientWebGLContext&,
ErrorResult* const out_error);
} // namespace webgl
void webgl::TexUnpackBlobDesc::Shrink(const webgl::PackingInfo& pi) {
if (cpuData) {
uint8_t bpp = 0;
if (!GetBytesPerPixel(pi, &bpp)) return;
const auto pixels = unpacking.UsedPixels(size);
const auto bytesNeeded = pixels * bpp;
if (!bytesNeeded.isValid()) return;
const auto& newSize = bytesNeeded.value();
cpuData->Shrink(newSize);
return;
}
}
void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget,
GLint level, GLenum respecFormat,
const ivec3& offset, const ivec3& isize,
@ -4021,30 +4007,14 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget,
// -
desc->Shrink(pi);
Run<RPROC(TexImage)>(static_cast<uint32_t>(level), respecFormat,
CastUvec3(offset), pi, std::move(*desc));
}
static Maybe<size_t> EstimateCompressedTexDataBytes(const GLenum sizedFormat,
const uvec3& size) {
const auto format = webgl::FindSizedFormat(sizedFormat);
if (!format || !format->compression) return {};
const auto& comp = *format->compression;
const auto xBlocks =
(CheckedInt<size_t>(size.x) + comp.blockWidth - 1) / comp.blockWidth;
const auto yBlocks =
(CheckedInt<size_t>(size.y) + comp.blockHeight - 1) / comp.blockHeight;
const auto bytes = xBlocks * yBlocks * size.z * comp.bytesPerBlock;
if (!bytes.isValid()) return {};
return Some(bytes.value());
}
void ClientWebGLContext::CompressedTexImage(bool sub, uint8_t funcDims,
GLenum imageTarget, GLint level,
GLenum format, const ivec3& offset,
const ivec3& isize, GLint border,
const ivec3& size, GLint border,
const TexImageSource& src,
GLsizei pboImageSize) const {
const FuncScope funcScope(*this, "compressedTex(Sub)Image[23]D");
@ -4075,15 +4045,9 @@ void ClientWebGLContext::CompressedTexImage(bool sub, uint8_t funcDims,
MOZ_CRASH("impossible");
}
const auto size = CastUvec3(isize);
const auto estBytes = EstimateCompressedTexDataBytes(format, size);
if (estBytes) {
range.Shrink(*estBytes);
}
Run<RPROC(CompressedTexImage)>(
sub, imageTarget, static_cast<uint32_t>(level), format, CastUvec3(offset),
size, range, static_cast<uint32_t>(pboImageSize), pboOffset);
CastUvec3(size), range, static_cast<uint32_t>(pboImageSize), pboOffset);
}
void ClientWebGLContext::CopyTexImage(uint8_t funcDims, GLenum imageTarget,

Просмотреть файл

@ -74,18 +74,16 @@ static inline V* FindOrNull(const std::map<K, V*>& dest, const K2& key) {
}
// Returns a pointer to the in-place value for `key`.
template <typename C, typename K2>
static inline auto FindPtrOrNull(C& container, const K2& key) {
auto itr = container.find(key);
using R = decltype(&(itr->second));
if (itr == container.end()) return R{nullptr};
template <typename K, typename V, typename K2>
static inline V* FindPtrOrNull(std::map<K, V>& dest, const K2& key) {
auto itr = dest.find(key);
if (itr == dest.end()) return nullptr;
return &(itr->second);
}
//////////////////////////////////////////////////////////////////////////////////////////
std::unordered_map<GLenum, EffectiveFormat> gSizedFormatMap;
std::map<EffectiveFormat, const CompressedFormatInfo> gCompressedFormatInfoMap;
std::map<EffectiveFormat, FormatInfo> gFormatInfoMap;
@ -283,8 +281,6 @@ static void AddFormatInfo(EffectiveFormat format, const char* name,
d,
s};
AlwaysInsert(gFormatInfoMap, format, info);
gSizedFormatMap.insert({sizedFormat, format});
}
static void InitFormatInfo() {
@ -584,16 +580,6 @@ const FormatInfo* GetFormat(EffectiveFormat format) {
return GetFormatInfo_NoLock(format);
}
const FormatInfo* FindSizedFormat(const GLenum sizedFormat) {
StaticMutexAutoLock lock(gFormatMapMutex);
EnsureInitFormatTables(lock);
const auto effFormat = FindPtrOrNull(gSizedFormatMap, sizedFormat);
if (!effFormat) return nullptr;
return GetFormatInfo_NoLock(*effFormat);
}
//////////////////////////////////////////////////////////////////////////////////////////
const FormatInfo* FormatInfo::GetCopyDecayFormat(UnsizedFormat uf) const {

Просмотреть файл

@ -288,7 +288,6 @@ struct FormatInfo {
//////////////////////////////////////////////////////////////////////////////////////////
const FormatInfo* FindSizedFormat(GLenum sizedFormat);
const FormatInfo* GetFormat(EffectiveFormat format);
uint8_t BytesPerPixel(const PackingInfo& packing);
bool GetBytesPerPixel(const PackingInfo& packing, uint8_t* const out_bytes);

Просмотреть файл

@ -739,11 +739,6 @@ class RawBuffer final {
const auto& begin() const { return mBegin; }
const auto& size() const { return mLen; }
void Shrink(const size_t newLen) {
if (mLen <= newLen) return;
mLen = newLen;
}
RawBuffer() = default;
RawBuffer(const RawBuffer&) = delete;
@ -939,31 +934,6 @@ struct WebGLPixelStore final {
return ret;
}
CheckedInt<size_t> UsedPixelsPerRow(const uvec3& size) const {
return CheckedInt<size_t>(mUnpackSkipPixels) + size.x;
}
CheckedInt<size_t> FullRowsNeeded(const uvec3& size) const {
if (!size.x || !size.y || !size.z) return 0;
// The spec doesn't bound SKIP_ROWS + height <= IMAGE_HEIGHT, unfortunately.
auto skipFullRows =
CheckedInt<size_t>(mUnpackSkipImages) * mUnpackImageHeight;
skipFullRows += mUnpackSkipRows;
// Full rows in the final image, excluding the tail.
auto usedFullRows = CheckedInt<size_t>(size.z - 1) * mUnpackImageHeight;
usedFullRows += size.y - 1;
return skipFullRows + usedFullRows;
}
CheckedInt<size_t> UsedPixels(const uvec3& size) const {
auto pixels = FullRowsNeeded(size) * mUnpackRowLength;
pixels += UsedPixelsPerRow(size);
return pixels;
}
};
struct TexImageData final {
@ -990,8 +960,6 @@ struct TexUnpackBlobDesc final {
RefPtr<gfx::DataSourceSurface> surf;
WebGLPixelStore unpacking;
void Shrink(const webgl::PackingInfo&);
};
} // namespace webgl