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

Unified Diff: gpu/command_buffer/service/framebuffer_manager.h

Issue 2142353002: Validate fbo color image format and fragment shader output variable type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: 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..b632db348dcc5e902d1750a2ad096401331776e1 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 {
@@ -180,9 +181,8 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
// Return true if the DrawBuffers() is actually called.
bool PrepareDrawBuffersForClear() const;
- // Restore draw buffers states that have been changed in
- // PrepareDrawBuffersForClear().
- void RestoreDrawBuffersAfterClear() const;
+ // Restore draw buffers states that have been changed.
+ void RestoreDrawBuffers() const;
// Return true if any draw buffers has an alpha channel.
bool HasAlphaMRT() const;
@@ -199,6 +199,11 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
return read_buffer_;
}
+ const std::vector<ShaderVariableBaseType>& GetColorAttachmentBaseTypes(
+ ) const {
+ return color_attachment_base_types_;
+ }
+
private:
friend class FramebufferManager;
friend class base::RefCounted<Framebuffer>;
@@ -213,6 +218,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 +226,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_;
@@ -240,6 +253,8 @@ class GPU_EXPORT Framebuffer : public base::RefCounted<Framebuffer> {
std::unique_ptr<GLenum[]> draw_buffers_;
+ std::vector<ShaderVariableBaseType> color_attachment_base_types_;
+
GLenum read_buffer_;
DISALLOW_COPY_AND_ASSIGN(Framebuffer);

Powered by Google App Engine
This is Rietveld 408576698