-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shader analysis with malioc #39005
Merged
Merged
Shader analysis with malioc #39005
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2013 The Flutter Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//build/compiled_action.gni") | ||
import("//flutter/common/config.gni") | ||
import("//flutter/impeller/tools/malioc.gni") | ||
import("//flutter/testing/testing.gni") | ||
|
||
declare_args() { | ||
# Maximum number of malioc processes to run in parallel. | ||
# | ||
# To avoid out-of-memory errors we explicitly reduce the number of jobs. | ||
impeller_concurrent_malioc_jobs = -1 | ||
} | ||
|
||
if (impeller_concurrent_malioc_jobs == -1) { | ||
_script = "//flutter/build/get_concurrent_jobs.py" | ||
_args = [ | ||
"--reserve-memory=1GB", | ||
"--memory-per-job", | ||
"malioc=100MB", | ||
] | ||
_concurrent_jobs = exec_script(_script, _args, "json", [ _script ]) | ||
impeller_concurrent_malioc_jobs = _concurrent_jobs.malioc | ||
assert(impeller_concurrent_malioc_jobs > 0) | ||
} | ||
|
||
pool("malioc_pool") { | ||
depth = impeller_concurrent_malioc_jobs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Copyright 2013 The Flutter Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//build/compiled_action.gni") | ||
import("//flutter/common/config.gni") | ||
import("//flutter/testing/testing.gni") | ||
|
||
declare_args() { | ||
# Path to the Mali offline compiler tool 'malioc'. | ||
impeller_malioc_path = "" | ||
|
||
impeller_malioc_cores = [] | ||
} | ||
|
||
if (impeller_malioc_path != "" && impeller_malioc_cores == []) { | ||
core_list_file = "$root_gen_dir/mali_core_list.json" | ||
exec_script("//build/gn_run_binary.py", | ||
[ | ||
rebase_path(impeller_malioc_path, root_build_dir), | ||
"--list", | ||
"--format", | ||
"json", | ||
"--output", | ||
rebase_path(core_list_file), | ||
]) | ||
_mali_cores = read_file(core_list_file, "json") | ||
foreach(mali_core, _mali_cores.cores) { | ||
impeller_malioc_cores += [ mali_core.core ] | ||
} | ||
} | ||
|
||
template("malioc_analyze_shaders") { | ||
# TODO(zra): Check that gles_language_version is in the supported set. For now | ||
# assume that if it is set, it is being set to 460, which malioc does not | ||
# support. | ||
if (impeller_malioc_path == "" || defined(invoker.gles_language_version)) { | ||
if (defined(invoker.gles_language_version) && | ||
invoker.gles_language_version != "460") { | ||
print("Disabling analysis for shaders in $target_name due to gles", | ||
"version explicitly set to ${invoker.gles_language_version}.") | ||
} | ||
group(target_name) { | ||
not_needed(invoker, "*") | ||
} | ||
} else { | ||
target_deps = [] | ||
foreach(core, impeller_malioc_cores) { | ||
foreach(source, invoker.shaders) { | ||
shader_file_name = get_path_info(source, "name") | ||
analysis_target = "${target_name}_${shader_file_name}_${core}_malioc" | ||
target_deps += [ ":$analysis_target" ] | ||
action(analysis_target) { | ||
forward_variables_from(invoker, | ||
"*", | ||
[ | ||
"args", | ||
"depfile", | ||
"inputs", | ||
"outputs", | ||
"pool", | ||
"script", | ||
]) | ||
|
||
script = "//build/gn_run_binary.py" | ||
pool = "//flutter/impeller/tools:malioc_pool" | ||
|
||
# Should be "gles" or "vkspv" | ||
backend_ext = get_path_info(source, "extension") | ||
assert(backend_ext == "gles", | ||
"Shader for unsupported backend passed to malioc: {{source}}") | ||
|
||
# Nest all malioc output under its own subdirectory of root_gen_dir | ||
# so that it's easier to diff it against the state before any changes. | ||
subdir = rebase_path(target_gen_dir, root_gen_dir) | ||
output_file = | ||
"$root_gen_dir/malioc/$subdir/${shader_file_name}.$core.json" | ||
outputs = [ output_file ] | ||
|
||
# Determine the kind of the shader from the file name | ||
name = get_path_info(source, "name") | ||
shader_kind_ext = get_path_info(name, "extension") | ||
|
||
if (shader_kind_ext == "comp") { | ||
shader_kind_flag = "--compute" | ||
} else if (shader_kind_ext == "frag") { | ||
shader_kind_flag = "--fragment" | ||
} else if (shader_kind_ext == "geom") { | ||
shader_kind_flag = "--geometry" | ||
} else if (shader_kind_ext == "tesc") { | ||
shader_kind_flag = "--tessellation_control" | ||
} else if (shader_kind_ext == "tese") { | ||
shader_kind_flag = "--tessellation_evaluation" | ||
} else if (shader_kind_ext == "vert") { | ||
shader_kind_flag = "--vertex" | ||
} else { | ||
assert(false, "Unknown shader kind: {{source}}") | ||
} | ||
|
||
args = [ | ||
rebase_path(impeller_malioc_path, root_build_dir), | ||
"--format", | ||
"json", | ||
shader_kind_flag, | ||
"--core", | ||
core, | ||
"--output", | ||
rebase_path(output_file), | ||
] | ||
|
||
if (backend_ext == "vkspv") { | ||
args += [ "--vulkan" ] | ||
} | ||
|
||
args += [ rebase_path(source) ] | ||
} | ||
} | ||
} | ||
|
||
group(target_name) { | ||
deps = target_deps | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonahwilliams ssbos requires a higher language version, so when any language version is set, analysis is skipped. This TODO is for tightening this logic to match what the analyzer supports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense!