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

Dynamic assemble/compile selection

parent 7488dbff
......@@ -298,7 +298,7 @@ void panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header
panwrap_log("};\n");
TOUCH(smem, shader_meta_ptr, *meta, "shader_meta", job_no, false);
panwrap_shader_disassemble(shader_ptr, job_no);
panwrap_shader_disassemble(shader_ptr, job_no, h->job_type);
} else
panwrap_msg("<no shader>\n");
......
......@@ -13,6 +13,7 @@
*/
#include "panwrap.h"
#include "panwrap-shader.h"
#include <mali-ioctl.h>
#include <mali-job.h>
#include <stdio.h>
......@@ -34,7 +35,7 @@
/* Disassemble the shader itself. */
void
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no)
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
{
struct panwrap_mapped_memory *shaders = panwrap_find_mapped_gpu_mem_containing(shader_ptr);
ptrdiff_t offset = shader_ptr - shaders->gpu_va;
......@@ -47,16 +48,18 @@ panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no)
/* ...but reassemble at runtime! */
panwrap_log("pandev_shader_assemble(%s + %d, shader_src_%d);\n\n",
panwrap_log("pandev_shader_%s(%s + %d, shader_src_%d, %d);\n\n",
type == SHADER_FRAGMENT ? "compile" : "assemble",
shaders->name,
offset / sizeof(uint32_t),
shader_no);
shader_no,
type);
}
#else
void
panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no)
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);
......
......@@ -19,6 +19,9 @@
#include <mali-job.h>
#include "panwrap.h"
void panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no);
#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);
#endif /* !PANWRAP_SHADER_H */
......@@ -25,7 +25,7 @@
/* TODO: Interface with Python C API directly? */
void
pandev_shader_assemble(uint32_t *dst, const char *src)
pandev_shader_assemble(uint32_t *dst, const char *src, int type)
{
FILE *fp0 = fopen("/dev/shm/shader.asm", "w");
fwrite(src, 1, strlen(src), fp0);
......@@ -49,7 +49,7 @@ pandev_shader_assemble(uint32_t *dst, const char *src)
/* TODO: Actually interface with Mesa here */
void
pandev_shader_compile(uint32_t *dst, const char *src, int fragment)
pandev_shader_compile(uint32_t *dst, const char *src, int type)
{
FILE *fp0 = fopen("/dev/shm/shader.glsl", "w");
fwrite(src, 1, strlen(src), fp0);
......@@ -57,7 +57,7 @@ pandev_shader_compile(uint32_t *dst, const char *src, int fragment)
/* TODO interface with compiler */
FILE *fp1 = fopen(fragment ? "/dev/shm/fragment.bin" : "/dev/shm/vertex.bin", "rb");
FILE *fp1 = fopen(type == JOB_TYPE_TILER ? "/dev/shm/fragment.bin" : "/dev/shm/vertex.bin", "rb");
fseek(fp1, 0, SEEK_END);
size_t sz = ftell(fp1);
......
......@@ -32,8 +32,8 @@ int pandev_ioctl(int fd, unsigned long request, void *args);
int pandev_standard_allocate(int fd, int va_pages, int flags, u64 *out);
int pandev_general_allocate(int fd, int va_pages, int commit_pages, int extent, int flags, u64 *out);
void pandev_shader_assemble(uint32_t *dst, const char *src);
void pandev_shader_compile(uint32_t *dst, const char *src, int fragment);
void pandev_shader_assemble(uint32_t *dst, const char *src, int type);
void pandev_shader_compile(uint32_t *dst, const char *src, int type);
off_t pandev_allocate_offset(off_t *stack, size_t sz);
mali_ptr pandev_upload(int cheating_offset, mali_ptr base, void *base_map, void *data, size_t sz);
......
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