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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 2197893003: Relax multi-sampling for floating-point color renderbuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix integer fallthrough Created 4 years, 5 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
Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
index 75809356337b366dc3d2653e2252e5034333a549..40c68f5803c5185dd8743befb25339a92011a5e0 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -340,7 +340,6 @@ ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
return ScriptValue::createNull(scriptState);
}
- bool floatType = false;
switch (internalformat) {
// Renderbuffer doesn't support unsized internal formats,
@@ -395,7 +394,6 @@ ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invalid internalformat when EXT_color_buffer_float is not enabled");
return ScriptValue::createNull(scriptState);
}
- floatType = true;
break;
default:
synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invalid internalformat");
@@ -407,20 +405,14 @@ ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
{
std::unique_ptr<GLint[]> values;
GLint length = -1;
- if (!floatType) {
- contextGL()->GetInternalformativ(target, internalformat, GL_NUM_SAMPLE_COUNTS, 1, &length);
- if (length <= 0)
- return WebGLAny(scriptState, DOMInt32Array::create(0));
-
- values = wrapArrayUnique(new GLint[length]);
- for (GLint ii = 0; ii < length; ++ii)
- values[ii] = 0;
- contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, length, values.get());
- } else {
- length = 1;
- values = wrapArrayUnique(new GLint[1]);
- values[0] = 1;
- }
+ contextGL()->GetInternalformativ(target, internalformat, GL_NUM_SAMPLE_COUNTS, 1, &length);
+ if (length <= 0)
+ return WebGLAny(scriptState, DOMInt32Array::create(0));
+
+ values = wrapArrayUnique(new GLint[length]);
+ for (GLint ii = 0; ii < length; ++ii)
+ values[ii] = 0;
+ contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, length, values.get());
return WebGLAny(scriptState, DOMInt32Array::create(values.get(), length));
}
default:
@@ -629,6 +621,22 @@ void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLs
}
}
+void WebGL2RenderingContextBase::callRenderbufferStorage(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName)
+{
+ if (!samples) {
+ contextGL()->RenderbufferStorage(target, internalformat, width, height);
+ } else {
+ GLint maxNumberOfSamples = 0;
+ contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples);
+ if (samples > maxNumberOfSamples) {
+ synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples out of range");
+ return;
+ }
+ contextGL()->RenderbufferStorageMultisampleCHROMIUM(
+ target, samples, internalformat, width, height);
qiankun 2016/08/02 02:47:55 Merge with line 635.
+ }
+}
+
void WebGL2RenderingContextBase::renderbufferStorageImpl(
GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
const char* functionName)
@@ -673,18 +681,7 @@ void WebGL2RenderingContextBase::renderbufferStorageImpl(
case GL_DEPTH24_STENCIL8:
case GL_DEPTH32F_STENCIL8:
case GL_STENCIL_INDEX8:
- if (!samples) {
- contextGL()->RenderbufferStorage(target, internalformat, width, height);
- } else {
- GLint maxNumberOfSamples = 0;
- contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples);
- if (samples > maxNumberOfSamples) {
- synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples out of range");
- return;
- }
- contextGL()->RenderbufferStorageMultisampleCHROMIUM(
- target, samples, internalformat, width, height);
- }
+ callRenderbufferStorage(target, samples, internalformat, width, height, functionName);
break;
case GL_DEPTH_STENCIL:
// To be WebGL 1 backward compatible.
@@ -692,7 +689,7 @@ void WebGL2RenderingContextBase::renderbufferStorageImpl(
synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat");
return;
}
- contextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8, width, height);
+ callRenderbufferStorage(target, 0, GL_DEPTH24_STENCIL8, width, height, functionName);
break;
case GL_R16F:
case GL_RG16F:
@@ -705,11 +702,7 @@ void WebGL2RenderingContextBase::renderbufferStorageImpl(
synthesizeGLError(GL_INVALID_ENUM, functionName, "EXT_color_buffer_float not enabled");
return;
}
- if (samples) {
- synthesizeGLError(GL_INVALID_VALUE, functionName, "multisampled float buffers not supported");
- return;
- }
- contextGL()->RenderbufferStorage(target, internalformat, width, height);
+ callRenderbufferStorage(target, samples, internalformat, width, height, functionName);
break;
default:
synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat");

Powered by Google App Engine
This is Rietveld 408576698