-------------------------------------------------------------------------
| 230 | } |
| 231 | //------------------------------------------------------------------------- |
| 232 | VkPipelineLayout VulkanRootLayout::createVulkanHandles() |
| 233 | { |
| 234 | if( mRootLayout ) |
| 235 | return mRootLayout; |
| 236 | |
| 237 | FastArray<FastArray<VkDescriptorSetLayoutBinding> > rootLayoutDesc; |
| 238 | |
| 239 | const size_t numSets = calculateNumUsedSets(); |
| 240 | rootLayoutDesc.resize( numSets ); |
| 241 | mSets.resize( numSets ); |
| 242 | mPools.resize( numSets ); |
| 243 | |
| 244 | for( size_t i = 0u; i < numSets; ++i ) |
| 245 | { |
| 246 | rootLayoutDesc[i].resize( calculateNumBindings( i ) ); |
| 247 | |
| 248 | size_t bindingIdx = 0u; |
| 249 | size_t bindingSlot = 0u; |
| 250 | |
| 251 | for( size_t j = 0u; j < DescBindingTypes::NumDescBindingTypes; ++j ) |
| 252 | { |
| 253 | const uint16 descSlotStart = mDescBindingRanges[i][j].start; |
| 254 | const FastArray<uint32>::const_iterator arrayRangesBeg = mArrayRanges[j].begin(); |
| 255 | const FastArray<uint32>::const_iterator arrayRangesEnd = mArrayRanges[j].end(); |
| 256 | |
| 257 | FastArray<uint32>::const_iterator arrayRanges = std::lower_bound( |
| 258 | arrayRangesBeg, arrayRangesEnd, ArrayDesc( descSlotStart, 0u ).toKey() ); |
| 259 | |
| 260 | const size_t numSlots = mDescBindingRanges[i][j].getNumUsedSlots(); |
| 261 | for( size_t k = 0u; k < numSlots; ++k ) |
| 262 | { |
| 263 | rootLayoutDesc[i][bindingIdx].binding = static_cast<uint32_t>( bindingSlot ); |
| 264 | rootLayoutDesc[i][bindingIdx].descriptorType = static_cast<VkDescriptorType>( |
| 265 | toVkDescriptorType( static_cast<DescBindingTypes::DescBindingTypes>( j ) ) ); |
| 266 | |
| 267 | rootLayoutDesc[i][bindingIdx].descriptorCount = 1u; |
| 268 | rootLayoutDesc[i][bindingIdx].stageFlags = |
| 269 | mCompute ? VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_ALL_GRAPHICS; |
| 270 | |
| 271 | if( !mCompute && j == DescBindingTypes::ParamBuffer && |
| 272 | ( mParamsBuffStages & c_allGraphicStagesMask ) != c_allGraphicStagesMask ) |
| 273 | { |
| 274 | if( mParamsBuffStages & ( 1u << VertexShader ) ) |
| 275 | rootLayoutDesc[i][bindingIdx].stageFlags |= VK_SHADER_STAGE_VERTEX_BIT; |
| 276 | if( mParamsBuffStages & ( 1u << PixelShader ) ) |
| 277 | rootLayoutDesc[i][bindingIdx].stageFlags |= VK_SHADER_STAGE_FRAGMENT_BIT; |
| 278 | if( mParamsBuffStages & ( 1u << GeometryShader ) ) |
| 279 | rootLayoutDesc[i][bindingIdx].stageFlags |= VK_SHADER_STAGE_GEOMETRY_BIT; |
| 280 | if( mParamsBuffStages & ( 1u << HullShader ) ) |
| 281 | { |
| 282 | rootLayoutDesc[i][bindingIdx].stageFlags |= |
| 283 | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
| 284 | } |
| 285 | if( mParamsBuffStages & ( 1u << DomainShader ) ) |
| 286 | { |
| 287 | rootLayoutDesc[i][bindingIdx].stageFlags |= |
| 288 | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
| 289 | } |
no test coverage detected