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

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

Issue 10635011: Add glBindUniformLocationCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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 #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
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
784 #include "../common/gles2_cmd_utils_implementation_autogen.h" 761 #include "../common/gles2_cmd_utils_implementation_autogen.h"
785 762
786 } // namespace gles2 763 } // namespace gles2
787 } // namespace gpu 764 } // namespace gpu
788 765
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/common/gles2_cmd_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698