Mesa (master): zink: implement Vk_EXT_index_type_uint8
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 2 07:25:35 UTC 2020
Module: Mesa
Branch: master
Commit: f2f57ef9f785459faeda61622bc96b139aa46e8f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2f57ef9f785459faeda61622bc96b139aa46e8f
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Jul 1 09:13:35 2020 -0400
zink: implement Vk_EXT_index_type_uint8
this is a simple extension that enables using uint8-sized index buffers,
which lets us avoid having those go through primconvert
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5712>
---
src/gallium/drivers/zink/zink_draw.c | 19 ++++++++++++++++---
src/gallium/drivers/zink/zink_screen.c | 18 ++++++++++++++++--
src/gallium/drivers/zink/zink_screen.h | 1 +
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 7d73a1231ea..7ffd3e800c6 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -210,7 +210,7 @@ zink_draw_vbo(struct pipe_context *pctx,
if (dinfo->mode >= PIPE_PRIM_QUADS ||
dinfo->mode == PIPE_PRIM_LINE_LOOP ||
- dinfo->index_size == 1) {
+ (dinfo->index_size == 1 && !screen->have_EXT_index_type_uint8)) {
if (!u_trim_pipe_prim(dinfo->mode, (unsigned *)&dinfo->count))
return;
@@ -424,8 +424,21 @@ zink_draw_vbo(struct pipe_context *pctx,
}
if (dinfo->index_size > 0) {
- assert(dinfo->index_size != 1);
- VkIndexType index_type = dinfo->index_size == 2 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32;
+ VkIndexType index_type;
+ switch (dinfo->index_size) {
+ case 1:
+ assert(screen->have_EXT_index_type_uint8);
+ index_type = VK_INDEX_TYPE_UINT8_EXT;
+ break;
+ case 2:
+ index_type = VK_INDEX_TYPE_UINT16;
+ break;
+ case 4:
+ index_type = VK_INDEX_TYPE_UINT32;
+ break;
+ default:
+ unreachable("unknown index size!");
+ }
struct zink_resource *res = zink_resource(index_buffer);
vkCmdBindIndexBuffer(batch->cmdbuf, res->buffer, index_offset, index_type);
zink_batch_reference_resoure(batch, res);
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 6e5f969fcdc..ba75b57bcc8 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -759,7 +759,7 @@ static struct pipe_screen *
zink_internal_create_screen(struct sw_winsys *winsys, int fd)
{
struct zink_screen *screen = CALLOC_STRUCT(zink_screen);
- bool have_tf_ext = false, have_cond_render_ext = false;
+ bool have_tf_ext = false, have_cond_render_ext = false, have_EXT_index_type_uint8 = false;
if (!screen)
return NULL;
@@ -798,6 +798,9 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
if (!strcmp(extensions[i].extensionName,
VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME))
have_tf_ext = true;
+ if (!strcmp(extensions[i].extensionName,
+ VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
+ have_EXT_index_type_uint8 = true;
}
FREE(extensions);
@@ -806,6 +809,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
VkPhysicalDeviceFeatures2 feats = {};
VkPhysicalDeviceTransformFeedbackFeaturesEXT tf_feats = {};
VkPhysicalDeviceConditionalRenderingFeaturesEXT cond_render_feats = {};
+ VkPhysicalDeviceIndexTypeUint8FeaturesEXT index_uint8_feats = {};
feats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
if (have_tf_ext) {
@@ -818,12 +822,19 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
cond_render_feats.pNext = feats.pNext;
feats.pNext = &cond_render_feats;
}
+ if (have_EXT_index_type_uint8) {
+ index_uint8_feats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT;
+ index_uint8_feats.pNext = feats.pNext;
+ feats.pNext = &index_uint8_feats;
+ }
vkGetPhysicalDeviceFeatures2(screen->pdev, &feats);
memcpy(&screen->feats, &feats.features, sizeof(screen->feats));
if (have_tf_ext && tf_feats.transformFeedback)
screen->have_EXT_transform_feedback = true;
if (have_cond_render_ext && cond_render_feats.conditionalRendering)
screen->have_EXT_conditional_rendering = true;
+ if (have_EXT_index_type_uint8 && index_uint8_feats.indexTypeUint8)
+ screen->have_EXT_index_type_uint8 = true;
VkPhysicalDeviceProperties2 props = {};
props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
@@ -855,7 +866,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
* this requires us to pass the whole VkPhysicalDeviceFeatures2 struct
*/
dci.pNext = &feats;
- const char *extensions[5] = {
+ const char *extensions[6] = {
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
};
num_extensions = 1;
@@ -873,6 +884,9 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
if (screen->have_EXT_conditional_rendering)
extensions[num_extensions++] = VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME;
+ if (screen->have_EXT_index_type_uint8)
+ extensions[num_extensions++] = VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME;
+
if (screen->have_EXT_transform_feedback)
extensions[num_extensions++] = VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME;
assert(num_extensions <= ARRAY_SIZE(extensions));
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index e1138c9249f..4625116c80b 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -54,6 +54,7 @@ struct zink_screen {
bool have_KHR_external_memory_fd;
bool have_EXT_conditional_rendering;
bool have_EXT_transform_feedback;
+ bool have_EXT_index_type_uint8;
bool have_X8_D24_UNORM_PACK32;
bool have_D24_UNORM_S8_UINT;
More information about the mesa-commit
mailing list