Commit b514268e authored by Connor Abbott's avatar Connor Abbott

WIP

parent 89474960
......@@ -191,7 +191,7 @@ enum mali_fbd_type {
#define FBD_TYPE (1)
#define FBD_MASK (~0x3f)
struct mali_payload_vertex_tiler {
struct mali_payload_vertex_tiler_32 {
/* Exactly as passed to glLineWidth */
float line_width;
......@@ -246,6 +246,113 @@ struct mali_payload_vertex_tiler {
} __attribute__((packed));
//ASSERT_SIZEOF_TYPE(struct mali_payload_vertex_tiler, 256, 256);
struct mali_payload_vertex_tiler_64 {
/* Off by one */
u32 vertex_count;
u32 unk1; // 0x28000000
u32 draw_mode;
u32 zero0;
u32 zero1;
/* Like many other strictly nonzero quantities, index_count is
* subtracted by one. For an indexed cube, this is equal to 35 = 6
* faces * 2 triangles/per face * 3 vertices/per triangle - 1. For
* non-indexed draws, equal to vertex_count. */
u32 index_count;
/* No hidden structure; literally just a pointer to an array of
* uint32_t indices. Thanks, guys, for not making my life insane for
* once! NULL for non-indexed draws. */
/* XXX verify this */
uintptr_t indices;
/* 0x20 */
u32 unk2; /* =0x2 */
u32 zero2;
u64 zero3;
/* 0x30 */
mali_ptr zero4;
mali_ptr unknown2;
/* 0x40 */
u64 zero5, zero6;
/* 0x50 */
mali_ptr uniforms;
u8 flags : 4;
uintptr_t _shader_upper : MALI_SHORT_PTR_BITS - 4; /* struct shader_meta */
/* 0x60 */
mali_ptr unknown5;
mali_ptr unknown6;
/* 0x70 */
mali_ptr unknown7;
mali_ptr unknown8;
/* 0x80 */
u64 zero7, zero8;
/* 0x90 */
mali_ptr framebuffer;
u64 zero9;
} __attribute__((packed));
/* Bifrost added a new specialized tiler payload */
struct mali_payload_tiler_bfr {
/* Off by one */
u32 vertex_count;
u32 unk1; /* 0x28000000 */
u32 draw_mode;
u32 zero0;
u32 zero1;
/* Like many other strictly nonzero quantities, index_count is
* subtracted by one. For an indexed cube, this is equal to 35 = 6
* faces * 2 triangles/per face * 3 vertices/per triangle - 1. For
* non-indexed draws, equal to vertex_count. */
u32 index_count;
/* No hidden structure; literally just a pointer to an array of
* uint32_t indices. Thanks, guys, for not making my life insane for
* once! NULL for non-indexed draws. */
/* XXX verify this */
uintptr_t indices;
/* 0x20 */
float line_width;
u32 zero2;
mali_ptr unknown0;
/* 0x30 */
u64 zero3, zero4, zero5, zero6, zero7, zero8;
/* 0x60 */
u32 gl_enables;
u32 zero9;
u64 zero10;
/* 0x70 */
mali_ptr unknown1;
mali_ptr unknown2;
u64 zero11, zero12;
/* 0x90 */
mali_ptr unknown3;
mali_ptr unknown4;
u64 zero13, zero14;
/* 0xB0 */
mali_ptr unknown5;
u64 zero15;
/* 0xC0 */
mali_ptr unknown6;
u64 zero16;
/* 0xD0 */
mali_ptr unknown7;
u64 zero17;
} __attribute__((packed));
/* Pointed to from texture_trampoline, mostly unknown still, haven't
* managed to replay successfully */
......@@ -372,9 +479,6 @@ struct mali_unknown6 {
#define MALI_COORDINATE_TO_TILE_MAX(W, H, flag) MALI_COORDINATE_TO_TILE(W, H, flag, 1)
struct mali_payload_fragment {
/* XXX: WTF? */
u32 zero;
/* XXX: we might be able to translate these into bitfields someday, but
* that will only be sensible if the mask of flags is limited to
* 0xF0000000 or 0x0000F000. If it's 0xF000F000, feel free to just
......
This diff is collapsed.
......@@ -84,10 +84,23 @@ void replay_memory()
{
struct panwrap_mapped_memory *pos;
panwrap_msg("/proc/self/maps:\n");
FILE *fd = fopen("/proc/self/maps", "r");
if (!fd)
panwrap_msg("Error opening!\n");
int c;
while (EOF != (c = fgetc(fd)))
putchar(c);
fclose(fd);
list_for_each_entry(pos, &mmaps, node) {
/* If we don't have write access, no replay :) */
if (!(pos->flags & MALI_MEM_PROT_CPU_WR)) continue;
panwrap_msg("addr: %p, length: %zd flags: %d\n", pos->addr, pos->length, pos->flags);
fflush(stdout);
fflush(stderr);
if (pos->flags & MALI_MEM_PROT_GPU_EX) {
/* Shader memory get dumped but not replayed, as the
* dis/assembler is setup in-tree as it is. */
......@@ -107,6 +120,9 @@ void replay_memory()
uint32_t *array = (uint32_t *) pos->addr;
for (uint32_t i = 0; i < pos->length / sizeof(uint32_t); ++i) {
panwrap_msg("addr: %p\n", &array[i]);
fflush(stdout);
fflush(stderr);
if (array[i])
panwrap_log("%s%s[%d] = %s;\n", pos->touched[i] ? "// " : "", pos->name, i, pointer_as_memory_reference(array[i]));
}
......@@ -173,6 +189,8 @@ void panwrap_track_mmap(mali_ptr gpu_va, void *addr, size_t length,
mapped_mem->gpu_va = gpu_va;
}
panwrap_msg("mapped %zd bytes to " MALI_PTR_FMT "\n", length, mapped_mem->gpu_va);
mapped_mem->length = length;
mapped_mem->addr = addr;
mapped_mem->prot = prot;
......
......@@ -25,17 +25,11 @@
* be integrated here as well in the near future, once an assembler is written
* for that platform. */
/* TODO: expose in meson so Lyude doesn't get annoyed at me for breaking
* Bifrost */
#define SHADER_MIDGARD
#ifdef SHADER_MIDGARD
/* Disassemble the shader itself. */
void
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
bool bifrost)
{
struct panwrap_mapped_memory *shaders = panwrap_find_mapped_gpu_mem_containing(shader_ptr);
ptrdiff_t offset = shader_ptr - shaders->gpu_va;
......@@ -43,7 +37,10 @@ panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
/* Disassemble it at trace time... */
panwrap_log("const char shader_src_%d[] = R\"(\n", shader_no);
DisassembleMidgard(shaders->addr + offset, shaders->length - offset);
if (bifrost)
DisassembleBifrost(shaders->addr + offset, shaders->length - offset);
else
DisassembleMidgard(shaders->addr + offset, shaders->length - offset);
panwrap_log(")\";\n\n");
/* ...but reassemble at runtime! */
......@@ -56,13 +53,3 @@ panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
type);
}
#else
void
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
{
panwrap_msg("Shader decoding is not yet supported on non-Midgard platforms\n");
panwrap_msg("No disassembly performed for shader at " MALI_PTR_FMT, shader_ptr);
}
#endif
......@@ -22,6 +22,7 @@
#define SHADER_VERTEX JOB_TYPE_VERTEX
#define SHADER_FRAGMENT JOB_TYPE_TILER
void panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type);
void panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
bool bifrost);
#endif /* !PANWRAP_SHADER_H */
......@@ -1014,6 +1014,8 @@ int ioctl(int fd, int _request, ...)
if (!panwrap_indent)
ignore = true;
panwrap_msg("case: %ld\n", IOCTL_CASE(request));
/* Queries are not interesting for replay */
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_MEM_QUERY))
ignore = true;
......@@ -1067,8 +1069,12 @@ int ioctl(int fd, int _request, ...)
ioctl_decode_pre(request, ptr);
}
panwrap_msg("got here\n");
ret = orig_ioctl(fd, request, ptr);
panwrap_msg("got here 2\n");
/* Track memory allocation if needed */
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_MEM_ALLOC)) {
const struct mali_ioctl_mem_alloc *args = ptr;
......@@ -1119,6 +1125,8 @@ int ioctl(int fd, int _request, ...)
panwrap_log_flush();
getchar();
}
panwrap_msg("got here 3\n");
out:
UNLOCK();
return ret;
......@@ -1184,6 +1192,7 @@ int munmap(void *addr, size_t length)
return orig_munmap(addr, length);
LOCK();
panwrap_msg("unmapped 0x%p, length %zd\n", addr, length);
ret = orig_munmap(addr, length);
mem = panwrap_find_mapped_mem(addr);
if (!mem)
......
......@@ -132,7 +132,7 @@ trans_attr(mali_ptr data, size_t type_sz, int columns, int vertices)
/* Vertex/tiler payload */
void
trans_rasterizer_state(struct mali_payload_vertex_tiler *vt,
trans_rasterizer_state(struct mali_payload_vertex_tiler_32 *vt,
float line_width,
int front_face)
{
......
......@@ -30,7 +30,7 @@ trans_viewport(int viewport_x0, int viewport_y0,
int viewport_x1, int viewport_y1);
void
trans_rasterizer_state(struct mali_payload_vertex_tiler *vt,
trans_rasterizer_state(struct mali_payload_vertex_tiler_32 *vt,
float line_width,
int front_face);
......
......@@ -261,7 +261,7 @@ int main(void) {
mali_ptr unknown6_1_p = pandev_upload(-1, alloc_gpu_va_19, memory_19, &unknown6_1, sizeof(unknown6_1), false);
struct mali_payload_vertex_tiler payload_1 = {
struct mali_payload_vertex_tiler_32 payload_1 = {
.vertex_count = MALI_POSITIVE(3),
.unk1 = 0x28000000,
.draw_mode = 0x14000000,
......@@ -326,7 +326,7 @@ int main(void) {
mali_ptr unknown6_2_p = pandev_upload(-1, alloc_gpu_va_19, memory_19, &unknown6_2, sizeof(unknown6_2), false);
struct mali_payload_vertex_tiler payload_2 = {
struct mali_payload_vertex_tiler_32 payload_2 = {
.vertex_count = MALI_POSITIVE(3),
.unk1 = 0x28000000,
.draw_mode = 0x18030000 | MALI_GL_TRIANGLES,
......
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