Commit c68cd914 authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Commit Bot

Expand GpuInfo to include image decode acceleration support.

This CL expands the GpuInfo structure to be able to convey information
about what image profiles the hardware supports for the purpose of image
decode acceleration.

The eventual plan is to fill-in this information in
GpuServiceImpl::UpdateGPUInfo(). On the client side,
ImageDecodeAcceleratorProxy will be able to use it through
GpuChannelHost::gpu_info() to determine what images can be sent to the
service for decoding.

Bug: 868400
Change-Id: I790a438c6c64ed418d0ac3bb9cfedd14286fe78f
Reviewed-on: https://chromium-review.googlesource.com/c/1471913
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632843}
parent b011f9b2
......@@ -90,6 +90,10 @@ class AuxGPUInfoEnumerator : public gpu::GPUInfo::Enumerator {
void EndVideoEncodeAcceleratorSupportedProfile() override {}
void BeginImageDecodeAcceleratorSupportedProfile() override {}
void EndImageDecodeAcceleratorSupportedProfile() override {}
void BeginOverlayCapability() override {}
void EndOverlayCapability() override {}
......
......@@ -50,6 +50,47 @@ void EnumerateVideoEncodeAcceleratorSupportedProfile(
enumerator->EndVideoEncodeAcceleratorSupportedProfile();
}
const char* ImageDecodeAcceleratorTypeToString(
gpu::ImageDecodeAcceleratorType type) {
switch (type) {
case gpu::ImageDecodeAcceleratorType::kJpeg:
return "JPEG";
case gpu::ImageDecodeAcceleratorType::kUnknown:
return "Unknown";
}
}
const char* ImageDecodeAcceleratorSubsamplingToString(
gpu::ImageDecodeAcceleratorSubsampling subsampling) {
switch (subsampling) {
case gpu::ImageDecodeAcceleratorSubsampling::k420:
return "4:2:0";
case gpu::ImageDecodeAcceleratorSubsampling::k422:
return "4:2:2";
}
}
void EnumerateImageDecodeAcceleratorSupportedProfile(
const gpu::ImageDecodeAcceleratorSupportedProfile& profile,
gpu::GPUInfo::Enumerator* enumerator) {
enumerator->BeginImageDecodeAcceleratorSupportedProfile();
enumerator->AddString("imageType",
ImageDecodeAcceleratorTypeToString(profile.image_type));
enumerator->AddString("minEncodedDimensions",
profile.min_encoded_dimensions.ToString());
enumerator->AddString("maxEncodedDimensions",
profile.max_encoded_dimensions.ToString());
std::string subsamplings;
for (size_t i = 0; i < profile.subsamplings.size(); i++) {
if (i > 0)
subsamplings += ", ";
subsamplings +=
ImageDecodeAcceleratorSubsamplingToString(profile.subsamplings[i]);
}
enumerator->AddString("subsamplings", subsamplings);
enumerator->EndImageDecodeAcceleratorSupportedProfile();
}
#if defined(OS_WIN)
void EnumerateOverlayCapability(const gpu::OverlayCapability& cap,
gpu::GPUInfo::Enumerator* enumerator) {
......@@ -104,6 +145,24 @@ VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities(
VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() =
default;
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile()
: image_type(ImageDecodeAcceleratorType::kUnknown) {}
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
const ImageDecodeAcceleratorSupportedProfile& other) = default;
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
ImageDecodeAcceleratorSupportedProfile&& other) = default;
ImageDecodeAcceleratorSupportedProfile::
~ImageDecodeAcceleratorSupportedProfile() = default;
ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile::
operator=(const ImageDecodeAcceleratorSupportedProfile& other) = default;
ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile::
operator=(ImageDecodeAcceleratorSupportedProfile&& other) = default;
GPUInfo::GPUDevice::GPUDevice()
: vendor_id(0),
device_id(0),
......@@ -201,10 +260,15 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
VideoEncodeAcceleratorSupportedProfiles
video_encode_accelerator_supported_profiles;
bool jpeg_decode_accelerator_supported;
ImageDecodeAcceleratorSupportedProfiles
image_decode_accelerator_supported_profiles;
#if defined(USE_X11)
VisualID system_visual;
VisualID rgba_visual;
#endif
bool oop_rasterization_supported;
};
......@@ -265,6 +329,8 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
enumerator->AddBool("jpegDecodeAcceleratorSupported",
jpeg_decode_accelerator_supported);
for (const auto& profile : image_decode_accelerator_supported_profiles)
EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator);
#if defined(USE_X11)
enumerator->AddInt64("systemVisual", system_visual);
enumerator->AddInt64("rgbaVisual", rgba_visual);
......
......@@ -113,6 +113,45 @@ struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile {
using VideoEncodeAcceleratorSupportedProfiles =
std::vector<VideoEncodeAcceleratorSupportedProfile>;
enum class ImageDecodeAcceleratorType {
kJpeg = 0,
kUnknown = 1,
kMaxValue = kUnknown,
};
enum class ImageDecodeAcceleratorSubsampling {
k420 = 0,
k422 = 1,
kMaxValue = k422,
};
// Specification of an image decoding profile supported by a hardware decoder.
struct GPU_EXPORT ImageDecodeAcceleratorSupportedProfile {
ImageDecodeAcceleratorSupportedProfile();
ImageDecodeAcceleratorSupportedProfile(
const ImageDecodeAcceleratorSupportedProfile& other);
ImageDecodeAcceleratorSupportedProfile(
ImageDecodeAcceleratorSupportedProfile&& other);
~ImageDecodeAcceleratorSupportedProfile();
ImageDecodeAcceleratorSupportedProfile& operator=(
const ImageDecodeAcceleratorSupportedProfile& other);
ImageDecodeAcceleratorSupportedProfile& operator=(
ImageDecodeAcceleratorSupportedProfile&& other);
// Fields common to all image types.
// Type of image to which this profile applies, e.g., JPEG.
ImageDecodeAcceleratorType image_type;
// Minimum and maximum supported pixel dimensions of the encoded image.
gfx::Size min_encoded_dimensions;
gfx::Size max_encoded_dimensions;
// Fields specific to |image_type| == kJpeg.
// The supported chroma subsampling formats, e.g. 4:2:0.
std::vector<ImageDecodeAcceleratorSubsampling> subsamplings;
};
using ImageDecodeAcceleratorSupportedProfiles =
std::vector<ImageDecodeAcceleratorSupportedProfile>;
#if defined(OS_WIN)
// Common overlay formats that we're interested in. Must match the OverlayFormat
// enum in //tools/metrics/histograms/enums.xml. Mapped to corresponding DXGI
......@@ -294,6 +333,9 @@ struct GPU_EXPORT GPUInfo {
video_encode_accelerator_supported_profiles;
bool jpeg_decode_accelerator_supported;
ImageDecodeAcceleratorSupportedProfiles
image_decode_accelerator_supported_profiles;
#if defined(USE_X11)
VisualID system_visual;
VisualID rgba_visual;
......@@ -335,6 +377,11 @@ struct GPU_EXPORT GPUInfo {
virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0;
virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0;
// Markers indicating that an ImageDecodeAcceleratorSupportedProfile is
// being described.
virtual void BeginImageDecodeAcceleratorSupportedProfile() = 0;
virtual void EndImageDecodeAcceleratorSupportedProfile() = 0;
// Markers indicating that "auxiliary" attributes of the GPUInfo
// (according to the DevTools protocol) are being described.
virtual void BeginAuxAttributes() = 0;
......
......@@ -76,6 +76,26 @@ struct VideoEncodeAcceleratorSupportedProfile {
uint32 max_framerate_denominator;
};
// gpu::ImageDecodeAcceleratorType
enum ImageDecodeAcceleratorType {
kJpeg,
kUnknown,
};
// gpu::ImageDecodeAcceleratorSubsampling
enum ImageDecodeAcceleratorSubsampling {
k420,
k422,
};
// gpu::ImageDecodeAcceleratorSupportedProfile
struct ImageDecodeAcceleratorSupportedProfile {
ImageDecodeAcceleratorType image_type;
gfx.mojom.Size min_encoded_dimensions;
gfx.mojom.Size max_encoded_dimensions;
array<ImageDecodeAcceleratorSubsampling> subsamplings;
};
// gpu::OverlayFormat
[EnableIf=is_win]
enum OverlayFormat {
......@@ -142,6 +162,10 @@ struct GpuInfo {
array<VideoEncodeAcceleratorSupportedProfile>
video_encode_accelerator_supported_profiles;
bool jpeg_decode_accelerator_supported;
array<ImageDecodeAcceleratorSupportedProfile>
image_decode_accelerator_supported_profiles;
uint64 system_visual;
uint64 rgba_visual;
bool oop_rasterization_supported;
......
......@@ -21,4 +21,5 @@ type_mappings = [
"gpu.mojom.VideoDecodeAcceleratorSupportedProfile=gpu::VideoDecodeAcceleratorSupportedProfile",
"gpu.mojom.VideoDecodeAcceleratorCapabilities=gpu::VideoDecodeAcceleratorCapabilities",
"gpu.mojom.VideoEncodeAcceleratorSupportedProfile=gpu::VideoEncodeAcceleratorSupportedProfile",
"gpu.mojom.ImageDecodeAcceleratorSupportedProfile=gpu::ImageDecodeAcceleratorSupportedProfile",
]
......@@ -5,6 +5,7 @@
#include "gpu/ipc/common/gpu_info_struct_traits.h"
#include "build/build_config.h"
#include "base/logging.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
namespace mojo {
......@@ -218,6 +219,77 @@ bool StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
data.ReadMaxResolution(&out->max_resolution);
}
// static
gpu::mojom::ImageDecodeAcceleratorType EnumTraits<
gpu::mojom::ImageDecodeAcceleratorType,
gpu::ImageDecodeAcceleratorType>::ToMojom(gpu::ImageDecodeAcceleratorType
image_type) {
switch (image_type) {
case gpu::ImageDecodeAcceleratorType::kJpeg:
return gpu::mojom::ImageDecodeAcceleratorType::kJpeg;
case gpu::ImageDecodeAcceleratorType::kUnknown:
return gpu::mojom::ImageDecodeAcceleratorType::kUnknown;
}
}
// static
bool EnumTraits<gpu::mojom::ImageDecodeAcceleratorType,
gpu::ImageDecodeAcceleratorType>::
FromMojom(gpu::mojom::ImageDecodeAcceleratorType input,
gpu::ImageDecodeAcceleratorType* out) {
switch (input) {
case gpu::mojom::ImageDecodeAcceleratorType::kJpeg:
*out = gpu::ImageDecodeAcceleratorType::kJpeg;
return true;
case gpu::mojom::ImageDecodeAcceleratorType::kUnknown:
*out = gpu::ImageDecodeAcceleratorType::kUnknown;
return true;
}
NOTREACHED() << "Invalid ImageDecodeAcceleratorType: " << input;
return false;
}
// static
gpu::mojom::ImageDecodeAcceleratorSubsampling
EnumTraits<gpu::mojom::ImageDecodeAcceleratorSubsampling,
gpu::ImageDecodeAcceleratorSubsampling>::
ToMojom(gpu::ImageDecodeAcceleratorSubsampling subsampling) {
switch (subsampling) {
case gpu::ImageDecodeAcceleratorSubsampling::k420:
return gpu::mojom::ImageDecodeAcceleratorSubsampling::k420;
case gpu::ImageDecodeAcceleratorSubsampling::k422:
return gpu::mojom::ImageDecodeAcceleratorSubsampling::k422;
}
}
// static
bool EnumTraits<gpu::mojom::ImageDecodeAcceleratorSubsampling,
gpu::ImageDecodeAcceleratorSubsampling>::
FromMojom(gpu::mojom::ImageDecodeAcceleratorSubsampling input,
gpu::ImageDecodeAcceleratorSubsampling* out) {
switch (input) {
case gpu::mojom::ImageDecodeAcceleratorSubsampling::k420:
*out = gpu::ImageDecodeAcceleratorSubsampling::k420;
return true;
case gpu::mojom::ImageDecodeAcceleratorSubsampling::k422:
*out = gpu::ImageDecodeAcceleratorSubsampling::k422;
return true;
}
NOTREACHED() << "Invalid ImageDecodeAcceleratorSubsampling: " << input;
return false;
}
// static
bool StructTraits<gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView,
gpu::ImageDecodeAcceleratorSupportedProfile>::
Read(gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView data,
gpu::ImageDecodeAcceleratorSupportedProfile* out) {
return data.ReadImageType(&out->image_type) &&
data.ReadMinEncodedDimensions(&out->min_encoded_dimensions) &&
data.ReadMaxEncodedDimensions(&out->max_encoded_dimensions) &&
data.ReadSubsamplings(&out->subsamplings);
}
#if defined(OS_WIN)
// static
gpu::mojom::OverlayFormat
......@@ -322,7 +394,9 @@ bool StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo>::Read(
data.ReadVideoDecodeAcceleratorCapabilities(
&out->video_decode_accelerator_capabilities) &&
data.ReadVideoEncodeAcceleratorSupportedProfiles(
&out->video_encode_accelerator_supported_profiles);
&out->video_encode_accelerator_supported_profiles) &&
data.ReadImageDecodeAcceleratorSupportedProfiles(
&out->image_decode_accelerator_supported_profiles);
}
} // namespace mojo
......@@ -141,6 +141,52 @@ struct StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
}
};
template <>
struct EnumTraits<gpu::mojom::ImageDecodeAcceleratorType,
gpu::ImageDecodeAcceleratorType> {
static gpu::mojom::ImageDecodeAcceleratorType ToMojom(
gpu::ImageDecodeAcceleratorType image_type);
static bool FromMojom(gpu::mojom::ImageDecodeAcceleratorType input,
gpu::ImageDecodeAcceleratorType* out);
};
template <>
struct EnumTraits<gpu::mojom::ImageDecodeAcceleratorSubsampling,
gpu::ImageDecodeAcceleratorSubsampling> {
static gpu::mojom::ImageDecodeAcceleratorSubsampling ToMojom(
gpu::ImageDecodeAcceleratorSubsampling subsampling);
static bool FromMojom(gpu::mojom::ImageDecodeAcceleratorSubsampling input,
gpu::ImageDecodeAcceleratorSubsampling* out);
};
template <>
struct StructTraits<gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView,
gpu::ImageDecodeAcceleratorSupportedProfile> {
static bool Read(
gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView data,
gpu::ImageDecodeAcceleratorSupportedProfile* out);
static gpu::ImageDecodeAcceleratorType image_type(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.image_type;
}
static const gfx::Size& min_encoded_dimensions(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.min_encoded_dimensions;
}
static const gfx::Size& max_encoded_dimensions(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.max_encoded_dimensions;
}
static std::vector<gpu::ImageDecodeAcceleratorSubsampling> subsamplings(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.subsamplings;
}
};
#if defined(OS_WIN)
template <>
struct EnumTraits<gpu::mojom::OverlayFormat, gpu::OverlayFormat> {
......@@ -323,6 +369,11 @@ struct StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo> {
return input.jpeg_decode_accelerator_supported;
}
static std::vector<gpu::ImageDecodeAcceleratorSupportedProfile>
image_decode_accelerator_supported_profiles(const gpu::GPUInfo& input) {
return input.image_decode_accelerator_supported_profiles;
}
static uint64_t system_visual(const gpu::GPUInfo& input) {
#if defined(USE_X11)
return input.system_visual;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment