MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp:361–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361bool GPUPipelineStateVulkan::Init(const Description& desc)
362{
363 if (IsValid())
364 OnReleaseGPU();
365
366 // Reset description
367 RenderToolsVulkan::ZeroStruct(_desc, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
368
369 // Stages
370 UsedStagesMask = 0;
371 HasDescriptorsPerStageMask = 0;
372 Platform::MemoryClear(ShaderBindingsPerStage, sizeof(ShaderBindingsPerStage));
373 Platform::MemoryClear(DescriptorInfoPerStage, sizeof(DescriptorInfoPerStage));
374#define INIT_SHADER_STAGE(type, set, bit) \
375 if(desc.type) \
376 { \
377 int32 stageIndex = (int32)DescriptorSet::set; \
378 UsedStagesMask |= (1 << stageIndex); \
379 auto bindings = &desc.type->GetBindings(); \
380 if (bindings->UsedCBsMask + bindings->UsedSRsMask + bindings->UsedUAsMask) \
381 HasDescriptorsPerStageMask |= (1 << stageIndex); \
382 ShaderBindingsPerStage[stageIndex] = bindings; \
383 DescriptorInfoPerStage[stageIndex] = &((GPUShaderProgram##type##Vulkan*)desc.type)->DescriptorInfo; \
384 auto& stage = _shaderStages[_desc.stageCount++]; \
385 RenderToolsVulkan::ZeroStruct(stage, VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO); \
386 stage.stage = bit; \
387 stage.module = (VkShaderModule)desc.type->GetBufferHandle(); \
388 stage.pName = desc.type->GetName().Get(); \
389 }
390 INIT_SHADER_STAGE(VS, Vertex, VK_SHADER_STAGE_VERTEX_BIT);
391#if GPU_ALLOW_TESSELLATION_SHADERS
392 INIT_SHADER_STAGE(HS, Hull, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
393 INIT_SHADER_STAGE(DS, Domain, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
394#endif
395#if GPU_ALLOW_GEOMETRY_SHADERS
396 INIT_SHADER_STAGE(GS, Geometry, VK_SHADER_STAGE_GEOMETRY_BIT);
397#endif
398 INIT_SHADER_STAGE(PS, Pixel, VK_SHADER_STAGE_FRAGMENT_BIT);
399#undef INIT_SHADER_STAGE
400 _desc.pStages = _shaderStages;
401
402 // Input Assembly
403 if (desc.VS)
404 {
405 VertexInputLayout = (GPUVertexLayoutVulkan*)desc.VS->InputLayout;
406 VertexBufferLayout = (GPUVertexLayoutVulkan*)desc.VS->Layout;
407 }
408 RenderToolsVulkan::ZeroStruct(_descInputAssembly, VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO);;
409 switch (desc.PrimitiveTopology)
410 {
411 case PrimitiveTopologyType::Point:
412 _descInputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
413 break;
414 case PrimitiveTopologyType::Line:
415 _descInputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST;
416 break;
417 case PrimitiveTopologyType::Triangle:
418 _descInputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;

Callers

nothing calls this directly

Calls 12

MemoryClearFunction · 0.85
ToVulkanStencilOpFunction · 0.85
ToVulkanBlendFactorFunction · 0.85
GetControlPointsCountMethod · 0.80
SetupDescriptorWritesMethod · 0.80
IsValidFunction · 0.50
InitFunction · 0.50
IsEmptyMethod · 0.45
AddZeroedMethod · 0.45
AddDefaultMethod · 0.45
SetAllMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected