cfg.suppress_inf_nan = true; /* XXX */
}
- memcpy(&meta->midgard1, &prop, sizeof(prop));
+ memcpy(&meta->midgard_props, &prop, sizeof(prop));
}
}
cfg.reads_depth_stencil = zs_enabled && fs->can_discard;
}
- memcpy(&fragmeta->midgard1, &prop, sizeof(prop));
+ memcpy(&fragmeta->midgard_props, &prop, sizeof(prop));
}
bool msaa = rast->multisample;
cfg.early_z_enable = true;
}
- memcpy(&fragmeta->midgard1, &prop, sizeof(prop));
+ memcpy(&fragmeta->midgard_props, &prop, sizeof(prop));
}
if (dev->quirks & MIDGARD_SFBD) {
#define MALI_CHANNEL_FLOAT 7
#define MALI_EXTRACT_BITS(fmt) (fmt & 0x7)
-/* Applies to midgard1.flags_lo */
-
-/* Should be set when the fragment shader updates the depth value. */
-#define MALI_WRITES_Z (1 << 4)
-
-/* Should the hardware perform early-Z testing? Set if the shader does not use
- * discard, alpha-to-coverage, shader depth writes, and if the shader has no
- * side effects (writes to global memory or images) unless early-z testing is
- * forced in the shader.
- */
-
-#define MALI_EARLY_Z (1 << 6)
-
-/* Should the hardware calculate derivatives (via helper invocations)? Set in a
- * fragment shader that uses texturing or derivative functions */
-
-#define MALI_HELPER_INVOCATIONS (1 << 7)
-
-/* Flags denoting the fragment shader's use of tilebuffer readback. If the
- * shader might read any part of the tilebuffer, set MALI_READS_TILEBUFFER. If
- * it might read depth/stencil in particular, also set MALI_READS_ZS */
-
-#define MALI_READS_ZS (1 << 8)
-
-/* The shader might write to global memory (via OpenCL, SSBOs, or images).
- * Reading is okay, as are ordinary writes to the tilebuffer/varyings. Setting
- * incurs a performance penalty. On a fragment shader, this bit implies there
- * are side effects, hence it interacts with early-z. */
-#define MALI_WRITES_GLOBAL (1 << 9)
-
-#define MALI_READS_TILEBUFFER (1 << 10)
-
-/* Applies to midgard1.flags_hi */
-
-/* Should be set when the fragment shader updates the stencil value. */
-#define MALI_WRITES_S (1 << 2)
-
-/* Mode to suppress generation of Infinity and NaN values by clamping inf
- * (-inf) to MAX_FLOAT (-MIN_FLOAT) and flushing NaN to 0.0
- *
- * Compare suppress_inf/suppress_nan flags on the Bifrost clause header for the
- * same functionality.
- *
- * This is not conformant on GLES3 or OpenCL, but is optional on GLES2, where
- * it works around app bugs (e.g. in glmark2-es2 -bterrain with FP16).
- */
-#define MALI_SUPPRESS_INF_NAN (1 << 3)
-
/* Flags for bifrost1.unk1 */
/* Shader uses less than 32 registers, partitioned as [R0, R15] U [R48, R63],
u32 uniform_buffer_count : 4;
u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler
} bifrost1;
- struct {
- unsigned uniform_buffer_count : 4;
- unsigned flags_lo : 12;
-
- /* vec4 units */
- unsigned work_count : 5;
- unsigned uniform_count : 5;
- unsigned flags_hi : 6;
- } midgard1;
+ struct mali_midgard_properties_packed midgard_props;
};
/* Same as glPolygoOffset() arguments */
};
#undef FLAG_INFO
-#define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
-static const struct pandecode_flag_info shader_midgard1_flag_lo_info [] = {
- FLAG_INFO(WRITES_Z),
- FLAG_INFO(EARLY_Z),
- FLAG_INFO(READS_TILEBUFFER),
- FLAG_INFO(WRITES_GLOBAL),
- FLAG_INFO(READS_ZS),
- {}
-};
-
-static const struct pandecode_flag_info shader_midgard1_flag_hi_info [] = {
- FLAG_INFO(WRITES_S),
- FLAG_INFO(SUPPRESS_INF_NAN),
- {}
-};
-#undef FLAG_INFO
-
#define FLAG_INFO(flag) { MALI_BIFROST_##flag, "MALI_BIFROST_" #flag }
static const struct pandecode_flag_info shader_bifrost_info [] = {
FLAG_INFO(FULL_THREAD),
if (s->shader & ~0xF)
info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost, gpu_id);
+ struct MALI_MIDGARD_PROPERTIES midg_props;
+
pandecode_log("struct mali_shader_meta shader_meta_%"PRIx64"_%d%s = {\n", p->shader, job_no, suffix);
pandecode_indent++;
uniform_count = s->bifrost2.uniform_count;
uniform_buffer_count = s->bifrost1.uniform_buffer_count;
} else {
- uniform_count = s->midgard1.uniform_count;
- uniform_buffer_count = s->midgard1.uniform_buffer_count;
+ uint32_t opaque = s->midgard_props.opaque[0];
+ MALI_MIDGARD_PROPERTIES_unpack((const uint8_t *) &opaque, &midg_props);
+
+ uniform_count = midg_props.uniform_count;
+ uniform_buffer_count = midg_props.uniform_buffer_count;
}
pandecode_shader_address("shader", s->shader);
pandecode_shader_prop("sampler_count", s->sampler_count, info.sampler_count, false);
pandecode_shader_prop("attribute_count", s->attribute_count, info.attribute_count, false);
pandecode_shader_prop("varying_count", s->varying_count, info.varying_count, false);
- pandecode_shader_prop("uniform_buffer_count",
- uniform_buffer_count,
- info.uniform_buffer_count, true);
-
- if (!is_bifrost) {
- pandecode_shader_prop("uniform_count",
- uniform_count,
- info.uniform_count, false);
-
- pandecode_shader_prop("work_count",
- s->midgard1.work_count, info.work_count, false);
- }
if (is_bifrost) {
pandecode_log("bifrost1.unk1 = ");
pandecode_log_decoded_flags(shader_bifrost_info, s->bifrost1.unk1);
pandecode_log_cont(",\n");
} else {
- bool helpers = s->midgard1.flags_lo & MALI_HELPER_INVOCATIONS;
-
- if (helpers != info.helper_invocations) {
- pandecode_msg("XXX: expected helpers %u but got %u\n",
- info.helper_invocations, helpers);
- }
-
- pandecode_log(".midgard1.flags_lo = ");
- pandecode_log_decoded_flags(shader_midgard1_flag_lo_info,
- s->midgard1.flags_lo & ~MALI_HELPER_INVOCATIONS);
- pandecode_log_cont(",\n");
-
- pandecode_log(".midgard1.flags_hi = ");
- pandecode_log_decoded_flags(shader_midgard1_flag_hi_info, s->midgard1.flags_hi);
- pandecode_log_cont(",\n");
+ MALI_MIDGARD_PROPERTIES_print(pandecode_dump_stream, &midg_props, 2);
}
if (s->depth_units || s->depth_factor) {
.sampler_count = 1,
.texture_count = 1,
.varying_count = 1,
- .midgard1 = {
- .flags_lo = 0x20,
- .work_count = 4,
- },
.coverage_mask = ~0,
.unknown2_3 = MALI_DEPTH_FUNC(MALI_FUNC_ALWAYS) | 0x10,
.unknown2_4 = 0x4e0,
}
};
+ struct mali_midgard_properties_packed midgard_props;
+
+ pan_pack(&midgard_props, MIDGARD_PROPERTIES, cfg) {
+ cfg.work_register_count = 4;
+ cfg.early_z_enable = (loc >= FRAG_RESULT_DATA0);
+ cfg.stencil_from_shader = (loc == FRAG_RESULT_STENCIL);
+ cfg.depth_source = (loc == FRAG_RESULT_DEPTH) ?
+ MALI_DEPTH_SOURCE_SHADER :
+ MALI_DEPTH_SOURCE_FIXED_FUNCTION;
+ }
+
+ memcpy(&shader_meta.midgard_props, &midgard_props, sizeof(midgard_props));
+
if (ms)
shader_meta.unknown2_3 |= MALI_HAS_MSAA | MALI_PER_SAMPLE;
else
shader_meta.blend = replace;
}
- if (loc == FRAG_RESULT_DEPTH) {
- shader_meta.midgard1.flags_lo |= MALI_WRITES_Z;
+ if (loc == FRAG_RESULT_DEPTH)
shader_meta.unknown2_3 |= MALI_DEPTH_WRITEMASK;
- } else if (loc == FRAG_RESULT_STENCIL) {
- shader_meta.midgard1.flags_hi |= MALI_WRITES_S;
+ else if (loc == FRAG_RESULT_STENCIL)
shader_meta.unknown2_4 |= MALI_STENCIL_TEST;
- } else {
- shader_meta.midgard1.flags_lo |= MALI_EARLY_Z;
- }
/* Create the texture descriptor. We partially compute the base address
* ourselves to account for layer, such that the texture descriptor