diff --git a/src/common/rendering/vulkan/pipelines/vk_renderpass.cpp b/src/common/rendering/vulkan/pipelines/vk_renderpass.cpp index 01cf166e0..c5c601761 100644 --- a/src/common/rendering/vulkan/pipelines/vk_renderpass.cpp +++ b/src/common/rendering/vulkan/pipelines/vk_renderpass.cpp @@ -128,12 +128,9 @@ VkVertexFormat *VkRenderPassManager::GetVertexFormat(int index) return &VertexFormats[index]; } -VulkanPipelineLayout* VkRenderPassManager::GetPipelineLayout(int numLayers, bool levelmesh) +VulkanPipelineLayout* VkRenderPassManager::GetPipelineLayout(bool levelmesh) { - if (PipelineLayouts[levelmesh].size() <= (size_t)numLayers) - PipelineLayouts[levelmesh].resize(numLayers + 1); - - auto &layout = PipelineLayouts[levelmesh][numLayers]; + auto &layout = PipelineLayouts[levelmesh]; if (layout) return layout.get(); @@ -314,7 +311,7 @@ std::unique_ptr VkRenderPassSetup::CreatePipeline(const VkPipeli builder.RasterizationSamples((VkSampleCountFlagBits)PassKey.Samples); - builder.Layout(fb->GetRenderPassManager()->GetPipelineLayout(key.NumTextureLayers, key.ShaderKey.UseLevelMesh)); + builder.Layout(fb->GetRenderPassManager()->GetPipelineLayout(key.ShaderKey.UseLevelMesh)); builder.RenderPass(GetRenderPass(0)); builder.DebugName("VkRenderPassSetup.Pipeline"); diff --git a/src/common/rendering/vulkan/pipelines/vk_renderpass.h b/src/common/rendering/vulkan/pipelines/vk_renderpass.h index 1fbc11a9c..4c24f9449 100644 --- a/src/common/rendering/vulkan/pipelines/vk_renderpass.h +++ b/src/common/rendering/vulkan/pipelines/vk_renderpass.h @@ -39,12 +39,12 @@ public: }; int VertexFormat = 0; - int NumTextureLayers = 0; + int Padding0 = 0; VkShaderKey ShaderKey; FRenderStyle RenderStyle; - int Padding = 0; // for 64 bit alignment + int Padding1 = 0; // for 64 bit alignment bool operator<(const VkPipelineKey &other) const { return memcmp(this, &other, sizeof(VkPipelineKey)) < 0; } bool operator==(const VkPipelineKey &other) const { return memcmp(this, &other, sizeof(VkPipelineKey)) == 0; } @@ -108,7 +108,7 @@ public: VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key); int GetVertexFormat(const std::vector& bufferStrides, const std::vector& attrs); VkVertexFormat *GetVertexFormat(int index); - VulkanPipelineLayout* GetPipelineLayout(int numLayers, bool levelmesh); + VulkanPipelineLayout* GetPipelineLayout(bool levelmesh); VkPPRenderPassSetup* GetPPRenderPass(const VkPPRenderPassKey& key); @@ -118,7 +118,7 @@ private: VulkanRenderDevice* fb = nullptr; std::map> RenderPassSetup; - std::vector> PipelineLayouts[2]; + std::unique_ptr PipelineLayouts[2]; std::vector VertexFormats; std::map> PPRenderPassSetup; diff --git a/src/common/rendering/vulkan/shaders/vk_shader.h b/src/common/rendering/vulkan/shaders/vk_shader.h index 322c34487..595a90299 100644 --- a/src/common/rendering/vulkan/shaders/vk_shader.h +++ b/src/common/rendering/vulkan/shaders/vk_shader.h @@ -10,8 +10,6 @@ #include #include -#define SHADER_MIN_REQUIRED_TEXTURE_LAYERS 11 - class ShaderIncludeResult; class VulkanRenderDevice; class VulkanDevice; diff --git a/src/common/rendering/vulkan/vk_renderdevice.cpp b/src/common/rendering/vulkan/vk_renderdevice.cpp index f0b2a38e0..1b79dcd94 100644 --- a/src/common/rendering/vulkan/vk_renderdevice.cpp +++ b/src/common/rendering/vulkan/vk_renderdevice.cpp @@ -633,8 +633,6 @@ int VulkanRenderDevice::GetLevelMeshPipelineID(const MeshApplyData& applyData, c pipelineKey.VertexFormat = levelVertexFormatIndex; pipelineKey.RenderStyle = applyData.RenderStyle; pipelineKey.DepthFunc = applyData.DepthFunc; - pipelineKey.NumTextureLayers = material.mMaterial ? material.mMaterial->NumLayers() : 0; - pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it if (applyData.SpecialEffect > EFF_NONE) { pipelineKey.ShaderKey.SpecialEffect = applyData.SpecialEffect; diff --git a/src/common/rendering/vulkan/vk_renderstate.cpp b/src/common/rendering/vulkan/vk_renderstate.cpp index e63079461..3d75d3205 100644 --- a/src/common/rendering/vulkan/vk_renderstate.cpp +++ b/src/common/rendering/vulkan/vk_renderstate.cpp @@ -235,8 +235,6 @@ void VkRenderState::ApplyRenderPass(int dt) pipelineKey.StencilPassOp = mStencilOp; pipelineKey.ColorMask = mColorMask; pipelineKey.CullMode = mCullMode; - pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->NumLayers() : 0; - pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it if (mSpecialEffect > EFF_NONE) { pipelineKey.ShaderKey.SpecialEffect = mSpecialEffect; @@ -435,7 +433,7 @@ void VkRenderState::ApplyPushConstants() mPushConstants.uBoneIndexBase = mBoneIndexBase; mPushConstants.uFogballIndex = mFogballIndex >= 0 ? (mFogballIndex % MAX_FOGBALL_DATA) : -1; - mCommandBuffer->pushConstants(fb->GetRenderPassManager()->GetPipelineLayout(mPipelineKey.NumTextureLayers, mPipelineKey.ShaderKey.UseLevelMesh), VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, (uint32_t)sizeof(PushConstants), &mPushConstants); + mCommandBuffer->pushConstants(fb->GetRenderPassManager()->GetPipelineLayout(mPipelineKey.ShaderKey.UseLevelMesh), VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, (uint32_t)sizeof(PushConstants), &mPushConstants); } void VkRenderState::ApplyMatrices() @@ -501,7 +499,7 @@ void VkRenderState::ApplyBufferSets() if (mViewpointOffset != mLastViewpointOffset || matrixOffset != mLastMatricesOffset || surfaceUniformsOffset != mLastSurfaceUniformsOffset || lightsOffset != mLastLightsOffset || fogballsOffset != mLastFogballsOffset) { auto descriptors = fb->GetDescriptorSetManager(); - VulkanPipelineLayout* layout = fb->GetRenderPassManager()->GetPipelineLayout(mPipelineKey.NumTextureLayers, mPipelineKey.ShaderKey.UseLevelMesh); + VulkanPipelineLayout* layout = fb->GetRenderPassManager()->GetPipelineLayout(mPipelineKey.ShaderKey.UseLevelMesh); uint32_t offsets[5] = { mViewpointOffset, matrixOffset, surfaceUniformsOffset, lightsOffset, fogballsOffset }; mCommandBuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptors->GetFixedSet()); @@ -924,7 +922,7 @@ void VkRenderState::DrawLevelMeshRange(VulkanCommandBuffer* cmdbuffer, VkPipelin pushConstants.uLightIndex = -1; pushConstants.uBoneIndexBase = -1; - VulkanPipelineLayout* layout = fb->GetRenderPassManager()->GetPipelineLayout(pipelineKey.NumTextureLayers, pipelineKey.ShaderKey.UseLevelMesh); + VulkanPipelineLayout* layout = fb->GetRenderPassManager()->GetPipelineLayout(pipelineKey.ShaderKey.UseLevelMesh); uint32_t viewpointOffset = mViewpointOffset; uint32_t matrixOffset = mRSBuffers->MatrixBuffer->Offset(); uint32_t lightsOffset = 0;