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

Merge branch 'bifrost_disassembler' into 'master'

Adds Bifrost boilerplate to the Panfrost driver

See merge request !11
parents 05275151 2ffb6f64
/*
* Copyright (C) 2018 Ryan Houdek <Sonicadvance1@gmail.com>
*
* 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, sublicense,
* 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 NONINFRINGEMENT. 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 "compiler/glsl/glsl_to_nir.h"
#include "compiler/nir_types.h"
#include "main/imports.h"
#include "compiler/nir/nir_builder.h"
#include "util/half_float.h"
#include "util/register_allocate.h"
#include "util/u_dynarray.h"
#include "util/list.h"
#include "main/mtypes.h"
#include "bifrost_compile.h"
int
bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program) {
nir_print_shader(nir, stdout);
return 0;
}
/*
* Copyright (C) 2018 Ryan Houdek <Sonicadvance1@gmail.com>
*
* 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, sublicense,
* 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 NONINFRINGEMENT. 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 "compiler/nir/nir.h"
typedef struct {
} bifrost_program;
int
bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program);
static const nir_shader_compiler_options bifrost_nir_options = {
.lower_ffma = true,
.lower_sub = true,
.lower_fpow = true,
.lower_scmp = true,
.lower_flrp32 = true,
.lower_flrp64 = true,
.lower_ffract = true,
.lower_fmod32 = true,
.lower_fmod64 = true,
.lower_fdiv = true,
.lower_idiv = true,
.vertex_id_zero_based = true,
.lower_extract_byte = true,
.lower_extract_word = true,
.native_integers = true
};
/*
* Copyright (C) 2018 Ryan Houdek <Sonicadvance1@gmail.com>
*
* 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, sublicense,
* 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 NONINFRINGEMENT. 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 "compiler/glsl/standalone.h"
#include "compiler/glsl/glsl_to_nir.h"
#include "compiler/nir_types.h"
#include "bifrost_compile.h"
#include "disassemble.h"
#include "util/u_dynarray.h"
#include "main/mtypes.h"
static void
compile_shader(char **argv)
{
struct gl_shader_program *prog;
nir_shader *nir;
struct standalone_options options = {
.glsl_version = 140,
.do_link = true,
};
prog = standalone_compile_shader(&options, 2, argv);
prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = MESA_SHADER_FRAGMENT;
bifrost_program compiled;
nir = glsl_to_nir(prog, MESA_SHADER_VERTEX, &bifrost_nir_options);
bifrost_compile_shader_nir(nir, &compiled);
nir = glsl_to_nir(prog, MESA_SHADER_FRAGMENT, &bifrost_nir_options);
bifrost_compile_shader_nir(nir, &compiled);
}
int
main(int argc, char **argv)
{
if (argc < 2) {
printf("Pass a command\n");
exit(1);
}
if (strcmp(argv[1], "compile") == 0) {
compile_shader(&argv[2]);
}
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Copyright (C) 2018 Connor Abbott <cwabbott0@gmail.com>
* Copyright (C) 2018 Lyude Paul <thatslyude@gmail.com>
* Copyright (C) 2018 Ryan Houdek <Sonicadvance1@gmail.com>
*
* 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, sublicense,
* 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 NONINFRINGEMENT. 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 <stddef.h>
void disassemble_bifrost(uint8_t *code, size_t size);
......@@ -28,6 +28,9 @@ files_panfrost = files(
'midgard/cppwrap.cpp',
'midgard/disassemble.c',
'bifrost/bifrost_compile.c',
'bifrost/disassemble.c',
'pan_context.c',
'pan_nondrm.c',
......@@ -68,6 +71,7 @@ libpanfrost = static_library(
inc_include,
inc_src,
include_directories('midgard'),
include_directories('bifrost'),
include_directories('include')
],
c_args : [c_vis_args, c_msvc_compat_args],
......@@ -85,6 +89,12 @@ files_midgard = files(
'midgard/cmdline.c',
)
files_bifrost = files(
'bifrost/bifrost_compile.c',
'bifrost/disassemble.c',
'bifrost/cmdline.c',
)
midgard_compiler = executable(
'midgard_compiler',
[files_midgard, midgard_nir_algebraic_c],
......@@ -108,4 +118,27 @@ midgard_compiler = executable(
build_by_default : true
)
bifrost_compiler = executable(
'bifrost_compiler',
[files_bifrost],
include_directories : [
inc_common,
inc_src,
inc_include,
inc_gallium,
inc_gallium_aux,
include_directories('bifrost')
],
dependencies : [
dep_thread,
idep_nir
],
link_with : [
libgallium,
libglsl_standalone,
libmesa_util
],
build_by_default : true
)
subdir('panwrap')
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