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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.h

Issue 9732010: Check that attachments are the correct type for the attachment type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // A wrapper for SafeAdd to remove the need to cast. 52 // A wrapper for SafeAdd to remove the need to cast.
53 inline bool SafeAddUint32(uint32 a, uint32 b, uint32* dst) { 53 inline bool SafeAddUint32(uint32 a, uint32 b, uint32* dst) {
54 return SafeAdd(a, b, dst); 54 return SafeAdd(a, b, dst);
55 } 55 }
56 56
57 // Utilties for GLES2 support. 57 // Utilties for GLES2 support.
58 class GLES2_UTILS_EXPORT GLES2Util { 58 class GLES2_UTILS_EXPORT GLES2Util {
59 public: 59 public:
60 static const int kNumFaces = 6; 60 static const int kNumFaces = 6;
61 61
62 // Bits returned by GetChannelsForFormat
63 enum ChannelBits {
64 kRed = 0x1,
65 kGreen = 0x2,
66 kBlue = 0x4,
67 kAlpha = 0x8,
68 kDepth = 0x10000,
69 kStencil = 0x20000,
70
71 kRGB = kRed | kGreen | kBlue,
72 kRGBA = kRGB | kAlpha
73 };
74
62 struct EnumToString { 75 struct EnumToString {
63 uint32 value; 76 uint32 value;
64 const char* name; 77 const char* name;
65 }; 78 };
66 79
67 GLES2Util() 80 GLES2Util()
68 : num_compressed_texture_formats_(0), 81 : num_compressed_texture_formats_(0),
69 num_shader_binary_formats_(0) { 82 num_shader_binary_formats_(0) {
70 } 83 }
71 84
(...skipping 27 matching lines...) Expand all
99 static uint32 GetGLDataTypeSizeForUniforms(int type); 112 static uint32 GetGLDataTypeSizeForUniforms(int type);
100 113
101 static size_t GetGLTypeSizeForTexturesAndBuffers(uint32 type); 114 static size_t GetGLTypeSizeForTexturesAndBuffers(uint32 type);
102 115
103 static uint32 GLErrorToErrorBit(uint32 gl_error); 116 static uint32 GLErrorToErrorBit(uint32 gl_error);
104 117
105 static uint32 GLErrorBitToGLError(uint32 error_bit); 118 static uint32 GLErrorBitToGLError(uint32 error_bit);
106 119
107 static uint32 IndexToGLFaceTarget(int index); 120 static uint32 IndexToGLFaceTarget(int index);
108 121
109 // Returns a bitmask for the channels the given format supports where 122 // Returns a bitmask for the channels the given format supports.
110 // 0x1 is red 123 // See ChannelBits.
111 // 0x2 is green
112 // 0x4 is blue
113 // 0x8 is alpha
114 static uint32 GetChannelsForFormat(int format); 124 static uint32 GetChannelsForFormat(int format);
115 125
126 // Returns a bitmask for the channels the given attachment type needs.
127 static uint32 GetChannelsNeededForAttachmentType(int type);
128
116 static bool IsNPOT(uint32 value) { 129 static bool IsNPOT(uint32 value) {
117 return value > 0 && (value & (value - 1)) != 0; 130 return value > 0 && (value & (value - 1)) != 0;
118 } 131 }
119 132
120 static std::string GetStringEnum(uint32 value); 133 static std::string GetStringEnum(uint32 value);
121 static std::string GetStringBool(uint32 value); 134 static std::string GetStringBool(uint32 value);
122 static std::string GetStringError(uint32 value); 135 static std::string GetStringError(uint32 value);
123 136
124 #include "../common/gles2_cmd_utils_autogen.h" 137 #include "../common/gles2_cmd_utils_autogen.h"
125 138
126 private: 139 private:
127 static std::string GetQualifiedEnumString( 140 static std::string GetQualifiedEnumString(
128 const EnumToString* table, size_t count, uint32 value); 141 const EnumToString* table, size_t count, uint32 value);
129 142
130 static const EnumToString* enum_to_string_table_; 143 static const EnumToString* enum_to_string_table_;
131 static const size_t enum_to_string_table_len_; 144 static const size_t enum_to_string_table_len_;
132 145
133 int num_compressed_texture_formats_; 146 int num_compressed_texture_formats_;
134 int num_shader_binary_formats_; 147 int num_shader_binary_formats_;
135 }; 148 };
136 149
137 } // namespace gles2 150 } // namespace gles2
138 } // namespace gpu 151 } // namespace gpu
139 152
140 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ 153 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_
141 154
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698