Mesa (main): panvk: Eliminate unused vertex attributes
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 27 14:41:06 UTC 2022
Module: Mesa
Branch: main
Commit: 3f824e0e85c7247e25bc3103160d94c65c0b9474
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f824e0e85c7247e25bc3103160d94c65c0b9474
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Tue Apr 26 19:52:28 2022 -0500
panvk: Eliminate unused vertex attributes
We use nir_assign_io_var_locations() which compacts the varyings and
eliminates any unused input slots. We need to do the same thing when
processing pVertexAttributeDescriptions[] or else we'll end up with
mismatches between the shader and the state setup code.
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16183>
---
src/panfrost/ci/deqp-panfrost-g52-vk.toml | 1 +
src/panfrost/lib/pan_shader.c | 1 +
src/panfrost/util/pan_ir.h | 1 +
src/panfrost/vulkan/panvk_vX_pipeline.c | 23 ++++++++++++++---------
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/panfrost/ci/deqp-panfrost-g52-vk.toml b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
index 494de1e5e46..1f33d7b24df 100644
--- a/src/panfrost/ci/deqp-panfrost-g52-vk.toml
+++ b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
@@ -20,6 +20,7 @@ include = [
"dEQP-VK.glsl.derivate.*.constant.*",
"dEQP-VK.glsl.derivate.*.linear.*",
"dEQP-VK.glsl.derivate.*.uniform_*",
+ "dEQP-VK.glsl.operator.*",
"dEQP-VK.image.load_store.with_format.*",
"dEQP-VK.pipeline.input_assembly.*",
"dEQP-VK.pipeline.sampler.view_type.*.format.r*.address_modes.all_mode_clamp_to_border*",
diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c
index 0e393262cba..d16a9f67d73 100644
--- a/src/panfrost/lib/pan_shader.c
+++ b/src/panfrost/lib/pan_shader.c
@@ -214,6 +214,7 @@ GENX(pan_shader_compile)(nir_shader *s,
switch (info->stage) {
case MESA_SHADER_VERTEX:
info->attribute_count = util_bitcount64(s->info.inputs_read);
+ info->attributes_read = s->info.inputs_read;
#if PAN_ARCH <= 5
bool vertex_id = BITSET_TEST(s->info.system_values_read,
diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h
index 0ae68b70bf6..9e58c69fcef 100644
--- a/src/panfrost/util/pan_ir.h
+++ b/src/panfrost/util/pan_ir.h
@@ -334,6 +334,7 @@ struct pan_shader_info {
unsigned texture_count;
unsigned ubo_count;
unsigned attribute_count;
+ unsigned attributes_read;
struct {
unsigned input_count;
diff --git a/src/panfrost/vulkan/panvk_vX_pipeline.c b/src/panfrost/vulkan/panvk_vX_pipeline.c
index 8db64430db2..e4568fd14a5 100644
--- a/src/panfrost/vulkan/panvk_vX_pipeline.c
+++ b/src/panfrost/vulkan/panvk_vX_pipeline.c
@@ -902,15 +902,6 @@ panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder
attribs->buf[desc->binding].special = false;
}
- for (unsigned i = 0; i < info->vertexAttributeDescriptionCount; i++) {
- const VkVertexInputAttributeDescription *desc =
- &info->pVertexAttributeDescriptions[i];
- attribs->attrib[desc->location].buf = desc->binding;
- attribs->attrib[desc->location].format =
- vk_format_to_pipe_format(desc->format);
- attribs->attrib[desc->location].offset = desc->offset;
- }
-
if (div_info) {
for (unsigned i = 0; i < div_info->vertexBindingDivisorCount; i++) {
const VkVertexInputBindingDivisorDescriptionEXT *div =
@@ -922,6 +913,20 @@ panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder
const struct pan_shader_info *vs =
&builder->shaders[MESA_SHADER_VERTEX]->info;
+ for (unsigned i = 0; i < info->vertexAttributeDescriptionCount; i++) {
+ const VkVertexInputAttributeDescription *desc =
+ &info->pVertexAttributeDescriptions[i];
+
+ unsigned attrib = desc->location + VERT_ATTRIB_GENERIC0;
+ unsigned slot = util_bitcount64(vs->attributes_read &
+ BITFIELD64_MASK(attrib));
+
+ attribs->attrib[slot].buf = desc->binding;
+ attribs->attrib[slot].format =
+ vk_format_to_pipe_format(desc->format);
+ attribs->attrib[slot].offset = desc->offset;
+ }
+
if (vs->attribute_count >= PAN_VERTEX_ID) {
attribs->buf[attribs->buf_count].special = true;
attribs->buf[attribs->buf_count].special_id = PAN_VERTEX_ID;
More information about the mesa-commit
mailing list