Mesa (master): gallium/nir/tgsi: add support for compact variables
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 19 01:23:15 UTC 2020
Module: Mesa
Branch: master
Commit: 597d0e9b5fd8d896c9837f5ed8d5322aa937a999
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=597d0e9b5fd8d896c9837f5ed8d5322aa937a999
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Aug 17 14:52:04 2020 +1000
gallium/nir/tgsi: add support for compact variables
vulkan tessellation uses compact variables for tess factors,
and trips over in the nir->tgsi info gathering, add support
to the info extraction for compact inputs and outputs.
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6339>
---
src/gallium/auxiliary/nir/nir_to_tgsi_info.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
index d03dbd39b0d..8d15a426230 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
@@ -63,10 +63,15 @@ static void gather_usage_helper(const nir_deref_instr **deref_ptr,
const nir_deref_instr *deref = *deref_ptr;
switch (deref->deref_type) {
case nir_deref_type_array: {
- unsigned elem_size =
+ bool is_compact = nir_deref_instr_get_variable(deref)->data.compact;
+ unsigned elem_size = is_compact ? DIV_ROUND_UP(glsl_get_length(deref->type), 4) :
glsl_count_attribute_slots(deref->type, false);
if (nir_src_is_const(deref->arr.index)) {
- location += elem_size * nir_src_as_uint(deref->arr.index);
+ if (is_compact) {
+ location += nir_src_as_uint(deref->arr.index) / 4;
+ mask <<= nir_src_as_uint(deref->arr.index) % 4;
+ } else
+ location += elem_size * nir_src_as_uint(deref->arr.index);
} else {
unsigned array_elems =
glsl_get_length(deref_ptr[-1]->type);
@@ -498,8 +503,8 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
type = glsl_get_array_element(type);
}
- unsigned attrib_count = glsl_count_attribute_slots(type,
- nir->info.stage == MESA_SHADER_VERTEX);
+ unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4) :
+ glsl_count_attribute_slots(type, nir->info.stage == MESA_SHADER_VERTEX);
i = variable->data.driver_location;
@@ -584,7 +589,8 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
type = glsl_get_array_element(type);
}
- unsigned attrib_count = glsl_count_attribute_slots(type, false);
+ unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4) :
+ glsl_count_attribute_slots(type, false);
for (unsigned k = 0; k < attrib_count; k++, i++) {
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
More information about the mesa-commit
mailing list