summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-11 03:50:06 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-11 03:50:06 +0000
commit6f9ae7ef9fdb15a29b653c2514a106b7f4258233 (patch)
tree62355195b3c655776a89cc23e92fac71c085af77 /gpu
parentc3ca8c13bf5322d7afa80409690e8effeb4b05be (diff)
downloadchromium_src-6f9ae7ef9fdb15a29b653c2514a106b7f4258233.zip
chromium_src-6f9ae7ef9fdb15a29b653c2514a106b7f4258233.tar.gz
chromium_src-6f9ae7ef9fdb15a29b653c2514a106b7f4258233.tar.bz2
Expose DXT3 and DXT5 through ANGLE
TEST=made demo and tested it. BUG=91046 Review URL: http://codereview.chromium.org/7604027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/GLES2/gl2ext.h12
-rw-r--r--gpu/command_buffer/client/gles2_demo.cc11
-rw-r--r--gpu/command_buffer/client/gles2_demo_cc.cc176
-rw-r--r--gpu/command_buffer/service/feature_info.cc6
4 files changed, 198 insertions, 7 deletions
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h
index c2bec34..68773a4 100644
--- a/gpu/GLES2/gl2ext.h
+++ b/gpu/GLES2/gl2ext.h
@@ -1034,6 +1034,18 @@ typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOCHROMIUM) ();
#define GL_UNPACK_FLIP_Y_CHROMIUM 0x9240
#endif
+/* GL_CHROMIUM_texture_compression_dxt3 */
+#ifndef GL_CHROMIUM_texture_compression_dxt3
+#define GL_CHROMIUM_texture_compression_dxt3 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#endif
+
+/* GL_CHROMIUM_texture_compression_dxt5 */
+#ifndef GL_CHROMIUM_texture_compression_dxt5
+#define GL_CHROMIUM_texture_compression_dxt5 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#endif
+
/* GL_ARB_robustness */
/* This extension is subsetted for the moment, incorporating only the
* enums necessary to describe the reasons that we might encounter for
diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc
index 7dde7f6..974f187 100644
--- a/gpu/command_buffer/client/gles2_demo.cc
+++ b/gpu/command_buffer/client/gles2_demo.cc
@@ -19,12 +19,14 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/shared_memory.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/gles2_demo_c.h"
#include "gpu/command_buffer/client/gles2_demo_cc.h"
+#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface.h"
using base::SharedMemory;
@@ -52,13 +54,20 @@ GLES2Demo::GLES2Demo() {
}
bool GLES2Demo::Setup(void* hwnd, int32 size) {
+#if defined(OS_WIN)
+ InitializeGLBindings(gfx::kGLImplementationEGLGLES2);
+#else
+ InitializeGLBindings(gfx::kGLImplementationDesktopGL);
+#endif
+
scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
if (!command_buffer->Initialize(size))
return NULL;
+ gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup());
GpuScheduler* gpu_scheduler = GpuScheduler::Create(command_buffer.get(),
NULL,
- NULL);
+ group.get());
if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd),
gfx::Size(),
false,
diff --git a/gpu/command_buffer/client/gles2_demo_cc.cc b/gpu/command_buffer/client/gles2_demo_cc.cc
index e271a0f..80837ea 100644
--- a/gpu/command_buffer/client/gles2_demo_cc.cc
+++ b/gpu/command_buffer/client/gles2_demo_cc.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,11 +14,15 @@
// This is here so we have at least some idea that the inline path is working.
#define GLES2_INLINE_OPTIMIZATION
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include "../common/logging.h"
namespace {
-GLuint g_texture = 0;
+int g_frameCount = 0;
+int g_textureIndex = 0;
+int g_numTextures = 1;
+GLuint g_textures[5];
int g_textureLoc = -1;
GLuint g_programObject = 0;
GLuint g_worldMatrixLoc = 0;
@@ -165,12 +169,167 @@ GLuint CreateCheckerboardTexture() {
return texture;
}
+GLuint CreateCompressedTexture(
+ const void* data,
+ GLsizeiptr size,
+ GLenum format,
+ GLint width,
+ GLint height) {
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glCompressedTexImage2D(
+ GL_TEXTURE_2D, 0, format, width, height, 0, size, data);
+ CheckGLError("CreateCompressedTxture", __LINE__);
+ return texture;
+}
+
+GLuint LoadDXT1RGBTexture() {
+ static unsigned char data[] = {
+ 0x00, 0xd0, 0x00, 0xef, 0x00, 0xaa, 0x95, 0xd5,
+ 0x00, 0x90, 0x57, 0xff, 0x00, 0xaa, 0xff, 0x55,
+ 0x00, 0x88, 0x99, 0xff, 0x00, 0xaa, 0xff, 0x55,
+ 0x20, 0xb8, 0xe4, 0xf6, 0x00, 0xaa, 0x5b, 0x5d,
+ 0x21, 0x09, 0xe6, 0x27, 0x15, 0x15, 0x15, 0x15,
+ 0xd7, 0xbd, 0xff, 0xff, 0x56, 0x16, 0x16, 0x56,
+ 0x00, 0x00, 0xff, 0xff, 0x55, 0x00, 0x00, 0x55,
+ 0xe0, 0x08, 0xa9, 0x2f, 0x51, 0x58, 0x56, 0x54,
+ 0xff, 0x07, 0x15, 0x09, 0x40, 0x6a, 0xd5, 0xd5,
+ 0xd7, 0xbd, 0xff, 0xff, 0x56, 0x16, 0x16, 0x16,
+ 0x91, 0x08, 0xff, 0xff, 0x55, 0xff, 0x00, 0x03,
+ 0xfe, 0x07, 0x5b, 0x09, 0x01, 0xa9, 0x55, 0xff,
+ 0x0d, 0x10, 0x18, 0xe8, 0xea, 0x15, 0x95, 0x55,
+ 0x08, 0x88, 0x3c, 0xe7, 0x55, 0x55, 0xff, 0x00,
+ 0x10, 0x20, 0x18, 0xe8, 0xa8, 0x54, 0x56, 0x55,
+ 0x1f, 0x78, 0x15, 0xf8, 0x00, 0xaa, 0x55, 0x55,
+ };
+ return CreateCompressedTexture(
+ data, sizeof(data), GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 16, 16);
+}
+
+GLuint LoadDXT1RGBATexture() {
+ static unsigned char data[] = {
+ 0xff, 0xff, 0x90, 0xee, 0x00, 0xaa, 0xff, 0x55,
+ 0x53, 0xde, 0xdd, 0xff, 0x55, 0x55, 0x00, 0xff,
+ 0xc9, 0xb4, 0xdd, 0xff, 0x55, 0x55, 0xaa, 0xff,
+ 0x6f, 0xee, 0xdd, 0xff, 0x55, 0x55, 0xa8, 0x03,
+ 0x60, 0xa3, 0xa5, 0xe5, 0x55, 0x55, 0xaa, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x80, 0xab, 0xc2, 0xc4, 0xff, 0x55, 0xaa, 0xff,
+ 0x60, 0x9b, 0xa5, 0xe5, 0x57, 0x56, 0xaa, 0x00,
+ 0x1f, 0xbf, 0xff, 0xf7, 0x55, 0x55, 0xaa, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xfe, 0xbe, 0x7e, 0xdf, 0xff, 0xaa, 0x55, 0x00,
+ 0xfe, 0xbe, 0xff, 0xf7, 0x54, 0x56, 0xaa, 0x00,
+ 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
+ 0xbb, 0x2c, 0x98, 0x54, 0xff, 0xff, 0x55, 0xaa,
+ 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
+ 0xfa, 0x4c, 0x7e, 0x9e, 0x55, 0xaa, 0x00, 0x00,
+ };
+ return CreateCompressedTexture(
+ data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 16, 16);
+}
+
+GLuint LoadDXT3RGBATexture() {
+ static unsigned char data[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xa3, 0x22, 0x03, 0x03, 0x55, 0xff, 0xaa, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0xcf, 0x7c, 0xc3, 0x12, 0x55, 0x55, 0x55, 0x54,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x83, 0x1a, 0x03, 0x03, 0x55, 0xff, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff,
+ 0xcf, 0x7c, 0xc3, 0x12, 0x55, 0x55, 0x55, 0x54,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc3, 0x59, 0x63, 0x32, 0x55, 0xff, 0xaa, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00,
+ 0x8f, 0x94, 0x03, 0x4a, 0x54, 0x94, 0x94, 0x54,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0xa3, 0x59, 0x43, 0x2a, 0x55, 0xff, 0xaa, 0x00,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
+ 0xaf, 0x84, 0x03, 0x42, 0x54, 0x55, 0x55, 0x55,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc3, 0xa0, 0x83, 0x71, 0x55, 0xff, 0xaa, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40,
+ 0x0f, 0xb4, 0x43, 0x81, 0x54, 0x94, 0x94, 0x94,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc3, 0xa0, 0x83, 0x69, 0x55, 0xff, 0xaa, 0x00,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc3, 0xa0, 0x83, 0x69, 0x55, 0xfd, 0xaa, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
+ 0x00, 0x40, 0x00, 0x40, 0xff, 0xff, 0xff, 0xff,
+ 0xf0, 0xc3, 0x43, 0xc0, 0x94, 0x94, 0x55, 0x55,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x23, 0xd0, 0xa3, 0xb0, 0x55, 0xff, 0xaa, 0x00,
+ };
+ return CreateCompressedTexture(
+ data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 16, 16);
+}
+
+GLuint LoadDXT5RGBATexture() {
+ static unsigned char data[] = {
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 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e, 0xac, 0xc4, 0x71, 0x15, 0x15, 0x15, 0x15,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x72, 0xdd, 0x03, 0x92, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0xfd, 0x00, 0x49, 0x9c, 0xc4, 0x00, 0x00, 0x00,
+ 0xb8, 0xf6, 0x53, 0xcd, 0xe0, 0xe0, 0x7f, 0xe0,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf1, 0xcc, 0x46, 0x82, 0x78, 0x78, 0x78, 0x78,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0e, 0xac, 0xc4, 0x71, 0x15, 0x15, 0x15, 0x15,
+ };
+ return CreateCompressedTexture(
+ data, sizeof(data), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, 16);
+}
+
} // anonymous namespace.
void GLFromCPPInit() {
CheckGLError("GLFromCPPInit", __LINE__);
+ g_textures[0] = CreateCheckerboardTexture();
glClearColor(0.f, 0.f, .7f, 1.f);
- g_texture = CreateCheckerboardTexture();
+ const char* extensions =
+ reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+ if (strstr(extensions, "GL_EXT_texture_compression_dxt1")) {
+ g_textures[g_numTextures++] = LoadDXT1RGBTexture();
+ g_textures[g_numTextures++] = LoadDXT1RGBATexture();
+ }
+ if (strstr(extensions, "GL_CHROMIUM_texture_compression_dxt3")) {
+ g_textures[g_numTextures++] = LoadDXT3RGBATexture();
+ }
+ if (strstr(extensions, "GL_CHROMIUM_texture_compression_dxt5")) {
+ g_textures[g_numTextures++] = LoadDXT5RGBATexture();
+ }
InitShaders();
CheckGLError("GLFromCPPInit", __LINE__);
@@ -210,9 +369,18 @@ void GLFromCPPDraw() {
rot_matrix[14] = 0.0f;
rot_matrix[15] = 1.0f;
+ g_frameCount++;
+ if (g_frameCount > 60)
+ {
+ g_frameCount = 0;
+ g_textureIndex = (g_textureIndex + 1) % g_numTextures;
+ }
+
// Note: the viewport is automatically set up to cover the entire Canvas.
// Clear the color buffer
glClear(GL_COLOR_BUFFER_BIT);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
CheckGLError("GLFromCPPDraw", __LINE__);
// Use the program object
glUseProgram(g_programObject);
@@ -229,7 +397,7 @@ void GLFromCPPDraw() {
reinterpret_cast<const void*>(g_texCoordOffset));
CheckGLError("GLFromCPPDraw", __LINE__);
// Bind the texture to texture unit 0
- glBindTexture(GL_TEXTURE_2D, g_texture);
+ glBindTexture(GL_TEXTURE_2D, g_textures[g_textureIndex]);
CheckGLError("GLFromCPPDraw", __LINE__);
// Point the uniform sampler to texture unit 0
glUniform1i(g_textureLoc, 0);
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index cde093d..b9e0d36 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -120,15 +120,17 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
bool enable_dxt3 = false;
bool enable_dxt5 = false;
bool have_s3tc = ext.Have("GL_EXT_texture_compression_s3tc");
+ bool have_dxt3 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt3");
+ bool have_dxt5 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt5");
if (ext.Desire("GL_EXT_texture_compression_dxt1") &&
(ext.Have("GL_EXT_texture_compression_dxt1") || have_s3tc)) {
enable_dxt1 = true;
}
- if (have_s3tc && ext.Desire("GL_CHROMIUM_texture_compression_dxt3")) {
+ if (have_dxt3 && ext.Desire("GL_CHROMIUM_texture_compression_dxt3")) {
enable_dxt3 = true;
}
- if (have_s3tc && ext.Desire("GL_CHROMIUM_texture_compression_dxt5")) {
+ if (have_dxt5 && ext.Desire("GL_CHROMIUM_texture_compression_dxt5")) {
enable_dxt5 = true;
}