Adding render pass key.
This commit is contained in:
@@ -18,15 +18,19 @@ VulkanDescriptorSetLayoutSerializer::VulkanDescriptorSetLayoutSerializer(
|
||||
buffer << "{" << std::endl;
|
||||
buffer << "\"binding\":" << info.pBindings[i].binding << "," << std::endl;
|
||||
buffer << "\"descriptor_type\":" << info.pBindings[i].descriptorType << "," << std::endl;
|
||||
buffer << "\"stage_flags\":" << info.pBindings[i].stageFlags << "," << std::endl;
|
||||
buffer << "\"immutable_samplers\":[" << std::endl;
|
||||
for (uint32_t i = 0; i < immutableSamplers.size(); ++i) {
|
||||
buffer << immutableSamplers[i];
|
||||
if (i < immutableSamplers.size() - 1) {
|
||||
buffer << ",";
|
||||
buffer << "\"stage_flags\":" << info.pBindings[i].stageFlags;
|
||||
if (immutableSamplers.size()) {
|
||||
buffer << "," << std::endl;
|
||||
buffer << "\"immutable_samplers\":[" << std::endl;
|
||||
for (uint32_t i = 0; i < immutableSamplers.size(); ++i) {
|
||||
buffer << immutableSamplers[i];
|
||||
if (i < immutableSamplers.size() - 1) {
|
||||
buffer << ",";
|
||||
}
|
||||
}
|
||||
buffer << "]";
|
||||
}
|
||||
buffer << "]" << std::endl;
|
||||
buffer << std::endl;
|
||||
buffer << "}";
|
||||
if (i < info.bindingCount - 1) {
|
||||
buffer << ",";
|
||||
|
||||
@@ -1666,7 +1666,7 @@ void VulkanDriver::beginRenderPass(Handle<HwRenderTarget> rth, const RenderPassP
|
||||
rpkey.subpassMask = uint8_t(params.subpassMask);
|
||||
|
||||
VkRenderPass renderPass = mFramebufferCache.getRenderPass(rpkey);
|
||||
mPipelineCache.bindRenderPass(renderPass, 0);
|
||||
mPipelineCache.bindRenderPass(renderPass, mFramebufferCache.getRenderPassKey(renderPass), 0);
|
||||
|
||||
// Create the VkFramebuffer or fetch it from cache.
|
||||
VulkanFboCache::FboKey fbkey = rt->getFboKey();
|
||||
@@ -1785,6 +1785,7 @@ void VulkanDriver::nextSubpass(int) {
|
||||
VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
mPipelineCache.bindRenderPass(mCurrentRenderPass.renderPass,
|
||||
mFramebufferCache.getRenderPassKey(mCurrentRenderPass.renderPass),
|
||||
++mCurrentRenderPass.currentSubpass);
|
||||
|
||||
if (mCurrentRenderPass.params.subpassMask & 0x1) {
|
||||
|
||||
@@ -202,6 +202,8 @@ VulkanPipelineCache::PipelineCacheEntry* VulkanPipelineCache::createPipeline() n
|
||||
|
||||
//layout
|
||||
serializer.setPipelineLayoutKey(mPipelineLayoutKey);
|
||||
// renderPass
|
||||
serializer.setRenderPassKey(mRenderPassKey);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||
@@ -256,7 +258,10 @@ VulkanPipelineCache::PipelineCacheEntry* VulkanPipelineCache::createPipeline() n
|
||||
FVK_LOGE << "vkCreateGraphicsPipelines error " << error;
|
||||
return nullptr;
|
||||
}
|
||||
serializer.setID(cacheEntry.handle);
|
||||
|
||||
PipelineHashFn hashFunc;
|
||||
|
||||
serializer.setID(hashFunc(mPipelineRequirements));
|
||||
return &mPipelines.emplace(mPipelineRequirements, cacheEntry).first.value();
|
||||
}
|
||||
|
||||
@@ -281,9 +286,10 @@ void VulkanPipelineCache::bindRasterState(RasterState const& rasterState) noexce
|
||||
mPipelineRequirements.rasterState = rasterState;
|
||||
}
|
||||
|
||||
void VulkanPipelineCache::bindRenderPass(VkRenderPass renderPass, int subpassIndex) noexcept {
|
||||
void VulkanPipelineCache::bindRenderPass(VkRenderPass renderPass, uint32_t passKey, int subpassIndex) noexcept {
|
||||
mPipelineRequirements.renderPass = renderPass;
|
||||
mPipelineRequirements.subpassIndex = subpassIndex;
|
||||
mRenderPassKey = passKey;
|
||||
}
|
||||
|
||||
void VulkanPipelineCache::bindPrimitiveTopology(VkPrimitiveTopology topology) noexcept {
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
// Each of the following methods are fast and do not make Vulkan calls.
|
||||
void bindProgram(fvkmemory::resource_ptr<VulkanProgram> program) noexcept;
|
||||
void bindRasterState(RasterState const& rasterState) noexcept;
|
||||
void bindRenderPass(VkRenderPass renderPass, int subpassIndex) noexcept;
|
||||
void bindRenderPass(VkRenderPass renderPass, uint32_t passKey, int subpassIndex) noexcept;
|
||||
void bindPrimitiveTopology(VkPrimitiveTopology topology) noexcept;
|
||||
void bindVertexArray(VkVertexInputAttributeDescription const* attribDesc,
|
||||
VkVertexInputBindingDescription const* bufferDesc, uint8_t count);
|
||||
@@ -211,6 +211,7 @@ private:
|
||||
uint64_t mVertexShaderHash;
|
||||
uint64_t mFragmentShaderHash;
|
||||
uint32_t mPipelineLayoutKey;
|
||||
uint32_t mRenderPassKey;
|
||||
|
||||
// Current bindings for the pipeline and descriptor sets.
|
||||
PipelineKey mBoundPipeline = {};
|
||||
|
||||
@@ -98,9 +98,13 @@ void VulkanPipelineStateSerializer::setPipelineLayoutKey(uint32_t pipelineLayout
|
||||
mBuffer << "\"layout\":" << pipelineLayoutKey << "," << std::endl;
|
||||
}
|
||||
|
||||
void VulkanPipelineStateSerializer::setID(VkPipeline cache) {
|
||||
void VulkanPipelineStateSerializer::setRenderPassKey(uint32_t renderPassKey) {
|
||||
mBuffer << "\"render_pass\":" << renderPassKey << "," << std::endl;
|
||||
}
|
||||
|
||||
void VulkanPipelineStateSerializer::setID(uint32_t key) {
|
||||
std::stringstream temp;
|
||||
temp << "pipeline_" << cache << ".json";
|
||||
temp << "pipeline_" << key << ".json";
|
||||
temp >> mFileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@ public:
|
||||
VulkanPipelineStateSerializer(const utils::CString& name);
|
||||
~VulkanPipelineStateSerializer();
|
||||
|
||||
void setID(VkPipeline cache);
|
||||
void setID(uint32_t key);
|
||||
void setPipelineLayoutKey(uint32_t pipelineLayoutKey);
|
||||
void setRenderPassKey(uint32_t renderPassKey);
|
||||
VulkanPipelineStateSerializer& operator<<(
|
||||
const VkPipelineInputAssemblyStateCreateInfo& inputAsm);
|
||||
VulkanPipelineStateSerializer& operator<<(const VkPipelineViewportStateCreateInfo& viewport);
|
||||
|
||||
@@ -54,7 +54,6 @@ VulkanSamplerStateSerializer::VulkanSamplerStateSerializer(const VulkanSamplerCa
|
||||
buffer << "\"anisotropy_log2\":" << uint32_t(samplerParams.anisotropyLog2) << "," << std::endl;
|
||||
buffer << "\"compare_mode\":" << uint32_t(samplerParams.compareMode) << "," << std::endl;
|
||||
buffer << "\"compare_func\":" << uint32_t(samplerParams.compareFunc) << "," << std::endl;
|
||||
buffer << "\"filter_min\":" << uint32_t(samplerParams.filterMin) << "," << std::endl;
|
||||
buffer << "\"ycbcr_conv_key\":" << ycbcr_conv_key << std::endl;
|
||||
buffer << "}" << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user