Skip to content

Commit

Permalink
gpu: Add check for queue that supports graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyBarbour committed Aug 22, 2023
1 parent 5a05387 commit ff10197
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions layers/gpu_validation/gpu_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void GpuAssisted::CreateDevice(const VkDeviceCreateInfo *pCreateInfo) {
}
}

CreateAccelerationStructureBuildValidationState();
CreateAccelerationStructureBuildValidationState(pCreateInfo);
}

void GpuAssistedPreDrawValidationState::Destroy(VkDevice device) {
Expand Down Expand Up @@ -249,7 +249,7 @@ void GpuAssisted::PreCallRecordDestroyDevice(VkDevice device, const VkAllocation
GpuAssistedBase::PreCallRecordDestroyDevice(device, pAllocator);
}

void GpuAssisted::CreateAccelerationStructureBuildValidationState() {
void GpuAssisted::CreateAccelerationStructureBuildValidationState(const VkDeviceCreateInfo *pCreateInfo) {
if (aborted) {
return;
}
Expand All @@ -263,6 +263,24 @@ void GpuAssisted::CreateAccelerationStructureBuildValidationState() {
return;
}

// Cannot use this validation without a queue that supports graphics
auto pd_state = Get<PHYSICAL_DEVICE_STATE>(physical_device);
bool graphics_queue_exists = false;
uint32_t graphics_queue_family = 0;
for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) {
auto qfi = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
if (pd_state->queue_family_properties[qfi].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
graphics_queue_family = qfi;
graphics_queue_exists = true;
break;
}
}
if (!graphics_queue_exists) {
LogWarning(device, "UNASSIGNED-GPU-Assisted Validation Warning", "No queue that supports graphics, GPU-AV aborted.");
aborted = true;
return;
}

// Outline:
// - Create valid bottom level acceleration structure which acts as replacement
// - Create and load vertex buffer
Expand Down Expand Up @@ -479,7 +497,7 @@ void GpuAssisted::CreateAccelerationStructureBuildValidationState() {

VkQueue queue = VK_NULL_HANDLE;
if (result == VK_SUCCESS) {
DispatchGetDeviceQueue(device, 0, 0, &queue);
DispatchGetDeviceQueue(device, graphics_queue_family, 0, &queue);

// Hook up queue dispatch
vkSetDeviceLoaderData(device, queue);
Expand Down
2 changes: 1 addition & 1 deletion layers/gpu_validation/gpu_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class GpuAssisted : public GpuAssistedBase {
VkResult result) override;
void PreCallRecordCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
VkBuffer* pBuffer, void* cb_state_data) override;
void CreateAccelerationStructureBuildValidationState();
void CreateAccelerationStructureBuildValidationState(const VkDeviceCreateInfo* pCreateInfo);
void PreCallRecordCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo,
VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update,
VkAccelerationStructureNV dst, VkAccelerationStructureNV src,
Expand Down

0 comments on commit ff10197

Please sign in to comment.