Merge "Ensure GL & Gralloc both support FP16 before using it" into pi-dev
am: bf39913bbc
Change-Id: Ic3a72f4684966e04b64101b2798c4ec3c0549549
This commit is contained in:
@@ -297,6 +297,26 @@ private:
|
||||
GLuint mTexture = 0;
|
||||
};
|
||||
|
||||
static bool isFP16Supported(const sk_sp<GrContext>& grContext) {
|
||||
static std::once_flag sOnceFlag;
|
||||
static bool supported = false;
|
||||
|
||||
std::call_once(sOnceFlag, [](const sk_sp<GrContext>& grContext) {
|
||||
if (!grContext->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig)) {
|
||||
supported = false;
|
||||
return;
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> buffer = new GraphicBuffer(1, 1, PIXEL_FORMAT_RGBA_FP16,
|
||||
GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_SW_WRITE_NEVER |
|
||||
GraphicBuffer::USAGE_SW_READ_NEVER, "tempFp16Buffer");
|
||||
status_t error = buffer->initCheck();
|
||||
supported = !error;
|
||||
}, grContext);
|
||||
|
||||
return supported;
|
||||
}
|
||||
|
||||
sk_sp<Bitmap> SkiaOpenGLPipeline::allocateHardwareBitmap(renderthread::RenderThread& renderThread,
|
||||
SkBitmap& skBitmap) {
|
||||
renderThread.eglManager().initialize();
|
||||
@@ -318,7 +338,7 @@ sk_sp<Bitmap> SkiaOpenGLPipeline::allocateHardwareBitmap(renderthread::RenderThr
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
isSupported = grContext->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig);
|
||||
isSupported = isFP16Supported(grContext);
|
||||
if (isSupported) {
|
||||
type = GL_HALF_FLOAT;
|
||||
pixelFormat = PIXEL_FORMAT_RGBA_FP16;
|
||||
|
||||
Reference in New Issue
Block a user