-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Vulkan framebuffer fetch via VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS #48458
Changes from 6 commits
9180bfb
a9fd144
6921c1b
5c395cb
b6cb2cb
1869497
b428f5f
808d257
4e79b47
a1153d9
76c4336
d5bff60
cef3581
371fbdd
55d111d
f5949b8
8dfb942
da822f4
4501eb3
7bf4115
b9ef69b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
#include "impeller/renderer/backend/vulkan/vk.h" | ||
#include "impeller/renderer/command.h" | ||
#include "impeller/renderer/compute_command.h" | ||
#include "vulkan/vulkan_core.h" | ||
|
||
namespace impeller { | ||
|
||
|
@@ -117,7 +118,8 @@ static bool BindBuffers(const Bindings& bindings, | |
fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateAndBindDescriptorSets( | ||
const ContextVK& context, | ||
const std::shared_ptr<CommandEncoderVK>& encoder, | ||
const std::vector<Command>& commands) { | ||
const std::vector<Command>& commands, | ||
const vk::ImageView& image_view) { | ||
if (commands.empty()) { | ||
return std::vector<vk::DescriptorSet>{}; | ||
} | ||
|
@@ -127,19 +129,22 @@ fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateAndBindDescriptorSets( | |
// to allocate a correctly sized descriptor pool. | ||
size_t buffer_count = 0; | ||
size_t samplers_count = 0; | ||
size_t subpass_count = 0; | ||
std::vector<vk::DescriptorSetLayout> layouts; | ||
layouts.reserve(commands.size()); | ||
|
||
for (const auto& command : commands) { | ||
buffer_count += command.vertex_bindings.buffers.size(); | ||
buffer_count += command.fragment_bindings.buffers.size(); | ||
samplers_count += command.fragment_bindings.sampled_images.size(); | ||
subpass_count += | ||
command.pipeline->GetDescriptor().GetHasSubpassDependency() ? 1 : 0; | ||
|
||
layouts.emplace_back( | ||
PipelineVK::Cast(*command.pipeline).GetDescriptorSetLayout()); | ||
} | ||
auto descriptor_result = | ||
encoder->AllocateDescriptorSets(buffer_count, samplers_count, layouts); | ||
auto descriptor_result = encoder->AllocateDescriptorSets( | ||
buffer_count, samplers_count, subpass_count, layouts); | ||
if (!descriptor_result.ok()) { | ||
return descriptor_result.status(); | ||
} | ||
|
@@ -153,9 +158,9 @@ fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateAndBindDescriptorSets( | |
std::vector<vk::DescriptorImageInfo> images; | ||
std::vector<vk::DescriptorBufferInfo> buffers; | ||
std::vector<vk::WriteDescriptorSet> writes; | ||
images.reserve(samplers_count); | ||
images.reserve(samplers_count + subpass_count); | ||
buffers.reserve(buffer_count); | ||
writes.reserve(samplers_count + buffer_count); | ||
writes.reserve(samplers_count + buffer_count + subpass_count); | ||
|
||
auto& allocator = *context.GetResourceAllocator(); | ||
auto desc_index = 0u; | ||
|
@@ -173,6 +178,24 @@ fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateAndBindDescriptorSets( | |
return fml::Status(fml::StatusCode::kUnknown, | ||
"Failed to bind texture or buffer."); | ||
} | ||
|
||
if (command.pipeline->GetDescriptor().GetHasSubpassDependency()) { | ||
vk::DescriptorImageInfo image_info; | ||
image_info.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal; | ||
image_info.sampler = VK_NULL_HANDLE; | ||
image_info.imageView = image_view; | ||
images.push_back(image_info); | ||
|
||
vk::WriteDescriptorSet write_set; | ||
write_set.dstSet = descriptor_sets[desc_index]; | ||
// MAGIC! see description in pipeline_library_vk.cc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just look this up on the descriptor sets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because the subpass doesn't show up in host builds I can't use any of the constants. |
||
write_set.dstBinding = 64u; | ||
write_set.descriptorCount = 1u; | ||
write_set.descriptorType = vk::DescriptorType::eInputAttachment; | ||
write_set.pImageInfo = &images.back(); | ||
|
||
writes.push_back(write_set); | ||
} | ||
desc_index += 1; | ||
} | ||
|
||
|
@@ -203,7 +226,7 @@ fml::StatusOr<std::vector<vk::DescriptorSet>> AllocateAndBindDescriptorSets( | |
ComputePipelineVK::Cast(*command.pipeline).GetDescriptorSetLayout()); | ||
} | ||
auto descriptor_result = | ||
encoder->AllocateDescriptorSets(buffer_count, samplers_count, layouts); | ||
encoder->AllocateDescriptorSets(buffer_count, samplers_count, 0, layouts); | ||
if (!descriptor_result.ok()) { | ||
return descriptor_result.status(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
#include <string> | ||
#include <vector> | ||
|
||
#include "flutter/fml/macros.h" | ||
#include "impeller/base/backend_cast.h" | ||
#include "impeller/renderer/backend/vulkan/vk.h" | ||
#include "impeller/renderer/capabilities.h" | ||
|
@@ -22,6 +21,8 @@ class ContextVK; | |
enum class OptionalDeviceExtensionVK : uint32_t { | ||
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_pipeline_creation_feedback.html | ||
kEXTPipelineCreationFeedback, | ||
kARMRasterizationOrderAttachmentAccess, | ||
kEXTRasterizationOrderAttachmentAccess, | ||
jonahwilliams marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kLast, | ||
}; | ||
|
||
|
@@ -110,6 +111,8 @@ class CapabilitiesVK final : public Capabilities, | |
vk::PhysicalDeviceProperties device_properties_; | ||
bool supports_compute_subgroups_ = false; | ||
bool supports_device_transient_textures_ = false; | ||
bool supports_framebuffer_fetch_ = false; | ||
; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stray line |
||
bool is_valid_ = false; | ||
|
||
bool HasExtension(const std::string& ext) const; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using an enum instead of a bool so that this reads more nicely at the callsites, e.g.
enum class UseSubpassInput { kYes, kNo, };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the nice parts of clangd is that it does this for me 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively use the google-style argument comments, but I prefer the enum. I don't have clangd when I'mr eading the callsites in your patch :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is why objective-c has YES and NO constants 😄