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

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

Issue 2461973002: [Command buffer] Feedback loop detection between texture and framebuffer attachments
Patch Set: Addressed zmo@'s feedback: MRT can be supported in WebGL1 or ES2 by extension Created 4 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 | « no previous file | no next file » | 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 c032dff22ae14ad9a95fdad3815abc464779af5b..f35c5770937a899b218ed24c83616d3e6c85c1d0 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1321,6 +1321,11 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
// of the draw operation are the same.
bool CheckDrawingFeedbackLoops();
+ // Helper for CheckDrawingFeedbackLoops. Returns true if the attachment is
+ // the same one where it samples from during drawing.
+ bool CheckDrawingFeedbackLoopsHelper(
+ const Framebuffer::Attachment* attachment);
+
bool SupportsDrawBuffers() const;
// Checks if a draw buffer's format and its corresponding fragment shader
@@ -8645,15 +8650,8 @@ bool GLES2DecoderImpl::CheckCurrentProgramForUniform(
location);
}
-bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() {
- Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
- if (!framebuffer)
- return false;
- const Framebuffer::Attachment* attachment =
- framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
- if (!attachment)
- return false;
-
+bool GLES2DecoderImpl::CheckDrawingFeedbackLoopsHelper(
+ const Framebuffer::Attachment* attachment) {
DCHECK(state_.current_program.get());
const Program::SamplerIndices& sampler_indices =
state_.current_program->sampler_indices();
@@ -8675,6 +8673,36 @@ bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() {
return false;
}
+bool GLES2DecoderImpl::CheckDrawingFeedbackLoops() {
+ if (!SupportsDrawBuffers()) {
+ Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
+ if (!framebuffer)
+ return false;
+ const Framebuffer::Attachment* attachment =
+ framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
+ if (!attachment)
+ return false;
+ return CheckDrawingFeedbackLoopsHelper(attachment);
+ } else {
+ Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER);
+ if (!framebuffer)
+ return false;
+ for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
+ GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + ii);
+ if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE)
+ continue;
+ GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii);
+ const Framebuffer::Attachment* draw_buffer =
+ framebuffer->GetAttachment(attachment);
+ if (!draw_buffer)
+ continue;
+ if (CheckDrawingFeedbackLoopsHelper(draw_buffer))
+ return true;
+ }
+ return false;
+ }
+}
+
bool GLES2DecoderImpl::SupportsDrawBuffers() const {
return feature_info_->IsWebGL1OrES2Context() ?
feature_info_->feature_flags().ext_draw_buffers : true;
« 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