summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 00:07:59 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 00:07:59 +0000
commitb5f1aa038b13b3a323b0b79867585264c475a6b2 (patch)
treed7db464996438107d3a1a33aadee225a457b94cf /gpu
parentad8a6ea045cdaf65c4a61e1ededb67f8c4d0534e (diff)
downloadchromium_src-b5f1aa038b13b3a323b0b79867585264c475a6b2.zip
chromium_src-b5f1aa038b13b3a323b0b79867585264c475a6b2.tar.gz
chromium_src-b5f1aa038b13b3a323b0b79867585264c475a6b2.tar.bz2
First step on the way to a native GLES2 backend for command
buffers. I mostly just copied the macros from O3D and make sure it compiled using our own GLES2 emu backend. It should theoretically compile on real native GLES2 but the setup in service/gles2_cmd_decoder.cc needs work. TEST=none BUG=none Review URL: http://codereview.chromium.org/799002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h22
-rw-r--r--gpu/command_buffer/service/gl_utils.h68
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc16
3 files changed, 81 insertions, 25 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index 965c212..e67fe69 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -11,15 +11,21 @@
// the GL headers where as client side code includes the Chrome version. Also
// the unit test code must include a mock GL header.
#if defined(UNIT_TEST)
-#include "../service/gl_mock.h"
+ #include "../service/gl_mock.h"
#elif defined(GLES2_GPU_SERVICE)
-#include <GL/glew.h> // NOLINT
-#if defined(OS_WIN)
-#include <GL/wglew.h> // NOLINT
-#endif
-#else
-#include <GLES2/gl2types.h> // NOLINT
-#endif
+ // TODO(gman): Set this from gyp
+ // #define GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 1
+ #if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ #include <GLES2/gl2.h> // NOLINT
+ #else // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
+ #include <GL/glew.h> // NOLINT
+ #if defined(OS_WIN)
+ #include <GL/wglew.h> // NOLINT
+ #endif
+ #endif // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
+#else // !GLES2_CPU_SERVICE
+ #include <GLES2/gl2types.h> // NOLINT
+#endif // UNIT_TEST
#include <string.h>
diff --git a/gpu/command_buffer/service/gl_utils.h b/gpu/command_buffer/service/gl_utils.h
index 6edc287..432dfb4 100644
--- a/gpu/command_buffer/service/gl_utils.h
+++ b/gpu/command_buffer/service/gl_utils.h
@@ -11,23 +11,59 @@
#include <build/build_config.h>
#if defined(UNIT_TEST)
-#include "gpu/command_buffer/service/gl_mock.h"
+ #include "gpu/command_buffer/service/gl_mock.h"
#else
-#include <GL/glew.h> // NOLINT
-#if defined(OS_WIN)
-#include <GL/wglew.h> // NOLINT
-#elif defined(OS_LINUX)
-#include <GL/glxew.h> // NOLINT
-#endif // OS_WIN
-
-// GLES2 defines not part of Desktop GL
-// Shader Precision-Specified Types
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_LOW_INT 0x8DF3
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_HIGH_INT 0x8DF5
+ #if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ #include <GLES2/gl2.h> // NOLINT
+
+ #define glClearDepth glClearDepthf
+ #define glDepthRange glDepthRangef
+
+ // Buffer Objects
+ #define glBindBufferARB glBindBuffer
+ #define glBufferDataARB glBufferData
+ #define glBufferSubDataARB glBufferSubData
+ #define glDeleteBuffersARB glDeleteBuffers
+ #define glGenBuffersARB glGenBuffers
+
+ // Framebuffer Objects
+ #define glBindFramebufferEXT glBindFramebuffer
+ #define glBindRenderbufferEXT glBindRenderbuffer
+ #define glCheckFramebufferStatusEXT glCheckFramebufferStatus
+ #define glDeleteFramebuffersEXT glDeleteFramebuffers
+ #define glDeleteRenderbuffersEXT glDeleteRenderbuffers
+ #define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
+ #define glFramebufferTexture2DEXT glFramebufferTexture2D
+ #define glGenFramebuffersEXT glGenFramebuffers
+ #define glGenRenderbuffersEXT glGenRenderbuffers
+ #define glGetFramebufferAttachmentParameterivEXT \
+ glGetFramebufferAttachmentParameteriv
+ #define glGetRenderbufferParameterivEXT glGetRenderbufferParameteriv
+ #define glIsFramebufferEXT glIsFramebuffer
+ #define glIsRenderbufferEXT glIsFramebuffer
+ #define glRenderbufferStorageEXT glRenderbufferStorage
+
+ // Texture Objects
+ #define glGenerateMipmapEXT glGenerateMipmap
+
+ #else // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
+ #include <GL/glew.h> // NOLINT
+ #if defined(OS_WIN)
+ #include <GL/wglew.h> // NOLINT
+ #elif defined(OS_LINUX)
+ #include <GL/glxew.h> // NOLINT
+ #endif // OS_WIN
+
+ // GLES2 defines not part of Desktop GL
+ // Shader Precision-Specified Types
+ #define GL_LOW_FLOAT 0x8DF0
+ #define GL_MEDIUM_FLOAT 0x8DF1
+ #define GL_HIGH_FLOAT 0x8DF2
+ #define GL_LOW_INT 0x8DF3
+ #define GL_MEDIUM_INT 0x8DF4
+ #define GL_HIGH_INT 0x8DF5
+
+ #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
#endif // UNIT_TEST
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index b9637e9..4b2e520 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -600,6 +600,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
ProgramManager::ProgramInfo::Ref current_program_;
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
static int pixel_format_;
HDC gl_device_context_;
@@ -621,6 +622,7 @@ GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
}
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
int GLES2DecoderImpl::pixel_format_;
#endif
@@ -635,6 +637,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
black_2d_texture_id_(0),
black_cube_texture_id_(0),
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
gl_device_context_(NULL),
gl_context_(NULL),
@@ -707,6 +710,7 @@ bool GLES2DecoderImpl::Initialize() {
// namespace {
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = {
@@ -933,6 +937,8 @@ void GLDeleteTexturesHelper(
bool GLES2DecoderImpl::MakeCurrent() {
#if defined(UNIT_TEST)
return true;
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ return true;
#elif defined(OS_WIN)
if (::wglGetCurrentDC() == gl_device_context_ &&
::wglGetCurrentContext() == gl_context_) {
@@ -999,6 +1005,7 @@ void GLES2DecoderImpl::UnregisterObjects(
bool GLES2DecoderImpl::InitPlatformSpecific() {
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
// Do one-off initialization.
static bool success = InitializeOneOff(anti_aliased_);
@@ -1059,7 +1066,7 @@ bool GLES2DecoderImpl::InitPlatformSpecific() {
}
bool GLES2DecoderImpl::InitGlew() {
-#if !defined(UNIT_TEST)
+#if !defined(UNIT_TEST) && !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
DLOG(INFO) << "Initializing GL and GLEW for GLES2Decoder.";
GLenum glew_error = glewInit();
@@ -1116,6 +1123,7 @@ bool GLES2DecoderImpl::InitGlew() {
void GLES2DecoderImpl::DestroyPlatformSpecific() {
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
if (gl_context_) {
::wglDeleteContext(gl_context_);
@@ -1142,6 +1150,8 @@ void GLES2DecoderImpl::DestroyPlatformSpecific() {
uint64 GLES2DecoderImpl::SetWindowSizeForIOSurface(int32 width, int32 height) {
#if defined(UNIT_TEST)
return 0;
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ return 0;
#else
return surface_.SetSurfaceSize(width, height);
#endif // !defined(UNIT_TEST)
@@ -1151,6 +1161,8 @@ TransportDIB::Handle GLES2DecoderImpl::SetWindowSizeForTransportDIB(
int32 width, int32 height) {
#if defined(UNIT_TEST)
return TransportDIB::DefaultHandleValue();
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+ return TransportDIB::DefaultHandleValue();
#else
return surface_.SetTransportDIBSize(width, height);
#endif // !defined(UNIT_TEST)
@@ -1169,6 +1181,7 @@ void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) {
void GLES2DecoderImpl::Destroy() {
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_LINUX)
DCHECK(window());
window()->Destroy();
@@ -1426,6 +1439,7 @@ void GLES2DecoderImpl::DoLinkProgram(GLuint program) {
void GLES2DecoderImpl::DoSwapBuffers() {
#if defined(UNIT_TEST)
+#elif defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#elif defined(OS_WIN)
::SwapBuffers(gl_device_context_);
#elif defined(OS_LINUX)