Added (color=8888|f16|srgb) option to gpu configurations, along with gpuf16 and gpusrgb predefined configs. Runs the gpu backend in gamma-correct mode (with either FP16 linear or sRGB 8888 frambuffers).
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1750383002 Committed: https://skia.googlesource.com/skia/+/a6f58194733c1c50e4fe5f98585e42344f29b6f0 Review URL: https://codereview.chromium.org/1750383002
This commit is contained in:
parent
e6d665e24f
commit
d93c120852
@ -815,7 +815,8 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return new GPUSink(contextType, contextOptions, gpuConfig->getSamples(),
|
return new GPUSink(contextType, contextOptions, gpuConfig->getSamples(),
|
||||||
gpuConfig->getUseDIText(), FLAGS_gpu_threading);
|
gpuConfig->getUseDIText(), gpuConfig->getColorType(),
|
||||||
|
gpuConfig->getProfileType(), FLAGS_gpu_threading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -930,11 +930,15 @@ GPUSink::GPUSink(GrContextFactory::GLContextType ct,
|
|||||||
GrContextFactory::GLContextOptions options,
|
GrContextFactory::GLContextOptions options,
|
||||||
int samples,
|
int samples,
|
||||||
bool diText,
|
bool diText,
|
||||||
|
SkColorType colorType,
|
||||||
|
SkColorProfileType profileType,
|
||||||
bool threaded)
|
bool threaded)
|
||||||
: fContextType(ct)
|
: fContextType(ct)
|
||||||
, fContextOptions(options)
|
, fContextOptions(options)
|
||||||
, fSampleCount(samples)
|
, fSampleCount(samples)
|
||||||
, fUseDIText(diText)
|
, fUseDIText(diText)
|
||||||
|
, fColorType(colorType)
|
||||||
|
, fProfileType(profileType)
|
||||||
, fThreaded(threaded) {}
|
, fThreaded(threaded) {}
|
||||||
|
|
||||||
void PreAbandonGpuContextErrorHandler(SkError, void*) {}
|
void PreAbandonGpuContextErrorHandler(SkError, void*) {}
|
||||||
@ -959,7 +963,8 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
|
|||||||
GrContextFactory factory(grOptions);
|
GrContextFactory factory(grOptions);
|
||||||
const SkISize size = src.size();
|
const SkISize size = src.size();
|
||||||
const SkImageInfo info =
|
const SkImageInfo info =
|
||||||
SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul_SkAlphaType);
|
SkImageInfo::Make(size.width(), size.height(), fColorType,
|
||||||
|
kPremul_SkAlphaType, fProfileType);
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
const int maxDimension = factory.getContextInfo(fContextType, fContextOptions).
|
const int maxDimension = factory.getContextInfo(fContextType, fContextOptions).
|
||||||
fGrContext->caps()->maxTextureSize();
|
fGrContext->caps()->maxTextureSize();
|
||||||
|
@ -233,7 +233,8 @@ public:
|
|||||||
class GPUSink : public Sink {
|
class GPUSink : public Sink {
|
||||||
public:
|
public:
|
||||||
GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions,
|
GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions,
|
||||||
int samples, bool diText, bool threaded);
|
int samples, bool diText, SkColorType colorType, SkColorProfileType profileType,
|
||||||
|
bool threaded);
|
||||||
|
|
||||||
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
||||||
bool serial() const override { return !fThreaded; }
|
bool serial() const override { return !fThreaded; }
|
||||||
@ -244,6 +245,8 @@ private:
|
|||||||
GrContextFactory::GLContextOptions fContextOptions;
|
GrContextFactory::GLContextOptions fContextOptions;
|
||||||
int fSampleCount;
|
int fSampleCount;
|
||||||
bool fUseDIText;
|
bool fUseDIText;
|
||||||
|
SkColorType fColorType;
|
||||||
|
SkColorProfileType fProfileType;
|
||||||
bool fThreaded;
|
bool fThreaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ DEF_TEST(ParseConfigs_Gpu, reporter) {
|
|||||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
|
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
|
||||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
|
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
|
||||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
|
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
|
||||||
|
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorType() == kN32_SkColorType);
|
||||||
|
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getProfileType()
|
||||||
|
== kLinear_SkColorProfileType);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +68,8 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
|
|||||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||||
"565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16", "msaa4",
|
"565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16", "msaa4",
|
||||||
"nonrendering", "null", "nullgpu", "nvprmsaa16", "nvprmsaa4", "pdf", "pdf_poppler",
|
"nonrendering", "null", "nullgpu", "nvprmsaa16", "nvprmsaa4", "pdf", "pdf_poppler",
|
||||||
"skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui"
|
"skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui",
|
||||||
|
"gpuf16", "gpusrgb", "anglesrgb"
|
||||||
});
|
});
|
||||||
|
|
||||||
SkCommandLineConfigArray configs;
|
SkCommandLineConfigArray configs;
|
||||||
@ -101,11 +105,22 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
|
|||||||
REPORTER_ASSERT(reporter, !configs[17]->asConfigGpu());
|
REPORTER_ASSERT(reporter, !configs[17]->asConfigGpu());
|
||||||
REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu());
|
REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu());
|
||||||
REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu());
|
REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu());
|
||||||
|
REPORTER_ASSERT(reporter, configs[24]->asConfigGpu()->getColorType()
|
||||||
|
== kRGBA_F16_SkColorType);
|
||||||
|
REPORTER_ASSERT(reporter, configs[24]->asConfigGpu()->getProfileType()
|
||||||
|
== kLinear_SkColorProfileType);
|
||||||
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorType()
|
||||||
|
== kN32_SkColorType);
|
||||||
|
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getProfileType()
|
||||||
|
== kSRGB_SkColorProfileType);
|
||||||
#if SK_ANGLE
|
#if SK_ANGLE
|
||||||
#ifdef SK_BUILD_FOR_WIN
|
#ifdef SK_BUILD_FOR_WIN
|
||||||
REPORTER_ASSERT(reporter, configs[19]->asConfigGpu());
|
REPORTER_ASSERT(reporter, configs[19]->asConfigGpu());
|
||||||
|
REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getProfileType()
|
||||||
|
== kSRGB_SkColorProfileType);
|
||||||
#else
|
#else
|
||||||
REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
|
REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
|
||||||
|
REPORTER_ASSERT(reporter, !configs[26]->asConfigGpu());
|
||||||
#endif
|
#endif
|
||||||
REPORTER_ASSERT(reporter, configs[20]->asConfigGpu());
|
REPORTER_ASSERT(reporter, configs[20]->asConfigGpu());
|
||||||
#else
|
#else
|
||||||
|
@ -23,7 +23,7 @@ static const char defaultConfigs[] =
|
|||||||
|
|
||||||
static const char configHelp[] =
|
static const char configHelp[] =
|
||||||
"Options: 565 8888 debug gpu gpudebug gpudft gpunull "
|
"Options: 565 8888 debug gpu gpudebug gpudft gpunull "
|
||||||
"msaa16 msaa4 nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
|
"msaa16 msaa4 gpuf16 gpusrgb nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
|
||||||
"pdf pdf_poppler skp svg xps"
|
"pdf pdf_poppler skp svg xps"
|
||||||
#if SK_ANGLE
|
#if SK_ANGLE
|
||||||
#ifdef SK_BUILD_FOR_WIN
|
#ifdef SK_BUILD_FOR_WIN
|
||||||
@ -47,7 +47,7 @@ static const char configExtendedHelp[] =
|
|||||||
"Possible backends and options:\n"
|
"Possible backends and options:\n"
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
"\n"
|
"\n"
|
||||||
"gpu(api=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n"
|
"gpu(api=string,color=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n"
|
||||||
"\tapi\ttype: string\tdefault: native.\n"
|
"\tapi\ttype: string\tdefault: native.\n"
|
||||||
"\t Select graphics API to use with gpu backend.\n"
|
"\t Select graphics API to use with gpu backend.\n"
|
||||||
"\t Options:\n"
|
"\t Options:\n"
|
||||||
@ -68,6 +68,12 @@ static const char configExtendedHelp[] =
|
|||||||
#if SK_MESA
|
#if SK_MESA
|
||||||
"\t\tmesa\t\t\tUse MESA.\n"
|
"\t\tmesa\t\t\tUse MESA.\n"
|
||||||
#endif
|
#endif
|
||||||
|
"\tcolor\ttype: string\tdefault: 8888.\n"
|
||||||
|
"\t Select framebuffer color format.\n"
|
||||||
|
"\t Options:\n"
|
||||||
|
"\t\t8888\t\t\tLinear 8888.\n"
|
||||||
|
"\t\tf16 \t\t\tLinear 16-bit floating point.\n"
|
||||||
|
"\t\tsrgb\t\t\tsRGB 8888.\n"
|
||||||
"\tdit\ttype: bool\tdefault: false.\n"
|
"\tdit\ttype: bool\tdefault: false.\n"
|
||||||
"\t Use device independent text.\n"
|
"\t Use device independent text.\n"
|
||||||
"\tnvpr\ttype: bool\tdefault: false.\n"
|
"\tnvpr\ttype: bool\tdefault: false.\n"
|
||||||
@ -81,6 +87,8 @@ static const char configExtendedHelp[] =
|
|||||||
"\tmsaa16 \t= gpu(samples=16)\n"
|
"\tmsaa16 \t= gpu(samples=16)\n"
|
||||||
"\tnvprmsaa4\t= gpu(nvpr=true,samples=4)\n"
|
"\tnvprmsaa4\t= gpu(nvpr=true,samples=4)\n"
|
||||||
"\tnvprmsaa16\t= gpu(nvpr=true,samples=16)\n"
|
"\tnvprmsaa16\t= gpu(nvpr=true,samples=16)\n"
|
||||||
|
"\tgpuf16 \t= gpu(color=f16)\n"
|
||||||
|
"\tgpusrgb \t= gpu(color=srgb)\n"
|
||||||
"\tgpudft \t= gpu(dit=true)\n"
|
"\tgpudft \t= gpu(dit=true)\n"
|
||||||
"\tgpudebug \t= gpu(api=debug)\n"
|
"\tgpudebug \t= gpu(api=debug)\n"
|
||||||
"\tgpunull \t= gpu(api=null)\n"
|
"\tgpunull \t= gpu(api=null)\n"
|
||||||
@ -114,6 +122,8 @@ static const struct {
|
|||||||
{ "msaa16", "gpu", "samples=16" },
|
{ "msaa16", "gpu", "samples=16" },
|
||||||
{ "nvprmsaa4", "gpu", "nvpr=true,samples=4,dit=true" },
|
{ "nvprmsaa4", "gpu", "nvpr=true,samples=4,dit=true" },
|
||||||
{ "nvprmsaa16", "gpu", "nvpr=true,samples=16,dit=true" },
|
{ "nvprmsaa16", "gpu", "nvpr=true,samples=16,dit=true" },
|
||||||
|
{ "gpuf16", "gpu", "color=f16" },
|
||||||
|
{ "gpusrgb", "gpu", "color=srgb" },
|
||||||
{ "gpudft", "gpu", "dit=true" },
|
{ "gpudft", "gpu", "dit=true" },
|
||||||
{ "gpudebug", "gpu", "api=debug" },
|
{ "gpudebug", "gpu", "api=debug" },
|
||||||
{ "gpunull", "gpu", "api=null" },
|
{ "gpunull", "gpu", "api=null" },
|
||||||
@ -148,12 +158,15 @@ SkCommandLineConfig::~SkCommandLineConfig() {
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
|
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
|
||||||
const SkString& tag, const SkTArray<SkString>& viaParts,
|
const SkString& tag, const SkTArray<SkString>& viaParts,
|
||||||
ContextType contextType, bool useNVPR, bool useDIText, int samples)
|
ContextType contextType, bool useNVPR, bool useDIText, int samples,
|
||||||
|
SkColorType colorType, SkColorProfileType profileType)
|
||||||
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
|
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
|
||||||
, fContextType(contextType)
|
, fContextType(contextType)
|
||||||
, fUseNVPR(useNVPR)
|
, fUseNVPR(useNVPR)
|
||||||
, fUseDIText(useDIText)
|
, fUseDIText(useDIText)
|
||||||
, fSamples(samples) {
|
, fSamples(samples)
|
||||||
|
, fColorType(colorType)
|
||||||
|
, fProfileType(profileType) {
|
||||||
}
|
}
|
||||||
static bool parse_option_int(const SkString& value, int* outInt) {
|
static bool parse_option_int(const SkString& value, int* outInt) {
|
||||||
if (value.isEmpty()) {
|
if (value.isEmpty()) {
|
||||||
@ -226,6 +239,26 @@ static bool parse_option_gpu_api(const SkString& value,
|
|||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
static bool parse_option_gpu_color(const SkString& value,
|
||||||
|
SkColorType* outColorType,
|
||||||
|
SkColorProfileType* outProfileType) {
|
||||||
|
if (value.equals("8888")) {
|
||||||
|
*outColorType = kN32_SkColorType;
|
||||||
|
*outProfileType = kLinear_SkColorProfileType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value.equals("f16")) {
|
||||||
|
*outColorType = kRGBA_F16_SkColorType;
|
||||||
|
*outProfileType = kLinear_SkColorProfileType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value.equals("srgb")) {
|
||||||
|
*outColorType = kN32_SkColorType;
|
||||||
|
*outProfileType = kSRGB_SkColorProfileType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
|
SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
|
||||||
const SkTArray<SkString>& vias,
|
const SkTArray<SkString>& vias,
|
||||||
@ -239,6 +272,9 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
|
|||||||
bool useDIText = false;
|
bool useDIText = false;
|
||||||
bool seenSamples = false;
|
bool seenSamples = false;
|
||||||
int samples = 0;
|
int samples = 0;
|
||||||
|
bool seenColor = false;
|
||||||
|
SkColorType colorType = kN32_SkColorType;
|
||||||
|
SkColorProfileType profileType = kLinear_SkColorProfileType;
|
||||||
|
|
||||||
SkTArray<SkString> optionParts;
|
SkTArray<SkString> optionParts;
|
||||||
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
|
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
|
||||||
@ -263,12 +299,16 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
|
|||||||
} else if (key.equals("samples") && !seenSamples) {
|
} else if (key.equals("samples") && !seenSamples) {
|
||||||
valueOk = parse_option_int(value, &samples);
|
valueOk = parse_option_int(value, &samples);
|
||||||
seenSamples = true;
|
seenSamples = true;
|
||||||
|
} else if (key.equals("color") && !seenColor) {
|
||||||
|
valueOk = parse_option_gpu_color(value, &colorType, &profileType);
|
||||||
|
seenColor = true;
|
||||||
}
|
}
|
||||||
if (!valueOk) {
|
if (!valueOk) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples);
|
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples,
|
||||||
|
colorType, profileType);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -52,18 +52,23 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
|
|||||||
public:
|
public:
|
||||||
typedef GrContextFactory::GLContextType ContextType;
|
typedef GrContextFactory::GLContextType ContextType;
|
||||||
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
|
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
|
||||||
ContextType contextType, bool useNVPR, bool useDIText, int samples);
|
ContextType contextType, bool useNVPR, bool useDIText, int samples,
|
||||||
|
SkColorType colorType, SkColorProfileType profileType);
|
||||||
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
|
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
|
||||||
ContextType getContextType() const { return fContextType; }
|
ContextType getContextType() const { return fContextType; }
|
||||||
bool getUseNVPR() const { return fUseNVPR; }
|
bool getUseNVPR() const { return fUseNVPR; }
|
||||||
bool getUseDIText() const { return fUseDIText; }
|
bool getUseDIText() const { return fUseDIText; }
|
||||||
int getSamples() const { return fSamples; }
|
int getSamples() const { return fSamples; }
|
||||||
|
SkColorType getColorType() const { return fColorType; }
|
||||||
|
SkColorProfileType getProfileType() const { return fProfileType; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContextType fContextType;
|
ContextType fContextType;
|
||||||
bool fUseNVPR;
|
bool fUseNVPR;
|
||||||
bool fUseDIText;
|
bool fUseDIText;
|
||||||
int fSamples;
|
int fSamples;
|
||||||
|
SkColorType fColorType;
|
||||||
|
SkColorProfileType fProfileType;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user