mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-24 14:58:10 +02:00
kk: Support new query pool and dynamic rendering flags
New flags allow for reseting query pools on create and configuring new resolve options on render pass resolves. Reviewed-by: Aitor Camacho <aitor@lunarg.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41663>
This commit is contained in:
parent
9027793074
commit
8aae6232ab
4 changed files with 105 additions and 67 deletions
|
|
@ -77,6 +77,7 @@ struct kk_per_draw_data {
|
|||
};
|
||||
|
||||
struct kk_attachment {
|
||||
VkRenderingAttachmentFlagsKHR flags;
|
||||
VkFormat vk_format;
|
||||
struct kk_image_view *iview;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,12 @@ clear_image(struct kk_cmd_buffer *cmd, struct kk_image *image,
|
|||
render.pStencilAttachment = &vk_att;
|
||||
|
||||
kk_CmdBeginRendering(kk_cmd_buffer_to_handle(cmd), &render);
|
||||
kk_CmdEndRendering(kk_cmd_buffer_to_handle(cmd));
|
||||
|
||||
static const VkRenderingEndInfoKHR end_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_END_INFO_KHR,
|
||||
.pNext = NULL,
|
||||
};
|
||||
kk_CmdEndRendering2KHR(kk_cmd_buffer_to_handle(cmd), &end_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "poly/geometry.h"
|
||||
|
||||
#include "vulkan/runtime/vk_render_pass.h"
|
||||
#include "vulkan/util/vk_format.h"
|
||||
|
||||
static void
|
||||
|
|
@ -60,6 +61,7 @@ kk_attachment_init(struct kk_attachment *att,
|
|||
|
||||
VK_FROM_HANDLE(kk_image_view, iview, info->imageView);
|
||||
*att = (struct kk_attachment){
|
||||
.flags = vk_get_rendering_attachment_flags(info),
|
||||
.vk_format = iview->vk.format,
|
||||
.iview = iview,
|
||||
};
|
||||
|
|
@ -443,7 +445,8 @@ kk_CmdBeginRendering(VkCommandBuffer commandBuffer,
|
|||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
kk_CmdEndRendering(VkCommandBuffer commandBuffer)
|
||||
kk_CmdEndRendering2KHR(VkCommandBuffer commandBuffer,
|
||||
UNUSED const VkRenderingEndInfoKHR *pRenderingEndInfo)
|
||||
{
|
||||
VK_FROM_HANDLE(kk_cmd_buffer, cmd, commandBuffer);
|
||||
struct kk_rendering_state *render = &cmd->state.gfx.render;
|
||||
|
|
@ -451,12 +454,19 @@ kk_CmdEndRendering(VkCommandBuffer commandBuffer)
|
|||
|
||||
/* Translate render state back to VK for meta */
|
||||
VkRenderingAttachmentInfo vk_color_att[KK_MAX_RTS];
|
||||
VkRenderingAttachmentFlagsInfoKHR vk_color_att_flags[KK_MAX_RTS];
|
||||
for (uint32_t i = 0; i < render->color_att_count; i++) {
|
||||
if (render->color_att[i].resolve_mode != VK_RESOLVE_MODE_NONE)
|
||||
need_resolve = true;
|
||||
|
||||
vk_color_att_flags[i] = (VkRenderingAttachmentFlagsInfoKHR) {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_FLAGS_INFO_KHR,
|
||||
.flags = render->color_att[i].flags,
|
||||
};
|
||||
|
||||
vk_color_att[i] = (VkRenderingAttachmentInfo){
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||
.pNext = &vk_color_att_flags[i],
|
||||
.imageView = kk_image_view_to_handle(render->color_att[i].iview),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.resolveMode = render->color_att[i].resolve_mode,
|
||||
|
|
@ -466,8 +476,13 @@ kk_CmdEndRendering(VkCommandBuffer commandBuffer)
|
|||
};
|
||||
}
|
||||
|
||||
const VkRenderingAttachmentFlagsInfoKHR vk_depth_att_flags = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_FLAGS_INFO_KHR,
|
||||
.flags = render->depth_att.flags,
|
||||
};
|
||||
const VkRenderingAttachmentInfo vk_depth_att = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||
.pNext = &vk_depth_att_flags,
|
||||
.imageView = kk_image_view_to_handle(render->depth_att.iview),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.resolveMode = render->depth_att.resolve_mode,
|
||||
|
|
@ -478,8 +493,13 @@ kk_CmdEndRendering(VkCommandBuffer commandBuffer)
|
|||
if (render->depth_att.resolve_mode != VK_RESOLVE_MODE_NONE)
|
||||
need_resolve = true;
|
||||
|
||||
const VkRenderingAttachmentFlagsInfoKHR vk_stencil_att_flags = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_FLAGS_INFO_KHR,
|
||||
.flags = render->stencil_att.flags,
|
||||
};
|
||||
const VkRenderingAttachmentInfo vk_stencil_att = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||
.pNext = &vk_stencil_att_flags,
|
||||
.imageView = kk_image_view_to_handle(render->stencil_att.iview),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.resolveMode = render->stencil_att.resolve_mode,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,79 @@ kk_reports_per_query(struct kk_query_pool *pool)
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t *
|
||||
kk_query_available_map(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(kk_has_available(pool));
|
||||
assert(query < pool->vk.query_count);
|
||||
return (uint32_t *)pool->bo->cpu + query;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_offset(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(query < pool->vk.query_count);
|
||||
return pool->query_start + query * pool->query_stride;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_report_addr(struct kk_device *dev, struct kk_query_pool *pool,
|
||||
uint32_t query)
|
||||
{
|
||||
if (pool->oq_queries) {
|
||||
uint16_t *oq_index = kk_pool_oq_index_ptr(pool);
|
||||
return dev->occlusion_queries.bo->gpu +
|
||||
(oq_index[query] * sizeof(uint64_t));
|
||||
} else {
|
||||
return pool->bo->gpu + kk_query_offset(pool, query);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_available_addr(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(kk_has_available(pool));
|
||||
assert(query < pool->vk.query_count);
|
||||
return pool->bo->gpu + query * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
static struct kk_query_report *
|
||||
kk_query_report_map(struct kk_device *dev, struct kk_query_pool *pool,
|
||||
uint32_t query)
|
||||
{
|
||||
if (pool->oq_queries) {
|
||||
uint64_t *queries = (uint64_t *)(dev->occlusion_queries.bo->cpu);
|
||||
uint16_t *oq_index = kk_pool_oq_index_ptr(pool);
|
||||
|
||||
return (struct kk_query_report *)&queries[oq_index[query]];
|
||||
} else {
|
||||
return (void *)((char *)pool->bo->cpu + kk_query_offset(pool, query));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
host_zero_queries(struct kk_device *dev, struct kk_query_pool *pool,
|
||||
uint32_t first_index, uint32_t num_queries,
|
||||
bool set_available)
|
||||
{
|
||||
for (uint32_t i = 0; i < num_queries; i++) {
|
||||
struct kk_query_report *reports =
|
||||
kk_query_report_map(dev, pool, first_index + i);
|
||||
|
||||
uint64_t value = 0;
|
||||
if (kk_has_available(pool)) {
|
||||
uint32_t *available = kk_query_available_map(pool, first_index + i);
|
||||
*available = set_available;
|
||||
} else {
|
||||
value = set_available ? 0 : UINT64_MAX;
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < kk_reports_per_query(pool); ++j) {
|
||||
reports[j].value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
kk_CreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
|
|
@ -116,6 +189,9 @@ kk_CreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
|
|||
oq_index[pool->oq_queries++] = index;
|
||||
}
|
||||
|
||||
if (pCreateInfo->flags & VK_QUERY_POOL_CREATE_RESET_BIT_KHR)
|
||||
host_zero_queries(dev, pool, 0, pool->vk.query_count, false);
|
||||
|
||||
*pQueryPool = kk_query_pool_to_handle(pool);
|
||||
|
||||
return result;
|
||||
|
|
@ -142,78 +218,14 @@ kk_DestroyQueryPool(VkDevice device, VkQueryPool queryPool,
|
|||
vk_query_pool_destroy(&dev->vk, pAllocator, &pool->vk);
|
||||
}
|
||||
|
||||
static uint32_t *
|
||||
kk_query_available_map(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(kk_has_available(pool));
|
||||
assert(query < pool->vk.query_count);
|
||||
return (uint32_t *)pool->bo->cpu + query;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_offset(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(query < pool->vk.query_count);
|
||||
return pool->query_start + query * pool->query_stride;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_report_addr(struct kk_device *dev, struct kk_query_pool *pool,
|
||||
uint32_t query)
|
||||
{
|
||||
if (pool->oq_queries) {
|
||||
uint16_t *oq_index = kk_pool_oq_index_ptr(pool);
|
||||
return dev->occlusion_queries.bo->gpu +
|
||||
(oq_index[query] * sizeof(uint64_t));
|
||||
} else {
|
||||
return pool->bo->gpu + kk_query_offset(pool, query);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
kk_query_available_addr(struct kk_query_pool *pool, uint32_t query)
|
||||
{
|
||||
assert(kk_has_available(pool));
|
||||
assert(query < pool->vk.query_count);
|
||||
return pool->bo->gpu + query * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
static struct kk_query_report *
|
||||
kk_query_report_map(struct kk_device *dev, struct kk_query_pool *pool,
|
||||
uint32_t query)
|
||||
{
|
||||
if (pool->oq_queries) {
|
||||
uint64_t *queries = (uint64_t *)(dev->occlusion_queries.bo->cpu);
|
||||
uint16_t *oq_index = kk_pool_oq_index_ptr(pool);
|
||||
|
||||
return (struct kk_query_report *)&queries[oq_index[query]];
|
||||
} else {
|
||||
return (void *)((char *)pool->bo->cpu + kk_query_offset(pool, query));
|
||||
}
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
kk_ResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
|
||||
uint32_t queryCount)
|
||||
{
|
||||
VK_FROM_HANDLE(kk_device, dev, device);
|
||||
VK_FROM_HANDLE(kk_query_pool, pool, queryPool);
|
||||
for (uint32_t i = 0; i < queryCount; i++) {
|
||||
struct kk_query_report *reports =
|
||||
kk_query_report_map(dev, pool, firstQuery + i);
|
||||
|
||||
uint64_t value = 0;
|
||||
if (kk_has_available(pool)) {
|
||||
uint32_t *available = kk_query_available_map(pool, firstQuery + i);
|
||||
*available = 0u;
|
||||
} else {
|
||||
value = UINT64_MAX;
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < kk_reports_per_query(pool); ++j) {
|
||||
reports[j].value = value;
|
||||
}
|
||||
}
|
||||
host_zero_queries(dev, pool, firstQuery, queryCount, false);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue