Skip to content

Commit

Permalink
sync: Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-lunarg committed Jan 24, 2025
1 parent 9010b19 commit 396cf65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
13 changes: 7 additions & 6 deletions layers/sync/sync_access_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,11 +958,12 @@ HazardResult::HazardState::HazardState(const ResourceAccessState *access_state_,

SyncExecScope SyncExecScope::MakeSrc(VkQueueFlags queue_flags, VkPipelineStageFlags2 mask_param,
const VkPipelineStageFlags2 disabled_feature_mask) {
const VkPipelineStageFlags2 expanded_mask = sync_utils::ExpandPipelineStages(mask_param, queue_flags, disabled_feature_mask);

SyncExecScope result;
result.mask_param = mask_param;
result.expanded_mask = sync_utils::ExpandPipelineStages(mask_param, queue_flags, disabled_feature_mask);
result.exec_scope = sync_utils::WithEarlierPipelineStages(result.expanded_mask);
result.valid_accesses = SyncStageAccess::AccessScopeByStage(result.expanded_mask);
result.exec_scope = sync_utils::WithEarlierPipelineStages(expanded_mask);
result.valid_accesses = SyncStageAccess::AccessScopeByStage(expanded_mask);
// ALL_COMMANDS stage includes all accesses performed by the gpu, not only accesses defined by the stages
if (mask_param & VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT) {
result.valid_accesses |= SYNC_IMAGE_LAYOUT_TRANSITION_BIT;
Expand All @@ -971,11 +972,11 @@ SyncExecScope SyncExecScope::MakeSrc(VkQueueFlags queue_flags, VkPipelineStageFl
}

SyncExecScope SyncExecScope::MakeDst(VkQueueFlags queue_flags, VkPipelineStageFlags2 mask_param) {
const VkPipelineStageFlags2 expanded_mask = sync_utils::ExpandPipelineStages(mask_param, queue_flags);
SyncExecScope result;
result.mask_param = mask_param;
result.expanded_mask = sync_utils::ExpandPipelineStages(mask_param, queue_flags);
result.exec_scope = sync_utils::WithLaterPipelineStages(result.expanded_mask);
result.valid_accesses = SyncStageAccess::AccessScopeByStage(result.expanded_mask);
result.exec_scope = sync_utils::WithLaterPipelineStages(expanded_mask);
result.valid_accesses = SyncStageAccess::AccessScopeByStage(expanded_mask);
// ALL_COMMANDS stage includes all accesses performed by the gpu, not only accesses defined by the stages
if (mask_param & VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT) {
result.valid_accesses |= SYNC_IMAGE_LAYOUT_TRANSITION_BIT;
Expand Down
16 changes: 7 additions & 9 deletions layers/sync/sync_access_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ class HazardResult {
};

struct SyncExecScope {
VkPipelineStageFlags2 mask_param; // the xxxStageMask parameter passed by the caller
VkPipelineStageFlags2 expanded_mask; // all stage bits covered by any 'catch all bits' in the parameter (eg. ALL_GRAPHICS_BIT).
VkPipelineStageFlags2 exec_scope; // all earlier or later stages that would be affected by a barrier using this scope.
SyncAccessFlags valid_accesses; // all valid accesses that can be used with this scope.

SyncExecScope() : mask_param(0), expanded_mask(0), exec_scope(0), valid_accesses(0) {}
SyncExecScope(VkPipelineStageFlags2 mask_param_, VkPipelineStageFlags2 expanded_mask_, VkPipelineStageFlags2 exec_scope_,
const SyncAccessFlags &valid_accesses_)
: mask_param(mask_param_), expanded_mask(expanded_mask_), exec_scope(exec_scope_), valid_accesses(valid_accesses_) {}
VkPipelineStageFlags2 mask_param; // the xxxStageMask parameter passed by the caller
VkPipelineStageFlags2 exec_scope; // all earlier or later stages that would be affected by a barrier using this scope.
SyncAccessFlags valid_accesses; // all valid accesses that can be used with this scope.

SyncExecScope() : mask_param(0), exec_scope(0), valid_accesses(0) {}
SyncExecScope(VkPipelineStageFlags2 mask_param, VkPipelineStageFlags2 exec_scope, const SyncAccessFlags &valid_accesses)
: mask_param(mask_param), exec_scope(exec_scope), valid_accesses(valid_accesses) {}

static SyncExecScope MakeSrc(VkQueueFlags queue_flags, VkPipelineStageFlags2 src_stage_mask,
const VkPipelineStageFlags2 disabled_feature_mask = 0);
Expand Down
14 changes: 10 additions & 4 deletions layers/sync/sync_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ class SyncOpEndRenderPass : public SyncOpBase {
protected:
vku::safe_VkSubpassEndInfo subpass_end_info_;
};
// The barrier operation for pipeline and subpass dependencies`

// The barrier operation for pipeline and subpass dependencies
struct PipelineBarrierOp {
SyncBarrier barrier;
bool layout_transition;
ResourceAccessState::QueueScopeOps scope;

PipelineBarrierOp(QueueId queue_id, const SyncBarrier &barrier_, bool layout_transition_)
: barrier(barrier_), layout_transition(layout_transition_), scope(queue_id) {
if (queue_id != kQueueIdInvalid) {
Expand All @@ -338,12 +340,16 @@ struct PipelineBarrierOp {
};

// Batch barrier ops don't modify in place, and thus don't need to hold pending state, and also are *never* layout transitions.
struct BatchBarrierOp : public PipelineBarrierOp {
struct BatchBarrierOp {
SyncBarrier barrier;
ResourceAccessState::QueueScopeOps scope;

BatchBarrierOp(QueueId queue_id, const SyncBarrier &barrier) : barrier(barrier), scope(queue_id) {}

void operator()(ResourceAccessState *access_state) const {
access_state->ApplyBarrier(scope, barrier, layout_transition);
access_state->ApplyBarrier(scope, barrier, false);
access_state->ApplyPendingBarriers(kInvalidTag); // There can't be any need for this tag
}
BatchBarrierOp(QueueId queue_id, const SyncBarrier &barrier_) : PipelineBarrierOp(queue_id, barrier_, false) {}
};

// The barrier operation for wait events
Expand Down
1 change: 0 additions & 1 deletion layers/sync/sync_submit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ class ApplyAcquireNextSemaphoreAction {
const SyncExecScope& getPresentSrcScope() const {
static const SyncExecScope kPresentSrcScope =
SyncExecScope(VK_PIPELINE_STAGE_2_PRESENT_ENGINE_BIT_SYNCVAL, // mask_param (unused)
VK_PIPELINE_STAGE_2_PRESENT_ENGINE_BIT_SYNCVAL, // expanded_mask
VK_PIPELINE_STAGE_2_PRESENT_ENGINE_BIT_SYNCVAL, // exec_scope
getPresentValidAccesses()); // valid_accesses
return kPresentSrcScope;
Expand Down

0 comments on commit 396cf65

Please sign in to comment.