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

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

Issue 72173002: gpu: Support ES3 msaa and depth/stencil formats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment, rebase Created 7 years, 1 month 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 | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 48142e6e57f8d5edfd193110a96c226fb54895eb..2b792130c00fe8cfa55c2bff58e1790879ceacc6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -407,7 +407,10 @@ class BackRenderbuffer {
void Create();
// Set the initial size and format of a render buffer or resize it.
- bool AllocateStorage(const gfx::Size& size, GLenum format, GLsizei samples);
+ bool AllocateStorage(const FeatureInfo* feature_info,
+ const gfx::Size& size,
+ GLenum format,
+ GLsizei samples);
// Destroy the render buffer. This must be explicitly called before destroying
// this object.
@@ -627,7 +630,25 @@ class GLES2DecoderImpl : public GLES2Decoder,
virtual void OnTextureRefDetachedFromFramebuffer(
TextureRef* texture) OVERRIDE;
- static bool IsAngle();
+ // Helpers to facilitate calling into compatible extensions.
+ static void RenderbufferStorageMultisampleHelper(
+ const FeatureInfo* feature_info,
+ GLenum target,
+ GLsizei samples,
+ GLenum internal_format,
+ GLsizei width,
+ GLsizei height);
+
+ void BlitFramebufferHelper(GLint srcX0,
+ GLint srcY0,
+ GLint srcX1,
+ GLint srcY1,
+ GLint dstX0,
+ GLint dstY0,
+ GLint dstX1,
+ GLint dstY1,
+ GLbitfield mask,
+ GLenum filter);
private:
friend class ScopedFrameBufferBinder;
@@ -1804,13 +1825,16 @@ ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder(
const int width = decoder_->offscreen_size_.width();
const int height = decoder_->offscreen_size_.height();
glDisable(GL_SCISSOR_TEST);
- if (GLES2DecoderImpl::IsAngle()) {
- glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- } else {
- glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
+ decoder->BlitFramebufferHelper(0,
+ 0,
+ width,
+ height,
+ 0,
+ 0,
+ width,
+ height,
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
glBindFramebufferEXT(GL_FRAMEBUFFER, targetid);
}
@@ -1962,7 +1986,9 @@ void BackRenderbuffer::Create() {
glGenRenderbuffersEXT(1, &id_);
}
-bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format,
+bool BackRenderbuffer::AllocateStorage(const FeatureInfo* feature_info,
+ const gfx::Size& size,
+ GLenum format,
GLsizei samples) {
ScopedGLErrorSuppressor suppressor(
"BackRenderbuffer::AllocateStorage", state_->GetErrorState());
@@ -1984,19 +2010,12 @@ bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format,
size.width(),
size.height());
} else {
- if (GLES2DecoderImpl::IsAngle()) {
- glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER,
- samples,
- format,
- size.width(),
- size.height());
- } else {
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
- samples,
- format,
- size.width(),
- size.height());
- }
+ GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(feature_info,
+ GL_RENDERBUFFER,
+ samples,
+ format,
+ size.width(),
+ size.height());
}
bool success = glGetError() == GL_NO_ERROR;
if (success) {
@@ -2094,14 +2113,6 @@ GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
return new GLES2DecoderImpl(group);
}
-bool GLES2DecoderImpl::IsAngle() {
-#if defined(OS_WIN)
- return gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
-#else
- return false;
-#endif
-}
-
GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
: GLES2Decoder(),
group_(group),
@@ -2303,7 +2314,7 @@ bool GLES2DecoderImpl::Initialize(
// ANGLE only supports packed depth/stencil formats, so use it if it is
// available.
const bool depth24_stencil8_supported =
- context_->HasExtension("GL_OES_packed_depth_stencil");
+ feature_info_->feature_flags().packed_depth24_stencil8;
VLOG(1) << "GL_OES_packed_depth_stencil "
<< (depth24_stencil8_supported ? "" : "not ") << "supported.";
if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) &&
@@ -2326,7 +2337,7 @@ bool GLES2DecoderImpl::Initialize(
// it's available, as some desktop GL drivers don't support any non-packed
// formats for depth attachments.
const bool depth24_stencil8_supported =
- context_->HasExtension("GL_EXT_packed_depth_stencil");
+ feature_info_->feature_flags().packed_depth24_stencil8;
VLOG(1) << "GL_EXT_packed_depth_stencil "
<< (depth24_stencil8_supported ? "" : "not ") << "supported.";
@@ -3321,7 +3332,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
DCHECK(offscreen_target_color_format_);
if (IsOffscreenBufferMultisampled()) {
if (!offscreen_target_color_render_buffer_->AllocateStorage(
- offscreen_size_, offscreen_target_color_format_,
+ feature_info_, offscreen_size_, offscreen_target_color_format_,
offscreen_target_samples_)) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
<< "to allocate storage for offscreen target color buffer.";
@@ -3337,7 +3348,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
}
if (offscreen_target_depth_format_ &&
!offscreen_target_depth_render_buffer_->AllocateStorage(
- offscreen_size_, offscreen_target_depth_format_,
+ feature_info_, offscreen_size_, offscreen_target_depth_format_,
offscreen_target_samples_)) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
<< "to allocate storage for offscreen target depth buffer.";
@@ -3345,7 +3356,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
}
if (offscreen_target_stencil_format_ &&
!offscreen_target_stencil_render_buffer_->AllocateStorage(
- offscreen_size_, offscreen_target_stencil_format_,
+ feature_info_, offscreen_size_, offscreen_target_stencil_format_,
offscreen_target_samples_)) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
<< "to allocate storage for offscreen target stencil buffer.";
@@ -4997,14 +5008,54 @@ void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(
}
glDisable(GL_SCISSOR_TEST);
- if (IsAngle()) {
+ BlitFramebufferHelper(
+ srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+ EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
+}
+
+void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(
+ const FeatureInfo* feature_info,
+ GLenum target,
+ GLsizei samples,
+ GLenum internal_format,
+ GLsizei width,
+ GLsizei height) {
+ // TODO(sievers): This could be resolved at the GL binding level, but the
+ // binding process is currently a bit too 'brute force'.
+ if (feature_info->feature_flags().is_angle) {
+ glRenderbufferStorageMultisampleANGLE(
+ target, samples, internal_format, width, height);
+ } else if (feature_info->feature_flags().use_core_framebuffer_multisample) {
+ glRenderbufferStorageMultisample(
+ target, samples, internal_format, width, height);
+ } else {
+ glRenderbufferStorageMultisampleEXT(
+ target, samples, internal_format, width, height);
+ }
+}
+
+void GLES2DecoderImpl::BlitFramebufferHelper(GLint srcX0,
+ GLint srcY0,
+ GLint srcX1,
+ GLint srcY1,
+ GLint dstX0,
+ GLint dstY0,
+ GLint dstX1,
+ GLint dstY1,
+ GLbitfield mask,
+ GLenum filter) {
+ // TODO(sievers): This could be resolved at the GL binding level, but the
+ // binding process is currently a bit too 'brute force'.
+ if (feature_info_->feature_flags().is_angle) {
glBlitFramebufferANGLE(
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+ } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) {
+ glBlitFramebuffer(
+ srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
} else {
glBlitFramebufferEXT(
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
- EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
}
bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample(
@@ -5074,13 +5125,8 @@ void GLES2DecoderImpl::DoRenderbufferStorageMultisampleCHROMIUM(
internalformat);
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(
"glRenderbufferStorageMultisampleCHROMIUM");
- if (IsAngle()) {
- glRenderbufferStorageMultisampleANGLE(
- target, samples, impl_format, width, height);
- } else {
- glRenderbufferStorageMultisampleEXT(
- target, samples, impl_format, width, height);
- }
+ RenderbufferStorageMultisampleHelper(
+ feature_info_, target, samples, impl_format, width, height);
GLenum error =
LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM");
if (error == GL_NO_ERROR) {
@@ -5220,7 +5266,8 @@ bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity(
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_);
- glBlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ BlitFramebufferHelper(
+ 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Read a pixel from the buffer.
glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
@@ -8851,7 +8898,7 @@ void GLES2DecoderImpl::DoSwapBuffers() {
// Ensure the side effects of the copy are visible to the parent
// context. There is no need to do this for ANGLE because it uses a
// single D3D device for all contexts.
- if (!IsAngle())
+ if (!feature_info_->feature_flags().is_angle)
glFlush();
}
} else {
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698