Mesa (master): zink: setup compiler options during init
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jan 10 13:11:57 UTC 2021
Module: Mesa
Branch: master
Commit: 6993109713b0618decebdc3657cf27ace1ed83ab
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6993109713b0618decebdc3657cf27ace1ed83ab
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Wed Jan 6 09:57:49 2021 +0100
zink: setup compiler options during init
This avoids duplicating the options just to change a single one.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8402>
---
src/gallium/drivers/zink/zink_compiler.c | 79 +++++++++++++-------------------
src/gallium/drivers/zink/zink_compiler.h | 3 ++
src/gallium/drivers/zink/zink_screen.c | 2 +
src/gallium/drivers/zink/zink_screen.h | 2 +
4 files changed, 39 insertions(+), 47 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 14f84e24e35..cde29572874 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -201,47 +201,36 @@ lower_64bit_vertex_attribs(nir_shader *shader)
return nir_shader_instructions_pass(shader, lower_64bit_vertex_attribs_instr, nir_metadata_dominance, NULL);
}
-static const struct nir_shader_compiler_options nir_options = {
- .lower_ffma16 = true,
- .lower_ffma32 = true,
- .lower_ffma64 = true,
- .lower_scmp = true,
- .lower_fdph = true,
- .lower_flrp32 = true,
- .lower_fpow = true,
- .lower_fsat = true,
- .lower_extract_byte = true,
- .lower_extract_word = true,
- .lower_mul_high = true,
- .lower_rotate = true,
- .lower_uadd_carry = true,
- .lower_pack_64_2x32_split = true,
- .lower_unpack_64_2x32_split = true,
- .use_scoped_barrier = true,
- .lower_int64_options = ~0,
- .lower_doubles_options = ~nir_lower_fp64_full_software,
-};
-
-static const struct nir_shader_compiler_options softfp_nir_options = {
- .lower_ffma16 = true,
- .lower_ffma32 = true,
- .lower_ffma64 = true,
- .lower_scmp = true,
- .lower_fdph = true,
- .lower_flrp32 = true,
- .lower_fpow = true,
- .lower_fsat = true,
- .lower_extract_byte = true,
- .lower_extract_word = true,
- .lower_mul_high = true,
- .lower_rotate = true,
- .lower_uadd_carry = true,
- .lower_pack_64_2x32_split = true,
- .lower_unpack_64_2x32_split = true,
- .use_scoped_barrier = true,
- .lower_int64_options = ~0,
- .lower_doubles_options = ~0,
-};
+void
+zink_screen_init_compiler(struct zink_screen *screen)
+{
+ static const struct nir_shader_compiler_options
+ default_options = {
+ .lower_ffma16 = true,
+ .lower_ffma32 = true,
+ .lower_ffma64 = true,
+ .lower_scmp = true,
+ .lower_fdph = true,
+ .lower_flrp32 = true,
+ .lower_fpow = true,
+ .lower_fsat = true,
+ .lower_extract_byte = true,
+ .lower_extract_word = true,
+ .lower_mul_high = true,
+ .lower_rotate = true,
+ .lower_uadd_carry = true,
+ .lower_pack_64_2x32_split = true,
+ .lower_unpack_64_2x32_split = true,
+ .use_scoped_barrier = true,
+ .lower_int64_options = ~0,
+ .lower_doubles_options = ~nir_lower_fp64_full_software,
+ };
+
+ screen->nir_options = default_options;
+
+ if (!screen->info.feats.features.shaderFloat64)
+ screen->nir_options.lower_doubles_options = ~0;
+}
const void *
zink_get_compiler_options(struct pipe_screen *pscreen,
@@ -249,11 +238,7 @@ zink_get_compiler_options(struct pipe_screen *pscreen,
enum pipe_shader_type shader)
{
assert(ir == PIPE_SHADER_IR_NIR);
- struct zink_screen *screen = zink_screen(pscreen);
- /* do we actually want this? fails a lot and not just from bugs I've added */
- if (!screen->info.feats.features.shaderFloat64)
- return &softfp_nir_options;
- return &nir_options;
+ return &zink_screen(pscreen)->nir_options;
}
struct nir_shader *
@@ -579,7 +564,7 @@ zink_shader_tcs_create(struct zink_context *ctx, struct zink_shader *vs)
ret->shader_id = 0; //special value for internal shaders
ret->programs = _mesa_pointer_set_create(NULL);
- nir_shader *nir = nir_shader_create(NULL, MESA_SHADER_TESS_CTRL, &nir_options, NULL);
+ nir_shader *nir = nir_shader_create(NULL, MESA_SHADER_TESS_CTRL, &zink_screen(ctx->base.screen)->nir_options, NULL);
nir_function *fn = nir_function_create(nir, "main");
fn->is_entrypoint = true;
nir_function_impl *impl = nir_function_impl_create(fn);
diff --git a/src/gallium/drivers/zink/zink_compiler.h b/src/gallium/drivers/zink/zink_compiler.h
index 5e3d8002c1e..bb03fcceb0a 100644
--- a/src/gallium/drivers/zink/zink_compiler.h
+++ b/src/gallium/drivers/zink/zink_compiler.h
@@ -81,6 +81,9 @@ struct zink_shader {
};
};
+void
+zink_screen_init_compiler(struct zink_screen *screen);
+
VkShaderModule
zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct zink_shader_key *key,
unsigned char *shader_slot_map, unsigned char *shader_slots_reserved);
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 89b4e61fc2e..3db568c182f 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1150,6 +1150,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
zink_screen_resource_init(&screen->base);
zink_screen_fence_init(&screen->base);
+ zink_screen_init_compiler(screen);
+
slab_create_parent(&screen->transfer_pool, sizeof(struct zink_transfer), 16);
return screen;
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index d47d9028208..aa16a2ad500 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -29,6 +29,7 @@
#include "pipe/p_screen.h"
#include "util/slab.h"
+#include "compiler/nir/nir.h"
#include <vulkan/vulkan.h>
@@ -59,6 +60,7 @@ struct zink_screen {
VkPhysicalDevice pdev;
struct zink_device_info info;
+ struct nir_shader_compiler_options nir_options;
bool have_X8_D24_UNORM_PACK32;
bool have_D24_UNORM_S8_UINT;
More information about the mesa-commit
mailing list