gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame^] | 7 | #ifndef COMPILER_TRANSLATOR_VARIABLEPACKER_H_ |
| 8 | #define COMPILER_TRANSLATOR_VARIABLEPACKER_H_ |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 9 | |
| 10 | #include <vector> |
Jamie Madill | d4a3a31 | 2014-06-25 16:04:56 -0400 | [diff] [blame] | 11 | #include "compiler/translator/VariableInfo.h" |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 12 | |
| 13 | class VariablePacker { |
| 14 | public: |
| 15 | // Returns true if the passed in variables pack in maxVectors following |
| 16 | // the packing rules from the GLSL 1.017 spec, Appendix A, section 7. |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 17 | template <typename VarT> |
| 18 | bool CheckVariablesWithinPackingLimits(unsigned int maxVectors, |
| 19 | const std::vector<VarT> &in_variables); |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 20 | |
| 21 | // Gets how many components in a row a data type takes. |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 22 | static int GetNumComponentsPerRow(sh::GLenum type); |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 23 | |
| 24 | // Gets how many rows a data type takes. |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 25 | static int GetNumRows(sh::GLenum type); |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 26 | |
Jamie Madill | aa72d78 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 27 | private: |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 28 | static const int kNumColumns = 4; |
| 29 | static const unsigned kColumnMask = (1 << kNumColumns) - 1; |
| 30 | |
| 31 | unsigned makeColumnFlags(int column, int numComponentsPerRow); |
| 32 | void fillColumns(int topRow, int numRows, int column, int numComponentsPerRow); |
| 33 | bool searchColumn(int column, int numRows, int* destRow, int* destSize); |
| 34 | |
| 35 | int topNonFullRow_; |
| 36 | int bottomNonFullRow_; |
| 37 | int maxRows_; |
| 38 | std::vector<unsigned> rows_; |
| 39 | }; |
| 40 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame^] | 41 | #endif // COMPILER_TRANSLATOR_VARIABLEPACKER_H_ |