OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 m_immutable = true; | 207 m_immutable = true; |
208 } | 208 } |
209 | 209 |
210 void WebGLTexture::generateMipmapLevelInfo() | 210 void WebGLTexture::generateMipmapLevelInfo() |
211 { | 211 { |
212 if (!object() || !m_target) | 212 if (!object() || !m_target) |
213 return; | 213 return; |
214 if (!canGenerateMipmaps()) | 214 if (!canGenerateMipmaps()) |
215 return; | 215 return; |
216 if (!m_isComplete) { | 216 if (!m_isComplete) { |
217 size_t baseLevel = std::min(m_baseLevel, m_info[0].size() - 1); | |
218 for (size_t ii = 0; ii < m_info.size(); ++ii) { | 217 for (size_t ii = 0; ii < m_info.size(); ++ii) { |
219 const LevelInfo& info0 = m_info[ii][baseLevel]; | 218 const LevelInfo& info0 = m_info[ii][m_baseLevel]; |
220 GLsizei width = info0.width; | 219 GLsizei width = info0.width; |
221 GLsizei height = info0.height; | 220 GLsizei height = info0.height; |
222 GLsizei depth = info0.depth; | 221 GLsizei depth = info0.depth; |
223 GLint levelCount = computeLevelCount(width, height, depth); | 222 GLint levelCount = computeLevelCount(width, height, depth); |
224 size_t maxLevel = m_isWebGL2OrHigher ? std::min(m_maxLevel, baseLeve l + levelCount - 1) : baseLevel + levelCount - 1; | 223 size_t maxLevel = m_isWebGL2OrHigher ? std::min(m_maxLevel, m_baseLe vel + levelCount - 1) : m_baseLevel + levelCount - 1; |
Ken Russell (switch to Gerrit)
2015/09/09 01:30:26
Is this code correct? It looks to me like it's pos
Zhenyao Mo
2015/09/09 01:34:48
in canGenerateMipmaps() the case where m_maxLevel
Ken Russell (switch to Gerrit)
2015/09/09 01:59:33
Sorry, could you please point me to that code? Loo
qiankun
2015/09/09 02:09:32
As we discussed in https://github.com/KhronosGroup
Ken Russell (switch to Gerrit)
2015/09/09 02:14:19
The question is what the loop below will do if max
Zhenyao Mo
2015/09/09 02:27:19
My bad. The check is in update(), unrelated to ge
qiankun
2015/09/09 04:36:06
WebGLRenderingContextBase::validateTexFuncDimensio
| |
225 for (size_t level = baseLevel + 1; level <= maxLevel; ++level) { | 224 for (size_t level = m_baseLevel + 1; level <= maxLevel; ++level) { |
226 width = std::max(1, width >> 1); | 225 width = std::max(1, width >> 1); |
227 height = std::max(1, height >> 1); | 226 height = std::max(1, height >> 1); |
228 depth = std::max(1, depth >> 1); | 227 depth = std::max(1, depth >> 1); |
229 LevelInfo& info = m_info[ii][level]; | 228 LevelInfo& info = m_info[ii][level]; |
230 info.setInfo(info0.internalFormat, width, height, depth, info0.t ype); | 229 info.setInfo(info0.internalFormat, width, height, depth, info0.t ype); |
231 } | 230 } |
232 } | 231 } |
233 m_isComplete = true; | 232 m_isComplete = true; |
234 } | 233 } |
235 m_needToUseBlackTexture = false; | 234 m_needToUseBlackTexture = false; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 return 0; | 346 return 0; |
348 } | 347 } |
349 return -1; | 348 return -1; |
350 } | 349 } |
351 | 350 |
352 bool WebGLTexture::canGenerateMipmaps() | 351 bool WebGLTexture::canGenerateMipmaps() |
353 { | 352 { |
354 if (!m_isWebGL2OrHigher && isNPOT()) | 353 if (!m_isWebGL2OrHigher && isNPOT()) |
355 return false; | 354 return false; |
356 | 355 |
357 size_t baseLevel = std::min(m_baseLevel, m_info[0].size() - 1); | 356 if (m_baseLevel >= m_info[0].size()) |
358 const LevelInfo& base = m_info[0][baseLevel]; | 357 return false; |
358 const LevelInfo& base = m_info[0][m_baseLevel]; | |
359 for (size_t ii = 0; ii < m_info.size(); ++ii) { | 359 for (size_t ii = 0; ii < m_info.size(); ++ii) { |
360 const LevelInfo& info = m_info[ii][baseLevel]; | 360 const LevelInfo& info = m_info[ii][m_baseLevel]; |
361 if (!info.valid | 361 if (!info.valid |
362 || info.width != base.width || info.height != base.height || info.de pth != base.depth | 362 || info.width != base.width || info.height != base.height || info.de pth != base.depth |
363 || info.internalFormat != base.internalFormat || info.type != base.t ype | 363 || info.internalFormat != base.internalFormat || info.type != base.t ype |
364 || (m_info.size() > 1 && !m_isCubeComplete)) | 364 || (m_info.size() > 1 && !m_isCubeComplete)) |
365 return false; | 365 return false; |
366 } | 366 } |
367 return true; | 367 return true; |
368 } | 368 } |
369 | 369 |
370 GLint WebGLTexture::computeLevelCount(GLsizei width, GLsizei height, GLsizei dep th) | 370 GLint WebGLTexture::computeLevelCount(GLsizei width, GLsizei height, GLsizei dep th) |
(...skipping 21 matching lines...) Expand all Loading... | |
392 m_isNPOT = false; | 392 m_isNPOT = false; |
393 for (size_t ii = 0; ii < m_info.size(); ++ii) { | 393 for (size_t ii = 0; ii < m_info.size(); ++ii) { |
394 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) { | 394 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) { |
395 m_isNPOT = true; | 395 m_isNPOT = true; |
396 break; | 396 break; |
397 } | 397 } |
398 } | 398 } |
399 m_isComplete = true; | 399 m_isComplete = true; |
400 m_isCubeComplete = true; | 400 m_isCubeComplete = true; |
401 | 401 |
402 size_t baseLevel = std::min(m_baseLevel, m_info[0].size() - 1); | 402 if (m_baseLevel > m_maxLevel || m_baseLevel >= m_info[0].size()) { |
403 const LevelInfo& base = m_info[0][baseLevel]; | |
404 size_t levelCount = computeLevelCount(base.width, base.height, base.depth); | |
405 size_t maxLevel = m_isWebGL2OrHigher ? std::min(m_maxLevel, baseLevel + leve lCount - 1) : baseLevel + levelCount - 1; | |
406 | |
407 if (baseLevel > maxLevel) { | |
408 m_isComplete = false; | 403 m_isComplete = false; |
409 } | 404 } |
410 else { | 405 else { |
406 const LevelInfo& base = m_info[0][m_baseLevel]; | |
407 size_t levelCount = computeLevelCount(base.width, base.height, base.dept h); | |
408 size_t maxLevel = m_isWebGL2OrHigher ? std::min(m_maxLevel, m_baseLevel + levelCount - 1) : m_baseLevel + levelCount - 1; | |
411 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) { | 409 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) { |
412 const LevelInfo& info0 = m_info[ii][baseLevel]; | 410 const LevelInfo& info0 = m_info[ii][m_baseLevel]; |
413 if (!info0.valid | 411 if (!info0.valid |
414 || info0.width != base.width || info0.height != base.height || i nfo0.depth != base.depth | 412 || info0.width != base.width || info0.height != base.height || i nfo0.depth != base.depth |
415 || info0.internalFormat != base.internalFormat || info0.type != base.type | 413 || info0.internalFormat != base.internalFormat || info0.type != base.type |
416 || (m_info.size() > 1 && info0.width != info0.height)) { | 414 || (m_info.size() > 1 && info0.width != info0.height)) { |
417 if (m_info.size() > 1) | 415 if (m_info.size() > 1) |
418 m_isCubeComplete = false; | 416 m_isCubeComplete = false; |
419 m_isComplete = false; | 417 m_isComplete = false; |
420 break; | 418 break; |
421 } | 419 } |
422 GLsizei width = info0.width; | 420 GLsizei width = info0.width; |
423 GLsizei height = info0.height; | 421 GLsizei height = info0.height; |
424 GLsizei depth = info0.depth; | 422 GLsizei depth = info0.depth; |
425 for (size_t level = baseLevel + 1; level <= maxLevel; ++level) { | 423 for (size_t level = m_baseLevel + 1; level <= maxLevel; ++level) { |
426 width = std::max(1, width >> 1); | 424 width = std::max(1, width >> 1); |
427 height = std::max(1, height >> 1); | 425 height = std::max(1, height >> 1); |
428 depth = std::max(1, depth >> 1); | 426 depth = std::max(1, depth >> 1); |
429 const LevelInfo& info = m_info[ii][level]; | 427 const LevelInfo& info = m_info[ii][level]; |
430 if (!info.valid | 428 if (!info.valid |
431 || info.width != width || info.height != height || info.dept h != depth | 429 || info.width != width || info.height != height || info.dept h != depth |
432 || info.internalFormat != info0.internalFormat || info.type != info0.type) { | 430 || info.internalFormat != info0.internalFormat || info.type != info0.type) { |
433 m_isComplete = false; | 431 m_isComplete = false; |
434 break; | 432 break; |
435 } | 433 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 588 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
591 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 589 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
592 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 590 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
593 return GL_UNSIGNED_BYTE; | 591 return GL_UNSIGNED_BYTE; |
594 default: | 592 default: |
595 return GL_NONE; | 593 return GL_NONE; |
596 } | 594 } |
597 } | 595 } |
598 | 596 |
599 } // namespace blink | 597 } // namespace blink |
OLD | NEW |