mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 20:00:10 +01:00
zink: enable conditional rendering if available
This doesn't seem to work perfect, but I'm not sure what is possible in GL vs Vulkan here Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2867 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4835>
This commit is contained in:
parent
5c7dea394f
commit
5743fa6e70
4 changed files with 78 additions and 2 deletions
|
|
@ -70,7 +70,8 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
|
||||||
if (util_format_get_mask(info->dst.format) != info->mask ||
|
if (util_format_get_mask(info->dst.format) != info->mask ||
|
||||||
util_format_get_mask(info->src.format) != info->mask ||
|
util_format_get_mask(info->src.format) != info->mask ||
|
||||||
info->scissor_enable ||
|
info->scissor_enable ||
|
||||||
info->alpha_blend)
|
info->alpha_blend ||
|
||||||
|
info->render_condition_enable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (util_format_is_depth_or_stencil(info->dst.format) &&
|
if (util_format_is_depth_or_stencil(info->dst.format) &&
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "zink_query.h"
|
#include "zink_query.h"
|
||||||
|
|
||||||
#include "zink_context.h"
|
#include "zink_context.h"
|
||||||
|
#include "zink_resource.h"
|
||||||
#include "zink_screen.h"
|
#include "zink_screen.h"
|
||||||
|
|
||||||
#include "util/u_dump.h"
|
#include "util/u_dump.h"
|
||||||
|
|
@ -247,6 +248,61 @@ zink_set_active_query_state(struct pipe_context *pctx, bool enable)
|
||||||
zink_resume_queries(ctx, batch);
|
zink_resume_queries(ctx, batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
zink_render_condition(struct pipe_context *pctx,
|
||||||
|
struct pipe_query *pquery,
|
||||||
|
bool condition,
|
||||||
|
enum pipe_render_cond_flag mode)
|
||||||
|
{
|
||||||
|
struct zink_context *ctx = zink_context(pctx);
|
||||||
|
struct zink_screen *screen = zink_screen(pctx->screen);
|
||||||
|
struct zink_query *query = (struct zink_query *)pquery;
|
||||||
|
struct zink_batch *batch = zink_curr_batch(ctx);
|
||||||
|
VkQueryResultFlagBits flags = 0;
|
||||||
|
|
||||||
|
if (query == NULL) {
|
||||||
|
screen->vk_CmdEndConditionalRenderingEXT(batch->cmdbuf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct pipe_resource *pres;
|
||||||
|
struct zink_resource *res;
|
||||||
|
struct pipe_resource templ = {};
|
||||||
|
templ.width0 = 8;
|
||||||
|
templ.height0 = 1;
|
||||||
|
templ.depth0 = 1;
|
||||||
|
templ.format = PIPE_FORMAT_R8_UINT;
|
||||||
|
templ.target = PIPE_BUFFER;
|
||||||
|
|
||||||
|
/* need to create a vulkan buffer to copy the data into */
|
||||||
|
pres = pctx->screen->resource_create(pctx->screen, &templ);
|
||||||
|
if (!pres)
|
||||||
|
return;
|
||||||
|
|
||||||
|
res = (struct zink_resource *)pres;
|
||||||
|
|
||||||
|
if (mode == PIPE_RENDER_COND_WAIT || mode == PIPE_RENDER_COND_BY_REGION_WAIT)
|
||||||
|
flags |= VK_QUERY_RESULT_WAIT_BIT;
|
||||||
|
|
||||||
|
if (query->use_64bit)
|
||||||
|
flags |= VK_QUERY_RESULT_64_BIT;
|
||||||
|
vkCmdCopyQueryPoolResults(batch->cmdbuf, query->query_pool, 0, 1,
|
||||||
|
res->buffer, 0, 0, flags);
|
||||||
|
|
||||||
|
VkConditionalRenderingFlagsEXT begin_flags = 0;
|
||||||
|
if (condition)
|
||||||
|
begin_flags = VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT;
|
||||||
|
VkConditionalRenderingBeginInfoEXT begin_info = {};
|
||||||
|
begin_info.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT;
|
||||||
|
begin_info.buffer = res->buffer;
|
||||||
|
begin_info.flags = begin_flags;
|
||||||
|
screen->vk_CmdBeginConditionalRenderingEXT(batch->cmdbuf, &begin_info);
|
||||||
|
|
||||||
|
zink_batch_reference_resoure(batch, res);
|
||||||
|
|
||||||
|
pipe_resource_reference(&pres, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zink_context_query_init(struct pipe_context *pctx)
|
zink_context_query_init(struct pipe_context *pctx)
|
||||||
{
|
{
|
||||||
|
|
@ -259,4 +315,5 @@ zink_context_query_init(struct pipe_context *pctx)
|
||||||
pctx->end_query = zink_end_query;
|
pctx->end_query = zink_end_query;
|
||||||
pctx->get_query_result = zink_get_query_result;
|
pctx->get_query_result = zink_get_query_result;
|
||||||
pctx->set_active_query_state = zink_set_active_query_state;
|
pctx->set_active_query_state = zink_set_active_query_state;
|
||||||
|
pctx->render_condition = zink_render_condition;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||||
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
|
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case PIPE_CAP_CONDITIONAL_RENDER:
|
||||||
|
return screen->have_EXT_conditional_rendering;
|
||||||
|
|
||||||
case PIPE_CAP_GLSL_FEATURE_LEVEL:
|
case PIPE_CAP_GLSL_FEATURE_LEVEL:
|
||||||
case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
|
case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
|
||||||
return 120;
|
return 120;
|
||||||
|
|
@ -716,6 +719,11 @@ load_device_extensions(struct zink_screen *screen)
|
||||||
if (screen->have_KHR_external_memory_fd)
|
if (screen->have_KHR_external_memory_fd)
|
||||||
GET_PROC_ADDR(GetMemoryFdKHR);
|
GET_PROC_ADDR(GetMemoryFdKHR);
|
||||||
|
|
||||||
|
if (screen->have_EXT_conditional_rendering) {
|
||||||
|
GET_PROC_ADDR(CmdBeginConditionalRenderingEXT);
|
||||||
|
GET_PROC_ADDR(CmdEndConditionalRenderingEXT);
|
||||||
|
}
|
||||||
|
|
||||||
#undef GET_PROC_ADDR
|
#undef GET_PROC_ADDR
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -759,6 +767,9 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
|
||||||
if (!strcmp(extensions[i].extensionName,
|
if (!strcmp(extensions[i].extensionName,
|
||||||
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME))
|
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME))
|
||||||
screen->have_KHR_external_memory_fd = true;
|
screen->have_KHR_external_memory_fd = true;
|
||||||
|
if (!strcmp(extensions[i].extensionName,
|
||||||
|
VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME))
|
||||||
|
screen->have_EXT_conditional_rendering = true;
|
||||||
}
|
}
|
||||||
FREE(extensions);
|
FREE(extensions);
|
||||||
}
|
}
|
||||||
|
|
@ -781,7 +792,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
|
||||||
dci.queueCreateInfoCount = 1;
|
dci.queueCreateInfoCount = 1;
|
||||||
dci.pQueueCreateInfos = &qci;
|
dci.pQueueCreateInfos = &qci;
|
||||||
dci.pEnabledFeatures = &screen->feats;
|
dci.pEnabledFeatures = &screen->feats;
|
||||||
const char *extensions[3] = {
|
const char *extensions[4] = {
|
||||||
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
|
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
num_extensions = 1;
|
num_extensions = 1;
|
||||||
|
|
@ -795,6 +806,10 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
|
||||||
extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME;
|
extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME;
|
||||||
extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
|
extensions[num_extensions++] = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (screen->have_EXT_conditional_rendering)
|
||||||
|
extensions[num_extensions++] = VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME;
|
||||||
|
|
||||||
assert(num_extensions <= ARRAY_SIZE(extensions));
|
assert(num_extensions <= ARRAY_SIZE(extensions));
|
||||||
|
|
||||||
dci.ppEnabledExtensionNames = extensions;
|
dci.ppEnabledExtensionNames = extensions;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ struct zink_screen {
|
||||||
|
|
||||||
bool have_KHR_maintenance1;
|
bool have_KHR_maintenance1;
|
||||||
bool have_KHR_external_memory_fd;
|
bool have_KHR_external_memory_fd;
|
||||||
|
bool have_EXT_conditional_rendering;
|
||||||
|
|
||||||
bool have_X8_D24_UNORM_PACK32;
|
bool have_X8_D24_UNORM_PACK32;
|
||||||
bool have_D24_UNORM_S8_UINT;
|
bool have_D24_UNORM_S8_UINT;
|
||||||
|
|
@ -59,6 +60,8 @@ struct zink_screen {
|
||||||
VkDevice dev;
|
VkDevice dev;
|
||||||
|
|
||||||
PFN_vkGetMemoryFdKHR vk_GetMemoryFdKHR;
|
PFN_vkGetMemoryFdKHR vk_GetMemoryFdKHR;
|
||||||
|
PFN_vkCmdBeginConditionalRenderingEXT vk_CmdBeginConditionalRenderingEXT;
|
||||||
|
PFN_vkCmdEndConditionalRenderingEXT vk_CmdEndConditionalRenderingEXT;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct zink_screen *
|
static inline struct zink_screen *
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue