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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp

Issue 1883153003: Fixed regression in WEBGL_draw_buffers support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expectation for single failing trybot Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 gl->GenTextures(1, &depth); 133 gl->GenTextures(1, &depth);
134 gl->BindTexture(GL_TEXTURE_2D, depth); 134 gl->BindTexture(GL_TEXTURE_2D, depth);
135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer); 135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer);
136 } 136 }
137 137
138 Vector<Platform3DObject> colors; 138 Vector<Platform3DObject> colors;
139 bool ok = true; 139 bool ok = true;
140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); 140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments);
141 for (GLint i = 0; i < maxAllowedBuffers; ++i) { 141 for (GLint i = 0; i < maxAllowedBuffers; ++i) {
142 GLuint color; 142 GLuint color;
143
143 gl->GenTextures(1, &color); 144 gl->GenTextures(1, &color);
144 colors.append(color); 145 colors.append(color);
145 gl->BindTexture(GL_TEXTURE_2D, color); 146 gl->BindTexture(GL_TEXTURE_2D, color);
146 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer); 147 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer);
147 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0); 148 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0);
148 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) { 149 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) {
149 ok = false; 150 ok = false;
150 break; 151 break;
151 } 152 }
152 if (supportsDepth) { 153 if (supportsDepth) {
153 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0); 154 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0);
154 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { 155 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) {
155 ok = false; 156 ok = false;
156 break; 157 break;
157 } 158 }
158 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); 159 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0);
159 } 160 }
160 if (supportsDepthStencil) { 161 if (supportsDepthStencil) {
161 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depthStencil, 0); 162 // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so w e emulate it
162 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, depthStencil, 0); 163 // at the command buffer level for WebGL contexts.
164 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D, depthStencil, 0);
163 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { 165 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) {
164 ok = false; 166 ok = false;
165 break; 167 break;
166 } 168 }
167 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); 169 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D, 0, 0);
168 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, 0, 0);
169 } 170 }
170 } 171 }
171 172
172 webglContext->restoreCurrentFramebuffer(); 173 webglContext->restoreCurrentFramebuffer();
173 gl->DeleteFramebuffers(1, &fbo); 174 gl->DeleteFramebuffers(1, &fbo);
174 webglContext->restoreCurrentTexture2D(); 175 webglContext->restoreCurrentTexture2D();
175 if (supportsDepth) 176 if (supportsDepth)
176 gl->DeleteTextures(1, &depth); 177 gl->DeleteTextures(1, &depth);
177 if (supportsDepthStencil) 178 if (supportsDepthStencil)
178 gl->DeleteTextures(1, &depthStencil); 179 gl->DeleteTextures(1, &depthStencil);
179 gl->DeleteTextures(colors.size(), colors.data()); 180 gl->DeleteTextures(colors.size(), colors.data());
181
180 return ok; 182 return ok;
181 } 183 }
182 184
183 } // namespace blink 185 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698