Skip to content

Commit

Permalink
Revert of Cleanup: Remove unneeded SSE2 checks and unused code. (patc…
Browse files Browse the repository at this point in the history
…hset #4 of https://codereview.chromium.org/459603003/)

Reason for revert:
Passed the win x64 trybot, but failed on the win 64 builder.

Original issue's description:
> Cleanup: Remove unneeded SSE2 checks and unused code.
>
> BUG=349320
>
> Committed: https://chromium.googlesource.com/chromium/src/+/b2cd99b39c3744f61231f8818f6c7a3d2881f0f0

TBR=cpu@chromium.org,dalecurtis@chromium.org,senorblanco@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=349320

Review URL: https://codereview.chromium.org/513663002

Cr-Commit-Position: refs/heads/master@{#292101}
  • Loading branch information
leizleiz authored and Commit bot committed Aug 27, 2014
1 parent 17e71b7 commit 5523449
Show file tree
Hide file tree
Showing 16 changed files with 342 additions and 25 deletions.
6 changes: 6 additions & 0 deletions chrome/app/chromium_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ be available for now. -->
This computer will no longer receive Chromium updates because its hardware is no longer supported.
</message>
</if>
<if expr="is_win">
<!-- Windows non-SSE2 deprecation -->
<message name="IDS_WIN_SSE_OBSOLETE_NOW" desc="A message displayed on an at-launch infobar and About (Help) page warning the user that the computer they are using is no longer supported.">
This computer will no longer receive Chromium updates because its hardware is no longer supported.
</message>
</if>
<message name="IDS_ACCNAME_APP" desc="The accessible name for the app menu.">
Chromium
</message>
Expand Down
6 changes: 6 additions & 0 deletions chrome/app/google_chrome_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ Chrome supports. -->
This computer will no longer receive Google Chrome updates because its hardware is no longer supported.
</message>
</if>
<if expr="is_win">
<!-- Windows non-SSE2 deprecation -->
<message name="IDS_WIN_SSE_OBSOLETE_NOW" desc="A message displayed on an at-launch infobar and About (Help) page warning the user that the computer they are using is no longer supported.">
This computer will no longer receive Google Chrome updates because its hardware is no longer supported.
</message>
</if>
<message name="IDS_ACCNAME_APP" desc="The accessible name for the app menu.">
Chrome
</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/cpu.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
Expand Down Expand Up @@ -248,6 +249,10 @@ void RegisterSwiftShaderPath(ComponentUpdateService* cus) {

void RegisterSwiftShaderComponent(ComponentUpdateService* cus) {
#if defined(ENABLE_SWIFTSHADER)
base::CPU cpu;

if (!cpu.has_sse2())
return;
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
base::Bind(&RegisterSwiftShaderPath, cus));
Expand Down
12 changes: 10 additions & 2 deletions chrome/browser/ui/startup/obsolete_system_infobar_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h"

#include "base/cpu.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
Expand All @@ -23,12 +24,17 @@ void ObsoleteSystemInfoBarDelegate::Create(InfoBarService* infobar_service) {
!ObsoleteSystemMac::Has32BitOnlyCPU()) {
return;
}
infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(new ObsoleteSystemInfoBarDelegate())));
#elif defined(OS_WIN)
// On Windows we no longer support non-SSE2 machines since Chrome 35.
if (base::CPU().has_sse2())
return;
#else
// No other platforms currently show this infobar.
return;
#endif

infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(new ObsoleteSystemInfoBarDelegate())));
}

ObsoleteSystemInfoBarDelegate::ObsoleteSystemInfoBarDelegate()
Expand All @@ -41,6 +47,8 @@ ObsoleteSystemInfoBarDelegate::~ObsoleteSystemInfoBarDelegate() {
base::string16 ObsoleteSystemInfoBarDelegate::GetMessageText() const {
#if defined(OS_MACOSX)
return ObsoleteSystemMac::LocalizedObsoleteSystemString();
#elif defined(OS_WIN)
return l10n_util::GetStringUTF16(IDS_WIN_SSE_OBSOLETE_NOW);
#else
return l10n_util::GetStringUTF16(IDS_SYSTEM_OBSOLETE_MESSAGE);
#endif
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/upgrade_detector_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/build_time.h"
#include "base/command_line.h"
#include "base/cpu.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
Expand Down Expand Up @@ -403,6 +404,11 @@ bool UpgradeDetectorImpl::DetectOutdatedInstall() {
// Don't show the update bubbles to enterprise users (i.e., on a domain).
if (base::win::IsEnrolledToDomain())
return false;

// On Windows, we don't want to warn about outdated installs when the
// machine doesn't support SSE2, it's been deprecated starting with M35.
if (!base::CPU().has_sse2())
return false;
#endif
}

Expand Down
11 changes: 9 additions & 2 deletions chrome/common/chrome_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chrome/common/chrome_content_client.h"

#include "base/command_line.h"
#include "base/cpu.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
Expand Down Expand Up @@ -73,9 +74,9 @@ const char kPDFPluginMimeType[] = "application/pdf";
const char kPDFPluginExtension[] = "pdf";
const char kPDFPluginDescription[] = "Portable Document Format";
const char kPDFPluginPrintPreviewMimeType[] =
"application/x-google-chrome-print-preview-pdf";
"application/x-google-chrome-print-preview-pdf";
const char kPDFPluginOutOfProcessMimeType[] =
"application/x-google-chrome-pdf";
"application/x-google-chrome-pdf";
const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_DEV;

Expand Down Expand Up @@ -395,6 +396,12 @@ bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
if (force_disable)
return false;

// For Linux ia32, Flapper requires SSE2.
#if defined(OS_LINUX) && defined(ARCH_CPU_X86)
if (!base::CPU().has_sse2())
return false;
#endif // ARCH_CPU_X86

base::FilePath flash_path;
if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
return false;
Expand Down
1 change: 1 addition & 0 deletions media/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ if (cpu_arch == "x86" || cpu_arch == "x64") {
yasm_assemble("media_yasm") {
sources = [
"simd/convert_rgb_to_yuv_ssse3.asm",
"simd/convert_yuv_to_rgb_mmx.asm",
"simd/convert_yuv_to_rgb_sse.asm",
"simd/convert_yuva_to_argb_mmx.asm",
"simd/empty_register_state_mmx.asm",
Expand Down
35 changes: 35 additions & 0 deletions media/base/simd/convert_yuv_to_rgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ MEDIA_EXPORT void ConvertYUVToRGB32_SSE(const uint8* yplane,
int rgbstride,
YUVType yuv_type);

MEDIA_EXPORT void ConvertYUVToRGB32_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
int width,
int height,
int ystride,
int uvstride,
int rgbstride,
YUVType yuv_type);

MEDIA_EXPORT void ConvertYUVAToARGB_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
Expand Down Expand Up @@ -115,6 +126,13 @@ extern "C" {
// issue on at least Win64. The C-equivalent RowProc versions' prototypes
// include the same change to ptrdiff_t to reuse the typedefs.

MEDIA_EXPORT void ConvertYUVToRGB32Row_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
ptrdiff_t width,
const int16 convert_table[1024][4]);

MEDIA_EXPORT void ConvertYUVAToARGBRow_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
Expand All @@ -130,6 +148,14 @@ MEDIA_EXPORT void ConvertYUVToRGB32Row_SSE(const uint8* yplane,
ptrdiff_t width,
const int16 convert_table[1024][4]);

MEDIA_EXPORT void ScaleYUVToRGB32Row_MMX(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
ptrdiff_t width,
ptrdiff_t source_dx,
const int16 convert_table[1024][4]);

MEDIA_EXPORT void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
Expand All @@ -147,6 +173,15 @@ MEDIA_EXPORT void ScaleYUVToRGB32Row_SSE2_X64(
ptrdiff_t source_dx,
const int16 convert_table[1024][4]);

MEDIA_EXPORT void LinearScaleYUVToRGB32Row_MMX(
const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
ptrdiff_t width,
ptrdiff_t source_dx,
const int16 convert_table[1024][4]);

MEDIA_EXPORT void LinearScaleYUVToRGB32Row_SSE(
const uint8* y_buf,
const uint8* u_buf,
Expand Down
23 changes: 23 additions & 0 deletions media/base/simd/convert_yuv_to_rgb_mmx.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Copyright (c) 2011 The Chromium Authors. All rights reserved.
; Use of this source code is governed by a BSD-style license that can be
; found in the LICENSE file.

%include "third_party/x86inc/x86inc.asm"

;
; This file uses MMX instructions.
;
SECTION_TEXT
CPU MMX

; Use movq to save the output.
%define MOVQ movq

; extern "C" void ConvertYUVToRGB32Row_MMX(const uint8* y_buf,
; const uint8* u_buf,
; const uint8* v_buf,
; uint8* rgb_buf,
; ptrdiff_t width,
; const int16 convert_table[1024][4]);
%define SYMBOL ConvertYUVToRGB32Row_MMX
%include "convert_yuv_to_rgb_mmx.inc"
28 changes: 28 additions & 0 deletions media/base/simd/convert_yuv_to_rgb_x86.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@

namespace media {

void ConvertYUVToRGB32_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
uint8* rgbframe,
int width,
int height,
int ystride,
int uvstride,
int rgbstride,
YUVType yuv_type) {
unsigned int y_shift = GetVerticalShift(yuv_type);
for (int y = 0; y < height; ++y) {
uint8* rgb_row = rgbframe + y * rgbstride;
const uint8* y_ptr = yplane + y * ystride;
const uint8* u_ptr = uplane + (y >> y_shift) * uvstride;
const uint8* v_ptr = vplane + (y >> y_shift) * uvstride;

ConvertYUVToRGB32Row_MMX(y_ptr,
u_ptr,
v_ptr,
rgb_row,
width,
GetLookupTable(yuv_type));
}

EmptyRegisterState();
}

void ConvertYUVAToARGB_MMX(const uint8* yplane,
const uint8* uplane,
const uint8* vplane,
Expand Down
43 changes: 26 additions & 17 deletions media/base/yuv_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,42 @@ void InitializeCPUSpecificYUVConversions() {
// Assembly code confuses MemorySanitizer.
#if defined(ARCH_CPU_X86_FAMILY) && !defined(MEMORY_SANITIZER)
base::CPU cpu;

g_convert_yuva_to_argb_proc_ = ConvertYUVAToARGB_MMX;
if (cpu.has_mmx()) {
g_convert_yuv_to_rgb32_row_proc_ = ConvertYUVToRGB32Row_MMX;
g_scale_yuv_to_rgb32_row_proc_ = ScaleYUVToRGB32Row_MMX;
g_convert_yuv_to_rgb32_proc_ = ConvertYUVToRGB32_MMX;
g_convert_yuva_to_argb_proc_ = ConvertYUVAToARGB_MMX;
g_linear_scale_yuv_to_rgb32_row_proc_ = LinearScaleYUVToRGB32Row_MMX;

#if defined(MEDIA_MMX_INTRINSICS_AVAILABLE)
g_filter_yuv_rows_proc_ = FilterYUVRows_MMX;
g_empty_register_state_proc_ = EmptyRegisterStateIntrinsic;
g_filter_yuv_rows_proc_ = FilterYUVRows_MMX;
g_empty_register_state_proc_ = EmptyRegisterStateIntrinsic;
#else
g_empty_register_state_proc_ = EmptyRegisterState_MMX;
g_empty_register_state_proc_ = EmptyRegisterState_MMX;
#endif
}

g_convert_yuv_to_rgb32_row_proc_ = ConvertYUVToRGB32Row_SSE;
g_scale_yuv_to_rgb32_row_proc_ = ScaleYUVToRGB32Row_SSE;
g_linear_scale_yuv_to_rgb32_row_proc_ = LinearScaleYUVToRGB32Row_SSE;
g_convert_yuv_to_rgb32_proc_ = ConvertYUVToRGB32_SSE;
if (cpu.has_sse()) {
g_convert_yuv_to_rgb32_row_proc_ = ConvertYUVToRGB32Row_SSE;
g_scale_yuv_to_rgb32_row_proc_ = ScaleYUVToRGB32Row_SSE;
g_linear_scale_yuv_to_rgb32_row_proc_ = LinearScaleYUVToRGB32Row_SSE;
g_convert_yuv_to_rgb32_proc_ = ConvertYUVToRGB32_SSE;
}

g_filter_yuv_rows_proc_ = FilterYUVRows_SSE2;
g_convert_rgb32_to_yuv_proc_ = ConvertRGB32ToYUV_SSE2;
if (cpu.has_sse2()) {
g_filter_yuv_rows_proc_ = FilterYUVRows_SSE2;
g_convert_rgb32_to_yuv_proc_ = ConvertRGB32ToYUV_SSE2;

#if defined(ARCH_CPU_X86_64)
g_scale_yuv_to_rgb32_row_proc_ = ScaleYUVToRGB32Row_SSE2_X64;
g_scale_yuv_to_rgb32_row_proc_ = ScaleYUVToRGB32Row_SSE2_X64;

// Technically this should be in the MMX section, but MSVC will optimize out
// the export of LinearScaleYUVToRGB32Row_MMX, which is required by the unit
// tests, if that decision can be made at compile time. Since all X64 CPUs
// have SSE2, we can hack around this by making the selection here.
g_linear_scale_yuv_to_rgb32_row_proc_ = LinearScaleYUVToRGB32Row_MMX_X64;
// Technically this should be in the MMX section, but MSVC will optimize out
// the export of LinearScaleYUVToRGB32Row_MMX, which is required by the unit
// tests, if that decision can be made at compile time. Since all X64 CPUs
// have SSE2, we can hack around this by making the selection here.
g_linear_scale_yuv_to_rgb32_row_proc_ = LinearScaleYUVToRGB32Row_MMX_X64;
#endif
}

if (cpu.has_ssse3()) {
g_convert_rgb24_to_yuv_proc_ = &ConvertRGB24ToYUV_SSSE3;
Expand Down
Loading

0 comments on commit 5523449

Please sign in to comment.