Commit 11b6ae07 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Factor apart tripipe and fragment shader core

parent 2551a3a4
......@@ -175,7 +175,7 @@ struct mali_blend_equation {
/* Applies to unknown1 */
#define MALI_NO_ALPHA_TO_COVERAGE (1 << 10)
struct mali_shader_meta {
struct mali_tripipe {
mali_ptr shader;
u32 zero1;
......@@ -183,7 +183,7 @@ struct mali_shader_meta {
u16 attribute_count;
u16 varying_count;
/* 0x200 except MALI_NO_ALPHA_TO_COVERAGE */
/* 0x200 except MALI_NO_ALPHA_TO_COVERAGE. Mysterious 1 other times. Who knows really? */
u16 unknown1;
/* Whole number of uniform registers used, times two; whole number of
......@@ -193,7 +193,9 @@ struct mali_shader_meta {
unsigned work_count : 5;
unsigned uniform_count : 5;
unsigned unknown2 : 6;
} __attribute__((packed));
struct mali_fragment_core {
/* Depth factor is exactly as passed to glDepthOffset. Depth units is
* equal to the value passed to glDeptOhffset + 1.0f (use
* MALI_NEGATIVE) */
......@@ -224,6 +226,13 @@ struct mali_shader_meta {
};
} __attribute__((packed));
/* See the presentations about Mali architecture for why these are together like this */
struct mali_shader_meta {
struct mali_tripipe tripipe;
struct mali_fragment_core fragment_core;
} __attribute__((packed));
/* This only concerns hardware jobs */
/* Possible values for job_descriptor_size */
......
......@@ -500,36 +500,46 @@ panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_log("struct mali_shader_meta shader_meta_%d = {\n", job_no);
panwrap_indent++;
mali_ptr shader_ptr = panwrap_replay_shader_address("shader", s->shader);
/* Shader meta contains metadata for the entire shader core */
struct mali_tripipe *t = &s->tripipe;
struct mali_fragment_core *f = &s->fragment_core;
if (s->zero1)
/* Save for dumps */
attribute_count = t->attribute_count;
varying_count = t->varying_count;
uniform_count = t->uniform_count;
panwrap_log(".tripipe = {\n");
panwrap_indent++;
mali_ptr shader_ptr = panwrap_replay_shader_address("shader", t->shader);
if (t->zero1)
panwrap_msg("XXX shader zero tripped\n");
panwrap_prop("attribute_count = %" PRId16, s->attribute_count);
panwrap_prop("varying_count = %" PRId16, s->varying_count);
panwrap_prop("uniform_count = %" PRId16, s->uniform_count);
panwrap_prop("work_count = %" PRId16, s->work_count);
panwrap_prop("attribute_count = %" PRId16, t->attribute_count);
panwrap_prop("varying_count = %" PRId16, t->varying_count);
panwrap_prop("uniform_count = %" PRId16, t->uniform_count);
panwrap_prop("work_count = %" PRId16, t->work_count);
panwrap_prop("unknown1 = %s0x%" PRIx32,
s->unknown1 & MALI_NO_ALPHA_TO_COVERAGE ? "MALI_NO_ALPHA_TO_COVERAGE | " : "",
s->unknown1 & ~MALI_NO_ALPHA_TO_COVERAGE);
panwrap_prop("unknown2 = 0x%" PRIx32, s->unknown2);
t->unknown1 & MALI_NO_ALPHA_TO_COVERAGE ? "MALI_NO_ALPHA_TO_COVERAGE | " : "",
t->unknown1 & ~MALI_NO_ALPHA_TO_COVERAGE);
panwrap_prop("unknown2 = 0x%" PRIx32, t->unknown2);
/* Save for dumps */
attribute_count = s->attribute_count;
varying_count = s->varying_count;
uniform_count = s->uniform_count;
panwrap_indent--;
panwrap_log("},\n");
panwrap_log(".fragment_core = {\n");
panwrap_indent++;
/* WTF? All zero for vertex shaders; block of assorted, largely
* unknown fields for fragment shaders. Let's figure it out,
* girls :) */
if (s->depth_units || s->depth_factor) {
panwrap_prop("depth_units = MALI_NEGATIVE(%f)", s->depth_units - 1.0f);
panwrap_prop("depth_factor = %f", s->depth_factor);
if (f->depth_units || f->depth_factor) {
panwrap_prop("depth_units = MALI_NEGATIVE(%f)", f->depth_units - 1.0f);
panwrap_prop("depth_factor = %f", f->depth_factor);
}
bool invert_alpha_coverage = s->alpha_coverage & 0xFFF0;
uint16_t inverted_coverage = invert_alpha_coverage ? ~s->alpha_coverage : s->alpha_coverage;
bool invert_alpha_coverage = f->alpha_coverage & 0xFFF0;
uint16_t inverted_coverage = invert_alpha_coverage ? ~f->alpha_coverage : f->alpha_coverage;
panwrap_prop("alpha_coverage = %sMALI_ALPHA_COVERAGE(%f)",
invert_alpha_coverage ? "~" : "",
......@@ -537,8 +547,8 @@ panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_log(".unknown2_3 = ");
int unknown2_3 = s->unknown2_3;
int unknown2_4 = s->unknown2_4;
int unknown2_3 = f->unknown2_3;
int unknown2_4 = f->unknown2_4;
/* We're not quite sure what these flags mean without the depth test, if anything */
......@@ -566,20 +576,24 @@ panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_log_decoded_flags(u4_flag_info, unknown2_4);
panwrap_log_cont(",\n");
panwrap_replay_stencil("front", &s->stencil_front);
panwrap_replay_stencil("back", &s->stencil_back);
panwrap_replay_stencil("front", &f->stencil_front);
panwrap_replay_stencil("back", &f->stencil_back);
panwrap_prop("unknown2_7 = 0x%" PRIx32, s->unknown2_7);
panwrap_prop("unknown2_8 = 0x%" PRIx32, s->unknown2_8);
panwrap_prop("unknown2_7 = 0x%" PRIx32, f->unknown2_7);
panwrap_prop("unknown2_8 = 0x%" PRIx32, f->unknown2_8);
if (s->unknown2_3 & MALI_HAS_BLEND_SHADER) {
panwrap_replay_shader_address("blend_shader", s->blend_shader);
if (f->unknown2_3 & MALI_HAS_BLEND_SHADER) {
panwrap_replay_shader_address("blend_shader", f->blend_shader);
} else {
panwrap_replay_blend_equation(&s->blend_equation);
panwrap_replay_blend_equation(&f->blend_equation);
}
panwrap_indent--;
panwrap_log("}\n");
panwrap_indent--;
panwrap_log("};\n");
TOUCH(smem, shader_meta_ptr, *meta, "shader_meta", job_no, false);
panwrap_shader_disassemble(shader_ptr, job_no, h->job_type);
......
......@@ -85,7 +85,7 @@ pandev_shader_compile(uint32_t *dst, const char *src, int type)
#include "trans-builder.h"
void
panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *meta, const char *src, int type)
panfrost_shader_compile(struct panfrost_context *ctx, struct mali_tripipe *meta, const char *src, int type)
{
void *dst = pandev_shader_compile(NULL, src, type);
meta->shader = panfrost_upload(&ctx->shaders, dst, last_shader_size, true) | 5;
......@@ -97,14 +97,13 @@ panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *m
meta->attribute_count = 2;
meta->varying_count = 3;
meta->uniform_count = 0;
meta->unknown1 = 1; /* XXX: WTF is this?! */
} else {
meta->attribute_count = 0;
meta->varying_count = 1;
meta->uniform_count = 0;
meta->unknown1 = MALI_NO_ALPHA_TO_COVERAGE | 0x200; /* XXX: WTF is this?! */
}
meta->work_count = 8;
if (!meta->unknown1)
meta->unknown1 = 1; /* XXX: WTF is this?! */
}
......@@ -40,7 +40,7 @@ void* pandev_shader_compile(uint32_t *dst, const char *src, int type);
struct panfrost_context;
void
panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *meta, const char *src, int type);
panfrost_shader_compile(struct panfrost_context *ctx, struct mali_tripipe *meta, const char *src, int type);
struct panfrost_memory {
uint8_t* cpu;
......
......@@ -240,8 +240,7 @@ trans_emit_vt_framebuffer(struct panfrost_context *ctx)
void
trans_default_shader_backend(struct panfrost_context *ctx)
{
struct mali_shader_meta shader = {
.unknown1 = MALI_NO_ALPHA_TO_COVERAGE | 0x200,
struct mali_fragment_core shader = {
.alpha_coverage = ~MALI_ALPHA_COVERAGE(0.000000),
.unknown2_3 = MALI_DEPTH_FUNC(MALI_FUNC_ALWAYS) | 0x3010,
.unknown2_4 = MALI_STENCIL_MASK_FRONT(0xFF) | MALI_STENCIL_MASK_BACK(0xFF) | MALI_NO_MSAA | 0x4f00000,
......
......@@ -66,7 +66,7 @@ struct panfrost_context {
* also everything else in the shader core, including blending, the
* stencil/depth tests, etc. Refer to the presentations. */
struct mali_shader_meta fragment_shader_core;
struct mali_fragment_core fragment_shader_core;
/* A frame is composed of a starting set value job, a number of vertex
* and tiler jobs, linked to the fragment job at the end. See the
......
......@@ -20,10 +20,11 @@ void main(void)
struct panfrost_context *ctx = (struct panfrost_context *) gallium;
trans_default_shader_backend(ctx);
panfrost_shader_compile(ctx, &ctx->fragment_shader_core, NULL, JOB_TYPE_TILER);
struct mali_shader_meta shader_meta_1;
panfrost_shader_compile(ctx, &shader_meta_1, NULL, JOB_TYPE_VERTEX);
struct mali_tripipe shader_f, shader_v;
panfrost_shader_compile(ctx, &shader_v, NULL, JOB_TYPE_VERTEX);
panfrost_shader_compile(ctx, &shader_f, NULL, JOB_TYPE_TILER);
for (int i = 0; i < 60; ++i) {
trans_emit_vertex_payload(ctx);
......@@ -32,8 +33,18 @@ void main(void)
/* Shaders */
struct mali_shader_meta shader_meta_1 = {
.tripipe = shader_v,
};
struct mali_shader_meta shader_meta_2 = {
.tripipe = shader_f
};
memcpy(&shader_meta_2.fragment_core, &ctx->fragment_shader_core, sizeof(struct mali_fragment_core));
ctx->payload_vertex._shader_upper = panfrost_upload(&ctx->cmdstream, &shader_meta_1, sizeof(struct mali_shader_meta), false) >> 4;
ctx->payload_tiler._shader_upper = panfrost_upload(&ctx->cmdstream, &ctx->fragment_shader_core, sizeof(struct mali_shader_meta), false) >> 4;
ctx->payload_tiler._shader_upper = panfrost_upload(&ctx->cmdstream, &shader_meta_2, sizeof(struct mali_shader_meta), false) >> 4;
/* Attributes / varyings */
......
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