Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: gpu/command_buffer/service/gles2_cmd_srgb_converter.cc

Issue 2900403003: Set the texture base level before generating sRGB mipmaps. (Closed)
Patch Set: Fix sizes for mips Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc b/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
index 1f560dd1909b4752948ce5291187d1028fe96280..a0fdd5649666a1077681598858bf395c38713f0a 100644
--- a/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
+++ b/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
@@ -478,20 +478,31 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
base::CheckedNumeric<GLint> level = base_level;
level += 1;
- for (; level.IsValid() && level.ValueOrDie() <= max_mipmap_available_level;
- ++level) {
- // copy mipmaps level by level from srgb_converter_textures_[1] to tex
- // generate mipmap for tex manually
+
+ if (!tex->IsImmutable()) {
glBindTexture(GL_TEXTURE_2D, tex->service_id());
- if (!tex->IsImmutable()) {
- glTexImage2D(GL_TEXTURE_2D, level.ValueOrDie(), internal_format, width,
- height, 0, format, type, nullptr);
+ GLsizei level_width = width;
+ GLsizei level_height = height;
+ for (base::CheckedNumeric<GLint> i = level;
+ i.IsValid() && i.ValueOrDie() <= max_mipmap_available_level; ++i) {
+ glTexImage2D(GL_TEXTURE_2D, i.ValueOrDie(), internal_format, level_width,
+ level_height, 0, format, type, nullptr);
+ level_width = (level_width == 1) ? 1 : level_width >> 1;
+ level_height = (level_height == 1) ? 1 : level_height >> 1;
}
+ }
+
+ glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
+ for (base::CheckedNumeric<GLint> i = level;
+ i.IsValid() && i.ValueOrDie() <= max_mipmap_available_level; ++i) {
+ // copy mipmaps level by level from srgb_converter_textures_[1] to tex
+ // generate mipmap for tex manually
glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, tex->service_id(),
- level.ValueOrDie());
+ GL_TEXTURE_2D, tex->service_id(), i.ValueOrDie());
+
+ DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
+ glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER));
- glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
glViewport(0, 0, width, height);
glDrawArrays(GL_TRIANGLES, 0, 6);
width = (width == 1) ? 1 : width >> 1;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698