Chromium Code Reviews| Index: gpu/command_buffer/common/gles2_cmd_utils.cc |
| diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc |
| index ea0bd7387487462c7ef9b953fcb2bffd739491d8..b4afb9ff7be6ac90c793c631f0e3b2e8d5ad9d8a 100644 |
| --- a/gpu/command_buffer/common/gles2_cmd_utils.cc |
| +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc |
| @@ -758,6 +758,29 @@ bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) { |
| return true; |
| } |
| +// Swizzles the locations to prevent developers from assuming they |
| +// can do math on uniforms. According to the OpenGL ES 2.0 spec |
| +// the location of "someuniform[1]" is not 'n' more than "someuniform[0]". |
|
apatrick_chromium
2012/06/18 18:58:03
nit: [1]->[n]
|
| +static int32 Swizzle(int32 location) { |
| + return (location & 0xF0000000U) | |
| + ((location & 0x0AAAAAAAU) >> 1) | |
| + ((location & 0x05555555U) << 1); |
| +} |
| + |
| +// Adds uniform_swizzle_ to prevent developers from assuming that locations are |
| +// always the same across GPUs and drivers. |
| +int32 GLES2Util::SwizzleLocation(int32 v) { |
| + return v < 0 ? v : Swizzle(v); |
| +} |
| + |
| +int32 GLES2Util::UnswizzleLocation(int32 v) { |
| + return v < 0 ? v : Swizzle(v); |
| +} |
| + |
| +int32 GLES2Util::MakeFakeLocation(int32 index, int32 element) { |
| + return index + element * 0x10000; |
| +} |
| + |
| #include "../common/gles2_cmd_utils_implementation_autogen.h" |
| } // namespace gles2 |