Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGenerate shaders in build time instead of run time #2891
Conversation
| fn get_shader_source(shader_name: &str, shaders: &HashMap<String, String>) -> Option<String> { | ||
| if let Some(shader_file) = shaders.get(shader_name) { | ||
| let shader_file_path = Path::new(shader_file); | ||
| if let Ok(mut shader_source_file) = File::open(shader_file_path) { |
This comment has been minimized.
This comment has been minimized.
| let mut file = File::open("res/shaders.ron").expect("Unable to open shaders.ron"); | ||
| let mut source = String::new(); | ||
| file.read_to_string(&mut source).expect("Unable to read shaders.ron"); | ||
| let shader_configs: Vec<Shader> = de::from_str(&source).expect("Unable to deserialize shaders.ron"); |
This comment has been minimized.
This comment has been minimized.
| ], | ||
| ),// [18] | ||
| ( | ||
| name: "pf_vector_stencil", |
This comment has been minimized.
This comment has been minimized.
| @@ -16,8 +16,6 @@ struct Shader { | |||
| features: &'static [&'static str], | |||
| } | |||
|
|
|||
| const SHADER_PREFIX: &str = "#define WR_MAX_VERTEX_TEXTURE_WIDTH 1024\n"; | |||
This comment has been minimized.
This comment has been minimized.
kvark
Jul 12, 2018
Member
why does the shader validator need to have a separate list of shaders and features, given that we already have them described in RON?
4ebd0e8
to
d969a8a
|
@kvark I have addressed your comments. The validator now loads the shader configs from the RON file, however I had to add a list of excluded features, because the extensions used by these features are not supported by the angle validator. |
|
@kvark Looks like this is ready to go? |
|
@gw3583 Thanks for looking (I assume you did, right?) |
|
|
Generate shaders in build time instead of run time The discussion about this stared here: szeged#197 (comment) 1. Added a helper `shaders.ron` file which contains the possible feature sets for each shader. 2. In the build script we generate shaders using the information from this `ron` file, for each possible feature configuration. The generated shader file names contain the feature names in lower case separated by a `_`. The shader processing code parts (get_shader_source, parse_shader_source, build_shader_strings) are moved in the build script from `device/gl.rs`. 3. In run-time we pass the base name of the shader and the used features to load the proper shader file. There is a hacky [part](master...szeged:build-shadersdiff-0ad2b4b9ac27cf5624c19208f294d671R186), because we don't always know which shader version (GL or GLES) we intend to use in build time. Replacing it in run-time, if we differ from the default `#version 150` (GL), seemed the best solution. @kvark, @gw3583 could you please take a look? <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2891) <!-- Reviewable:end -->
|
|
|
I'm guessing this PR is the one that broke firefox CI with shader errors: https://treeherder.mozilla.org/#/jobs?repo=try&revision=059d4f6b01e13547633496cc649c76b0f8c6e282 |
|
@staktrace that is unfortunate. Reverting in #2912 until the Gecko side is clear. |
Revert #2891 - shader generation at build time due to #2891 (comment) r? @staktrace cc @zakorgy <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2912) <!-- Reviewable:end -->
|
@staktrace could you please point me how can I reproduce the error from the CI. I'm not familiar with gecko tests, and it would be nice to know which command/script should I use. |
|
@zakorgy The simplest way is to build Firefox using the [instructions] (https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions) and then apply your changes to the |
zakorgy commentedJul 12, 2018
•
edited by larsbergstrom
The discussion about this stared here: szeged#197 (comment)
shaders.ronfile which contains the possible feature sets for each shader.ronfile, for each possible feature configuration. The generated shader file names contain the feature names in lower case separated by a_.The shader processing code parts (get_shader_source, parse_shader_source, build_shader_strings) are moved in the build script from
device/gl.rs.There is a hacky part, because we don't always know which shader version (GL or GLES) we intend to use in build time. Replacing it in run-time, if we differ from the default
#version 150(GL), seemed the best solution.@kvark, @gw3583 could you please take a look?
This change is