| 144 | } |
| 145 | |
| 146 | Tr2TextureAL Tr2TextureArray::CreateTexture() const |
| 147 | { |
| 148 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 149 | std::vector<Tr2SubresourceData> initialData; |
| 150 | Tr2SubresourceData filler; |
| 151 | bool validFiller = false; |
| 152 | auto mipCount = m_dimensions.GetTrueMipCount(); |
| 153 | for( auto& element : m_elements ) |
| 154 | { |
| 155 | if( element.IsValid() ) |
| 156 | { |
| 157 | filler = { element.GetMipRawData( 0 ), |
| 158 | element.GetMipPitch( 0 ), |
| 159 | element.GetMipSize( 0 ) }; |
| 160 | validFiller = true; |
| 161 | for( uint32_t i = 0; i < mipCount; ++i ) |
| 162 | { |
| 163 | initialData.push_back( { element.GetMipRawData( i ), element.GetMipPitch( i ), element.GetMipSize( i ) } ); |
| 164 | } |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | for( uint32_t i = 0; i < mipCount; ++i ) |
| 169 | { |
| 170 | initialData.push_back( { nullptr, 0, 0 } ); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | for( uint32_t i = uint32_t( m_elements.size() ); i < m_dimensions.GetArraySize(); ++i ) |
| 175 | { |
| 176 | for( uint32_t i = 0; i < mipCount; ++i ) |
| 177 | { |
| 178 | initialData.push_back( { nullptr, 0, 0 } ); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | Tr2TextureAL newTexture; |
| 183 | if( validFiller ) |
| 184 | { |
| 185 | for( auto& data : initialData ) |
| 186 | { |
| 187 | if( !data.m_sysMem ) |
| 188 | { |
| 189 | data = filler; |
| 190 | } |
| 191 | } |
| 192 | newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, initialData.data(), renderContext ); |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, nullptr, renderContext ); |
| 197 | } |
| 198 | |
| 199 | return newTexture; |
| 200 | } |
| 201 | |
| 202 | |
| 203 | Tr2TextureArrayElement::operator bool() const |
nothing calls this directly
no test coverage detected