summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 00:08:47 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 00:08:47 +0000
commit9c374dbfeb787d684ffcc397d5a7105eae67dce4 (patch)
tree81d9b2be907032fd7f898968bf5edaabe77869bc /gpu/command_buffer
parent614b4a701aa26a3979f2b0f14ead01c3f3a49423 (diff)
downloadchromium_src-9c374dbfeb787d684ffcc397d5a7105eae67dce4.zip
chromium_src-9c374dbfeb787d684ffcc397d5a7105eae67dce4.tar.gz
chromium_src-9c374dbfeb787d684ffcc397d5a7105eae67dce4.tar.bz2
Adds support for GL_EXT_texture_compression_s3tc,
GL_EXT_texture_filter_anisotropic, GL_OES_packed_depth_stencil GL_GOOGLE_depth_texture TEST=unit tests and ran conformance tests BUG=53262,53264,53266,53270 Review URL: http://codereview.chromium.org/3135048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py2
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc6
-rw-r--r--gpu/command_buffer/service/context_group.cc61
-rw-r--r--gpu/command_buffer/service/context_group_unittest.cc121
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h5
-rw-r--r--gpu/command_buffer/service/texture_manager.cc3
6 files changed, 189 insertions, 9 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 05310a4..59ed349 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -56,7 +56,7 @@ GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green,
GL_APICALL void GL_APIENTRY glCompileShader (GLidShader shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenumTextureTarget target, GLint level, GLenumCompressedTextureFormat internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenumTextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenumCompressedTextureFormat format, GLsizei imageSize, const void* data);
-GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenumTextureTarget target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenumTextureTarget target, GLint level, GLenumTextureInternalFormat internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenumTextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenumShaderType type);
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index 6f28bc5..a517c89 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -6,6 +6,7 @@
// includes where appropriate.
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include <GLES2/gles2_command_buffer.h>
#include "../common/gles2_cmd_utils.h"
@@ -304,6 +305,7 @@ int ElementsPerGroup(int format, int type) {
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_INT_24_8_OES:
return 1;
default:
break;
@@ -313,12 +315,13 @@ int ElementsPerGroup(int format, int type) {
case GL_RGB:
return 3;
case GL_LUMINANCE_ALPHA:
- return 2;
case GL_RGBA:
case GL_BGRA_EXT:
return 4;
case GL_ALPHA:
case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL_OES:
return 1;
default:
return 0;
@@ -329,6 +332,7 @@ int ElementsPerGroup(int format, int type) {
int BytesPerElement(int type) {
switch (type) {
case GL_FLOAT:
+ case GL_UNSIGNED_INT_24_8_OES:
return 4;
case GL_HALF_FLOAT_OES:
case GL_UNSIGNED_SHORT:
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index 64150ca..8c85917 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -55,9 +55,20 @@ bool ContextGroup::Initialize() {
AddExtensionString("GL_CHROMIUM_map_sub");
- // Check if we should allow GL_EXT_texture_compression_dxt1.
- if (strstr(extensions, "GL_EXT_texture_compression_dxt1") ||
- strstr(extensions, "GL_EXT_texture_compression_s3tc")) {
+ // Check if we should allow GL_EXT_texture_compression_dxt1 and
+ // GL_EXT_texture_compression_s3tc.
+ bool enable_dxt1 = false;
+ bool enable_s3tc = false;
+
+ if (strstr(extensions, "GL_EXT_texture_compression_dxt1")) {
+ enable_dxt1 = true;
+ }
+ if (strstr(extensions, "GL_EXT_texture_compression_s3tc")) {
+ enable_dxt1 = true;
+ enable_s3tc = true;
+ }
+
+ if (enable_dxt1) {
AddExtensionString("GL_EXT_texture_compression_dxt1");
validators_.compressed_texture_format.AddValue(
GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
@@ -65,6 +76,48 @@ bool ContextGroup::Initialize() {
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
}
+ if (enable_s3tc) {
+ AddExtensionString("GL_EXT_texture_compression_s3tc");
+ validators_.compressed_texture_format.AddValue(
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
+ validators_.compressed_texture_format.AddValue(
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
+ }
+
+ // Check if we should enable GL_EXT_texture_filter_anisotropic.
+ if (strstr(extensions, "GL_EXT_texture_filter_anisotropic")) {
+ AddExtensionString("GL_EXT_texture_filter_anisotropic");
+ validators_.texture_parameter.AddValue(
+ GL_TEXTURE_MAX_ANISOTROPY_EXT);
+ validators_.g_l_state.AddValue(
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
+ }
+
+ // Check if we should support GL_OES_packed_depth_stencil and/or
+ // GL_GOOGLE_depth_texture.
+ bool enable_depth_texture = false;
+ if (strstr(extensions, "GL_ARB_depth_texture") ||
+ strstr(extensions, "GL_OES_depth_texture")) {
+ enable_depth_texture = true;
+ AddExtensionString("GL_GOOGLE_depth_texture");
+ validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
+ validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
+ validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
+ validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
+ }
+ // TODO(gman): Add depth types fo ElementsPerGroup and BytesPerElement
+
+ if (strstr(extensions, "GL_EXT_packed_depth_stencil") ||
+ strstr(extensions, "GL_OES_packed_depth_stencil")) {
+ AddExtensionString("GL_OES_packed_depth_stencil");
+ if (enable_depth_texture) {
+ validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
+ validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
+ validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
+ }
+ validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
+ }
+
bool enable_texture_format_bgra8888 = false;
bool enable_read_format_bgra = false;
// Check if we should allow GL_EXT_texture_format_BGRA8888
@@ -148,7 +201,6 @@ bool ContextGroup::Initialize() {
validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT);
- validators_.g_l_state.AddValue(GL_DRAW_FRAMEBUFFER_BINDING_EXT);
validators_.render_buffer_parameter.AddValue(GL_MAX_SAMPLES_EXT);
AddExtensionString("GL_EXT_framebuffer_multisample");
AddExtensionString("GL_EXT_framebuffer_blit");
@@ -157,7 +209,6 @@ bool ContextGroup::Initialize() {
// TODO(gman): Add support for these extensions.
// GL_OES_depth24
// GL_OES_depth32
- // GL_OES_packed_depth_stencil
// GL_OES_element_index_uint
buffer_manager_.reset(new BufferManager());
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc
index be6888e..066da29 100644
--- a/gpu/command_buffer/service/context_group_unittest.cc
+++ b/gpu/command_buffer/service/context_group_unittest.cc
@@ -82,8 +82,37 @@ TEST_F(ContextGroupTest, InitializeNoExtensions) {
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
+ EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
+ EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
EXPECT_FALSE(group_.validators()->read_pixel_format.IsValid(
GL_BGRA_EXT));
+ EXPECT_FALSE(group_.validators()->texture_parameter.IsValid(
+ GL_TEXTURE_MAX_ANISOTROPY_EXT));
+ EXPECT_FALSE(group_.validators()->g_l_state.IsValid(
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
+ EXPECT_FALSE(group_.validators()->frame_buffer_target.IsValid(
+ GL_READ_FRAMEBUFFER_EXT));
+ EXPECT_FALSE(group_.validators()->frame_buffer_target.IsValid(
+ GL_DRAW_FRAMEBUFFER_EXT));
+ EXPECT_FALSE(group_.validators()->g_l_state.IsValid(
+ GL_READ_FRAMEBUFFER_BINDING_EXT));
+ EXPECT_FALSE(group_.validators()->render_buffer_parameter.IsValid(
+ GL_MAX_SAMPLES_EXT));
+ EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+ EXPECT_FALSE(group_.validators()->render_buffer_format.IsValid(
+ GL_DEPTH24_STENCIL8));
+ EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_STENCIL));
+ EXPECT_FALSE(group_.validators()->texture_format.IsValid(
+ GL_DEPTH_STENCIL));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(
+ GL_UNSIGNED_INT_24_8));
}
TEST_F(ContextGroupTest, InitializeNPOTExtensionGLES) {
@@ -109,6 +138,10 @@ TEST_F(ContextGroupTest, InitializeDXTExtensionGLES2) {
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
+ EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
+ EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
}
TEST_F(ContextGroupTest, InitializeDXTExtensionGL) {
@@ -116,10 +149,16 @@ TEST_F(ContextGroupTest, InitializeDXTExtensionGL) {
group_.Initialize();
EXPECT_THAT(group_.extensions(),
HasSubstr("GL_EXT_texture_compression_dxt1"));
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_EXT_texture_compression_s3tc"));
EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid(
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
+ EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
+ EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid(
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
}
TEST_F(ContextGroupTest, InitializeEXT_texture_format_BGRA8888GLES2) {
@@ -244,12 +283,90 @@ TEST_F(ContextGroupTest, InitializeEXT_framebuffer_multisample) {
GL_DRAW_FRAMEBUFFER_EXT));
EXPECT_TRUE(group_.validators()->g_l_state.IsValid(
GL_READ_FRAMEBUFFER_BINDING_EXT));
- EXPECT_TRUE(group_.validators()->g_l_state.IsValid(
- GL_DRAW_FRAMEBUFFER_BINDING_EXT));
EXPECT_TRUE(group_.validators()->render_buffer_parameter.IsValid(
GL_MAX_SAMPLES_EXT));
}
+TEST_F(ContextGroupTest, InitializeEXT_texture_filter_anisotropic) {
+ SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_EXT_texture_filter_anisotropic"));
+ EXPECT_TRUE(group_.validators()->texture_parameter.IsValid(
+ GL_TEXTURE_MAX_ANISOTROPY_EXT));
+ EXPECT_TRUE(group_.validators()->g_l_state.IsValid(
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
+}
+
+TEST_F(ContextGroupTest, InitializeEXT_ARB_depth_texture) {
+ SetupInitExpectations("GL_ARB_depth_texture");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_GOOGLE_depth_texture"));
+ EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+}
+
+TEST_F(ContextGroupTest, InitializeOES_ARB_depth_texture) {
+ SetupInitExpectations("GL_OES_depth_texture");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_GOOGLE_depth_texture"));
+ EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+}
+
+TEST_F(ContextGroupTest, InitializeEXT_packed_depth_stencil) {
+ SetupInitExpectations("GL_EXT_packed_depth_stencil");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_OES_packed_depth_stencil"));
+ EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid(
+ GL_DEPTH24_STENCIL8));
+ EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+}
+
+TEST_F(ContextGroupTest, InitializeOES_packed_depth_stencil) {
+ SetupInitExpectations("GL_OES_packed_depth_stencil");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_OES_packed_depth_stencil"));
+ EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid(
+ GL_DEPTH24_STENCIL8));
+ EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
+ EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
+}
+
+TEST_F(ContextGroupTest,
+ InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) {
+ SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
+ group_.Initialize();
+ EXPECT_THAT(group_.extensions(),
+ HasSubstr("GL_OES_packed_depth_stencil"));
+ EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid(
+ GL_DEPTH24_STENCIL8));
+ EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid(
+ GL_DEPTH_STENCIL));
+ EXPECT_TRUE(group_.validators()->texture_format.IsValid(
+ GL_DEPTH_STENCIL));
+ EXPECT_TRUE(group_.validators()->pixel_type.IsValid(
+ GL_UNSIGNED_INT_24_8));
+}
+
+
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index aefe831..7e15253 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -367,6 +367,11 @@ error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
SetGLError(GL_INVALID_ENUM, "glCopyTexImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
+ if (!validators_->texture_internal_format.IsValid(internalformat)) {
+ SetGLError(
+ GL_INVALID_ENUM, "glCopyTexImage2D: internalformat GL_INVALID_ENUM");
+ return error::kNoError;
+ }
if (width < 0) {
SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D: width < 0");
return error::kNoError;
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 607938e..66a8d55 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -268,6 +268,9 @@ void TextureManager::TextureInfo::SetParameter(
case GL_TEXTURE_WRAP_T:
wrap_t_ = param;
break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ // Nothing to do for this case at the moment.
+ break;
default:
NOTREACHED();
break;