OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 contains the implementation of the helper functions for resources. | 5 // This file contains the implementation of the helper functions for resources. |
6 | 6 |
7 #include "gpu/command_buffer/common/resource.h" | 7 #include "gpu/command_buffer/common/resource.h" |
8 | 8 |
9 namespace gpu { | 9 namespace gpu { |
10 | 10 |
11 namespace texture { | 11 namespace texture { |
12 | 12 |
13 // Gets the number of bytes per block for a given format. | 13 // Gets the number of bytes per block for a given format. |
14 unsigned int GetBytesPerBlock(Format format) { | 14 unsigned int GetBytesPerBlock(Format format) { |
15 switch (format) { | 15 switch (format) { |
16 case kXRGB8: | 16 case kXRGB8: |
17 case kARGB8: | 17 case kARGB8: |
18 case kR32F: | 18 case kR32F: |
19 return 4; | 19 return 4; |
20 case kABGR16F: | 20 case kABGR16F: |
21 return 8; | 21 return 8; |
22 case kABGR32F: | 22 case kABGR32F: |
23 return 16; | 23 return 16; |
24 case kDXT1: | 24 case kDXT1: |
25 return 8; | 25 return 8; |
26 case kUnknown: | |
apatrick
2009/12/29 20:26:38
It's strange that NaCl's gcc needs this. Have you
alokp
2009/12/29 20:51:46
NaCl compile environment is really strict. They us
| |
26 default: | 27 default: |
27 // TODO(petersont): Add DXT3/5 support. | 28 // TODO(petersont): Add DXT3/5 support. |
28 LOG(FATAL) << "Invalid format"; | 29 LOG(FATAL) << "Invalid format"; |
29 return 1; | 30 return 1; |
30 } | 31 } |
31 } | 32 } |
32 | 33 |
33 // Gets the width of a block for a given format. | 34 // Gets the width of a block for a given format. |
34 unsigned int GetBlockSizeX(Format format) { | 35 unsigned int GetBlockSizeX(Format format) { |
35 switch (format) { | 36 switch (format) { |
36 case kXRGB8: | 37 case kXRGB8: |
37 case kARGB8: | 38 case kARGB8: |
38 case kABGR16F: | 39 case kABGR16F: |
39 case kR32F: | 40 case kR32F: |
40 case kABGR32F: | 41 case kABGR32F: |
41 return 1; | 42 return 1; |
42 case kDXT1: | 43 case kDXT1: |
43 return 4; | 44 return 4; |
45 case kUnknown: | |
44 default: | 46 default: |
45 // TODO(petersont): Add DXT3/5 support. | 47 // TODO(petersont): Add DXT3/5 support. |
46 LOG(FATAL) << "Invalid format"; | 48 LOG(FATAL) << "Invalid format"; |
47 return 1; | 49 return 1; |
48 } | 50 } |
49 } | 51 } |
50 | 52 |
51 // Gets the height of a block for a given format. | 53 // Gets the height of a block for a given format. |
52 unsigned int GetBlockSizeY(Format format) { | 54 unsigned int GetBlockSizeY(Format format) { |
53 // NOTE: currently only supported formats use square blocks. | 55 // NOTE: currently only supported formats use square blocks. |
(...skipping 20 matching lines...) Expand all Loading... | |
74 case kMatrix4: | 76 case kMatrix4: |
75 return sizeof(float) * 16; // NOLINT | 77 return sizeof(float) * 16; // NOLINT |
76 case kInt: | 78 case kInt: |
77 return sizeof(int); // NOLINT | 79 return sizeof(int); // NOLINT |
78 case kBool: | 80 case kBool: |
79 return sizeof(bool); // NOLINT | 81 return sizeof(bool); // NOLINT |
80 case kSampler: | 82 case kSampler: |
81 return sizeof(ResourceId); // NOLINT | 83 return sizeof(ResourceId); // NOLINT |
82 case kTexture: | 84 case kTexture: |
83 return sizeof(ResourceId); // NOLINT | 85 return sizeof(ResourceId); // NOLINT |
86 case kNumTypes: | |
87 case kMake32Bit: | |
84 default: | 88 default: |
85 LOG(FATAL) << "Invalid type."; | 89 LOG(FATAL) << "Invalid type."; |
86 return 0; | 90 return 0; |
87 } | 91 } |
88 } | 92 } |
89 | 93 |
90 } // namespace effect_param | 94 } // namespace effect_param |
91 | 95 |
92 } // namespace gpu | 96 } // namespace gpu |
OLD | NEW |