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

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

Issue 8341128: Defer clearing textures and renderbuffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix one more unit test Created 9 years, 2 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/texture_manager.h
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index dbb22186c87251f49cb736ddb726c3bb69450b89..0fccbf6cf1f96a9d996bcfcf44810de7904e8b7e 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -16,6 +16,7 @@ namespace gpu {
namespace gles2 {
class FeatureInfo;
+class GLES2Decoder;
// This class keeps track of the textures and their sizes so we can do NPOT and
// texture complete checking.
@@ -32,6 +33,8 @@ class TextureManager {
explicit TextureInfo(GLuint service_id)
: service_id_(service_id),
deleted_(false),
+ cleared_(true),
+ num_uncleared_mips_(0),
target_(0),
min_filter_(GL_NEAREST_MIPMAP_LINEAR),
mag_filter_(GL_LINEAR),
@@ -63,6 +66,10 @@ class TextureManager {
return wrap_t_;
}
+ int num_uncleared_mips() const {
+ return num_uncleared_mips_;
+ }
+
// True if this texture meets all the GLES2 criteria for rendering.
// See section 3.8.2 of the GLES2 spec.
bool CanRender(const FeatureInfo* feature_info) const;
@@ -101,6 +108,10 @@ class TextureManager {
return npot_;
}
+ bool SafeToRenderFrom() const {
+ return cleared_;
+ }
+
// Returns true if mipmaps can be generated by GL.
bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
@@ -146,7 +157,7 @@ class TextureManager {
}
void DetachFromFramebuffer() {
- DCHECK(framebuffer_attachment_count_ > 0);
+ DCHECK_GT(framebuffer_attachment_count_, 0);
--framebuffer_attachment_count_;
}
@@ -158,6 +169,9 @@ class TextureManager {
return stream_texture_;
}
+ // Whether a particular level/face is cleared.
+ bool IsLevelCleared(GLenum target, GLint level);
+
private:
friend class TextureManager;
friend class base::RefCounted<TextureInfo>;
@@ -166,7 +180,9 @@ class TextureManager {
struct LevelInfo {
LevelInfo()
- : valid(false),
+ : cleared(true),
+ target(0),
+ level(-1),
internal_format(0),
width(0),
height(0),
@@ -176,7 +192,9 @@ class TextureManager {
type(0) {
}
- bool valid;
+ bool cleared;
+ GLenum target;
+ GLint level;
GLenum internal_format;
GLsizei width;
GLsizei height;
@@ -197,7 +215,22 @@ class TextureManager {
GLsizei depth,
GLint border,
GLenum format,
- GLenum type);
+ GLenum type,
+ bool cleared);
+
+ // Marks a particular level as cleared or uncleared.
+ void SetLevelCleared(GLenum target, GLint level);
+
+ // Updates the cleared flag for this texture by inspecting all the mips.
+ void UpdateCleared();
+
+ // Clears any renderable uncleared levels.
+ // Returns false if a GL error was generated.
+ bool ClearRenderableLevels(GLES2Decoder* decoder);
+
+ // Clears the level.
+ // Returns false if a GL error was generated.
+ bool ClearLevel(GLES2Decoder* decoder, GLenum target, GLint level);
// Sets a texture parameter.
// TODO(gman): Expand to SetParameteri,f,iv,fv
@@ -236,6 +269,11 @@ class TextureManager {
// Whether this texture has been deleted.
bool deleted_;
+ // Whether all renderable mips of this texture have been cleared.
+ bool cleared_;
+
+ int num_uncleared_mips_;
+
// The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
GLenum target_;
@@ -333,7 +371,11 @@ class TextureManager {
GLsizei depth,
GLint border,
GLenum format,
- GLenum type);
+ GLenum type,
+ bool cleared);
+
+ // Sets a mip as cleared.
+ void SetLevelCleared(TextureInfo* info, GLenum target, GLint level);
// Sets a texture parameter of a TextureInfo
// TODO(gman): Expand to SetParameteri,f,iv,fv
@@ -343,9 +385,14 @@ class TextureManager {
// Makes each of the mip levels as though they were generated.
// Returns false if that's not allowed for the given texture.
- bool MarkMipmapsGenerated(
- const FeatureInfo* feature_info,
- TextureManager::TextureInfo* info);
+ bool MarkMipmapsGenerated(const FeatureInfo* feature_info, TextureInfo* info);
+
+ // Clears any uncleared renderable levels.
+ bool ClearRenderableLevels(GLES2Decoder* decoder, TextureInfo* info);
+
+ // Clear a specific level.
+ bool ClearTextureLevel(
+ GLES2Decoder* decoder,TextureInfo* info, GLenum target, GLint level);
// Creates a new texture info.
TextureInfo* CreateTextureInfo(
@@ -378,6 +425,14 @@ class TextureManager {
return num_unrenderable_textures_ > 0;
}
+ bool HaveUnsafeTextures() const {
+ return num_unsafe_textures_ > 0;
+ }
+
+ bool HaveUnclearedMips() const {
+ return num_uncleared_mips_ > 0;
+ }
+
GLuint black_texture_id(GLenum target) const {
switch (target) {
case GL_SAMPLER_2D:
@@ -403,6 +458,8 @@ class TextureManager {
GLint max_cube_map_levels_;
int num_unrenderable_textures_;
+ int num_unsafe_textures_;
+ int num_uncleared_mips_;
// Black (0,0,0,1) textures for when non-renderable textures are used.
// NOTE: There is no corresponding TextureInfo for these textures.
« no previous file with comments | « gpu/command_buffer/service/renderbuffer_manager_unittest.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698