Commit 0500571c authored by yizhou.jiang's avatar yizhou.jiang Committed by Commit bot

optimize precision for conversion from srgb to linear

Convertion from sRGB to 8-bit linear is going to reduce the
precision of the texture, and the downsampling will do the
same thing. We should set texture internalformat to rgba32f
to optimize precision.

BUG=634519
TEST=conformance2/textures/misc/tex-srgb-mipmap.html
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2420813002
Cr-Commit-Position: refs/heads/master@{#427014}
parent 391fa63b
......@@ -161,6 +161,14 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
void EnableOESTextureFloatLinear();
void EnableOESTextureHalfFloatLinear();
bool ext_color_buffer_float_available() const {
return ext_color_buffer_float_available_;
}
bool oes_texture_float_linear_available() const {
return oes_texture_float_linear_available_;
}
private:
friend class base::RefCounted<FeatureInfo>;
friend class BufferManagerClientSideArraysTest;
......
......@@ -360,10 +360,15 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
const GLint mipmap_levels =
TextureManager::ComputeMipMapCount(target, width, height, depth);
// bind srgb_decoder_textures_[1] to draw framebuffer
glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
if (feature_info_->ext_color_buffer_float_available() &&
feature_info_->oes_texture_float_linear_available()) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, nullptr);
} else {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, nullptr);
}
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_decoder_fbo_);
glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, srgb_converter_textures_[1], 0);
......@@ -387,7 +392,6 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
glDrawArrays(GL_TRIANGLES, 0, 6);
// generateMipmap for srgb_decoder_textures_[1]
glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
glGenerateMipmapEXT(GL_TEXTURE_2D);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment