Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Fix state rebuilder to handle status change in query pools #2442

Merged
merged 1 commit into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions gapii/cc/vulkan_inlines.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
inline void VulkanSpy::notifyPendingCommandAdded(CallObserver*, VkQueue) {}

inline void VulkanSpy::vkErrInvalidHandle(CallObserver*, std::string handleType, uint64_t handle){
GAPID_WARNING("Error: Invalid %s: %" PRIu64, handleType.c_str(), handle)
GAPID_DEBUG("Error: Invalid %s: %" PRIu64, handleType.c_str(), handle)
}

inline void VulkanSpy::vkErrNullPointer(CallObserver*, std::string pointerType) {
Expand All @@ -36,46 +36,46 @@ inline void VulkanSpy::vkErrUnrecognizedExtension(CallObserver*, std::string nam
}

inline void VulkanSpy::vkErrExpectNVDedicatedlyAllocatedHandle(CallObserver*, std::string handleType, uint64_t handle) {
GAPID_WARNING("Error: Expected handle that was allocated with a dedicated allocation: %s: %" PRIu64, handleType.c_str(), handle)
GAPID_DEBUG("Error: Expected handle that was allocated with a dedicated allocation: %s: %" PRIu64, handleType.c_str(), handle)
}

inline void VulkanSpy::vkErrInvalidDescriptorArrayElement(CallObserver*, uint64_t set, uint32_t binding, uint32_t array_index) {
GAPID_WARNING("Error: Invalid descriptor array element specified by descriptor set: %" PRIu64 ", binding: %" PRIu32 ", array index: %" PRIu32, set, binding, array_index);
GAPID_DEBUG("Error: Invalid descriptor array element specified by descriptor set: %" PRIu64 ", binding: %" PRIu32 ", array index: %" PRIu32, set, binding, array_index);
}

inline void VulkanSpy::vkErrCommandBufferIncomplete(CallObserver*, VkCommandBuffer cmdbuf) {
GAPID_WARNING("Error: Executing command buffer %zu was not in the COMPLETED state", cmdbuf)
GAPID_DEBUG("Error: Executing command buffer %zu was not in the COMPLETED state", cmdbuf)
}

inline void VulkanSpy::vkErrCommandBufferNotRecording(CallObserver*, VkCommandBuffer cmdbuf) {
GAPID_WARNING("Error: Executing command buffer %zu was not in the RECORDING state", cmdbuf)
GAPID_DEBUG("Error: Executing command buffer %zu was not in the RECORDING state", cmdbuf)
}

inline void VulkanSpy::vkErrQueryOutOfRange(CallObserver*, VkQueryPool queryPool, uint32_t query) {
GAPID_WARNING("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was out of range", query, queryPool)
GAPID_DEBUG("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was out of range", query, queryPool)
}

inline void VulkanSpy::vkErrQueryUninitialized(CallObserver*, VkQueryPool queryPool, uint32_t query) {
GAPID_WARNING("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was uninitialized", query, queryPool)
GAPID_DEBUG("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was uninitialized", query, queryPool)
}

inline void VulkanSpy::vkErrQueryNotInactive(CallObserver*, VkQueryPool queryPool, uint32_t query) {
GAPID_WARNING("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was not in the INACTIVE state", query, queryPool)
GAPID_DEBUG("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was not in the INACTIVE state", query, queryPool)
}

inline void VulkanSpy::vkErrQueryNotActive(CallObserver*, VkQueryPool queryPool, uint32_t query) {
GAPID_WARNING("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was not in the ACTIVE state", query, queryPool)
GAPID_DEBUG("Error: Query %" PRIu32 " in QueryPool %" PRIu64 " was not in the ACTIVE state", query, queryPool)
}

inline void VulkanSpy::vkErrInvalidImageLayout(CallObserver*, VkImage img, uint32_t aspect, uint32_t layer, uint32_t level, uint32_t layout, uint32_t expectedLayout) {
GAPID_WARNING("Error: Image subresource at Image: %" PRIu64 ", AspectBit: %" PRIu32 ", Layer: %" PRIu32 ", Level: %" PRIu32 " was in layout %" PRIu32 ", but was expected to be in layout %" PRIu32,
GAPID_DEBUG("Error: Image subresource at Image: %" PRIu64 ", AspectBit: %" PRIu32 ", Layer: %" PRIu32 ", Level: %" PRIu32 " was in layout %" PRIu32 ", but was expected to be in layout %" PRIu32,
img, aspect, layer, level, layout, expectedLayout);
}

inline void VulkanSpy::vkErrInvalidImageSubresource(CallObserver*, VkImage img, std::string subresourceType, uint32_t value) {
GAPID_WARNING("Error: Accessing invalid image subresource at Image: %" PRIu64 ", %s: %" PRIu32, img, subresourceType.c_str(), value);
GAPID_DEBUG("Error: Accessing invalid image subresource at Image: %" PRIu64 ", %s: %" PRIu32, img, subresourceType.c_str(), value);
}

inline void VulkanSpy::vkErrInvalidDescriptorBindingType(CallObserver*, VkDescriptorSet set, uint32_t binding, uint32_t layout_type, uint32_t update_type) {
GAPID_WARNING("Error: Updating descriptor binding at: %" PRIu64 ": %" PRIu32 " with type: %" PRIu32 ", but the type defined in descriptor set layout is: %" PRIu32 "", set, binding, layout_type, update_type);
GAPID_DEBUG("Error: Updating descriptor binding at: %" PRIu64 ": %" PRIu32 " with type: %" PRIu32 ", but the type defined in descriptor set layout is: %" PRIu32 "", set, binding, layout_type, update_type);
}
34 changes: 18 additions & 16 deletions gapis/api/vulkan/state_rebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2757,14 +2757,14 @@ func (sb *stateBuilder) createQueryPool(qp QueryPoolObjectʳ) {
VkResult_VK_SUCCESS,
))

anyActive := false
anyInitialized := false
for _, k := range qp.Status().All() {
if k != QueryStatus_QUERY_STATUS_INACTIVE {
anyActive = true
if k != QueryStatus_QUERY_STATUS_UNINITIALIZED {
anyInitialized = true
break
}
}
if !anyActive {
if !anyInitialized {
return
}
queue := sb.getQueueFor(
Expand All @@ -2778,18 +2778,20 @@ func (sb *stateBuilder) createQueryPool(qp QueryPoolObjectʳ) {
defer tsk.commit()
tsk.recordCmdBufCommand(func(commandBuffer VkCommandBuffer) {
for i := uint32(0); i < qp.QueryCount(); i++ {
if qp.Status().Get(i) != QueryStatus_QUERY_STATUS_INACTIVE {
sb.write(sb.cb.VkCmdBeginQuery(
commandBuffer,
qp.VulkanHandle(),
i,
VkQueryControlFlags(0)))
}
if qp.Status().Get(i) == QueryStatus_QUERY_STATUS_COMPLETE {
sb.write(sb.cb.VkCmdEndQuery(
commandBuffer,
qp.VulkanHandle(),
i))
switch qp.Status().Get(i) {
case QueryStatus_QUERY_STATUS_UNINITIALIZED:
// do nothing
case QueryStatus_QUERY_STATUS_INACTIVE:
sb.write(sb.cb.VkCmdResetQueryPool(commandBuffer, qp.VulkanHandle(), i, 1))
case QueryStatus_QUERY_STATUS_ACTIVE:
sb.write(sb.cb.VkCmdBeginQuery(commandBuffer, qp.VulkanHandle(), i, VkQueryControlFlags(0)))
case QueryStatus_QUERY_STATUS_COMPLETE:
if qp.QueryType() == VkQueryType_VK_QUERY_TYPE_TIMESTAMP {
sb.write(sb.cb.VkCmdWriteTimestamp(commandBuffer, VkPipelineStageFlagBits_VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, qp.VulkanHandle(), i))
} else {
sb.write(sb.cb.VkCmdBeginQuery(commandBuffer, qp.VulkanHandle(), i, VkQueryControlFlags(0)))
sb.write(sb.cb.VkCmdEndQuery(commandBuffer, qp.VulkanHandle(), i))
}
}
}
})
Expand Down