| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "command_buffer/common/cross/resource.h" | 35 #include "command_buffer/common/cross/resource.h" |
| 36 | 36 |
| 37 namespace o3d { | 37 namespace o3d { |
| 38 namespace command_buffer { | 38 namespace command_buffer { |
| 39 | 39 |
| 40 namespace texture { | 40 namespace texture { |
| 41 | 41 |
| 42 // Gets the number of bytes per block for a given format. | 42 // Gets the number of bytes per block for a given format. |
| 43 unsigned int GetBytesPerBlock(Format format) { | 43 unsigned int GetBytesPerBlock(Format format) { |
| 44 switch (format) { | 44 switch (format) { |
| 45 case XRGB8: | 45 case kXRGB8: |
| 46 case ARGB8: | 46 case kARGB8: |
| 47 return 4; | 47 return 4; |
| 48 case ABGR16F: | 48 case kABGR16F: |
| 49 return 8; | 49 return 8; |
| 50 case DXT1: | 50 case kDXT1: |
| 51 return 8; | 51 return 8; |
| 52 default: | 52 default: |
| 53 LOG(FATAL) << "Invalid format"; | 53 LOG(FATAL) << "Invalid format"; |
| 54 return 1; | 54 return 1; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Gets the width of a block for a given format. | 58 // Gets the width of a block for a given format. |
| 59 unsigned int GetBlockSizeX(Format format) { | 59 unsigned int GetBlockSizeX(Format format) { |
| 60 switch (format) { | 60 switch (format) { |
| 61 case XRGB8: | 61 case kXRGB8: |
| 62 case ARGB8: | 62 case kARGB8: |
| 63 case ABGR16F: | 63 case kABGR16F: |
| 64 return 1; | 64 return 1; |
| 65 case DXT1: | 65 case kDXT1: |
| 66 return 4; | 66 return 4; |
| 67 default: | 67 default: |
| 68 LOG(FATAL) << "Invalid format"; | 68 LOG(FATAL) << "Invalid format"; |
| 69 return 1; | 69 return 1; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Gets the height of a block for a given format. | 73 // Gets the height of a block for a given format. |
| 74 unsigned int GetBlockSizeY(Format format) { | 74 unsigned int GetBlockSizeY(Format format) { |
| 75 // NOTE: currently only supported formats use square blocks. | 75 // NOTE: currently only supported formats use square blocks. |
| 76 return GetBlockSizeX(format); | 76 return GetBlockSizeX(format); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace texture | 79 } // namespace texture |
| 80 | 80 |
| 81 namespace effect_param { | 81 namespace effect_param { |
| 82 | 82 |
| 83 // Gets the size of the data of a given parameter type. | 83 // Gets the size of the data of a given parameter type. |
| 84 unsigned int GetDataSize(DataType type) { | 84 unsigned int GetDataSize(DataType type) { |
| 85 switch (type) { | 85 switch (type) { |
| 86 case UNKNOWN: | 86 case kUnknown: |
| 87 return 0; | 87 return 0; |
| 88 case FLOAT1: | 88 case kFloat1: |
| 89 return sizeof(float); // NOLINT | 89 return sizeof(float); // NOLINT |
| 90 case FLOAT2: | 90 case kFloat2: |
| 91 return sizeof(float)*2; // NOLINT | 91 return sizeof(float) * 2; // NOLINT |
| 92 case FLOAT3: | 92 case kFloat3: |
| 93 return sizeof(float)*3; // NOLINT | 93 return sizeof(float) * 3; // NOLINT |
| 94 case FLOAT4: | 94 case kFloat4: |
| 95 return sizeof(float)*4; // NOLINT | 95 return sizeof(float) * 4; // NOLINT |
| 96 case MATRIX4: | 96 case kMatrix4: |
| 97 return sizeof(float)*16; // NOLINT | 97 return sizeof(float) * 16; // NOLINT |
| 98 case INT: | 98 case kInt: |
| 99 return sizeof(int); // NOLINT | 99 return sizeof(int); // NOLINT |
| 100 case BOOL: | 100 case kBool: |
| 101 return sizeof(bool); // NOLINT | 101 return sizeof(bool); // NOLINT |
| 102 case SAMPLER: | 102 case kSampler: |
| 103 return sizeof(ResourceID); // NOLINT | 103 return sizeof(ResourceId); // NOLINT |
| 104 case TEXTURE: | 104 case kTexture: |
| 105 return sizeof(ResourceID); // NOLINT | 105 return sizeof(ResourceId); // NOLINT |
| 106 default: | 106 default: |
| 107 LOG(FATAL) << "Invalid type."; | 107 LOG(FATAL) << "Invalid type."; |
| 108 return 0; | 108 return 0; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace effect_param | 112 } // namespace effect_param |
| 113 | 113 |
| 114 } // namespace command_buffer | 114 } // namespace command_buffer |
| 115 } // namespace o3d | 115 } // namespace o3d |
| OLD | NEW |