diff options
author | Matt Turner <[email protected]> | 2018-12-10 11:06:16 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2019-01-09 16:42:41 -0800 |
commit | 613ac3aaa295ad2a6271ee8315e16ee31456fa9d (patch) | |
tree | adbea420332b7522ef0a59bf5b94ec7159a5586f /src/mesa/drivers/dri/i965 | |
parent | 18b4e87370d3ebb9d7dbb51e58b2da1b64a2227f (diff) |
i965: Compile fp64 software routines and lower double-ops
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r-- | src/mesa/drivers/dri/i965/Makefile.am | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.c | 61 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/meson.build | 2 |
3 files changed, 63 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/Makefile.am b/src/mesa/drivers/dri/i965/Makefile.am index 3df8cdec320..491d3c8f780 100644 --- a/src/mesa/drivers/dri/i965/Makefile.am +++ b/src/mesa/drivers/dri/i965/Makefile.am @@ -26,6 +26,7 @@ include Makefile.sources AM_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/ \ + -I$(top_builddir)/src/ \ -I$(top_srcdir)/src/mapi \ -I$(top_srcdir)/src/mesa/ \ -I$(top_srcdir)/src/gallium/include \ diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 730d6dc0d5a..168a2bd5f50 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -41,6 +41,7 @@ #include "util/ralloc.h" #include "compiler/glsl/ir.h" #include "compiler/glsl/glsl_to_nir.h" +#include "compiler/glsl/float64_glsl.h" #include "brw_program.h" #include "brw_context.h" @@ -53,6 +54,9 @@ #include "brw_vs.h" #include "brw_wm.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" + static bool brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar) { @@ -67,6 +71,54 @@ brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar) } } +static struct gl_program *brwNewProgram(struct gl_context *ctx, GLenum target, + GLuint id, bool is_arb_asm); + +static nir_shader * +compile_fp64_funcs(struct gl_context *ctx, + const nir_shader_compiler_options *options, + void *mem_ctx, + gl_shader_stage stage) +{ + const GLuint name = ~0; + struct gl_shader *sh; + + sh = _mesa_new_shader(name, stage); + + sh->Source = float64_source; + sh->CompileStatus = COMPILE_FAILURE; + _mesa_compile_shader(ctx, sh); + + if (!sh->CompileStatus) { + if (sh->InfoLog) { + _mesa_problem(ctx, + "fp64 software impl compile failed:\n%s\nsource:\n%s\n", + sh->InfoLog, float64_source); + } + } + + struct gl_shader_program *sh_prog; + sh_prog = _mesa_new_shader_program(name); + sh_prog->Label = NULL; + sh_prog->NumShaders = 1; + sh_prog->Shaders = malloc(sizeof(struct gl_shader *)); + sh_prog->Shaders[0] = sh; + + struct gl_linked_shader *linked = rzalloc(NULL, struct gl_linked_shader); + linked->Stage = stage; + linked->Program = + brwNewProgram(ctx, + _mesa_shader_stage_to_program(stage), + name, false); + + linked->ir = sh->ir; + sh_prog->_LinkedShaders[stage] = linked; + + nir_shader *nir = glsl_to_nir(sh_prog, stage, options); + + return nir_shader_clone(mem_ctx, nir); +} + nir_shader * brw_create_nir(struct brw_context *brw, const struct gl_shader_program *shader_prog, @@ -101,6 +153,15 @@ brw_create_nir(struct brw_context *brw, } nir_validate_shader(nir, "before brw_preprocess_nir"); + nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); + + if (nir->info.uses_64bit) { + nir_shader *fp64 = compile_fp64_funcs(ctx, options, ralloc_parent(nir), stage); + + nir_validate_shader(fp64, "fp64"); + exec_list_append(&nir->functions, &fp64->functions); + } + nir = brw_preprocess_nir(brw->screen->compiler, nir); NIR_PASS_V(nir, brw_nir_lower_image_load_store, devinfo); diff --git a/src/mesa/drivers/dri/i965/meson.build b/src/mesa/drivers/dri/i965/meson.build index 24172955e9b..3b71cf2605b 100644 --- a/src/mesa/drivers/dri/i965/meson.build +++ b/src/mesa/drivers/dri/i965/meson.build @@ -213,7 +213,7 @@ endif libi965 = static_library( 'i965', [files_i965, i965_oa_sources, ir_expression_operation_h, - xmlpool_options_h], + xmlpool_options_h, float64_glsl_h], include_directories : [ inc_common, inc_intel, inc_dri_common, inc_util, inc_drm_uapi, ], |