Update material data to buffer.
Registry ShaderModule.
Iter the constantParams and fill it's data to memoryblock.
Instance a VkWriteDescriptorSet.
Update DescriptorSet.
Not supported format.
Create ConstantParameter Buffer .
Fill in data to memory block.
Registry ShaderModule.
Iter the constantParams and fill it's data to memoryblock.
Instance a VkWriteDescriptorSet.
Update DescriptorSet.
Not supported format.
Create ConstantParameter Buffer .
Fill in data to memory block.
370 {
372
373 std::unique_lock<std::mutex> lock(
m_Mutex);
374
378 {
380
382 {
383 for (int i = 0; i < pair.second.size(); i++)
384 {
385 std::stringstream ss;
386 ss << pair.first << "." << pair.second[i];
387
388 ResourcePool<Shader>::Load<Shader>(ss.str(), pair.second[i], pair.first);
389 }
390 }
391 }
392
396 {
398
400
401 m_ConstantParams.for_each([&](
const std::string& k,
const ConstantParams& v) {
403 return false;
404 });
405
407 }
408
412 {
414
415 int tindex = 0;
417
422 if (v.textureType == "Texture2D")
423 {
424 if (v.texturePath == "")
425 {
426 v.index = -1;
427 }
428 else
429 {
430 std::shared_ptr<Texture> texture = ResourcePool<Texture>::Load<Texture2D>(v.texturePath, v.texturePath);
431 v.index = BindLessTextureManager::Registry(v.texturePath);
432
433 auto descriptorSet = DescriptorSetManager::Registry("PreRenderer", SpicesShader::BINDLESS_TEXTURE_SET);
434
438 VkWriteDescriptorSet write {};
439 write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
440 write.dstBinding = SpicesShader::BINDLESS_TEXTURE_BINDING;
441 write.dstSet = descriptorSet->Get();
442 write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
443 write.pImageInfo = texture->GetResource<VulkanImage>()->GetImageInfo();
444 write.descriptorCount = 1;
445 write.dstArrayElement = v.index;
446
451 }
452
455 }
456
460 else
461 {
462 SPICES_CORE_ERROR("Material::BuildMaterial(): Invalid textureType.")
463 }
464
465 tindex++;
466 return false;
467 });
468 }
469
473 {
475
479
483 if (ref.paramType == "float4")
484 {
485 *static_cast<glm::vec4*>(pt) = std::any_cast<glm::vec4>(ref.paramValue);
488 }
489 else if (ref.paramType == "float3")
490 {
491 *static_cast<glm::vec3*>(pt) = std::any_cast<glm::vec3>(ref.paramValue);
494 }
495 else if (ref.paramType == "float2")
496 {
497 *static_cast<glm::vec2*>(pt) = std::any_cast<glm::vec2>(ref.paramValue);
500 }
501 else if (ref.paramType == "float")
502 {
503 *static_cast<float*>(pt) = std::any_cast<float>(ref.paramValue);
506 }
507 else if (ref.paramType == "int")
508 {
509 *static_cast<int*>(pt) = std::any_cast<int>(ref.paramValue);
512 }
513 else if (ref.paramType == "bool")
514 {
515 *static_cast<bool*>(pt) = std::any_cast<bool>(ref.paramValue);
518 }
519 else
520 {
521 SPICES_CORE_ERROR("Material::BuildMaterial(): Invalid paramType.")
522 }
523
524 return false;
525 });
526 }
527 }
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
scl::linked_unordered_map< std::string, ConstantParams > m_ConstantParams
Constant parameters. Key: parameter name, Value: parameter value.
std::unordered_map< std::string, std::vector< std::string > > m_Shaders
Shader path Key: shader usage, Value: shader file name.
scl::runtime_memory_block m_Buffermemoryblocks
m_Buffers's c++ data container. Key: set, Value: scl::runtime_memory_block.
scl::linked_unordered_map< std::string, TextureParam > m_TextureParams
Texture parameters. Key: parameter name, Value: parameter value.
std::mutex m_Mutex
Mutex of this material.
std::unique_ptr< VulkanBuffer > m_MaterialParameterBuffer
static VulkanState & GetState()
Get VulkanState in use.
void for_each(const std::function< bool(const std::string &name, void *pt)> &fn) const
Iter the object_ and call explain_element() to filling data.
void build()
Malloc a memory to begin_.
void add_element(const std::string &name, const std::string &type)
Add a element to object_, means a memory block will be occupied with given param type.
size_t item_location(const std::string &name)
Get item location in blocks.
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...