OpenCL version of SourceAlpha, SourceGraphics and FETurbulence filter effects
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2012 17:18:25 +0000 (17:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2012 17:18:25 +0000 (17:18 +0000)
commit702a60dbe7fe365c0842595675db145764f3ecbf
tree2aff583f929f01cbb8d6aa56c7f88c31a08bcca1
parent37d8e20b4c9c4a8eaa104dff58178b8be1707b01
OpenCL version of SourceAlpha, SourceGraphics and FETurbulence filter effects
https://bugs.webkit.org/show_bug.cgi?id=99829

Patch by Tamas Czene <tczene@inf.u-szeged.hu> on 2012-11-26
Reviewed by Zoltan Herczeg.

This patch contains the OpenCL implementation of SourceAlpha, SourceGraphic, FETurbulence and a simple OpenCL environment.
At the moment only the Qt build system is supported
~3x speed-up (depending on hardware configuration)

* Target.pri:
* WebCore.pri:
* platform/graphics/filters/FETurbulence.h: Added platformApplyOpenCL() virtual function.
(FETurbulence):
* platform/graphics/filters/FilterEffect.cpp: Added platform specific apply.
(WebCore::FilterEffect::apply):
(WebCore):
(WebCore::FilterEffect::platformApplyOpenCL): A function to use software computing if a filter is not implemented on OpenCL. It will be deleted after all of the filters are implemented.
(WebCore::FilterEffect::clearResult):
(WebCore::FilterEffect::asImageBuffer):
(WebCore::FilterEffect::openCLImageToImageBuffer): Gets the result of the filter from the OpenCL device and converts it to ImageBuffer type.
(WebCore::FilterEffect::createOpenCLImageResult): Allocates memory on OpenCL device and if it gets an image as a parameter, it uploads the image to the OpenCL device.
(WebCore::FilterEffect::transformResultColorSpace):
* platform/graphics/filters/FilterEffect.h:
(FilterEffect):
(WebCore::FilterEffect::openCLImage):
(WebCore::FilterEffect::setOpenCLImage):
(WebCore::FilterEffect::hasResult):
* platform/graphics/filters/SourceAlpha.h:
(SourceAlpha):
* platform/graphics/filters/SourceGraphic.h:
(SourceGraphic):
* platform/graphics/gpu/opencl/FilterContextOpenCL.cpp: Added.
(WebCore):
(WebCore::FilterContextOpenCL::context): Configures the OpenCL environment.
(WebCore::FilterContextOpenCL::createOpenCLImage): Allocates memory on OpenCL device.
(WebCore::FilterContextOpenCL::openCLTransformColorSpace): OpenCL implementation of transformColorSpace.
(WebCore::FilterContextOpenCL::compileProgram):
* platform/graphics/gpu/opencl/FilterContextOpenCL.h: Added.
(WebCore):
(FilterContextOpenCL):
(WebCore::FilterContextOpenCL::deviceId):
(WebCore::FilterContextOpenCL::deviceContext):
(WebCore::FilterContextOpenCL::commandQueue):
(RunKernel):
(WebCore::FilterContextOpenCL::RunKernel::RunKernel):
(WebCore::FilterContextOpenCL::RunKernel::addArgument):
(WebCore::FilterContextOpenCL::RunKernel::run):
(WebCore::FilterContextOpenCL::kernelByName): Returns the reference of a function in the OpenCL program.
* platform/graphics/gpu/opencl/OpenCLFESourceAlpha.cpp: Added.
(WebCore):
(WebCore::SourceAlpha::platformApplyOpenCL):
* platform/graphics/gpu/opencl/OpenCLFESourceGraphic.cpp: Added.
(WebCore):
(WebCore::SourceGraphic::platformApplyOpenCL):
* platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp: Added.
(WebCore):
(WebCore::FilterContextOpenCL::compileFETurbulence):
(WebCore::FilterContextOpenCL::applyFETurbulence):
(WebCore::FETurbulence::platformApplyOpenCL):
* platform/graphics/gpu/opencl/OpenCLHandle.h: Added.
(WebCore):
(OpenCLHandle):
(WebCore::OpenCLHandle::OpenCLHandle):
(WebCore::OpenCLHandle::operator cl_mem):
(WebCore::OpenCLHandle::operator=):
(WebCore::OpenCLHandle::operator UnspecifiedBoolType):
(WebCore::OpenCLHandle::handleAddress):
(WebCore::OpenCLHandle::clear):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Target.pri
Source/WebCore/WebCore.pri
Source/WebCore/platform/graphics/filters/FETurbulence.h
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.h
Source/WebCore/platform/graphics/filters/SourceAlpha.h
Source/WebCore/platform/graphics/filters/SourceGraphic.h
Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h [new file with mode: 0644]
Source/WebCore/platform/graphics/gpu/opencl/OpenCLFESourceAlpha.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gpu/opencl/OpenCLFESourceGraphic.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h [new file with mode: 0644]