2022-02-25 10:28:39 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2022 Imagination Technologies Ltd.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
2022-10-05 16:49:08 +05:00
|
|
|
*
|
2022-11-16 14:17:08 +00:00
|
|
|
* 'pvr_write_query_to_buffer()' and 'pvr_wait_for_available()' based on anv:
|
2022-10-05 16:49:08 +05:00
|
|
|
* Copyright © 2015 Intel Corporation
|
2022-02-25 10:28:39 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-02-23 11:48:05 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2023-09-04 12:24:05 +01:00
|
|
|
#include <string.h>
|
2022-02-23 11:48:05 +00:00
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
|
|
|
|
|
#include "pvr_bo.h"
|
|
|
|
|
#include "pvr_csb.h"
|
|
|
|
|
#include "pvr_device_info.h"
|
2022-02-25 10:28:39 +00:00
|
|
|
#include "pvr_private.h"
|
2022-02-23 11:48:05 +00:00
|
|
|
#include "util/macros.h"
|
2022-11-16 14:17:08 +00:00
|
|
|
#include "util/os_time.h"
|
2022-02-23 11:48:05 +00:00
|
|
|
#include "vk_log.h"
|
|
|
|
|
#include "vk_object.h"
|
2022-02-25 10:28:39 +00:00
|
|
|
|
|
|
|
|
VkResult pvr_CreateQueryPool(VkDevice _device,
|
|
|
|
|
const VkQueryPoolCreateInfo *pCreateInfo,
|
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
|
VkQueryPool *pQueryPool)
|
|
|
|
|
{
|
2022-02-23 11:48:05 +00:00
|
|
|
PVR_FROM_HANDLE(pvr_device, device, _device);
|
|
|
|
|
const uint32_t core_count = device->pdevice->dev_runtime_info.core_count;
|
|
|
|
|
const uint32_t query_size = pCreateInfo->queryCount * sizeof(uint32_t);
|
|
|
|
|
struct pvr_query_pool *pool;
|
|
|
|
|
uint64_t alloc_size;
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
/* Vulkan 1.0 supports only occlusion, timestamp, and pipeline statistics
|
|
|
|
|
* query.
|
|
|
|
|
* We don't currently support timestamp queries.
|
|
|
|
|
* VkQueueFamilyProperties->timestampValidBits = 0.
|
|
|
|
|
* We don't currently support pipeline statistics queries.
|
|
|
|
|
* VkPhysicalDeviceFeatures->pipelineStatisticsQuery = false.
|
|
|
|
|
*/
|
2023-03-22 16:38:43 +00:00
|
|
|
assert(!device->vk.enabled_features.pipelineStatisticsQuery);
|
2022-02-23 11:48:05 +00:00
|
|
|
assert(pCreateInfo->queryType == VK_QUERY_TYPE_OCCLUSION);
|
|
|
|
|
|
|
|
|
|
pool = vk_object_alloc(&device->vk,
|
|
|
|
|
pAllocator,
|
|
|
|
|
sizeof(*pool),
|
|
|
|
|
VK_OBJECT_TYPE_QUERY_POOL);
|
|
|
|
|
if (!pool)
|
|
|
|
|
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
|
|
|
|
|
|
pool->result_stride =
|
|
|
|
|
ALIGN_POT(query_size, PVRX(CR_ISP_OCLQRY_BASE_ADDR_ALIGNMENT));
|
|
|
|
|
|
2022-10-06 17:13:27 +05:00
|
|
|
pool->query_count = pCreateInfo->queryCount;
|
|
|
|
|
|
2022-02-23 11:48:05 +00:00
|
|
|
/* Each Phantom writes to a separate offset within the vis test heap so
|
|
|
|
|
* allocate space for the total number of Phantoms.
|
|
|
|
|
*/
|
2022-09-25 20:11:53 +01:00
|
|
|
alloc_size = (uint64_t)pool->result_stride * core_count;
|
2022-02-23 11:48:05 +00:00
|
|
|
|
2023-05-15 17:26:55 +01:00
|
|
|
result = pvr_bo_suballoc(&device->suballoc_vis_test,
|
|
|
|
|
alloc_size,
|
|
|
|
|
PVRX(CR_ISP_OCLQRY_BASE_ADDR_ALIGNMENT),
|
|
|
|
|
false,
|
|
|
|
|
&pool->result_buffer);
|
2022-02-23 11:48:05 +00:00
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
goto err_free_pool;
|
|
|
|
|
|
2023-05-15 17:26:55 +01:00
|
|
|
result = pvr_bo_suballoc(&device->suballoc_general,
|
|
|
|
|
query_size,
|
|
|
|
|
sizeof(uint32_t),
|
|
|
|
|
false,
|
|
|
|
|
&pool->availability_buffer);
|
2022-02-23 11:48:05 +00:00
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
goto err_free_result_buffer;
|
|
|
|
|
|
|
|
|
|
*pQueryPool = pvr_query_pool_to_handle(pool);
|
|
|
|
|
|
2022-02-25 10:28:39 +00:00
|
|
|
return VK_SUCCESS;
|
2022-02-23 11:48:05 +00:00
|
|
|
|
|
|
|
|
err_free_result_buffer:
|
2023-05-15 17:26:55 +01:00
|
|
|
pvr_bo_suballoc_free(pool->result_buffer);
|
2022-02-23 11:48:05 +00:00
|
|
|
|
|
|
|
|
err_free_pool:
|
|
|
|
|
vk_object_free(&device->vk, pAllocator, pool);
|
|
|
|
|
|
|
|
|
|
return result;
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pvr_DestroyQueryPool(VkDevice _device,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
|
|
|
|
{
|
2022-02-23 11:48:05 +00:00
|
|
|
PVR_FROM_HANDLE(pvr_query_pool, pool, queryPool);
|
|
|
|
|
PVR_FROM_HANDLE(pvr_device, device, _device);
|
|
|
|
|
|
2023-05-04 16:37:28 +01:00
|
|
|
if (!pool)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-05-15 17:26:55 +01:00
|
|
|
pvr_bo_suballoc_free(pool->availability_buffer);
|
|
|
|
|
pvr_bo_suballoc_free(pool->result_buffer);
|
2022-02-23 11:48:05 +00:00
|
|
|
|
|
|
|
|
vk_object_free(&device->vk, pAllocator, pool);
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-16 14:17:08 +00:00
|
|
|
/* Note: make sure to make the availability buffer's memory defined in
|
|
|
|
|
* accordance to how the device is expected to fill it. We don't make it defined
|
|
|
|
|
* here since that would cover up usage of this function while the underlying
|
|
|
|
|
* buffer region being accessed wasn't expect to have been written by the
|
|
|
|
|
* device.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool pvr_query_is_available(const struct pvr_query_pool *pool,
|
|
|
|
|
uint32_t query_idx)
|
|
|
|
|
{
|
2023-05-15 17:26:55 +01:00
|
|
|
volatile uint32_t *available =
|
|
|
|
|
pvr_bo_suballoc_get_map_addr(pool->availability_buffer);
|
2022-11-16 14:17:08 +00:00
|
|
|
return !!available[query_idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define NSEC_PER_SEC UINT64_C(1000000000)
|
|
|
|
|
#define PVR_WAIT_TIMEOUT UINT64_C(5)
|
|
|
|
|
|
|
|
|
|
/* Note: make sure to make the availability buffer's memory defined in
|
|
|
|
|
* accordance to how the device is expected to fill it. We don't make it defined
|
|
|
|
|
* here since that would cover up usage of this function while the underlying
|
|
|
|
|
* buffer region being accessed wasn't expect to have been written by the
|
|
|
|
|
* device.
|
|
|
|
|
*/
|
|
|
|
|
/* TODO: Handle device loss scenario properly. */
|
2023-05-15 09:07:16 +01:00
|
|
|
static VkResult pvr_wait_for_available(struct pvr_device *device,
|
|
|
|
|
const struct pvr_query_pool *pool,
|
|
|
|
|
uint32_t query_idx)
|
2022-11-16 14:17:08 +00:00
|
|
|
{
|
|
|
|
|
const uint64_t abs_timeout =
|
|
|
|
|
os_time_get_absolute_timeout(PVR_WAIT_TIMEOUT * NSEC_PER_SEC);
|
|
|
|
|
|
|
|
|
|
/* From the Vulkan 1.0 spec:
|
|
|
|
|
*
|
|
|
|
|
* Commands that wait indefinitely for device execution (namely
|
|
|
|
|
* vkDeviceWaitIdle, vkQueueWaitIdle, vkWaitForFences or
|
|
|
|
|
* vkAcquireNextImageKHR with a maximum timeout, and
|
|
|
|
|
* vkGetQueryPoolResults with the VK_QUERY_RESULT_WAIT_BIT bit set in
|
|
|
|
|
* flags) must return in finite time even in the case of a lost device,
|
|
|
|
|
* and return either VK_SUCCESS or VK_ERROR_DEVICE_LOST.
|
|
|
|
|
*/
|
|
|
|
|
while (os_time_get_nano() < abs_timeout) {
|
|
|
|
|
if (pvr_query_is_available(pool, query_idx) != 0)
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef NSEC_PER_SEC
|
|
|
|
|
#undef PVR_WAIT_TIMEOUT
|
|
|
|
|
|
2022-10-05 16:49:08 +05:00
|
|
|
static inline void pvr_write_query_to_buffer(uint8_t *buffer,
|
|
|
|
|
VkQueryResultFlags flags,
|
|
|
|
|
uint32_t idx,
|
|
|
|
|
uint64_t value)
|
|
|
|
|
{
|
|
|
|
|
if (flags & VK_QUERY_RESULT_64_BIT) {
|
|
|
|
|
uint64_t *query_data = (uint64_t *)buffer;
|
|
|
|
|
query_data[idx] = value;
|
|
|
|
|
} else {
|
|
|
|
|
uint32_t *query_data = (uint32_t *)buffer;
|
|
|
|
|
query_data[idx] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 10:28:39 +00:00
|
|
|
VkResult pvr_GetQueryPoolResults(VkDevice _device,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t firstQuery,
|
|
|
|
|
uint32_t queryCount,
|
|
|
|
|
size_t dataSize,
|
|
|
|
|
void *pData,
|
|
|
|
|
VkDeviceSize stride,
|
|
|
|
|
VkQueryResultFlags flags)
|
|
|
|
|
{
|
2022-10-05 16:49:08 +05:00
|
|
|
PVR_FROM_HANDLE(pvr_query_pool, pool, queryPool);
|
|
|
|
|
PVR_FROM_HANDLE(pvr_device, device, _device);
|
2023-05-15 17:26:55 +01:00
|
|
|
VG(volatile uint32_t *available =
|
|
|
|
|
pvr_bo_suballoc_get_map_addr(pool->availability_buffer));
|
|
|
|
|
volatile uint32_t *query_results =
|
|
|
|
|
pvr_bo_suballoc_get_map_addr(pool->result_buffer);
|
2022-10-05 16:49:08 +05:00
|
|
|
const uint32_t core_count = device->pdevice->dev_runtime_info.core_count;
|
|
|
|
|
uint8_t *data = (uint8_t *)pData;
|
|
|
|
|
VkResult result = VK_SUCCESS;
|
|
|
|
|
|
2022-11-16 14:17:08 +00:00
|
|
|
/* TODO: Instead of making the memory defined here for valgrind, to better
|
|
|
|
|
* catch out of bounds access and other memory errors we should move them
|
|
|
|
|
* where where the query buffers are changed by the driver or device (e.g.
|
|
|
|
|
* "vkCmdResetQueryPool()", "vkGetQueryPoolResults()", etc.).
|
|
|
|
|
*/
|
|
|
|
|
|
2022-10-05 16:49:08 +05:00
|
|
|
VG(VALGRIND_MAKE_MEM_DEFINED(&available[firstQuery],
|
|
|
|
|
queryCount * sizeof(uint32_t)));
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < core_count; i++) {
|
|
|
|
|
VG(VALGRIND_MAKE_MEM_DEFINED(
|
|
|
|
|
&query_results[firstQuery + i * pool->result_stride],
|
|
|
|
|
queryCount * sizeof(uint32_t)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < queryCount; i++) {
|
2022-11-16 14:17:08 +00:00
|
|
|
bool is_available = pvr_query_is_available(pool, firstQuery + i);
|
2022-10-05 16:49:08 +05:00
|
|
|
uint64_t count = 0;
|
|
|
|
|
|
2022-11-16 14:17:08 +00:00
|
|
|
if (flags & VK_QUERY_RESULT_WAIT_BIT && !is_available) {
|
|
|
|
|
result = pvr_wait_for_available(device, pool, firstQuery + i);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
is_available = true;
|
2022-10-05 16:49:08 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < core_count; j++)
|
|
|
|
|
count += query_results[pool->result_stride * j + firstQuery + i];
|
|
|
|
|
|
|
|
|
|
if (is_available || (flags & VK_QUERY_RESULT_PARTIAL_BIT))
|
2023-09-04 12:24:05 +01:00
|
|
|
pvr_write_query_to_buffer(data, flags, 0, count);
|
2022-10-05 16:49:08 +05:00
|
|
|
else
|
|
|
|
|
result = VK_NOT_READY;
|
|
|
|
|
|
|
|
|
|
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)
|
2023-09-04 12:24:05 +01:00
|
|
|
pvr_write_query_to_buffer(data, flags, 1, is_available);
|
2022-10-05 16:49:08 +05:00
|
|
|
|
|
|
|
|
data += stride;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VG(VALGRIND_MAKE_MEM_UNDEFINED(&available[firstQuery],
|
|
|
|
|
queryCount * sizeof(uint32_t)));
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < core_count; i++) {
|
|
|
|
|
VG(VALGRIND_MAKE_MEM_UNDEFINED(
|
|
|
|
|
&query_results[firstQuery + i * pool->result_stride],
|
|
|
|
|
queryCount * sizeof(uint32_t)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pvr_CmdResetQueryPool(VkCommandBuffer commandBuffer,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t firstQuery,
|
|
|
|
|
uint32_t queryCount)
|
|
|
|
|
{
|
2022-10-06 01:57:52 +05:00
|
|
|
PVR_FROM_HANDLE(pvr_cmd_buffer, cmd_buffer, commandBuffer);
|
|
|
|
|
struct pvr_query_info query_info;
|
|
|
|
|
|
|
|
|
|
PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer);
|
|
|
|
|
|
|
|
|
|
query_info.type = PVR_QUERY_TYPE_RESET_QUERY_POOL;
|
|
|
|
|
|
|
|
|
|
query_info.reset_query_pool.query_pool = queryPool;
|
|
|
|
|
query_info.reset_query_pool.first_query = firstQuery;
|
|
|
|
|
query_info.reset_query_pool.query_count = queryCount;
|
|
|
|
|
|
|
|
|
|
pvr_add_query_program(cmd_buffer, &query_info);
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
2023-09-04 12:24:05 +01:00
|
|
|
void pvr_ResetQueryPool(VkDevice _device,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t firstQuery,
|
|
|
|
|
uint32_t queryCount)
|
|
|
|
|
{
|
|
|
|
|
PVR_FROM_HANDLE(pvr_query_pool, pool, queryPool);
|
|
|
|
|
uint32_t *availability =
|
|
|
|
|
pvr_bo_suballoc_get_map_addr(pool->availability_buffer);
|
|
|
|
|
|
|
|
|
|
memset(availability + firstQuery, 0, sizeof(uint32_t) * queryCount);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 10:28:39 +00:00
|
|
|
void pvr_CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t firstQuery,
|
|
|
|
|
uint32_t queryCount,
|
|
|
|
|
VkBuffer dstBuffer,
|
|
|
|
|
VkDeviceSize dstOffset,
|
|
|
|
|
VkDeviceSize stride,
|
|
|
|
|
VkQueryResultFlags flags)
|
|
|
|
|
{
|
2022-10-06 01:58:16 +05:00
|
|
|
PVR_FROM_HANDLE(pvr_cmd_buffer, cmd_buffer, commandBuffer);
|
|
|
|
|
struct pvr_query_info query_info;
|
2022-10-07 12:40:11 +05:00
|
|
|
VkResult result;
|
2022-10-06 01:58:16 +05:00
|
|
|
|
|
|
|
|
PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer);
|
|
|
|
|
|
|
|
|
|
query_info.type = PVR_QUERY_TYPE_COPY_QUERY_RESULTS;
|
|
|
|
|
|
|
|
|
|
query_info.copy_query_results.query_pool = queryPool;
|
|
|
|
|
query_info.copy_query_results.first_query = firstQuery;
|
|
|
|
|
query_info.copy_query_results.query_count = queryCount;
|
|
|
|
|
query_info.copy_query_results.dst_buffer = dstBuffer;
|
|
|
|
|
query_info.copy_query_results.dst_offset = dstOffset;
|
|
|
|
|
query_info.copy_query_results.stride = stride;
|
|
|
|
|
query_info.copy_query_results.flags = flags;
|
|
|
|
|
|
2022-10-07 12:40:11 +05:00
|
|
|
result = pvr_cmd_buffer_start_sub_cmd(cmd_buffer, PVR_SUB_CMD_TYPE_EVENT);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* The Vulkan 1.3.231 spec says:
|
|
|
|
|
*
|
|
|
|
|
* "vkCmdCopyQueryPoolResults is considered to be a transfer operation,
|
|
|
|
|
* and its writes to buffer memory must be synchronized using
|
|
|
|
|
* VK_PIPELINE_STAGE_TRANSFER_BIT and VK_ACCESS_TRANSFER_WRITE_BIT before
|
|
|
|
|
* using the results."
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
/* We record barrier event sub commands to sync the compute job used for the
|
|
|
|
|
* copy query results program with transfer jobs to prevent an overlapping
|
|
|
|
|
* transfer job with the compute job.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-20 10:31:12 +00:00
|
|
|
cmd_buffer->state.current_sub_cmd->event = (struct pvr_sub_cmd_event){
|
2022-10-07 12:40:11 +05:00
|
|
|
.type = PVR_EVENT_TYPE_BARRIER,
|
|
|
|
|
.barrier = {
|
|
|
|
|
.wait_for_stage_mask = PVR_PIPELINE_STAGE_TRANSFER_BIT,
|
|
|
|
|
.wait_at_stage_mask = PVR_PIPELINE_STAGE_OCCLUSION_QUERY_BIT,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result = pvr_cmd_buffer_end_sub_cmd(cmd_buffer);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-10-06 01:58:16 +05:00
|
|
|
pvr_add_query_program(cmd_buffer, &query_info);
|
2022-10-07 12:40:11 +05:00
|
|
|
|
|
|
|
|
result = pvr_cmd_buffer_start_sub_cmd(cmd_buffer, PVR_SUB_CMD_TYPE_EVENT);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-01-20 10:31:12 +00:00
|
|
|
cmd_buffer->state.current_sub_cmd->event = (struct pvr_sub_cmd_event){
|
2022-10-07 12:40:11 +05:00
|
|
|
.type = PVR_EVENT_TYPE_BARRIER,
|
|
|
|
|
.barrier = {
|
|
|
|
|
.wait_for_stage_mask = PVR_PIPELINE_STAGE_OCCLUSION_QUERY_BIT,
|
|
|
|
|
.wait_at_stage_mask = PVR_PIPELINE_STAGE_TRANSFER_BIT,
|
|
|
|
|
},
|
|
|
|
|
};
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pvr_CmdBeginQuery(VkCommandBuffer commandBuffer,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t query,
|
|
|
|
|
VkQueryControlFlags flags)
|
|
|
|
|
{
|
2022-10-05 17:18:33 +05:00
|
|
|
PVR_FROM_HANDLE(pvr_cmd_buffer, cmd_buffer, commandBuffer);
|
|
|
|
|
struct pvr_cmd_buffer_state *state = &cmd_buffer->state;
|
|
|
|
|
PVR_FROM_HANDLE(pvr_query_pool, pool, queryPool);
|
|
|
|
|
|
|
|
|
|
PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer);
|
|
|
|
|
|
|
|
|
|
/* Occlusion queries can't be nested. */
|
|
|
|
|
assert(!state->vis_test_enabled);
|
|
|
|
|
|
|
|
|
|
if (state->current_sub_cmd) {
|
|
|
|
|
assert(state->current_sub_cmd->type == PVR_SUB_CMD_TYPE_GRAPHICS);
|
|
|
|
|
|
|
|
|
|
if (!state->current_sub_cmd->gfx.query_pool) {
|
|
|
|
|
state->current_sub_cmd->gfx.query_pool = pool;
|
|
|
|
|
} else if (state->current_sub_cmd->gfx.query_pool != pool) {
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
/* Kick render. */
|
|
|
|
|
state->current_sub_cmd->gfx.barrier_store = true;
|
|
|
|
|
|
|
|
|
|
result = pvr_cmd_buffer_end_sub_cmd(cmd_buffer);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
result =
|
|
|
|
|
pvr_cmd_buffer_start_sub_cmd(cmd_buffer, PVR_SUB_CMD_TYPE_GRAPHICS);
|
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Use existing render setup, but load color attachments from HW
|
|
|
|
|
* BGOBJ.
|
|
|
|
|
*/
|
|
|
|
|
state->current_sub_cmd->gfx.barrier_load = true;
|
|
|
|
|
state->current_sub_cmd->gfx.barrier_store = false;
|
|
|
|
|
state->current_sub_cmd->gfx.query_pool = pool;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state->query_pool = pool;
|
|
|
|
|
state->vis_test_enabled = true;
|
|
|
|
|
state->vis_reg = query;
|
|
|
|
|
state->dirty.vis_test = true;
|
|
|
|
|
|
|
|
|
|
/* Add the index to the list for this render. */
|
|
|
|
|
util_dynarray_append(&state->query_indices, __typeof__(query), query);
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pvr_CmdEndQuery(VkCommandBuffer commandBuffer,
|
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
|
uint32_t query)
|
|
|
|
|
{
|
2022-10-05 17:19:18 +05:00
|
|
|
PVR_FROM_HANDLE(pvr_cmd_buffer, cmd_buffer, commandBuffer);
|
|
|
|
|
struct pvr_cmd_buffer_state *state = &cmd_buffer->state;
|
|
|
|
|
|
|
|
|
|
PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer);
|
|
|
|
|
|
|
|
|
|
state->vis_test_enabled = false;
|
|
|
|
|
state->dirty.vis_test = true;
|
2022-02-25 10:28:39 +00:00
|
|
|
}
|