Commit 0087a9dc authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Begin removing freedreno-specific code in midgard

Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa@rosenzweig.io>
parent 14428e29
/*
* Copyright (C) 2014 Rob Clark <robclark@freedesktop.org>
* Copyright (C) 2018 Alyssa Rosenzweig <alyssa@rosenzweig.io>
......@@ -36,17 +35,6 @@
#include <stdio.h>
#include <err.h>
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_text.h"
#include "tgsi/tgsi_dump.h"
#include "freedreno_util.h"
#include "ir3_compiler.h"
#include "ir3_nir.h"
#include "instr-a3xx.h"
#include "ir3.h"
#include "compiler/glsl/standalone.h"
#include "compiler/glsl/glsl_to_nir.h"
#include "compiler/nir_types.h"
......@@ -55,7 +43,7 @@ static void dump_info(struct ir3_shader_variant *so, const char *str)
{
uint32_t *bin;
const char *type = ir3_shader_stage(so->shader);
bin = ir3_shader_assemble(so, so->shader->compiler->gpu_id);
bin = ir3_shader_assemble(so);
debug_printf("; %s: %s\n", type, str);
ir3_shader_disasm(so, bin);
free(bin);
......@@ -98,7 +86,22 @@ fixup_varying_slots(struct exec_list *var_list)
}
}
static struct ir3_compiler *compiler;
static const nir_shader_compiler_options nir_options = {
.lower_fpow = true,
.lower_fsat = true,
.lower_scmp = true,
.lower_flrp32 = true,
.lower_flrp64 = true,
.lower_ffract = true,
.lower_fmod32 = true,
.lower_fmod64 = true,
.lower_fdiv = true,
.fuse_ffma = true,
.native_integers = true,
.vertex_id_zero_based = true,
.lower_extract_byte = true,
.lower_extract_word = true,
};
static nir_shader *
load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
......@@ -113,7 +116,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
if (!prog)
errx(1, "couldn't parse `%s'", files[0]);
nir_shader *nir = glsl_to_nir(prog, stage, ir3_get_compiler_options(compiler));
nir_shader *nir = glsl_to_nir(prog, stage, nir_options);
/* required NIR passes: */
/* TODO cmdline args for some of the conditional lowering passes? */
......@@ -199,7 +202,7 @@ read_file(const char *filename, void **ptr, size_t *size)
static void print_usage(void)
{
printf("Usage: ir3_compiler [OPTIONS]... <file.tgsi | (file.vert | file.frag)*>\n");
printf("Usage: midgard_compiler [OPTIONS]... <(file.vert | file.frag)*>\n");
printf(" --verbose - verbose compiler/debug messages\n");
printf(" --binning-pass - generate binning pass shader (VERT)\n");
printf(" --color-two-side - emulate two-sided color (FRAG)\n");
......@@ -210,7 +213,6 @@ static void print_usage(void)
printf(" --astc-srgb MASK - bitmask of samplers to enable astc-srgb workaround\n");
printf(" --stream-out - enable stream-out (aka transform feedback)\n");
printf(" --ucp MASK - bitmask of enabled user-clip-planes\n");
printf(" --gpu GPU_ID - specify gpu-id (default 320)\n");
printf(" --help - show this message\n");
}
......@@ -223,8 +225,6 @@ int main(int argc, char **argv)
struct ir3_shader_variant v;
struct ir3_shader s;
struct ir3_shader_key key = {};
/* TODO cmdline option to target different gpus: */
unsigned gpu_id = 320;
const char *info;
void *ptr;
size_t size;
......@@ -320,13 +320,6 @@ int main(int argc, char **argv)
continue;
}
if (!strcmp(argv[n], "--gpu")) {
debug_printf(" %s %s", argv[n], argv[n+1]);
gpu_id = strtol(argv[n+1], NULL, 0);
n += 2;
continue;
}
if (!strcmp(argv[n], "--help")) {
print_usage();
return 0;
......@@ -340,19 +333,11 @@ int main(int argc, char **argv)
char *filename = argv[n];
char *ext = rindex(filename, '.');
if (strcmp(ext, ".tgsi") == 0) {
if (num_files != 0)
errx(1, "in TGSI mode, only a single file may be specified");
s.from_tgsi = true;
} else if (strcmp(ext, ".frag") == 0) {
if (s.from_tgsi)
errx(1, "cannot mix GLSL and TGSI");
if (strcmp(ext, ".frag") == 0) {
if (num_files >= ARRAY_SIZE(filenames))
errx(1, "too many GLSL files");
stage = MESA_SHADER_FRAGMENT;
} else if (strcmp(ext, ".vert") == 0) {
if (s.from_tgsi)
errx(1, "cannot mix GLSL and TGSI");
if (num_files >= ARRAY_SIZE(filenames))
errx(1, "too many GLSL files");
stage = MESA_SHADER_VERTEX;
......@@ -368,28 +353,7 @@ int main(int argc, char **argv)
nir_shader *nir;
compiler = ir3_compiler_create(NULL, gpu_id);
if (s.from_tgsi) {
struct tgsi_token toks[65536];
ret = read_file(filenames[0], &ptr, &size);
if (ret) {
print_usage();
return ret;
}
if (fd_mesa_debug & FD_DBG_OPTMSGS)
debug_printf("%s\n", (char *)ptr);
if (!tgsi_text_translate(ptr, toks, ARRAY_SIZE(toks)))
errx(1, "could not parse `%s'", filenames[0]);
if (fd_mesa_debug & FD_DBG_OPTMSGS)
tgsi_dump(toks, 0);
nir = ir3_tgsi_to_nir(toks);
} else if (num_files > 0) {
if (num_files > 0) {
nir = load_glsl(num_files, filenames, stage);
} else {
print_usage();
......
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