diff options
author | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 19:57:56 +0000 |
---|---|---|
committer | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 19:57:56 +0000 |
commit | f45e5deec9729cf2fcd5edb8a23b76e91334984d (patch) | |
tree | 009b6e9127f32aa1cdcb0699a9de88940e9c5b41 /o3d | |
parent | 35b6e20279d714ab37fb9196ee57253111bbb83e (diff) | |
download | chromium_src-f45e5deec9729cf2fcd5edb8a23b76e91334984d.zip chromium_src-f45e5deec9729cf2fcd5edb8a23b76e91334984d.tar.gz chromium_src-f45e5deec9729cf2fcd5edb8a23b76e91334984d.tar.bz2 |
Added 32-bit float textures to command buffers, also changed the texture::Format enum to be more like Texture::Format in o3d.
Review URL: http://codereview.chromium.org/227011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/command_buffer/common/cross/resource.cc | 7 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/resource.h | 6 | ||||
-rw-r--r-- | o3d/command_buffer/service/cross/gapi_decoder.cc | 6 | ||||
-rw-r--r-- | o3d/command_buffer/service/cross/gl/texture_gl.cc | 35 | ||||
-rw-r--r-- | o3d/command_buffer/service/win/d3d9/texture_d3d9.cc | 11 | ||||
-rw-r--r-- | o3d/core/cross/command_buffer/texture_cb.cc | 10 |
6 files changed, 55 insertions, 20 deletions
diff --git a/o3d/command_buffer/common/cross/resource.cc b/o3d/command_buffer/common/cross/resource.cc index a077bf1..5ecdda7 100644 --- a/o3d/command_buffer/common/cross/resource.cc +++ b/o3d/command_buffer/common/cross/resource.cc @@ -44,12 +44,16 @@ unsigned int GetBytesPerBlock(Format format) { switch (format) { case kXRGB8: case kARGB8: + case kR32F: return 4; case kABGR16F: return 8; + case kABGR32F: + return 16; case kDXT1: return 8; default: + // TODO(petersont): Add DXT3/5 support. LOG(FATAL) << "Invalid format"; return 1; } @@ -61,10 +65,13 @@ unsigned int GetBlockSizeX(Format format) { case kXRGB8: case kARGB8: case kABGR16F: + case kR32F: + case kABGR32F: return 1; case kDXT1: return 4; default: + // TODO(petersont): Add DXT3/5 support. LOG(FATAL) << "Invalid format"; return 1; } diff --git a/o3d/command_buffer/common/cross/resource.h b/o3d/command_buffer/common/cross/resource.h index 3cd4d3b..fce64a2 100644 --- a/o3d/command_buffer/common/cross/resource.h +++ b/o3d/command_buffer/common/cross/resource.h @@ -162,11 +162,13 @@ enum Flags { // Texel formats. enum Format { + kUnknown, kXRGB8, kARGB8, kABGR16F, - kDXT1, - kNumFormats + kR32F, + kABGR32F, + kDXT1 }; // Texture type. diff --git a/o3d/command_buffer/service/cross/gapi_decoder.cc b/o3d/command_buffer/service/cross/gapi_decoder.cc index 3e6f0a2..9a4be8a 100644 --- a/o3d/command_buffer/service/cross/gapi_decoder.cc +++ b/o3d/command_buffer/service/cross/gapi_decoder.cc @@ -531,7 +531,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d( unsigned int max_levels = 1 + base::bits::Log2Ceiling(std::max(width, height)); if ((width == 0) || (height == 0) || (levels > max_levels) || - (unused != 0) || (format >= texture::kNumFormats) || (levels == 0)) + (unused != 0) || (format == texture::kUnknown) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTexture2D(args.texture_id, width, height, levels, @@ -558,7 +558,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d( 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); if ((width == 0) || (height == 0) || (depth == 0) || (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || - (format >= texture::kNumFormats) || (levels == 0)) + (format == texture::kUnknown) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels, @@ -582,7 +582,7 @@ BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube( unsigned int flags = cmd::CreateTextureCube::Flags::Get(levels_format_flags); unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); if ((side == 0) || (levels > max_levels) || (unused1 != 0) || - (unused2 != 0) || (format >= texture::kNumFormats) || (levels == 0)) + (unused2 != 0) || (format == texture::kUnknown) || (levels == 0)) return BufferSyncInterface::kParseInvalidArguments; bool enable_render_surfaces = !!flags; return gapi_->CreateTextureCube(args.texture_id, side, levels, diff --git a/o3d/command_buffer/service/cross/gl/texture_gl.cc b/o3d/command_buffer/service/cross/gl/texture_gl.cc index 68a471a..2b01e48 100644 --- a/o3d/command_buffer/service/cross/gl/texture_gl.cc +++ b/o3d/command_buffer/service/cross/gl/texture_gl.cc @@ -47,29 +47,48 @@ bool GetGLFormatType(texture::Format format, GLenum *gl_format, GLenum *gl_type) { switch (format) { - case texture::kXRGB8: + case texture::kXRGB8: { *internal_format = GL_RGB; *gl_format = GL_BGRA; *gl_type = GL_UNSIGNED_BYTE; - return true; - case texture::kARGB8: + break; + } + case texture::kARGB8: { *internal_format = GL_RGBA; *gl_format = GL_BGRA; *gl_type = GL_UNSIGNED_BYTE; - return true; - case texture::kABGR16F: + break; + } + case texture::kABGR16F: { *internal_format = GL_RGBA16F_ARB; *gl_format = GL_RGBA; *gl_type = GL_HALF_FLOAT_ARB; - return true; - case texture::kDXT1: + break; + } + case texture::kR32F: { + *internal_format = GL_LUMINANCE32F_ARB; + *gl_format = GL_LUMINANCE; + *gl_type = GL_FLOAT; + break; + } + case texture::kABGR32F: { + *internal_format = GL_RGBA32F_ARB; + *gl_format = GL_BGRA; + *gl_type = GL_FLOAT; + break; + } + case texture::kDXT1: { *internal_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; *gl_format = 0; *gl_type = 0; - return true; + break; + } + // TODO(petersont): Add DXT3/5 support. default: return false; } + + return true; } // Helper class used to prepare image data to match the layout that diff --git a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc index db723d5..fd03fb6 100644 --- a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc +++ b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc @@ -42,10 +42,13 @@ namespace command_buffer { // Converts a texture format to a D3D texture format. D3DFORMAT TextureD3D9::D3DFormat(texture::Format format) { switch (format) { - case texture::kXRGB8: return D3DFMT_X8R8G8B8; - case texture::kARGB8: return D3DFMT_A8R8G8B8; - case texture::kABGR16F: return D3DFMT_A16B16G16R16F; - case texture::kDXT1: return D3DFMT_DXT1; + case texture::XRGB8: return D3DFMT_X8R8G8B8; + case texture::ARGB8: return D3DFMT_A8R8G8B8; + case texture::ABGR16F: return D3DFMT_A16B16G16R16F; + case texture::R32F: return D3DFMT_R32F; + case texture::ABGR32F: return D3DFMT_A32B32G32R32F; + case texture::DXT1: return D3DFMT_DXT1; + // TODO(petersont): Add DXT3/5 support. default: return D3DFMT_UNKNOWN; }; } diff --git a/o3d/core/cross/command_buffer/texture_cb.cc b/o3d/core/cross/command_buffer/texture_cb.cc index 91791df..3b6b32d 100644 --- a/o3d/core/cross/command_buffer/texture_cb.cc +++ b/o3d/core/cross/command_buffer/texture_cb.cc @@ -65,6 +65,10 @@ texture::Format CBFormatFromO3DFormat(Texture::Format format) { return texture::kARGB8; case Texture::ABGR16F: return texture::kABGR16F; + case Texture::R32F: + return texture::kR32F; + case Texture::ABGR32F: + return texture::kABGR32F; case Texture::DXT1: return texture::kDXT1; // TODO: DXT3/5. It's not yet supported by the command buffer @@ -74,7 +78,7 @@ texture::Format CBFormatFromO3DFormat(Texture::Format format) { } // failed to find a matching format LOG(ERROR) << "Unrecognized Texture format type."; - return texture::kNumFormats; + return texture::kUnknown; } // Checks that enums match in value, so that they can be directly used in @@ -267,7 +271,7 @@ Texture2DCB* Texture2DCB::Create(ServiceLocator* service_locator, RendererCB *renderer = static_cast<RendererCB *>( service_locator->GetService<Renderer>()); texture::Format cb_format = CBFormatFromO3DFormat(format); - if (cb_format == texture::kNumFormats) { + if (cb_format == texture::kUnknown) { O3D_ERROR(service_locator) << "Unsupported format in Texture2DCB::Create."; return NULL; @@ -482,7 +486,7 @@ TextureCUBECB* TextureCUBECB::Create(ServiceLocator* service_locator, RendererCB *renderer = static_cast<RendererCB *>( service_locator->GetService<Renderer>()); texture::Format cb_format = CBFormatFromO3DFormat(format); - if (cb_format == texture::kNumFormats) { + if (cb_format == texture::kUnknown) { O3D_ERROR(service_locator) << "Unsupported format in Texture2DCB::Create."; return NULL; |