| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 class FencedAllocatorWrapper; | 44 class FencedAllocatorWrapper; |
| 45 class IdAllocator; | 45 class IdAllocator; |
| 46 class CommandBufferHelper; | 46 class CommandBufferHelper; |
| 47 | 47 |
| 48 // A helper class to find parameters in an effect. | 48 // A helper class to find parameters in an effect. |
| 49 class EffectHelper { | 49 class EffectHelper { |
| 50 public: | 50 public: |
| 51 // A more usable version of effect_param::Desc | 51 // A more usable version of effect_param::Desc |
| 52 struct EffectParamDesc { | 52 struct EffectParamDesc { |
| 53 ResourceID id; // The resource ID for the param. | 53 ResourceId id; // The resource ID for the param. |
| 54 String name; // The name of the param. | 54 String name; // The name of the param. |
| 55 String semantic; // The semantic of the param. | 55 String semantic; // The semantic of the param. |
| 56 effect_param::DataType data_type; // The data type of a param. | 56 effect_param::DataType data_type; // The data type of a param. |
| 57 unsigned int data_size; // The size of the data for a param. | 57 unsigned int data_size; // The size of the data for a param. |
| 58 int num_elements; // The number of array entries if the | 58 int num_elements; // The number of array entries if the |
| 59 // parameter is an array, 0 otherwise. | 59 // parameter is an array, 0 otherwise. |
| 60 unsigned int cmd_desc_size; // The size of the effect_param::Desc | 60 unsigned int cmd_desc_size; // The size of the effect_param::Desc |
| 61 // structure (counting strings) for a | 61 // structure (counting strings) for a |
| 62 // param. | 62 // param. |
| 63 }; | 63 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 // strings with a single command within GetParamStrings, so it should be left | 85 // strings with a single command within GetParamStrings, so it should be left |
| 86 // alone. | 86 // alone. |
| 87 // | 87 // |
| 88 // The ResourceIDs will be allocated in the param_id_allocator. | 88 // The ResourceIDs will be allocated in the param_id_allocator. |
| 89 // Temporary buffers will be allocated in the shm_allocator, but they will be | 89 // Temporary buffers will be allocated in the shm_allocator, but they will be |
| 90 // freed before the function returns (possibly pending a token). At least | 90 // freed before the function returns (possibly pending a token). At least |
| 91 // sizeof(effect_param::Desc) must be available for this function to succeed. | 91 // sizeof(effect_param::Desc) must be available for this function to succeed. |
| 92 // This function will call Finish(), hence will block. | 92 // This function will call Finish(), hence will block. |
| 93 // | 93 // |
| 94 // Parameters: | 94 // Parameters: |
| 95 // effect_id: the ResourceID of the effect. | 95 // effect_id: the ResourceId of the effect. |
| 96 // descs: A pointer to a vector containing the returned descriptions. | 96 // descs: A pointer to a vector containing the returned descriptions. |
| 97 // The pointed vector will be cleared. | 97 // The pointed vector will be cleared. |
| 98 // Returns: | 98 // Returns: |
| 99 // true if successful. Reasons for failure are: | 99 // true if successful. Reasons for failure are: |
| 100 // - invalid effect_id, | 100 // - invalid effect_id, |
| 101 // - not enough memory in the shm_allocator_. | 101 // - not enough memory in the shm_allocator_. |
| 102 bool CreateEffectParameters(ResourceID effect_id, | 102 bool CreateEffectParameters(ResourceId effect_id, |
| 103 std::vector<EffectParamDesc> *descs); | 103 std::vector<EffectParamDesc> *descs); |
| 104 | 104 |
| 105 // Gets the strings for a desc. This will fill in the values for the name and | 105 // Gets the strings for a desc. This will fill in the values for the name and |
| 106 // semantic fields. | 106 // semantic fields. |
| 107 // Temporary buffers will be allocated in the shm_allocator, but they will be | 107 // Temporary buffers will be allocated in the shm_allocator, but they will be |
| 108 // freed before the function returns (possibly pending a token). At least | 108 // freed before the function returns (possibly pending a token). At least |
| 109 // desc.cmd_desc_size (as returned by CreateEffectParameters) must be | 109 // desc.cmd_desc_size (as returned by CreateEffectParameters) must be |
| 110 // available for this function to succeed. | 110 // available for this function to succeed. |
| 111 // This function will call Finish(), hence will block. | 111 // This function will call Finish(), hence will block. |
| 112 // | 112 // |
| 113 // Parameters: | 113 // Parameters: |
| 114 // desc: a pointer to the description for a parameter. The id field should | 114 // desc: a pointer to the description for a parameter. The id field should |
| 115 // be set to the ResourceID of the parameter. | 115 // be set to the ResourceId of the parameter. |
| 116 // Returns: | 116 // Returns: |
| 117 // true if successful. Reasons for failure are: | 117 // true if successful. Reasons for failure are: |
| 118 // - invalid parameter ResourceID, | 118 // - invalid parameter ResourceId, |
| 119 // - not enough memory in the shm_allocator_. | 119 // - not enough memory in the shm_allocator_. |
| 120 bool GetParamStrings(EffectParamDesc *desc); | 120 bool GetParamStrings(EffectParamDesc *desc); |
| 121 | 121 |
| 122 // Destroys all parameter resources referenced by the descriptions. The | 122 // Destroys all parameter resources referenced by the descriptions. The |
| 123 // ResourceID will be freed from the param_id_allocator. | 123 // ResourceId will be freed from the param_id_allocator. |
| 124 // Parameters: | 124 // Parameters: |
| 125 // descs: the vector of descriptions containing the ResourceIDs of the | 125 // descs: the vector of descriptions containing the ResourceIDs of the |
| 126 // parameters to destroy. | 126 // parameters to destroy. |
| 127 void DestroyEffectParameters(const std::vector<EffectParamDesc> &descs); | 127 void DestroyEffectParameters(const std::vector<EffectParamDesc> &descs); |
| 128 | 128 |
| 129 // Gets all the input stream semantics and semantic indices in an | 129 // Gets all the input stream semantics and semantic indices in an |
| 130 // array. These will be retrieved as many as possible at a time. At least | 130 // array. These will be retrieved as many as possible at a time. At least |
| 131 // sizeof(effect_param::Desc) must be available for this function to succeed. | 131 // sizeof(effect_param::Desc) must be available for this function to succeed. |
| 132 // This function will call Finish(), hence will block. | 132 // This function will call Finish(), hence will block. |
| 133 // | 133 // |
| 134 // Parameters: | 134 // Parameters: |
| 135 // effect_id: the ResourceID of the effect. | 135 // effect_id: the ResourceId of the effect. |
| 136 // descs: A pointer to a vector containing the returned descriptions. | 136 // descs: A pointer to a vector containing the returned descriptions. |
| 137 // The pointed vector will be cleared. | 137 // The pointed vector will be cleared. |
| 138 // Returns: | 138 // Returns: |
| 139 // true if successful. Reasons for failure are: | 139 // true if successful. Reasons for failure are: |
| 140 // - invalid effect_id, | 140 // - invalid effect_id, |
| 141 // - not enough memory in the shm_allocator_. | 141 // - not enough memory in the shm_allocator_. |
| 142 bool GetEffectStreams(ResourceID effect_id, | 142 bool GetEffectStreams(ResourceId effect_id, |
| 143 std::vector<EffectStreamDesc> *descs); | 143 std::vector<EffectStreamDesc> *descs); |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 CommandBufferHelper *helper_; | 146 CommandBufferHelper *helper_; |
| 147 FencedAllocatorWrapper *shm_allocator_; | 147 FencedAllocatorWrapper *shm_allocator_; |
| 148 unsigned int shm_id_; | 148 unsigned int shm_id_; |
| 149 IdAllocator *param_id_allocator_; | 149 IdAllocator *param_id_allocator_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(EffectHelper); | 151 DISALLOW_COPY_AND_ASSIGN(EffectHelper); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace command_buffer | 154 } // namespace command_buffer |
| 155 } // namespace o3d | 155 } // namespace o3d |
| 156 | 156 |
| 157 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_EFFECT_HELPER_H_ | 157 #endif // O3D_COMMAND_BUFFER_CLIENT_CROSS_EFFECT_HELPER_H_ |
| OLD | NEW |