OLD | NEW |
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 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 return true; | 751 return true; |
752 default: | 752 default: |
753 GPU_DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 753 GPU_DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
754 return false; | 754 return false; |
755 } | 755 } |
756 } | 756 } |
757 | 757 |
758 return true; | 758 return true; |
759 } | 759 } |
760 | 760 |
| 761 // Swizzles the locations to prevent developers from assuming they |
| 762 // can do math on uniforms. According to the OpenGL ES 2.0 spec |
| 763 // the location of "someuniform[1]" is not '1' more than "someuniform[0]". |
| 764 static int32 Swizzle(int32 location) { |
| 765 return (location & 0xF0000000U) | |
| 766 ((location & 0x0AAAAAAAU) >> 1) | |
| 767 ((location & 0x05555555U) << 1); |
| 768 } |
| 769 |
| 770 // Adds uniform_swizzle_ to prevent developers from assuming that locations are |
| 771 // always the same across GPUs and drivers. |
| 772 int32 GLES2Util::SwizzleLocation(int32 v) { |
| 773 return v < 0 ? v : Swizzle(v); |
| 774 } |
| 775 |
| 776 int32 GLES2Util::UnswizzleLocation(int32 v) { |
| 777 return v < 0 ? v : Swizzle(v); |
| 778 } |
| 779 |
| 780 int32 GLES2Util::MakeFakeLocation(int32 index, int32 element) { |
| 781 return index + element * 0x10000; |
| 782 } |
| 783 |
761 #include "../common/gles2_cmd_utils_implementation_autogen.h" | 784 #include "../common/gles2_cmd_utils_implementation_autogen.h" |
762 | 785 |
763 } // namespace gles2 | 786 } // namespace gles2 |
764 } // namespace gpu | 787 } // namespace gpu |
765 | 788 |
OLD | NEW |