| 237 | } |
| 238 | |
| 239 | static void CreateAttributes(dmGraphics::HContext graphics_context, Material* m) |
| 240 | { |
| 241 | uint32_t num_program_attributes = dmGraphics::GetAttributeCount(m->m_Program); |
| 242 | uint32_t num_attribute_byte_size = 0; |
| 243 | |
| 244 | m->m_MaterialAttributes.SetCapacity(num_program_attributes); |
| 245 | m->m_MaterialAttributes.SetSize(num_program_attributes); |
| 246 | m->m_VertexAttributeInfos.SetCapacity(num_program_attributes); |
| 247 | m->m_VertexAttributeInfos.SetSize(num_program_attributes); |
| 248 | |
| 249 | bool instancing_supported = m->m_InstancingSupported; |
| 250 | |
| 251 | for (int i = 0; i < num_program_attributes; ++i) |
| 252 | { |
| 253 | dmhash_t name_hash = 0; |
| 254 | dmGraphics::Type type = (dmGraphics::Type) -1; |
| 255 | uint32_t num_values = 0; |
| 256 | uint32_t element_count = 0; |
| 257 | int32_t location = -1; |
| 258 | |
| 259 | dmGraphics::GetAttribute(m->m_Program, i, &name_hash, &type, &element_count, &num_values, &location); |
| 260 | |
| 261 | MaterialAttribute& material_attribute = m->m_MaterialAttributes[i]; |
| 262 | material_attribute.m_Location = location; |
| 263 | material_attribute.m_ValueIndex = num_attribute_byte_size; |
| 264 | material_attribute.m_ValueCount = num_values; |
| 265 | |
| 266 | SetVertexAttributeInfoDefaultSettings(&m->m_VertexAttributeInfos[i], name_hash, type, element_count, instancing_supported); |
| 267 | |
| 268 | dmGraphics::Type base_type = dmGraphics::GetGraphicsType(m->m_VertexAttributeInfos[i].m_DataType); |
| 269 | num_attribute_byte_size += dmGraphics::GetTypeSize(base_type) * element_count; |
| 270 | } |
| 271 | |
| 272 | m->m_MaterialAttributeValues.SetCapacity(num_attribute_byte_size); |
| 273 | m->m_MaterialAttributeValues.SetSize(num_attribute_byte_size); |
| 274 | memset(m->m_MaterialAttributeValues.Begin(), 0, num_attribute_byte_size); |
| 275 | |
| 276 | // Set value pointers now that the buffer is allocated |
| 277 | UpdateVertexAttributeValuePointers(m); |
| 278 | } |
| 279 | |
| 280 | void CreateConstants(dmGraphics::HContext graphics_context, HMaterial material) |
| 281 | { |
no test coverage detected