diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-12-27 16:01:34 -0500 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-12-30 17:11:08 -0500 |
commit | 67fe2afa51984398a7d9d458447b99522a847def (patch) | |
tree | 2359ff09d4944b4ae765094332938347dd547461 | |
parent | 62d056d8e32c10e430ee7b742daaa1f6f7d6cc71 (diff) |
panfrost: Implement integer varyings
We need to actually work out the varying format on demand, rather than
assuming rgba32f.
Fixes dEQP-GLES3.functional.fragment_out.basic.int.*
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_assemble.c | 2 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 53 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_compile.h | 1 |
3 files changed, 55 insertions, 1 deletions
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 6928f33faae..acb688651e6 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -148,7 +148,7 @@ panfrost_shader_compile( /* Default to a vec4 varying */ struct mali_attr_meta v = { - .format = MALI_RGBA32F, + .format = program.varying_type[i], .swizzle = default_vec4_swizzle, .unknown1 = 0x2, }; diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index abdd07cbb96..0c7d60cd675 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -2533,6 +2533,58 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx) return first_tag; } +static unsigned +pan_format_from_nir_base(nir_alu_type base) +{ + switch (base) { + case nir_type_int: + return MALI_FORMAT_SINT; + case nir_type_uint: + case nir_type_bool: + return MALI_FORMAT_UINT; + case nir_type_float: + return MALI_CHANNEL_FLOAT; + default: + unreachable("Invalid base"); + } +} + +static unsigned +pan_format_from_nir_size(nir_alu_type base, unsigned size) +{ + if (base == nir_type_float) { + switch (size) { + case 16: return MALI_FORMAT_SINT; + case 32: return MALI_FORMAT_UNORM; + default: + unreachable("Invalid float size for format"); + } + } else { + switch (size) { + case 1: + case 8: return MALI_CHANNEL_8; + case 16: return MALI_CHANNEL_16; + case 32: return MALI_CHANNEL_32; + default: + unreachable("Invalid int size for format"); + } + } +} + +static enum mali_format +pan_format_from_glsl(const struct glsl_type *type) +{ + enum glsl_base_type glsl_base = glsl_get_base_type(glsl_without_array(type)); + nir_alu_type t = nir_get_nir_type_for_glsl_base_type(glsl_base); + + unsigned base = nir_alu_type_get_base_type(t); + unsigned size = nir_alu_type_get_type_size(t); + + return pan_format_from_nir_base(base) | + pan_format_from_nir_size(base, size) | + MALI_NR_CHANNELS(4); +} + int midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id, bool shaderdb) { @@ -2573,6 +2625,7 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl for (int c = 0; c < sz; ++c) { program->varyings[loc + c] = var->data.location + c; + program->varying_type[loc + c] = pan_format_from_glsl(var->type); max_varying = MAX2(max_varying, loc + c); } } diff --git a/src/panfrost/midgard/midgard_compile.h b/src/panfrost/midgard/midgard_compile.h index 317a2b9e4c4..9f29cab5076 100644 --- a/src/panfrost/midgard/midgard_compile.h +++ b/src/panfrost/midgard/midgard_compile.h @@ -78,6 +78,7 @@ typedef struct { unsigned sysvals[MAX_SYSVAL_COUNT]; unsigned varyings[32]; + enum mali_format varying_type[32]; /* Boolean properties of the program */ bool writes_point_size; |