@@ -158,7 +158,7 @@ Cache::PipelineLayout Cache::Pipeline::getPipelineAndDescriptorLayout(const vks:
158158 return layout;
159159}
160160
161- Cache::Pipeline::RenderpassKey Cache::Pipeline::getRenderPassKey (gpu::Framebuffer* framebuffer) const {
161+ Cache::Pipeline::RenderpassKey Cache::Pipeline::getRenderPassKey (gpu::Framebuffer* framebuffer, const vks::Context &context ) const {
162162 RenderpassKey result;
163163 if (!framebuffer) {
164164 result.emplace_back (VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_UNDEFINED); // VKTODO: this is definitely wrong, why is it that way?
@@ -176,7 +176,7 @@ Cache::Pipeline::RenderpassKey Cache::Pipeline::getRenderPassKey(gpu::Framebuffe
176176 layout = attachmentTexture->getVkImageLayout ();
177177 }
178178 }
179- result.emplace_back (evalTexelFormatInternal (attachment._texture ->getTexelFormat ()), layout);
179+ result.emplace_back (evalTexelFormatInternal (attachment._texture ->getTexelFormat (), context ), layout);
180180 }
181181 }
182182 if (framebuffer->hasDepthStencil ()) {
@@ -190,7 +190,7 @@ Cache::Pipeline::RenderpassKey Cache::Pipeline::getRenderPassKey(gpu::Framebuffe
190190 }
191191 }
192192 }
193- result.emplace_back (evalTexelFormatInternal (framebuffer->getDepthStencilBufferFormat ()), layout);
193+ result.emplace_back (evalTexelFormatInternal (framebuffer->getDepthStencilBufferFormat (), context ), layout);
194194 }
195195 }
196196 return result;
@@ -199,7 +199,7 @@ Cache::Pipeline::RenderpassKey Cache::Pipeline::getRenderPassKey(gpu::Framebuffe
199199VkRenderPass Cache::Pipeline::getRenderPass (const vks::Context& context) {
200200 const auto framebuffer = gpu::acquire (this ->framebuffer );
201201
202- RenderpassKey key = getRenderPassKey (framebuffer);
202+ RenderpassKey key = getRenderPassKey (framebuffer, context );
203203 auto itr = _renderPassMap.find (key);
204204 if (itr == _renderPassMap.end ()) {
205205 auto &renderBuffers = framebuffer->getRenderBuffers ();
@@ -357,9 +357,9 @@ std::string Cache::Pipeline::getStridesKey() const {
357357}
358358
359359// VKTODO: use binary key if performance with text key is not good enough
360- std::string Cache::Pipeline::getKey () const {
360+ std::string Cache::Pipeline::getKey (const vks::Context& context ) const {
361361 const auto framebuffer = gpu::acquire (this ->framebuffer );
362- RenderpassKey renderpassKey = getRenderPassKey (framebuffer);
362+ RenderpassKey renderpassKey = getRenderPassKey (framebuffer, context );
363363 const gpu::Pipeline& pipeline = *gpu::acquire (this ->pipeline );
364364 const gpu::State& state = *pipeline.getState ();
365365 const auto & vertexShader = pipeline.getProgram ()->getShaders ()[0 ]->getSource ();
@@ -406,7 +406,7 @@ VkShaderModule Cache::getShaderModule(const vks::Context& context, const shader:
406406}
407407
408408Cache::PipelineLayout Cache::getPipeline (const vks::Context& context) {
409- auto key = pipelineState.getKey ();
409+ auto key = pipelineState.getKey (context );
410410 auto pipelineIterator = pipelineMap.find (key);
411411 if (pipelineIterator != pipelineMap.end ()) {
412412 return pipelineIterator->second ;
@@ -541,13 +541,31 @@ Cache::PipelineLayout Cache::getPipeline(const vks::Context& context) {
541541 isAttributeSlotOccupied[slot] = true ;
542542
543543 attributeDescriptions.push_back (
544- { slot, attribute._channel , evalTexelFormatInternal (attribute._element ), (uint32_t )attribute._offset });
544+ { slot, attribute._channel , evalTexelFormatInternal (attribute._element , context ), (uint32_t )attribute._offset });
545545 }
546546
547547 if (!colorFound && vertexReflection.validInput (Stream::COLOR)) {
548548 attributeDescriptions.push_back ({ Stream::COLOR, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
549549 }
550550
551+ if (!isAttributeSlotOccupied[Stream::TANGENT] && vertexReflection.validInput (Stream::TANGENT)) {
552+ attributeDescriptions.push_back ({ Stream::TANGENT, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
553+ }
554+
555+ // VKTODO: is it safe to provide empty skin cluster data?
556+ // It would be used for meshes with blendshapes but no skinning.
557+ // Since blendshapes and skinning use the same shader, currently I added
558+ // a workaround that disables blendshapes on meshes with blendshapes but no skinning.
559+ /* if (!isAttributeSlotOccupied[Stream::SKIN_CLUSTER_INDEX] && vertexReflection.validInput(Stream::SKIN_CLUSTER_INDEX)) {
560+ // VKTODO: provide valid format here.
561+ attributeDescriptions.push_back({ Stream::SKIN_CLUSTER_INDEX, 0, VK_FORMAT_R8G8B8A8_UNORM, 0 });
562+ }
563+
564+ if (!isAttributeSlotOccupied[Stream::SKIN_CLUSTER_WEIGHT] && vertexReflection.validInput(Stream::SKIN_CLUSTER_WEIGHT)) {
565+ // VKTODO: provide valid format here.
566+ attributeDescriptions.push_back({ Stream::SKIN_CLUSTER_WEIGHT, 0, VK_FORMAT_R8G8B8A8_UNORM, 0 });
567+ }*/
568+
551569 if (!isAttributeSlotOccupied[Stream::TEXCOORD0] && vertexReflection.validInput (Stream::TEXCOORD0)) {
552570 attributeDescriptions.push_back ({ Stream::TEXCOORD0, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
553571 }
@@ -556,6 +574,35 @@ Cache::PipelineLayout Cache::getPipeline(const vks::Context& context) {
556574 attributeDescriptions.push_back ({ Stream::TEXCOORD1, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
557575 }
558576
577+ if (!isAttributeSlotOccupied[Stream::TEXCOORD2] && vertexReflection.validInput (Stream::TEXCOORD2)) {
578+ attributeDescriptions.push_back ({ Stream::TEXCOORD2, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
579+ }
580+
581+ if (!isAttributeSlotOccupied[Stream::TEXCOORD3] && vertexReflection.validInput (Stream::TEXCOORD3)) {
582+ attributeDescriptions.push_back ({ Stream::TEXCOORD3, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
583+ }
584+
585+ if (!isAttributeSlotOccupied[Stream::TEXCOORD4] && vertexReflection.validInput (Stream::TEXCOORD4)) {
586+ attributeDescriptions.push_back ({ Stream::TEXCOORD4, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
587+ }
588+
589+ // VKTODO: Fade inputs are not set for shapes drawn with drawIndexed.
590+ // I currently don't know how to fix it, so I added a workaround.
591+ if (!isAttributeSlotOccupied[GPU_ATTR_FADEDATA5] && vertexReflection.validInput (GPU_ATTR_FADEDATA5)) {
592+ // VKTODO: provide valid format here.
593+ attributeDescriptions.push_back ({ GPU_ATTR_FADEDATA5, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
594+ }
595+
596+ if (!isAttributeSlotOccupied[GPU_ATTR_FADEDATA6] && vertexReflection.validInput (GPU_ATTR_FADEDATA6)) {
597+ // VKTODO: provide valid format here.
598+ attributeDescriptions.push_back ({ GPU_ATTR_FADEDATA6, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
599+ }
600+
601+ if (!isAttributeSlotOccupied[GPU_ATTR_FADEDATA7] && vertexReflection.validInput (GPU_ATTR_FADEDATA7)) {
602+ // VKTODO: provide valid format here.
603+ attributeDescriptions.push_back ({ GPU_ATTR_FADEDATA7, 0 , VK_FORMAT_R8G8B8A8_UNORM, 0 });
604+ }
605+
559606 // Explicitly add the draw call info slot if required
560607 if (vertexReflection.validInput (gpu::slot::attr::DrawCallInfo)) {
561608 attributeDescriptions.push_back (
0 commit comments