Skip to content

Commit

Permalink
layers: Rename vvl::Queue members
Browse files Browse the repository at this point in the history
According to conventions.
  • Loading branch information
artem-lunarg committed Jul 6, 2024
1 parent 159a00a commit 6e54314
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion layers/best_practices/bp_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void BestPractices::ValidateImageInQueueArmImg(Func command, const bp_state::Ima

void BestPractices::ValidateImageInQueue(const vvl::Queue& qs, const vvl::CommandBuffer& cbs, Func command, bp_state::Image& state,
IMAGE_SUBRESOURCE_USAGE_BP usage, uint32_t array_layer, uint32_t mip_level) {
auto queue_family = qs.queueFamilyIndex;
auto queue_family = qs.queue_family_index;
auto last_usage = state.UpdateUsage(array_layer, mip_level, usage, queue_family);

// Concurrent sharing usage of image with exclusive sharing mode
Expand Down
3 changes: 2 additions & 1 deletion layers/best_practices/bp_instance_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ bool BestPractices::PreCallValidateQueueBindSparse(VkQueue queue, uint32_t bindI

if (VendorCheckEnabled(kBPVendorNVIDIA)) {
auto queue_state = Get<vvl::Queue>(queue);
if (queue_state && queue_state->queueFamilyProperties.queueFlags != (VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT)) {
if (queue_state &&
queue_state->queue_family_properties.queueFlags != (VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT)) {
skip |= LogPerformanceWarning("BestPractices-NVIDIA-QueueBindSparse-NotAsync", queue, error_obj.location,
"issued on queue %s. All binds should happen on an asynchronous copy "
"queue to hide the OS scheduling and submit costs.",
Expand Down
2 changes: 1 addition & 1 deletion layers/best_practices/bp_synchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ void BestPractices::RecordCmdPipelineBarrierImageBarrier(VkCommandBuffer command
const vvl::CommandBuffer& cbs) -> bool {
ForEachSubresource(*image, subresource_range, [&](uint32_t layer, uint32_t level) {
// Update queue family index without changing usage, signifying a correct queue family transfer
image->UpdateUsage(layer, level, image->GetUsageType(layer, level), qs.queueFamilyIndex);
image->UpdateUsage(layer, level, image->GetUsageType(layer, level), qs.queue_family_index);
});
return false;
});
Expand Down
20 changes: 10 additions & 10 deletions layers/core_checks/cc_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool CoreChecks::PreCallValidateQueueSubmit(VkQueue queue, uint32_t submitCount,

auto queue_state = Get<vvl::Queue>(queue);
CommandBufferSubmitState cb_submit_state(*this, queue_state.get());
SemaphoreSubmitState sem_submit_state(*this, queue, queue_state->queueFamilyProperties.queueFlags);
SemaphoreSubmitState sem_submit_state(*this, queue, queue_state->queue_family_properties.queueFlags);

// Now verify each individual submit
for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) {
Expand Down Expand Up @@ -224,7 +224,7 @@ bool CoreChecks::PreCallValidateQueueSubmit(VkQueue queue, uint32_t submitCount,
auto protected_submit_info = vku::FindStructInPNextChain<VkProtectedSubmitInfo>(submit.pNext);
if (protected_submit_info) {
protected_submit = protected_submit_info->protectedSubmit == VK_TRUE;
if ((protected_submit == true) && ((queue_state->flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) == 0)) {
if ((protected_submit == true) && ((queue_state->create_flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) == 0)) {
skip |= LogError("VUID-vkQueueSubmit-queue-06448", queue, submit_loc,
"contains a protected submission to %s which was not created with "
"VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT",
Expand Down Expand Up @@ -316,7 +316,7 @@ bool CoreChecks::ValidateQueueSubmit2(VkQueue queue, uint32_t submitCount, const

auto queue_state = Get<vvl::Queue>(queue);
CommandBufferSubmitState cb_submit_state(*this, queue_state.get());
SemaphoreSubmitState sem_submit_state(*this, queue, queue_state->queueFamilyProperties.queueFlags);
SemaphoreSubmitState sem_submit_state(*this, queue, queue_state->queue_family_properties.queueFlags);

// Now verify each individual submit
for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) {
Expand All @@ -328,7 +328,7 @@ bool CoreChecks::ValidateQueueSubmit2(VkQueue queue, uint32_t submitCount, const
skip |= ValidateSemaphoresForSubmit(sem_submit_state, submit, submit_loc);

const bool protected_submit = (submit.flags & VK_SUBMIT_PROTECTED_BIT_KHR) != 0;
if ((protected_submit == true) && ((queue_state->flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT)) == 0) {
if ((protected_submit == true) && ((queue_state->create_flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT)) == 0) {
skip |= LogError("VUID-vkQueueSubmit2-queue-06447", queue, submit_loc,
"contains a protected submission to %s which was not created with "
"VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT",
Expand Down Expand Up @@ -488,14 +488,14 @@ bool CoreChecks::ValidateQueueFamilyIndices(const Location &loc, const vvl::Comm
auto pool = cb_state.command_pool;
ASSERT_AND_RETURN_SKIP(pool);

if (pool->queueFamilyIndex != queue_state.queueFamilyIndex) {
if (pool->queueFamilyIndex != queue_state.queue_family_index) {
const LogObjectList objlist(cb_state.Handle(), queue_state.Handle());
const auto &vuid = GetQueueSubmitVUID(loc, SubmitError::kCmdWrongQueueFamily);
skip |= LogError(vuid, objlist, loc,
"Primary command buffer %s created in queue family %d is being submitted on %s "
"from queue family %d.",
FormatHandle(cb_state).c_str(), pool->queueFamilyIndex, FormatHandle(queue_state.Handle()).c_str(),
queue_state.queueFamilyIndex);
queue_state.queue_family_index);
}

// Ensure that any bound images or buffers created with SHARING_MODE_CONCURRENT have access to the current queue family
Expand All @@ -504,7 +504,7 @@ bool CoreChecks::ValidateQueueFamilyIndices(const Location &loc, const vvl::Comm
case kVulkanObjectTypeImage: {
auto image_state = static_cast<const vvl::Image *>(state_object.get());
if (image_state && image_state->create_info.sharingMode == VK_SHARING_MODE_CONCURRENT) {
skip |= ValidImageBufferQueue(cb_state, image_state->Handle(), queue_state.queueFamilyIndex,
skip |= ValidImageBufferQueue(cb_state, image_state->Handle(), queue_state.queue_family_index,
image_state->create_info.queueFamilyIndexCount,
image_state->create_info.pQueueFamilyIndices, loc);
}
Expand All @@ -513,7 +513,7 @@ bool CoreChecks::ValidateQueueFamilyIndices(const Location &loc, const vvl::Comm
case kVulkanObjectTypeBuffer: {
auto buffer_state = static_cast<const vvl::Buffer *>(state_object.get());
if (buffer_state && buffer_state->create_info.sharingMode == VK_SHARING_MODE_CONCURRENT) {
skip |= ValidImageBufferQueue(cb_state, buffer_state->Handle(), queue_state.queueFamilyIndex,
skip |= ValidImageBufferQueue(cb_state, buffer_state->Handle(), queue_state.queue_family_index,
buffer_state->create_info.queueFamilyIndexCount,
buffer_state->create_info.pQueueFamilyIndices, loc);
}
Expand Down Expand Up @@ -645,10 +645,10 @@ bool CoreChecks::PreCallValidateQueueBindSparse(VkQueue queue, uint32_t bindInfo
if (skip) return skip;

auto queue_state = Get<vvl::Queue>(queue);
const VkQueueFlags queue_flags = queue_state->queueFamilyProperties.queueFlags;
const VkQueueFlags queue_flags = queue_state->queue_family_properties.queueFlags;
if (!(queue_flags & VK_QUEUE_SPARSE_BINDING_BIT)) {
skip |= LogError("VUID-vkQueueBindSparse-queuetype", queue, error_obj.location,
"queueFamilyIndex %" PRIu32 " queueFlags are %s.", queue_state->queueFamilyIndex,
"queueFamilyIndex %" PRIu32 " queueFlags are %s.", queue_state->queue_family_index,
string_VkQueueFlags(queue_flags).c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion layers/core_checks/cc_synchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ class ValidatorState {
// application input.
static bool ValidateAtQueueSubmit(const vvl::Queue *queue_state, const ValidationStateTracker &device_data, uint32_t src_family,
uint32_t dst_family, const ValidatorState &val) {
uint32_t queue_family = queue_state->queueFamilyIndex;
uint32_t queue_family = queue_state->queue_family_index;
if ((src_family != queue_family) && (dst_family != queue_family)) {
const char *src_annotation = val.GetFamilyAnnotation(src_family);
const char *dst_annotation = val.GetFamilyAnnotation(dst_family);
Expand Down
7 changes: 3 additions & 4 deletions layers/core_checks/cc_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ bool CoreChecks::ValidateCreateSwapchain(const VkSwapchainCreateInfoKHR &create_
if (!IsExtEnabled(instance_extensions.vk_khr_android_surface)) {
// restrict search only to queue families of VkDeviceQueueCreateInfos, not the whole physical device
const bool is_supported = AnyOf<vvl::Queue>([this, surface_state](const vvl::Queue &queue_state) {
return surface_state->GetQueueSupport(physical_device, queue_state.queueFamilyIndex);
return surface_state->GetQueueSupport(physical_device, queue_state.queue_family_index);
});

if (!is_supported) {
Expand Down Expand Up @@ -794,8 +794,7 @@ bool CoreChecks::PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentIn
bool skip = false;
auto queue_state = Get<vvl::Queue>(queue);

SemaphoreSubmitState sem_submit_state(*this, queue,
physical_device_state->queue_family_properties[queue_state->queueFamilyIndex].queueFlags);
SemaphoreSubmitState sem_submit_state(*this, queue, queue_state->queue_family_properties.queueFlags);

const Location present_info_loc = error_obj.location.dot(Struct::VkPresentInfoKHR, Field::pPresentInfo);
for (uint32_t i = 0; i < pPresentInfo->waitSemaphoreCount; ++i) {
Expand Down Expand Up @@ -866,7 +865,7 @@ bool CoreChecks::PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentIn
// All physical devices and queue families are required to be able to present to any native window on Android
if (!IsExtEnabled(instance_extensions.vk_khr_android_surface)) {
auto surface_state = Get<vvl::Surface>(swapchain_data->create_info.surface);
if (surface_state && !surface_state->GetQueueSupport(physical_device, queue_state->queueFamilyIndex)) {
if (surface_state && !surface_state->GetQueueSupport(physical_device, queue_state->queue_family_index)) {
skip |= LogError("VUID-vkQueuePresentKHR-pSwapchains-01292", pPresentInfo->pSwapchains[i], swapchain_loc,
"image on queue that cannot present to this surface.");
}
Expand Down
2 changes: 1 addition & 1 deletion layers/gpu/core/gpu_state_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void Queue::SubmitBarrier(const Location &loc, uint64_t seq) {
VkResult result = VK_SUCCESS;

VkCommandPoolCreateInfo pool_create_info = vku::InitStructHelper();
pool_create_info.queueFamilyIndex = queueFamilyIndex;
pool_create_info.queueFamilyIndex = queue_family_index;
result = DispatchCreateCommandPool(shader_instrumentor_.device, &pool_create_info, nullptr, &barrier_command_pool_);
if (result != VK_SUCCESS) {
shader_instrumentor_.InternalError(vvl::Queue::VkHandle(), loc, "Unable to create command pool for barrier CB.");
Expand Down
18 changes: 10 additions & 8 deletions layers/state_tracker/queue_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ struct PreSubmitResult {
uint64_t submission_with_external_fence_seq = 0;
};

class Queue: public StateObject {
class Queue : public StateObject {
public:
Queue(ValidationStateTracker &dev_data, VkQueue handle, uint32_t family_index, uint32_t queue_index,
VkDeviceQueueCreateFlags flags, const VkQueueFamilyProperties &queueFamilyProperties)
: StateObject(handle, kVulkanObjectTypeQueue),
queueFamilyIndex(family_index),
queue_family_index(family_index),
queue_index(queue_index),
flags(flags),
queueFamilyProperties(queueFamilyProperties),
create_flags(flags),
queue_family_properties(queueFamilyProperties),
dev_data_(dev_data) {}

~Queue() { Destroy(); }
Expand All @@ -115,14 +115,15 @@ class Queue: public StateObject {
// Helper that combines Notify and Wait
void NotifyAndWait(const Location &loc, uint64_t until_seq = kU64Max);

public:
// Queue family index. As queueFamilyIndex parameter in vkGetDeviceQueue.
const uint32_t queueFamilyIndex;
const uint32_t queue_family_index;

// Index of the queue within a queue family. As queueIndex parameter in vkGetDeviceQueue.
const uint32_t queue_index;

const VkDeviceQueueCreateFlags flags;
const VkQueueFamilyProperties queueFamilyProperties;
const VkDeviceQueueCreateFlags create_flags;
const VkQueueFamilyProperties queue_family_properties;

// Track command buffer label stack accross all command buffers submitted to this queue.
// Access to this variable relies on external queue synchronization.
Expand All @@ -135,6 +136,7 @@ class Queue: public StateObject {
// Stop per-queue label tracking after the first label mismatch error.
// Access to this variable relies on external queue synchronization.
bool found_unbalanced_cmdbuf_label = false;

protected:
// called from the various PostCallRecordQueueSubmit() methods
virtual void PostSubmit(QueueSubmission &submission) {}
Expand All @@ -160,4 +162,4 @@ class Queue: public StateObject {
// condition to wake up the queue's thread
std::condition_variable cond_;
};
} // namespace vvl
} // namespace vvl
2 changes: 1 addition & 1 deletion layers/sync/sync_submit.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class QueueSyncState {
QueueBatchContext::Ptr LastBatch() { return last_batch_; }
void UpdateLastBatch();
const vvl::Queue *GetQueueState() const { return queue_state_.get(); }
VkQueueFlags GetQueueFlags() const { return queue_state_->queueFamilyProperties.queueFlags; }
VkQueueFlags GetQueueFlags() const { return queue_state_->queue_family_properties.queueFlags; }
QueueId GetQueueId() const { return id_; }

// Method is const but updates mutable sumbit_index atomically.
Expand Down
4 changes: 2 additions & 2 deletions layers/sync/sync_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ void SyncValidator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, cons
std::vector<std::shared_ptr<vvl::Queue>> queues;
ForEachShared<vvl::Queue>([&queues](const std::shared_ptr<vvl::Queue> &queue) { queues.emplace_back(queue); });
std::sort(queues.begin(), queues.end(), [](const auto &q1, const auto &q2) {
return (q1->queueFamilyIndex < q2->queueFamilyIndex) ||
(q1->queueFamilyIndex == q2->queueFamilyIndex && q1->queue_index < q2->queue_index);
return (q1->queue_family_index < q2->queue_family_index) ||
(q1->queue_family_index == q2->queue_family_index && q1->queue_index < q2->queue_index);
});
return queues;
};
Expand Down

0 comments on commit 6e54314

Please sign in to comment.