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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_srgb_converter.cc

Issue 2419153003: Use high precision texture format during srgb conversion emulation for blitFramebuffer (Closed)
Patch Set: addressed zmo@'s feedback Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h" 5 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h"
6 6
7 #include "gpu/command_buffer/service/texture_manager.h" 7 #include "gpu/command_buffer/service/texture_manager.h"
8 #include "ui/gl/gl_version_info.h" 8 #include "ui/gl/gl_version_info.h"
9 9
10 namespace { 10 namespace {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // The steps are: 191 // The steps are:
192 // 1) Copy and crop pixels from source srgb image to the 1st texture(srgb). 192 // 1) Copy and crop pixels from source srgb image to the 1st texture(srgb).
193 // 2) Sampling from the 1st texture and drawing to the 2nd texture(linear). 193 // 2) Sampling from the 1st texture and drawing to the 2nd texture(linear).
194 // During this step, color space is converted from srgb to linear. 194 // During this step, color space is converted from srgb to linear.
195 // 3) Blit pixels from the 2nd texture to the 3rd texture(linear). 195 // 3) Blit pixels from the 2nd texture to the 3rd texture(linear).
196 // 4) Sampling from the 3rd texture and drawing to the dst image(srgb). 196 // 4) Sampling from the 3rd texture and drawing to the dst image(srgb).
197 // During this step, color space is converted from linear to srgb. 197 // During this step, color space is converted from linear to srgb.
198 // If we need to blit from linear to srgb or vice versa, some steps will be 198 // If we need to blit from linear to srgb or vice versa, some steps will be
199 // skipped. 199 // skipped.
200 DCHECK(srgb_converter_initialized_); 200 DCHECK(srgb_converter_initialized_);
201 // Use RGBA32F as the temp texture's internalformat to prevent precision
202 // loss during srgb conversion. But it is not color-renderable and
203 // texture-filterable in ES context.
204 DCHECK(!feature_info_->gl_version_info().is_es);
201 205
202 // Set the states 206 // Set the states
203 glActiveTexture(GL_TEXTURE0); 207 glActiveTexture(GL_TEXTURE0);
204 glDisable(GL_SCISSOR_TEST); 208 glDisable(GL_SCISSOR_TEST);
205 glDisable(GL_DEPTH_TEST); 209 glDisable(GL_DEPTH_TEST);
206 glDisable(GL_STENCIL_TEST); 210 glDisable(GL_STENCIL_TEST);
207 glDisable(GL_CULL_FACE); 211 glDisable(GL_CULL_FACE);
208 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 212 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
209 glDepthMask(GL_FALSE); 213 glDepthMask(GL_FALSE);
210 glDisable(GL_BLEND); 214 glDisable(GL_BLEND);
(...skipping 21 matching lines...) Expand all
232 xoffset = c.x() - x; 236 xoffset = c.x() - x;
233 yoffset = c.y() - y; 237 yoffset = c.y() - y;
234 glCopyTexImage2D(GL_TEXTURE_2D, 0, src_framebuffer_internal_format, 238 glCopyTexImage2D(GL_TEXTURE_2D, 0, src_framebuffer_internal_format,
235 c.x(), c.y(), c.width(), c.height(), 0); 239 c.x(), c.y(), c.width(), c.height(), 0);
236 240
237 // Make a temporary linear texture as the 2nd texture, where we 241 // Make a temporary linear texture as the 2nd texture, where we
238 // render the converted (srgb to linear) result to. 242 // render the converted (srgb to linear) result to.
239 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 243 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
240 244
241 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); 245 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
242 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 246 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
243 c.width(), c.height(), 247 c.width(), c.height(),
244 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); 248 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
245 glBindFramebufferEXT(GL_FRAMEBUFFER, srgb_decoder_fbo_); 249 glBindFramebufferEXT(GL_FRAMEBUFFER, srgb_decoder_fbo_);
246 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 250 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
247 GL_TEXTURE_2D, srgb_converter_textures_[1], 0); 251 GL_TEXTURE_2D, srgb_converter_textures_[1], 0);
248 252
249 // Sampling from the 1st texture(srgb) and drawing to the 253 // Sampling from the 1st texture(srgb) and drawing to the
250 // 2nd texture(linear), 254 // 2nd texture(linear),
251 glUseProgram(srgb_converter_program_); 255 glUseProgram(srgb_converter_program_);
252 glViewport(0, 0, width_read, height_read); 256 glViewport(0, 0, width_read, height_read);
(...skipping 12 matching lines...) Expand all
265 // from the 2nd texture(linear) to the 3rd texture. Filtering is done 269 // from the 2nd texture(linear) to the 3rd texture. Filtering is done
266 // during bliting. Note that the src and dst coordinates may be reversed. 270 // during bliting. Note that the src and dst coordinates may be reversed.
267 GLuint width_draw = 0, height_draw = 0; 271 GLuint width_draw = 0, height_draw = 0;
268 if (encode) { 272 if (encode) {
269 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[0]); 273 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[0]);
270 274
271 width_draw = dstX1 > dstX0 ? dstX1 - dstX0 : dstX0 - dstX1; 275 width_draw = dstX1 > dstX0 ? dstX1 - dstX0 : dstX0 - dstX1;
272 height_draw = dstY1 > dstY0 ? dstY1 - dstY0 : dstY0 - dstY1; 276 height_draw = dstY1 > dstY0 ? dstY1 - dstY0 : dstY0 - dstY1;
273 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 277 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
274 glTexImage2D( 278 glTexImage2D(
275 GL_TEXTURE_2D, 0, decode ? GL_RGBA : src_framebuffer_internal_format, 279 GL_TEXTURE_2D, 0, decode ? GL_RGBA32F : src_framebuffer_internal_format,
276 width_draw, height_draw, 0, 280 width_draw, height_draw, 0,
277 decode ? GL_RGBA : src_framebuffer_format, 281 decode ? GL_RGBA : src_framebuffer_format,
278 decode ? GL_UNSIGNED_BYTE : src_framebuffer_type, 282 decode ? GL_UNSIGNED_BYTE : src_framebuffer_type,
279 nullptr); 283 nullptr);
280 284
281 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); 285 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_);
282 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 286 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
283 GL_TEXTURE_2D, srgb_converter_textures_[0], 0); 287 GL_TEXTURE_2D, srgb_converter_textures_[0], 0);
284 } else { 288 } else {
285 // Set approriate draw framebuffer if encoding is skipped. 289 // Set approriate draw framebuffer if encoding is skipped.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 decoder->RestoreActiveTexture(); 424 decoder->RestoreActiveTexture();
421 decoder->RestoreProgramBindings(); 425 decoder->RestoreProgramBindings();
422 decoder->RestoreBufferBindings(); 426 decoder->RestoreBufferBindings();
423 decoder->RestoreFramebufferBindings(); 427 decoder->RestoreFramebufferBindings();
424 decoder->RestoreGlobalState(); 428 decoder->RestoreGlobalState();
425 decoder->RestoreTextureState(tex->service_id()); 429 decoder->RestoreTextureState(tex->service_id());
426 } 430 }
427 431
428 } // namespace gles2. 432 } // namespace gles2.
429 } // namespace gpu 433 } // namespace gpu
OLDNEW
« 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