aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2015-08-12 12:19:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-12 12:19:36 -0700
commita50e17a391bb57771feac8c1e78a2b1627f7b9e2 (patch)
tree121f426f0d485a2c1f83b6dfa8bbe564443c4b8d
parent082e329887a8f1efe4e1020f0a0a6ea09961712d (diff)
Add support for a new GPU interface
-rw-r--r--include/gpu/GrTypes.h4
-rwxr-xr-xsrc/gpu/GrContextFactory.cpp4
-rw-r--r--src/gpu/GrGpuFactory.cpp11
3 files changed, 16 insertions, 3 deletions
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 082cdf1dc4..f516388874 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -126,7 +126,11 @@ static inline int GrNextPow2(int n) {
*/
enum GrBackend {
kOpenGL_GrBackend,
+ kVulkan_GrBackend,
+
+ kLast_GrBackend = kVulkan_GrBackend
};
+const int kBackendCount = kLast_GrBackend + 1;
/**
* Backend-specific 3D context handle
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 6ed2c259e2..1f371302f4 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -76,7 +76,11 @@ GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI)
glCtx->makeCurrent();
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
+#ifdef SK_VULKAN
+ grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
+#else
grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
+#endif
if (!grCtx.get()) {
return NULL;
}
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index 3001a0d41a..854e484747 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -13,8 +13,13 @@
#include "gl/GrGLConfig.h"
#include "gl/GrGLGpu.h"
-static const int kMaxNumBackends = 4;
-static CreateGpuProc gGpuFactories[kMaxNumBackends] = {GrGLGpu::Create, NULL, NULL, NULL};
+static CreateGpuProc gGpuFactories[kBackendCount] = { GrGLGpu::Create, NULL };
+
+#ifdef SK_VULKAN
+extern GrGpu* vk_gpu_create(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context);
+GrGpuFactoryRegistrar gVkGpuFactoryProc(kVulkan_GrBackend, vk_gpu_create);
+#endif
GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
gGpuFactories[i] = proc;
@@ -24,7 +29,7 @@ GrGpu* GrGpu::Create(GrBackend backend,
GrBackendContext backendContext,
const GrContextOptions& options,
GrContext* context) {
- SkASSERT((int)backend < kMaxNumBackends);
+ SkASSERT((int)backend < kBackendCount);
if (!gGpuFactories[backend]) {
return NULL;
}