mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-06 03:55:08 +01:00
Use attachment formats rather than views in VK pipeline cache
This commit is contained in:
parent
e849264028
commit
ce428af2e6
@ -36,15 +36,11 @@ namespace skyline::gpu::cache {
|
|||||||
|
|
||||||
colorBlendState.pAttachments = colorBlendAttachments.data();
|
colorBlendState.pAttachments = colorBlendAttachments.data();
|
||||||
|
|
||||||
for (auto &colorAttachment : state.colorAttachments) {
|
for (auto &colorFormat : state.colorFormats)
|
||||||
if (colorAttachment)
|
colorFormats.emplace_back(colorFormat);
|
||||||
colorAttachments.emplace_back(AttachmentMetadata{colorAttachment->format->vkFormat, colorAttachment->texture->sampleCount});
|
|
||||||
else
|
|
||||||
colorAttachments.emplace_back(AttachmentMetadata{vk::Format::eUndefined, vk::SampleCountFlagBits::e1});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.depthStencilAttachment)
|
depthStencilFormat = state.depthStencilFormat;
|
||||||
depthStencilAttachment.emplace(AttachmentMetadata{state.depthStencilAttachment->format->vkFormat, state.depthStencilAttachment->texture->sampleCount});
|
sampleCount = state.sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef VEC_CPY
|
#undef VEC_CPY
|
||||||
@ -168,45 +164,23 @@ namespace skyline::gpu::cache {
|
|||||||
HASH(static_cast<VkBlendFactor>(attachment.srcColorBlendFactor));
|
HASH(static_cast<VkBlendFactor>(attachment.srcColorBlendFactor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HASH(key.colorFormats.size());
|
||||||
|
for (auto format : key.colorFormats) {
|
||||||
|
HASH(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
HASH(key.depthStencilFormat);
|
||||||
|
HASH(key.sampleCount);
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GraphicsPipelineCache::PipelineStateHash::operator()(const GraphicsPipelineCache::PipelineState &key) const {
|
size_t GraphicsPipelineCache::PipelineStateHash::operator()(const GraphicsPipelineCache::PipelineState &key) const {
|
||||||
size_t hash{HashCommonPipelineState(key)};
|
return HashCommonPipelineState(key);
|
||||||
|
|
||||||
HASH(key.colorAttachments.size());
|
|
||||||
for (const auto &attachment : key.colorAttachments) {
|
|
||||||
if (attachment) {
|
|
||||||
HASH(attachment->format->vkFormat);
|
|
||||||
HASH(attachment->texture->sampleCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HASH(key.depthStencilAttachment != nullptr);
|
|
||||||
if (key.depthStencilAttachment != nullptr) {
|
|
||||||
HASH(key.depthStencilAttachment->format->vkFormat);
|
|
||||||
HASH(key.depthStencilAttachment->texture->sampleCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GraphicsPipelineCache::PipelineStateHash::operator()(const GraphicsPipelineCache::PipelineCacheKey &key) const {
|
size_t GraphicsPipelineCache::PipelineStateHash::operator()(const GraphicsPipelineCache::PipelineCacheKey &key) const {
|
||||||
size_t hash{HashCommonPipelineState(key)};
|
return HashCommonPipelineState(key);
|
||||||
|
|
||||||
HASH(key.colorAttachments.size());
|
|
||||||
for (const auto &attachment : key.colorAttachments) {
|
|
||||||
HASH(attachment.format);
|
|
||||||
HASH(attachment.sampleCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
HASH(key.depthStencilAttachment.has_value());
|
|
||||||
if (key.depthStencilAttachment) {
|
|
||||||
HASH(key.depthStencilAttachment->format);
|
|
||||||
HASH(key.depthStencilAttachment->sampleCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef HASH
|
#undef HASH
|
||||||
@ -296,16 +270,13 @@ namespace skyline::gpu::cache {
|
|||||||
KEYNEQ(colorBlendState.blendConstants)
|
KEYNEQ(colorBlendState.blendConstants)
|
||||||
)
|
)
|
||||||
|
|
||||||
RETF(CARREQ(colorAttachments.begin(), colorAttachments.size(), {
|
RETF(CARREQ(colorFormats.begin(), colorFormats.size(), {
|
||||||
return lhs.format == rhs->format->vkFormat && lhs.sampleCount == rhs->texture->sampleCount;
|
return lhs == rhs;
|
||||||
}))
|
}))
|
||||||
|
|
||||||
RETF(lhs.depthStencilAttachment.has_value() != (rhs.depthStencilAttachment != nullptr) ||
|
RETF(lhs.depthStencilFormat == rhs.depthStencilFormat)
|
||||||
(lhs.depthStencilAttachment.has_value() &&
|
RETF(lhs.sampleCount == rhs.sampleCount)
|
||||||
lhs.depthStencilAttachment->format != rhs.depthStencilAttachment->format->vkFormat &&
|
|
||||||
lhs.depthStencilAttachment->sampleCount != rhs.depthStencilAttachment->texture->sampleCount
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
#undef ARREQ
|
#undef ARREQ
|
||||||
#undef CARREQ
|
#undef CARREQ
|
||||||
@ -349,22 +320,22 @@ namespace skyline::gpu::cache {
|
|||||||
boost::container::small_vector<vk::AttachmentDescription, 8> attachmentDescriptions;
|
boost::container::small_vector<vk::AttachmentDescription, 8> attachmentDescriptions;
|
||||||
boost::container::small_vector<vk::AttachmentReference, 8> attachmentReferences;
|
boost::container::small_vector<vk::AttachmentReference, 8> attachmentReferences;
|
||||||
|
|
||||||
auto pushAttachment{[&](TextureView *view) {
|
auto pushAttachment{[&](vk::Format format) {
|
||||||
if (view) {
|
if (format != vk::Format::eUndefined) {
|
||||||
attachmentDescriptions.push_back(vk::AttachmentDescription{
|
attachmentDescriptions.push_back(vk::AttachmentDescription{
|
||||||
.format = view->format->vkFormat,
|
.format = format,
|
||||||
.samples = view->texture->sampleCount,
|
.samples = state.sampleCount,
|
||||||
.loadOp = vk::AttachmentLoadOp::eLoad,
|
.loadOp = vk::AttachmentLoadOp::eLoad,
|
||||||
.storeOp = vk::AttachmentStoreOp::eStore,
|
.storeOp = vk::AttachmentStoreOp::eStore,
|
||||||
.stencilLoadOp = vk::AttachmentLoadOp::eLoad,
|
.stencilLoadOp = vk::AttachmentLoadOp::eLoad,
|
||||||
.stencilStoreOp = vk::AttachmentStoreOp::eStore,
|
.stencilStoreOp = vk::AttachmentStoreOp::eStore,
|
||||||
.initialLayout = view->texture->layout,
|
.initialLayout = vk::ImageLayout::eGeneral,
|
||||||
.finalLayout = view->texture->layout,
|
.finalLayout = vk::ImageLayout::eGeneral,
|
||||||
.flags = vk::AttachmentDescriptionFlagBits::eMayAlias
|
.flags = vk::AttachmentDescriptionFlagBits::eMayAlias
|
||||||
});
|
});
|
||||||
attachmentReferences.push_back(vk::AttachmentReference{
|
attachmentReferences.push_back(vk::AttachmentReference{
|
||||||
.attachment = static_cast<u32>(attachmentDescriptions.size() - 1),
|
.attachment = static_cast<u32>(attachmentDescriptions.size() - 1),
|
||||||
.layout = view->texture->layout,
|
.layout = vk::ImageLayout::eGeneral,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
attachmentReferences.push_back(vk::AttachmentReference{
|
attachmentReferences.push_back(vk::AttachmentReference{
|
||||||
@ -378,11 +349,11 @@ namespace skyline::gpu::cache {
|
|||||||
.pipelineBindPoint = vk::PipelineBindPoint::eGraphics,
|
.pipelineBindPoint = vk::PipelineBindPoint::eGraphics,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto &colorAttachment : state.colorAttachments)
|
for (auto &colorAttachment : state.colorFormats)
|
||||||
pushAttachment(colorAttachment);
|
pushAttachment(colorAttachment);
|
||||||
|
|
||||||
if (state.depthStencilAttachment) {
|
if (state.depthStencilFormat != vk::Format::eUndefined) {
|
||||||
pushAttachment(state.depthStencilAttachment);
|
pushAttachment(state.depthStencilFormat);
|
||||||
|
|
||||||
subpassDescription.pColorAttachments = attachmentReferences.data();
|
subpassDescription.pColorAttachments = attachmentReferences.data();
|
||||||
subpassDescription.colorAttachmentCount = static_cast<u32>(attachmentReferences.size() - 1);
|
subpassDescription.colorAttachmentCount = static_cast<u32>(attachmentReferences.size() - 1);
|
||||||
|
@ -31,8 +31,9 @@ namespace skyline::gpu::cache {
|
|||||||
const vk::PipelineColorBlendStateCreateInfo &colorBlendState;
|
const vk::PipelineColorBlendStateCreateInfo &colorBlendState;
|
||||||
const vk::PipelineDynamicStateCreateInfo &dynamicState;
|
const vk::PipelineDynamicStateCreateInfo &dynamicState;
|
||||||
|
|
||||||
span<TextureView *> colorAttachments; //!< All color attachments in the subpass of this pipeline
|
span<vk::Format> colorFormats; //!< All color attachment formats in the subpass of this pipeline
|
||||||
TextureView *depthStencilAttachment; //!< A nullable pointer to the depth/stencil attachment in the subpass of this pipeline
|
vk::Format depthStencilFormat; //!< The depth attachment format in the subpass of this pipeline, 'Undefined' if there is no depth attachment
|
||||||
|
vk::SampleCountFlagBits sampleCount; //!< The sample count of the subpass of this pipeline
|
||||||
|
|
||||||
constexpr const vk::PipelineVertexInputStateCreateInfo &VertexInputState() const {
|
constexpr const vk::PipelineVertexInputStateCreateInfo &VertexInputState() const {
|
||||||
return vertexState.get<vk::PipelineVertexInputStateCreateInfo>();
|
return vertexState.get<vk::PipelineVertexInputStateCreateInfo>();
|
||||||
@ -63,9 +64,8 @@ namespace skyline::gpu::cache {
|
|||||||
*/
|
*/
|
||||||
struct AttachmentMetadata {
|
struct AttachmentMetadata {
|
||||||
vk::Format format;
|
vk::Format format;
|
||||||
vk::SampleCountFlagBits sampleCount;
|
|
||||||
|
|
||||||
constexpr AttachmentMetadata(vk::Format format, vk::SampleCountFlagBits sampleCount) : format(format), sampleCount(sampleCount) {}
|
constexpr AttachmentMetadata(vk::Format format, vk::SampleCountFlagBits sampleCount) : format(format) {}
|
||||||
|
|
||||||
bool operator==(const AttachmentMetadata &rhs) const = default;
|
bool operator==(const AttachmentMetadata &rhs) const = default;
|
||||||
};
|
};
|
||||||
@ -91,8 +91,9 @@ namespace skyline::gpu::cache {
|
|||||||
vk::PipelineDynamicStateCreateInfo dynamicState;
|
vk::PipelineDynamicStateCreateInfo dynamicState;
|
||||||
std::vector<vk::PipelineColorBlendAttachmentState> colorBlendAttachments;
|
std::vector<vk::PipelineColorBlendAttachmentState> colorBlendAttachments;
|
||||||
|
|
||||||
std::vector<AttachmentMetadata> colorAttachments;
|
std::vector<vk::Format> colorFormats;
|
||||||
std::optional<AttachmentMetadata> depthStencilAttachment;
|
vk::Format depthStencilFormat;
|
||||||
|
vk::SampleCountFlagBits sampleCount;
|
||||||
|
|
||||||
PipelineCacheKey(const PipelineState& state);
|
PipelineCacheKey(const PipelineState& state);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user