Backed out changeset 45887183c584 (bug 1715690) for causing failures at SanitizeRenderer. CLOSED TREE

This commit is contained in:
Butkovits Atila 2021-06-12 04:12:18 +03:00
Родитель b9038da640
Коммит c5dac06788
9 изменённых файлов: 114 добавлений и 477 удалений

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

@ -11,6 +11,7 @@
#include "HostWebGLContext.h"
#include "js/ScalarType.h" // js::Scalar::Type
#include "mozilla/dom/Document.h"
#include "mozilla/dom/SanitizeRenderer.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/WebGLContextEvent.h"
#include "mozilla/dom/WorkerCommon.h"
@ -36,12 +37,6 @@
namespace mozilla {
namespace webgl {
std::string SanitizeRenderer(const std::string&);
} // namespace webgl
// -
webgl::NotLostData::NotLostData(ClientWebGLContext& _context)
: context(_context) {}
@ -1877,12 +1872,10 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
return;
// 2 ints
case LOCAL_GL_MAX_VIEWPORT_DIMS: {
const auto dims =
std::array<uint32_t, 2>{limits.maxViewportDim, limits.maxViewportDim};
retval.set(CreateAs<dom::Int32Array, const int32_t*>(cx, this, dims, rv));
case LOCAL_GL_MAX_VIEWPORT_DIMS:
retval.set(CreateAs<dom::Int32Array, const int32_t*>(
cx, this, limits.maxViewportDims, rv));
return;
}
// 4 ints
case LOCAL_GL_SCISSOR_BOX:
@ -1969,8 +1962,7 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
return;
case LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
retval.set(
JS::NumberValue(webgl::kMaxTransformFeedbackSeparateAttribs));
retval.set(JS::NumberValue(limits.maxTransformFeedbackSeparateAttribs));
return;
case LOCAL_GL_MAX_UNIFORM_BUFFER_BINDINGS:
retval.set(JS::NumberValue(limits.maxUniformBufferBindings));
@ -2071,11 +2063,9 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
const auto maybe = GetString(driverEnum);
if (maybe) {
std::string str = *maybe;
if (driverEnum == LOCAL_GL_RENDERER) {
str = webgl::SanitizeRenderer(str);
}
retval.set(StringValue(cx, str, rv));
std::string renderer = *maybe;
mozilla::dom::SanitizeRenderer(renderer);
retval.set(StringValue(cx, renderer, rv));
}
return;
}
@ -2891,11 +2881,11 @@ Maybe<webgl::ErrorInfo> CheckBindBufferRange(
switch (target) {
case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER:
if (index >= webgl::kMaxTransformFeedbackSeparateAttribs) {
if (index >= limits.maxTransformFeedbackSeparateAttribs) {
const auto info = nsPrintfCString(
"`index` (%u) must be less than "
"MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS (%u).",
index, webgl::kMaxTransformFeedbackSeparateAttribs);
index, limits.maxTransformFeedbackSeparateAttribs);
return fnSome(LOCAL_GL_INVALID_VALUE, info);
}
@ -6118,7 +6108,7 @@ WebGLShaderJS::WebGLShaderJS(const ClientWebGLContext& webgl, const GLenum type)
WebGLTransformFeedbackJS::WebGLTransformFeedbackJS(
const ClientWebGLContext& webgl)
: webgl::ObjectJS(webgl),
mAttribBuffers(webgl::kMaxTransformFeedbackSeparateAttribs) {}
mAttribBuffers(webgl.Limits().maxTransformFeedbackSeparateAttribs) {}
WebGLVertexArrayJS::WebGLVertexArrayJS(const ClientWebGLContext& webgl)
: webgl::ObjectJS(webgl), mAttribBuffers(webgl.Limits().maxVertexAttribs) {}

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

@ -1,298 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/gfx/Logging.h"
#include "mozilla/IntegerRange.h"
#include <regex>
#include <string>
namespace mozilla {
namespace webgl {
static bool Contains(const std::string& str, const std::string& part) {
return str.find(str) != size_t(-1);
}
/**
* Narrow renderer string space down to representative replacements.
* E.g. "GeForce RTX 3090" => "GeForce GTX 980"
*
* For example strings:
* https://hackmd.io/Ductv3pQTMej74gbveD4yw
*/
static std::string ChooseDeviceReplacement(const std::string& str) {
if (str.find("llvmpipe") == 0) return "llvmpipe";
if (str.find("Apple") == 0) return "Apple M1";
std::smatch m;
// -
if (Contains(str, "FirePro") || Contains(str, "Radeon")) {
static const std::string RADEON_HD_3000 = "Radeon HD 3200 Graphics";
static const std::string RADEON_HD_5850 = "Radeon HD 5850";
static const std::string RADEON_R9_290 = "Radeon R9 200 Series";
const auto RADEON_D3D_FL10_1 = RADEON_HD_3000;
const auto RADEON_GCN_GEN2 = RADEON_R9_290; // GCN Gen2
if (Contains(str, "Vega")) {
return RADEON_R9_290;
}
if (Contains(str, "VII")) {
return RADEON_R9_290;
}
if (Contains(str, "Fury")) {
return RADEON_R9_290;
}
static const std::regex kRadeon(
"Radeon.*?((R[579X]|HD) )?([0-9][0-9][0-9]+)");
if (std::regex_search(str, m, kRadeon)) {
const auto& rxOrHd = m.str(2);
const auto modelNum = stoul(m.str(3));
if (rxOrHd == "HD") {
if (modelNum >= 5000) {
return RADEON_HD_5850;
}
if (modelNum >= 3000) {
return RADEON_HD_3000; // FL10_1
}
// HD 2000 is FL10_0, but webgl2 needs 10_1, so claim "old".
return RADEON_D3D_FL10_1;
}
// R5/7/9/X
return RADEON_R9_290;
}
static const std::regex kFirePro("FirePro.*?([VDW])[0-9][0-9][0-9]+");
if (std::regex_search(str, m, kFirePro)) {
const auto& vdw = m.str(1);
if (vdw == "V") {
return RADEON_HD_3000; // FL10_1
}
return RADEON_R9_290;
}
return RADEON_D3D_FL10_1;
}
// -
static const std::string GEFORCE_8800 = "GeForce 8800 GTX";
static const std::string GEFORCE_480 = "GeForce GTX 480";
static const std::string GEFORCE_980 = "GeForce GTX 980";
if (Contains(str, "GeForce") || Contains(str, "Quadro")) {
static const std::regex kGeForce("GeForce.*?([0-9][0-9][0-9]+)");
if (std::regex_search(str, m, kGeForce)) {
const auto modelNum = stoul(m.str(1));
if (modelNum >= 8000) {
// Tesla+: D3D10.0, SM4.0
return GEFORCE_8800;
}
if (modelNum >= 900) {
// Maxwell Gen2+: D3D12 FL12_1
return GEFORCE_980;
}
if (modelNum >= 400) {
// Fermi+: D3D12 FL11_0
return GEFORCE_480;
}
// Tesla+: D3D10.0, SM4.0
return GEFORCE_8800;
}
static const std::regex kQuadro("Quadro.*?([KMPVT]?)[0-9][0-9][0-9]+");
if (std::regex_search(str, m, kQuadro)) {
if (Contains(str, "RTX")) return GEFORCE_980;
const auto archLetter = m.str(1);
if (archLetter.size()) {
switch (archLetter[0]) {
case 'M': // Maxwell
case 'P': // Pascal
case 'V': // Volta
case 'T': // Turing, mobile-only
return GEFORCE_980;
case 'K': // Kepler
default:
return GEFORCE_480;
}
}
return GEFORCE_8800; // Close enough.
}
}
/* Similarities for Titans:
* 780
* * GeForce GTX TITAN
* * -
* * Black
* * Z
* 980
* * GeForce GTX TITAN X
* 1080
* * Nvidia TITAN X
* * Nvidia TITAN Xp
* * Nvidia TITAN V
* 2080
* * Nvidia TITAN RTX
*/
static const std::regex kTitan("TITAN( [BZXVR])?");
if (std::regex_search(str, m, kTitan)) {
char letter = ' ';
const auto sub = m.str(1);
if (sub.length()) {
letter = sub[1];
}
switch (letter) {
case ' ':
case 'B':
case 'Z':
return GEFORCE_480;
default:
return GEFORCE_980;
}
}
static const std::regex kNouveau("NV(1?[0-9A-F][0-9A-F])");
if (std::regex_match(str, m, kNouveau)) {
const auto modelNum = stoul(m.str(1), nullptr, 16);
// https://nouveau.freedesktop.org/CodeNames.html#NV110
if (modelNum >= 0x120) return GEFORCE_980;
if (modelNum >= 0xC0) return GEFORCE_480;
return GEFORCE_8800;
}
// -
if (Contains(str, "Intel")) {
static const std::string HD_GRAPHICS = "Intel(R) HD Graphics";
static const std::string HD_GRAPHICS_400 = "Intel(R) HD Graphics 400";
static const std::string INTEL_945GM = "Intel 945GM";
static const std::regex kIntelHD("Intel.*Graphics( P?([0-9][0-9][0-9]+))?");
if (std::regex_search(str, m, kIntelHD)) {
if (!m.str(1).size()) {
return HD_GRAPHICS;
}
const auto modelNum = stoul(m.str(2));
if (modelNum >= 5000) {
return HD_GRAPHICS_400;
}
if (modelNum >= 1000) {
return HD_GRAPHICS;
}
return HD_GRAPHICS_400;
}
return INTEL_945GM;
}
// -
static const std::regex kAdreno("Adreno.*?([0-9][0-9][0-9]+)");
if (std::regex_search(str, m, kAdreno)) {
const auto modelNum = stoul(m.str(1));
if (modelNum >= 600) {
return "Adreno (TM) 650";
}
if (modelNum >= 500) {
return "Adreno (TM) 540";
}
if (modelNum >= 400) {
return "Adreno (TM) 430";
}
if (modelNum >= 300) {
return "Adreno (TM) 330";
}
return "Adreno (TM) 225";
}
static const std::regex kMali("Mali.*?([0-9][0-9]+)");
if (std::regex_search(str, m, kMali)) {
const auto modelNum = stoul(m.str(1));
if (modelNum >= 800) {
return "Mali-T880";
}
if (modelNum >= 700) {
return "Mali-T760";
}
if (modelNum >= 600) {
return "Mali-T628";
}
if (modelNum >= 400) {
return "Mali-400 MP";
}
return "Mali-G51";
}
if (Contains(str, "PowerVR")) {
if (Contains(str, "Rogue")) {
return "PowerVR Rogue G6200";
}
return "PowerVR SGX 540";
}
if (Contains(str, "Vivante")) return "Vivante GC1000";
if (Contains(str, "VideoCore")) return "VideoCore IV HW";
if (Contains(str, "Tegra")) return "NVIDIA Tegra";
// -
static const std::string D3D_WARP = "Microsoft Basic Render Driver";
if (Contains(str, D3D_WARP)) return str;
gfxCriticalNote << "Couldn't sanitize RENDERER device: " << str;
return "Generic Renderer";
}
// -
std::string SanitizeRenderer(const std::string& str) {
std::smatch m;
static const std::regex kReAngle("(.*ANGLE [(])(.*)( Direct3D.*)");
if (std::regex_match(str, m, kReAngle)) {
auto prefix = m.str(1);
auto dev = m.str(2);
// ANGLE seems to do this:
// "GeForce RTX 3070..." => ANGLE (NVIDIA GeForce RTX 3070..."
static const std::regex kStripAngleVendorPrefix("(NVIDIA) (.*)");
std::smatch m2;
if (std::regex_match(dev, m2, kStripAngleVendorPrefix)) {
prefix += m2.str(1) + " ";
dev = m2.str(2);
}
const auto dev2 = ChooseDeviceReplacement(dev);
return prefix + dev2 + m.str(3);
}
static const std::regex kReOpenglEngine("(.*) OpenGL Engine");
static const std::regex kRePcieSse2("(.*)(/PCIe?/SSE2)");
static const std::regex kReStandard("(.*)( [(].*[)])");
if (std::regex_match(str, m, kReOpenglEngine)) {
const auto& dev = m.str(1);
const auto dev2 = ChooseDeviceReplacement(dev);
return dev2;
}
if (std::regex_match(str, m, kRePcieSse2)) {
const auto& dev = m.str(1);
const auto dev2 = ChooseDeviceReplacement(dev);
return dev2 + m.str(2);
}
if (std::regex_match(str, m, kReStandard)) {
const auto& dev = m.str(1);
const auto dev2 = ChooseDeviceReplacement(dev);
return dev2;
}
const auto& dev = str;
const auto dev2 = ChooseDeviceReplacement(dev);
return dev2;
}
}; // namespace webgl
}; // namespace mozilla

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

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_RendererSanitizer_h
#define mozilla_RendererSanitizer_h
#include <string>
namespace mozilla {
namespace dom {
inline static void SanitizeRenderer(std::string& aRenderer) {
// Remove DRM, kernel, and LLVM versions exposed by amdgpu.
// The string looks like this:
//
// AMD Radeon (TM) GPU model Graphics (GPUgeneration, DRM
// DRMversion, kernelversion, LLVM LLVMversion)
//
// e.g. AMD Radeon (TM) RX 460 Graphics (POLARIS11,
// DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)
//
// OR
//
// AMD Radeon GPU model (GPUgeneration, DRM DRMversion, kernelversion, LLVM
// LLVMversion)
//
// Just in case, let's handle the case without GPUgeneration, i.e.
//
// AMD Radeon GPU model (DRM DRMversion, kernelversion, LLVM LLVMversion)
//
// even though there's no existence proof of this variant.
if (aRenderer.empty()) {
return;
}
if (aRenderer.back() != ')') {
return;
}
auto pos = aRenderer.find(", DRM ");
if (pos != std::string::npos) {
aRenderer.resize(pos);
aRenderer.push_back(')');
return;
}
pos = aRenderer.find(" (DRM ");
if (pos != std::string::npos) {
aRenderer.resize(pos);
return;
}
}
}; // namespace dom
}; // namespace mozilla
#endif // mozilla_RendererSanitizer_h

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

@ -1437,8 +1437,8 @@ void WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
}
const auto& limits = Limits();
width = std::min(width, static_cast<GLsizei>(limits.maxViewportDim));
height = std::min(height, static_cast<GLsizei>(limits.maxViewportDim));
width = std::min(width, static_cast<GLsizei>(limits.maxViewportDims[0]));
height = std::min(height, static_cast<GLsizei>(limits.maxViewportDims[1]));
gl->fViewport(x, y, width, height);

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

@ -184,15 +184,13 @@ bool WebGLContext::ValidateAttribArraySetter(uint32_t setterElemSize,
static webgl::Limits MakeLimits(const WebGLContext& webgl) {
webgl::Limits limits;
gl::GLContext& gl = *webgl.GL();
// -
for (const auto i : IntegerRange(UnderlyingValue(WebGLExtensionID::Max))) {
const auto ext = WebGLExtensionID(i);
limits.supportedExtensions[ext] = webgl.IsExtensionSupported(ext);
}
gl::GLContext& gl = *webgl.GL();
// -
// WebGL 1
@ -205,10 +203,7 @@ static webgl::Limits MakeLimits(const WebGLContext& webgl) {
gl.GetUIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &limits.maxTex2dSize);
gl.GetUIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &limits.maxTexCubeSize);
gl.GetUIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &limits.maxVertexAttribs);
auto dims = std::array<uint32_t, 2>{};
gl.GetUIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, dims.data());
limits.maxViewportDim = std::min(dims[0], dims[1]);
gl.GetUIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, limits.maxViewportDims.data());
if (!gl.IsCoreProfile()) {
gl.fGetFloatv(LOCAL_GL_ALIASED_LINE_WIDTH_RANGE,
@ -226,6 +221,8 @@ static webgl::Limits MakeLimits(const WebGLContext& webgl) {
gl.GetUIntegerv(LOCAL_GL_MAX_ARRAY_TEXTURE_LAYERS,
&limits.maxTexArrayLayers);
gl.GetUIntegerv(LOCAL_GL_MAX_3D_TEXTURE_SIZE, &limits.maxTex3dSize);
gl.GetUIntegerv(LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
&limits.maxTransformFeedbackSeparateAttribs);
gl.GetUIntegerv(LOCAL_GL_MAX_UNIFORM_BUFFER_BINDINGS,
&limits.maxUniformBufferBindings);
gl.GetUIntegerv(LOCAL_GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
@ -495,7 +492,8 @@ bool WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) {
RestrictCap(&limits.lineWidthRange[1], kCommonAliasedLineWidthRangeMax);
ok &=
RestrictCap(&limits.pointSizeRange[1], kCommonAliasedPointSizeRangeMax);
ok &= RestrictCap(&limits.maxViewportDim, kCommonMaxViewportDims);
ok &= RestrictCap(&limits.maxViewportDims[0], kCommonMaxViewportDims);
ok &= RestrictCap(&limits.maxViewportDims[1], kCommonMaxViewportDims);
if (!ok) {
GenerateWarning(

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

@ -17,7 +17,7 @@ namespace mozilla {
WebGLTransformFeedback::WebGLTransformFeedback(WebGLContext* webgl, GLuint tf)
: WebGLContextBoundObject(webgl),
mGLName(tf),
mIndexedBindings(webgl::kMaxTransformFeedbackSeparateAttribs),
mIndexedBindings(webgl->Limits().maxTransformFeedbackSeparateAttribs),
mIsPaused(false),
mIsActive(false) {}

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

@ -601,8 +601,6 @@ struct InitContextDesc final {
uint32_t principalKey = 0;
};
constexpr uint32_t kMaxTransformFeedbackSeparateAttribs = 4;
struct Limits final {
ExtensionBits supportedExtensions;
@ -611,13 +609,14 @@ struct Limits final {
uint32_t maxTex2dSize = 0;
uint32_t maxTexCubeSize = 0;
uint32_t maxVertexAttribs = 0;
uint32_t maxViewportDim = 0;
std::array<uint32_t, 2> maxViewportDims = {};
std::array<float, 2> pointSizeRange = {{1, 1}};
std::array<float, 2> lineWidthRange = {{1, 1}};
// WebGL 2
uint32_t maxTexArrayLayers = 0;
uint32_t maxTex3dSize = 0;
uint32_t maxTransformFeedbackSeparateAttribs = 0;
uint32_t maxUniformBufferBindings = 0;
uint32_t uniformBufferOffsetAlignment = 0;

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

@ -4,164 +4,56 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gtest/gtest.h"
#include "mozilla/dom/SanitizeRenderer.h"
namespace mozilla {
namespace webgl {
std::string SanitizeRenderer(const std::string&);
} // namespace webgl
} // namespace mozilla
TEST(SanitizeRenderer, TestLinuxRadeon)
TEST(SanitizeRenderer, TestRadeonTM)
{
const std::string renderer(
"AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
const std::string expectation("Radeon R9 200 Series");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinuxRadeonTM)
{
const std::string renderer(
std::string renderer(
"AMD Radeon (TM) RX 460 Graphics (POLARIS11, DRM 3.35.0, "
"5.4.0-65-generic, LLVM 11.0.0)");
const std::string expectation("Radeon R9 200 Series");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
std::string expectation("AMD Radeon (TM) RX 460 Graphics (POLARIS11)");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}
TEST(SanitizeRenderer, TestLinuxRadeonWithoutGeneration)
TEST(SanitizeRenderer, TestRadeon)
{
const std::string renderer(
std::string renderer(
"AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
std::string expectation("AMD Radeon RX 5700 (NAVI10)");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}
TEST(SanitizeRenderer, TestRadeonWithoutGeneration)
{
std::string renderer(
"AMD Radeon RX 5700 (DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)");
const std::string expectation("Radeon R9 200 Series");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
std::string expectation("AMD Radeon RX 5700");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}
TEST(SanitizeRenderer, TestWindowsVega)
TEST(SanitizeRenderer, TestVega)
{
const std::string renderer("Radeon RX Vega");
const std::string expectation("Radeon R9 200 Series");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
std::string renderer("Radeon RX Vega");
std::string expectation("Radeon RX Vega");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}
TEST(SanitizeRenderer, TestMacAmd)
TEST(SanitizeRenderer, TestIntel)
{
const std::string renderer("AMD Radeon Pro 5300M OpenGL Engine");
const std::string expectation("Radeon R9 200 Series");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinuxIntel620)
{
const std::string renderer("Mesa Intel(R) UHD Graphics 620 (KBL GT2)");
const std::string expectation("Intel(R) HD Graphics 400");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinuxIntel4000)
{
const std::string renderer("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)");
const std::string expectation("Intel(R) HD Graphics");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestMacIntel)
{
const std::string renderer("Intel(R) HD Graphics 530");
const std::string expectation("Intel(R) HD Graphics 400");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestMacApple)
{
const std::string renderer("Apple M1");
const std::string expectation("Apple M1");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
std::string renderer("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)");
std::string expectation("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}
TEST(SanitizeRenderer, TestPipe)
{
const std::string renderer("llvmpipe (LLVM 11.0.0, 128 bits)");
const std::string expectation("llvmpipe");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
// -
TEST(SanitizeRenderer, TestAngleVega)
{
const std::string renderer("ANGLE (Radeon RX Vega Direct3D11 vs_5_0 ps_5_0)");
const std::string expectation(
"ANGLE (Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0)");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestAngleWarp)
{
const std::string renderer(
"ANGLE (Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0)");
const std::string expectation = renderer;
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestAngle3070)
{
const std::string renderer(
"ANGLE (NVIDIA GeForce RTX 3070 Direct3D11 vs_5_0 ps_5_0)");
const std::string expectation(
"ANGLE (NVIDIA GeForce GTX 980 Direct3D11 vs_5_0 ps_5_0)");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestWindows3070)
{
const std::string renderer("GeForce RTX 3070/PCIe/SSE2");
const std::string expectation("GeForce GTX 980/PCIe/SSE2");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestAngleK600)
{
const std::string renderer(
"ANGLE (NVIDIA Quadro K600 Direct3D11 vs_5_0 ps_5_0)");
const std::string expectation(
"ANGLE (NVIDIA GeForce GTX 480 Direct3D11 vs_5_0 ps_5_0)");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinuxK600)
{
const std::string renderer("NVE7");
const std::string expectation("GeForce GTX 480");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestLinux980)
{
const std::string renderer("NV124");
const std::string expectation("GeForce GTX 980");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
}
TEST(SanitizeRenderer, TestAdreno512)
{
const std::string renderer("Adreno (TM) 512");
const std::string expectation("Adreno (TM) 540");
const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer);
EXPECT_EQ(sanitized, expectation);
std::string renderer("llvmpipe (LLVM 11.0.0, 256 bits)");
std::string expectation("llvmpipe (LLVM 11.0.0, 256 bits)");
mozilla::dom::SanitizeRenderer(renderer);
EXPECT_EQ(renderer, expectation);
}

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

@ -62,6 +62,7 @@ EXPORTS.mozilla.dom += [
"IpdlQueue.h",
"OffscreenCanvas.h",
"QueueParamTraits.h",
"SanitizeRenderer.h",
"TextMetrics.h",
"WebGLChild.h",
"WebGLCommandQueue.h",
@ -98,7 +99,6 @@ UNIFIED_SOURCES += [
"ClientWebGLContext.cpp",
"ClientWebGLExtensions.cpp",
"HostWebGLContext.cpp",
"SanitizeRenderer.cpp",
"TexUnpackBlob.cpp",
"WebGL2Context.cpp",
"WebGL2ContextBuffers.cpp",