1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/* Copyright (c) 2019-2025 The Khronos Group Inc.
* Copyright (c) 2019-2025 Valve Corporation
* Copyright (c) 2019-2025 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <vulkan/vulkan.h>
#include "sync/sync_common.h"
#include "sync/sync_access_context.h"
#include "sync/sync_op.h"
struct LastBound;
namespace vvl {
class CommandBuffer;
}
namespace syncval_state {
enum class AttachmentType { kColor, kDepth, kStencil };
struct DynamicRenderingInfo {
struct Attachment {
const vku::safe_VkRenderingAttachmentInfo &info;
std::shared_ptr<const vvl::ImageView> view;
std::shared_ptr<const vvl::ImageView> resolve_view;
ImageRangeGen view_gen;
std::optional<ImageRangeGen> resolve_gen;
AttachmentType type;
Attachment(const SyncValidator &state, const vku::safe_VkRenderingAttachmentInfo &info, const AttachmentType type_,
const VkOffset3D &offset, const VkExtent3D &extent);
SyncAccessIndex GetLoadUsage() const;
SyncAccessIndex GetStoreUsage() const;
SyncOrdering GetOrdering() const;
Location GetLocation(const Location &loc, uint32_t index = 0) const;
bool IsWriteable(const LastBound &last_bound_state) const;
bool IsValid() const { return view.get(); }
};
// attachments store references to this info, so make sure this doesn't get moved around.
DynamicRenderingInfo(const DynamicRenderingInfo &) = delete;
DynamicRenderingInfo(DynamicRenderingInfo &&) = delete;
DynamicRenderingInfo &operator=(const DynamicRenderingInfo &) = delete;
DynamicRenderingInfo &operator=(DynamicRenderingInfo &&) = delete;
DynamicRenderingInfo(const SyncValidator &state, const VkRenderingInfo &rendering_info);
const vvl::ImageView *GetClearAttachmentView(const VkClearAttachment &clear_attachment) const;
vku::safe_VkRenderingInfo info;
std::vector<Attachment> attachments; // All attachments (with internal typing)
};
struct BeginRenderingCmdState {
BeginRenderingCmdState(std::shared_ptr<const vvl::CommandBuffer> &&cb_state_) : cb_state(std::move(cb_state_)) {}
void AddRenderingInfo(const SyncValidator &state, const VkRenderingInfo &rendering_info);
const DynamicRenderingInfo &GetRenderingInfo() const;
std::shared_ptr<const vvl::CommandBuffer> cb_state;
std::unique_ptr<DynamicRenderingInfo> info;
};
} // namespace syncval_state
void InitSubpassContexts(VkQueueFlags queue_flags, const vvl::RenderPass &rp_state, const AccessContext *external_context,
std::vector<AccessContext> &subpass_contexts);
class RenderPassAccessContext {
public:
static AttachmentViewGenVector CreateAttachmentViewGen(const VkRect2D &render_area,
const std::vector<const vvl::ImageView *> &attachment_views);
RenderPassAccessContext() : rp_state_(nullptr), render_area_(VkRect2D()), current_subpass_(0) {}
RenderPassAccessContext(const vvl::RenderPass &rp_state, const VkRect2D &render_area, VkQueueFlags queue_flags,
const std::vector<const vvl::ImageView *> &attachment_views, const AccessContext *external_context);
static bool ValidateLayoutTransitions(const CommandBufferAccessContext &cb_context, const AccessContext &access_context,
const vvl::RenderPass &rp_state, const VkRect2D &render_area, uint32_t subpass,
const AttachmentViewGenVector &attachment_views, vvl::Func command);
static bool ValidateLoadOperation(const CommandBufferAccessContext &cb_context, const AccessContext &access_context,
const vvl::RenderPass &rp_state, const VkRect2D &render_area, uint32_t subpass,
const AttachmentViewGenVector &attachment_views, vvl::Func command);
bool ValidateStoreOperation(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
bool ValidateResolveOperations(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
static void UpdateAttachmentResolveAccess(const vvl::RenderPass &rp_state, const AttachmentViewGenVector &attachment_views,
uint32_t subpass, const ResourceUsageTag tag, AccessContext access_context);
static void UpdateAttachmentStoreAccess(const vvl::RenderPass &rp_state, const AttachmentViewGenVector &attachment_views,
uint32_t subpass, const ResourceUsageTag tag, AccessContext &access_context);
static void RecordLayoutTransitions(const vvl::RenderPass &rp_state, uint32_t subpass,
const AttachmentViewGenVector &attachment_views, const ResourceUsageTag tag,
AccessContext &access_context);
bool ValidateDrawSubpassAttachment(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
void RecordDrawSubpassAttachment(const vvl::CommandBuffer &cmd_buffer, ResourceUsageTag tag);
const vvl::ImageView *GetClearAttachmentView(const VkClearAttachment &clear_attachment) const;
bool ValidateNextSubpass(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
bool ValidateEndRenderPass(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
bool ValidateFinalSubpassLayoutTransitions(const CommandBufferAccessContext &cb_context, vvl::Func command) const;
void RecordLayoutTransitions(ResourceUsageTag tag);
void RecordLoadOperations(ResourceUsageTag tag);
void RecordBeginRenderPass(ResourceUsageTag tag, ResourceUsageTag load_tag);
void RecordNextSubpass(ResourceUsageTag store_tag, ResourceUsageTag barrier_tag, ResourceUsageTag load_tag);
void RecordEndRenderPass(AccessContext *external_context, ResourceUsageTag store_tag, ResourceUsageTag barrier_tag);
AccessContext &CurrentContext() { return subpass_contexts_[current_subpass_]; }
const AccessContext &CurrentContext() const { return subpass_contexts_[current_subpass_]; }
const std::vector<AccessContext> &GetContexts() const { return subpass_contexts_; }
uint32_t GetCurrentSubpass() const { return current_subpass_; }
const vvl::RenderPass *GetRenderPassState() const { return rp_state_; }
AccessContext *CreateStoreResolveProxy() const;
private:
const vvl::RenderPass *rp_state_;
const VkRect2D render_area_;
uint32_t current_subpass_;
std::vector<AccessContext> subpass_contexts_;
AttachmentViewGenVector attachment_views_;
};
|