10 #include "fml/logging.h"
22 CommandBufferVK::CommandBufferVK(
23 std::weak_ptr<const Context> context,
24 std::weak_ptr<const DeviceHolderVK> device_holder,
25 std::shared_ptr<TrackedObjectsVK> tracked_objects)
26 : CommandBuffer(
std::move(context)),
27 device_holder_(
std::move(device_holder)),
28 tracked_objects_(
std::move(tracked_objects)) {}
30 CommandBufferVK::~CommandBufferVK() =
default;
32 void CommandBufferVK::SetLabel(std::string_view label)
const {
34 auto context = context_.lock();
38 ContextVK::Cast(*context).SetDebugName(GetCommandBuffer(), label);
42 bool CommandBufferVK::IsValid()
const {
46 bool CommandBufferVK::OnSubmitCommands(
bool block_on_schedule,
47 CompletionCallback callback) {
51 void CommandBufferVK::OnWaitUntilCompleted() {}
53 void CommandBufferVK::OnWaitUntilScheduled() {}
55 std::shared_ptr<RenderPass> CommandBufferVK::OnCreateRenderPass(
56 RenderTarget target) {
57 auto context = context_.lock();
62 std::shared_ptr<RenderPassVK>(
new RenderPassVK(context,
66 if (!pass->IsValid()) {
72 std::shared_ptr<BlitPass> CommandBufferVK::OnCreateBlitPass() {
76 auto context = context_.lock();
80 auto pass = std::shared_ptr<BlitPassVK>(
new BlitPassVK(
81 shared_from_this(), ContextVK::Cast(*context).GetWorkarounds()));
82 if (!pass->IsValid()) {
88 std::shared_ptr<ComputePass> CommandBufferVK::OnCreateComputePass() {
92 auto context = context_.lock();
97 std::shared_ptr<ComputePassVK>(
new ComputePassVK(context,
100 if (!pass->IsValid()) {
106 bool CommandBufferVK::EndCommandBuffer()
const {
107 InsertDebugMarker(
"QueueSubmit");
109 auto command_buffer = GetCommandBuffer();
110 tracked_objects_->GetGPUProbe().RecordCmdBufferEnd(command_buffer);
112 auto status = command_buffer.end();
113 if (status != vk::Result::eSuccess) {
114 VALIDATION_LOG <<
"Failed to end command buffer: " << vk::to_string(status);
120 vk::CommandBuffer CommandBufferVK::GetCommandBuffer()
const {
121 if (tracked_objects_) {
122 return tracked_objects_->GetCommandBuffer();
127 bool CommandBufferVK::Track(
const std::shared_ptr<SharedObjectVK>&
object) {
131 tracked_objects_->Track(
object);
135 bool CommandBufferVK::Track(
const std::shared_ptr<const DeviceBuffer>& buffer) {
139 tracked_objects_->Track(buffer);
143 bool CommandBufferVK::Track(
144 const std::shared_ptr<const TextureSourceVK>& texture) {
148 tracked_objects_->Track(texture);
152 bool CommandBufferVK::Track(
const std::shared_ptr<const Texture>& texture) {
159 return Track(TextureVK::Cast(*texture).GetTextureSource());
162 fml::StatusOr<vk::DescriptorSet> CommandBufferVK::AllocateDescriptorSets(
163 const vk::DescriptorSetLayout& layout,
167 return fml::Status(fml::StatusCode::kUnknown,
"command encoder invalid");
170 return tracked_objects_->GetDescriptorPool().AllocateDescriptorSets(
171 layout, pipeline_key, context);
174 void CommandBufferVK::PushDebugGroup(std::string_view label)
const {
178 vk::DebugUtilsLabelEXT label_info;
179 label_info.pLabelName = label.data();
180 if (
auto command_buffer = GetCommandBuffer()) {
181 command_buffer.beginDebugUtilsLabelEXT(label_info);
185 void CommandBufferVK::PopDebugGroup()
const {
189 if (
auto command_buffer = GetCommandBuffer()) {
190 command_buffer.endDebugUtilsLabelEXT();
194 void CommandBufferVK::InsertDebugMarker(std::string_view label)
const {
198 vk::DebugUtilsLabelEXT label_info;
199 label_info.pLabelName = label.data();
200 if (
auto command_buffer = GetCommandBuffer()) {
201 command_buffer.insertDebugUtilsLabelEXT(label_info);
206 return tracked_objects_->GetDescriptorPool();
A per-frame descriptor pool. Descriptors from this pool don't need to be freed individually....
bool HasValidationLayers()