| Index: gpu/command_buffer/service/framebuffer_manager.h
|
| diff --git a/gpu/command_buffer/service/framebuffer_manager.h b/gpu/command_buffer/service/framebuffer_manager.h
|
| index 2337843f68ef929b447efbf1cb4c81f7a4658d44..2cf4cde2b979c48b9b35133b667564b22cc88122 100644
|
| --- a/gpu/command_buffer/service/framebuffer_manager.h
|
| +++ b/gpu/command_buffer/service/framebuffer_manager.h
|
| @@ -16,6 +16,7 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "gpu/command_buffer/service/context_group.h"
|
| #include "gpu/command_buffer/service/gl_utils.h"
|
| +#include "gpu/command_buffer/service/shader_manager.h"
|
| #include "gpu/gpu_export.h"
|
|
|
| namespace gpu {
|
| @@ -178,11 +179,20 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| // If a color buffer is attached to GL_COLOR_ATTACHMENTi, enable that
|
| // draw buffer for glClear().
|
| // Return true if the DrawBuffers() is actually called.
|
| - bool PrepareDrawBuffersForClear() const;
|
| + bool PrepareDrawBuffersForClearingUninitializedAttachments() const;
|
|
|
| - // Restore draw buffers states that have been changed in
|
| - // PrepareDrawBuffersForClear().
|
| - void RestoreDrawBuffersAfterClear() const;
|
| + // Restore |adjusted_draw_buffers_|.
|
| + void RestoreDrawBuffers() const;
|
| +
|
| + // Checks if a draw buffer's format and its corresponding fragment shader
|
| + // output's type are compatible, i.e., a signed integer typed variable is
|
| + // incompatible with a float or unsigned integer buffer.
|
| + // If it's for Clear(), then |fragment_output_base_types| is nullptr.
|
| + // Return false if incompaticle.
|
| + // Otherwise, filter out the draw buffers that are not written to but are not
|
| + // NONE through DrawBuffers, to be on the safe side. Return true.
|
| + bool ValidateAndAdjustDrawBuffers(
|
| + const ShaderVariableBaseType* fragment_output_base_types);
|
|
|
| // Return true if any draw buffers has an alpha channel.
|
| bool HasAlphaMRT() const;
|
| @@ -199,6 +209,10 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| return read_buffer_;
|
| }
|
|
|
| + const ShaderVariableBaseType* GetColorAttachmentBaseTypes() const {
|
| + return color_attachment_base_types_.get();
|
| + }
|
| +
|
| private:
|
| friend class FramebufferManager;
|
| friend class base::RefCounted<Framebuffer>;
|
| @@ -213,6 +227,7 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| bool cleared);
|
|
|
| void MarkAsComplete(unsigned state_id) {
|
| + UpdateColorAttachmentBaseTypes();
|
| framebuffer_complete_state_count_id_ = state_id;
|
| }
|
|
|
| @@ -220,6 +235,13 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| return framebuffer_complete_state_count_id_;
|
| }
|
|
|
| + // Cache color attachments' base types (FLOAT, INT, UINT) for optimization
|
| + // purpose. If an attachment point has no image, it's set as UNDEFINED_TYPE.
|
| + // This call is only valid on a complete fbo.
|
| + void UpdateColorAttachmentBaseTypes();
|
| +
|
| + void ResetColorAttachmentBaseTypes();
|
| +
|
| // The managers that owns this.
|
| FramebufferManager* manager_;
|
|
|
| @@ -238,8 +260,17 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
|
| typedef base::hash_map<GLenum, scoped_refptr<Attachment> > AttachmentMap;
|
| AttachmentMap attachments_;
|
|
|
| + // User's draw buffers setting through DrawBuffers() call.
|
| std::unique_ptr<GLenum[]> draw_buffers_;
|
|
|
| + // If a draw buffer does not have an image, or it has no corresponding
|
| + // fragment shader output variable, it might be filtered out as NONE.
|
| + // Note that the actually draw buffers setting sent to the driver is always
|
| + // consistent with |adjusted_draw_buffers_|, not |draw_buffers_|.
|
| + std::unique_ptr<GLenum[]> adjusted_draw_buffers_;
|
| +
|
| + std::unique_ptr<ShaderVariableBaseType[]> color_attachment_base_types_;
|
| +
|
| GLenum read_buffer_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(Framebuffer);
|
|
|