summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2017-11-06 12:42:51 -0500
committerConnor Abbott <cwabbott0@gmail.com>2017-11-06 12:42:51 -0500
commitda5bdc6f88d4ee24c857591ebfe172c6381659d2 (patch)
treecddc67d7febf84aae41806d783573af70968537e
parenta761b38a3e292c507868ec1ec8d663b3ac9eb51b (diff)
lima: lower matrix ops for standalone compilercwabbott-lima
-rw-r--r--src/gallium/drivers/lima/Makefile.am16
-rw-r--r--src/gallium/drivers/lima/standalone/glsl.cpp35
-rw-r--r--src/gallium/drivers/lima/standalone/glsl.h34
-rw-r--r--src/gallium/drivers/lima/standalone/lima_compiler_cmdline.c (renamed from src/gallium/drivers/lima/lima_compiler_cmdline.c)15
4 files changed, 95 insertions, 5 deletions
diff --git a/src/gallium/drivers/lima/Makefile.am b/src/gallium/drivers/lima/Makefile.am
index 4157aec716..881ecd509e 100644
--- a/src/gallium/drivers/lima/Makefile.am
+++ b/src/gallium/drivers/lima/Makefile.am
@@ -29,6 +29,13 @@ AM_CFLAGS = \
$(GALLIUM_DRIVER_CFLAGS) \
$(LIBDRM_CFLAGS)
+AM_CXXFLAGS = \
+ -I$(top_srcdir)/include/drm-uapi \
+ -I$(top_builddir)/src/compiler/nir \
+ -I$(top_srcdir)/src/compiler/nir \
+ $(GALLIUM_DRIVER_CXXFLAGS) \
+ $(LIBDRM_CXXFLAGS)
+
noinst_LTLIBRARIES = liblima.la
liblima_la_SOURCES = $(C_SOURCES)
@@ -36,13 +43,20 @@ liblima_la_SOURCES = $(C_SOURCES)
noinst_PROGRAMS = lima_compiler
lima_compiler_SOURCES = \
- lima_compiler_cmdline.c
+ standalone/lima_compiler_cmdline.c \
+ standalone/glsl.cpp
lima_compiler_CFLAGS = \
$(AM_CFLAGS) \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/mapi
+lima_compiler_CXXFLAGS = \
+ $(AM_CXXFLAGS) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/mesa \
+ -I$(top_srcdir)/src/mapi
+
lima_compiler_LDADD = \
liblima.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
diff --git a/src/gallium/drivers/lima/standalone/glsl.cpp b/src/gallium/drivers/lima/standalone/glsl.cpp
new file mode 100644
index 0000000000..c769b93bc7
--- /dev/null
+++ b/src/gallium/drivers/lima/standalone/glsl.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Lima Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "standalone/glsl.h"
+#include "compiler/glsl/ir.h"
+#include "compiler/glsl/ir_optimization.h"
+
+void
+lima_do_glsl_optimizations(struct exec_list *ir)
+{
+ _mesa_print_ir(stdout, ir, NULL);
+ do_mat_op_to_vec(ir);
+ _mesa_print_ir(stdout, ir, NULL);
+}
diff --git a/src/gallium/drivers/lima/standalone/glsl.h b/src/gallium/drivers/lima/standalone/glsl.h
new file mode 100644
index 0000000000..2eac88ebac
--- /dev/null
+++ b/src/gallium/drivers/lima/standalone/glsl.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Lima Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void lima_do_glsl_optimizations(struct exec_list *ir);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/src/gallium/drivers/lima/lima_compiler_cmdline.c b/src/gallium/drivers/lima/standalone/lima_compiler_cmdline.c
index 4de26c48d4..847e91552e 100644
--- a/src/gallium/drivers/lima/lima_compiler_cmdline.c
+++ b/src/gallium/drivers/lima/standalone/lima_compiler_cmdline.c
@@ -34,6 +34,7 @@
#include "lima_program.h"
#include "lima_context.h"
#include "ir/lima_ir.h"
+#include "standalone/glsl.h"
static void
print_usage(void)
@@ -82,10 +83,14 @@ fixup_varying_slots(struct exec_list *var_list)
int
main(int argc, char **argv)
{
- int n = 1;
-
- while (n < argc) {
- if (!strcmp(argv[n], "--help")) {
+ int n;
+
+ for (n = 1; n < argc; n++) {
+ if (!strcmp(argv[n], "--debug")) {
+ lima_shader_debug_gp = true;
+ lima_shader_debug_pp = true;
+ continue;
+ } else if (!strcmp(argv[n], "--help")) {
print_usage();
return 0;
}
@@ -122,6 +127,8 @@ main(int argc, char **argv)
if (!prog)
errx(1, "couldn't parse `%s'", filename[0]);
+ lima_do_glsl_optimizations(prog->_LinkedShaders[stage]->ir);
+
nir_shader *nir = glsl_to_nir(prog, stage,
lima_program_get_compiler_options(shader));