Commit e8245279 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Decode stencil test

parent 60bbc654
......@@ -69,6 +69,28 @@ enum mali_gl_mode {
/* Next flags to unknown4 */
#define MALI_NO_MSAA (1 << 30)
#define MALI_STENCIL_TEST (1 << 16)
/* These are packed, but also duplicated so it's better to construct like this.
* func should be a value from mali_stencil_func, corresponding to the
* according OpenGL stencil functions.
*
* Applies to stencil_0 and stencil_1
*/
#define MAKE_STENCIL_TEST(func, mask, ref) \
(func << 16) | (mask << 8) | (ref << 0)
enum mali_stencil_func {
MALI_STENCIL_NEVER = 0,
MALI_STENCIL_LESS = 1,
MALI_STENCIL_EQUAL = 2,
MALI_STENCIL_LEQUAL = 3,
MALI_STENCIL_GREATER = 4,
MALI_STENCIL_NOTEQUAL = 5,
MALI_STENCIL_GEQUAL = 6,
MALI_STENCIL_ALWAYS = 7
};
struct mali_shader_meta {
mali_ptr shader;
......@@ -99,8 +121,12 @@ struct mali_shader_meta {
u32 unknown2_2;
u32 unknown2_3;
u32 unknown2_4;
u32 unknown2_5;
u32 unknown2_6;
/* Like clear_color, these fields appear to always be duplicated */
u32 stencil_0;
u32 stencil_1;
u32 unknown2_7;
u32 unknown2_8;
......
......@@ -58,6 +58,7 @@ static const struct panwrap_flag_info u3_flag_info[] = {
static const struct panwrap_flag_info u4_flag_info[] = {
FLAG_INFO(NO_MSAA),
FLAG_INFO(STENCIL_TEST),
{}
};
#undef FLAG_INFO
......@@ -111,6 +112,23 @@ static char *panwrap_gl_mode_name(enum mali_gl_mode mode)
#undef DEFINE_CASE
}
static char *panwrap_stencil_func_name(enum mali_stencil_func mode)
{
#define DEFINE_CASE(name) case MALI_STENCIL_ ## name: return "MALI_STENCIL_" #name
switch(mode) {
DEFINE_CASE(NEVER);
DEFINE_CASE(LESS);
DEFINE_CASE(EQUAL);
DEFINE_CASE(LEQUAL);
DEFINE_CASE(GREATER);
DEFINE_CASE(NOTEQUAL);
DEFINE_CASE(GEQUAL);
DEFINE_CASE(ALWAYS);
default: return "MALI_STENCIL_NEVER /* XXX: Unknown stencil function, check dump */";
}
#undef DEFINE_CASE
}
static void panwrap_property_u32_list(const char *name, const u32 *lst, size_t c)
{
panwrap_log(".%s = { ", name);
......@@ -371,8 +389,21 @@ panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_log_decoded_flags(u4_flag_info, s->unknown2_4);
panwrap_log_cont(",\n");
panwrap_prop("unknown2_5 = 0x%" PRIx32, s->unknown2_5);
panwrap_prop("unknown2_6 = 0x%" PRIx32, s->unknown2_6);
if (s->stencil_0 != s->stencil_1) {
panwrap_msg("Stencil fields are not equal, not decoding");
panwrap_prop("stencil_0 = 0x%" PRIx32, s->stencil_0);
panwrap_prop("stencil_1 = 0x%" PRIx32, s->stencil_1);
} else if (s->stencil_0) {
uint8_t ref = s->stencil_0 & 0xFF;
uint8_t mask = (s->stencil_0 >> 8) & 0xFF;
uint8_t func = s->stencil_0 >> 16;
const char *func_str = panwrap_stencil_func_name(func);
panwrap_prop("stencil_0 = MAKE_STENCIL_TEST(%s, %d, %d)", func_str, mask, ref);
panwrap_prop("stencil_1 = MAKE_STENCIL_TEST(%s, %d, %d)", func_str, mask, ref);
}
panwrap_prop("unknown2_7 = 0x%" PRIx32, s->unknown2_7);
panwrap_prop("unknown2_8 = 0x%" PRIx32, s->unknown2_8);
......
......@@ -192,14 +192,6 @@ void main(void) {
.work_count = 12,
.unknown1 = 0x1,
.unknown2 = 0x8,
.unknown2_2 = 0x0,
.unknown2_3 = 0x0,
.unknown2_4 = 0x0,
.unknown2_5 = 0x0,
.unknown2_6 = 0x0,
.unknown2_7 = 0x0,
.unknown2_8 = 0x0,
.blend_equation = 0x0,
};
mali_ptr shader_meta_1_p = pandev_upload(-1, alloc_gpu_va_19, memory_19, &shader_meta_1, sizeof(shader_meta_1), false);
......@@ -311,8 +303,8 @@ void main(void) {
.unknown2_2 = 0x0,
.unknown2_3 = MALI_HAS_MSAA | 0x3710ffff,
.unknown2_4 = /*MALI_NO_MSAA | */0x6f0ffff,
.unknown2_5 = 0x7ff00,
.unknown2_6 = 0x7ff00,
.stencil_0 = MAKE_STENCIL_TEST(MALI_STENCIL_ALWAYS, 0xFF, 0),
.stencil_1 = MAKE_STENCIL_TEST(MALI_STENCIL_ALWAYS, 0xFF, 0),
.unknown2_7 = 0x0,
.unknown2_8 = 0x0,
.blend_equation = 0xf0122122,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment