-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] use SSBOs for gradients where supported (metal/vulkan) #37654
Changes from all commits
ac5289a
a993117
1e0b407
6464e63
c6764e1
ad2913d
6205d78
0693dbd
da02aea
377b3e5
8428aea
b843436
652553e
21cc74a
283957a
642a3e9
ace492f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,10 +45,14 @@ static CompilerBackend CreateGLSLCompiler(const spirv_cross::ParsedIR& ir, | |
| sl_options.force_zero_initialized_variables = true; | ||
| sl_options.vertex.fixup_clipspace = true; | ||
| if (source_options.target_platform == TargetPlatform::kOpenGLES) { | ||
| sl_options.version = 100; | ||
| sl_options.version = source_options.gles_language_version > 0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should do source language selection based on #version directives now instead of applying command line options. Omitting them was fine when we only had a single version.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that sounds reasonable, but I'm not quite sure how to make make shaderc and spirvcross work together on this. I'll file a bug
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ? source_options.gles_language_version | ||
| : 100; | ||
| sl_options.es = true; | ||
| } else { | ||
| sl_options.version = 120; | ||
| sl_options.version = source_options.gles_language_version > 0 | ||
| ? source_options.gles_language_version | ||
| : 120; | ||
| sl_options.es = false; | ||
| } | ||
| gl_compiler->set_common_options(sl_options); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // 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. | ||
|
|
||
| #ifndef GRADIENT_GLSL_ | ||
| #define GRADIENT_GLSL_ | ||
|
|
||
| #include <impeller/texture.glsl> | ||
|
|
||
| /// Compute the indexes and mix coefficient used to mix colors for an | ||
| /// arbitrarily sized color gradient. | ||
| /// | ||
| /// The returned values are the lower index, upper index, and mix | ||
| /// coefficient. | ||
| vec3 IPComputeFixedGradientValues(float t, float colors_length) { | ||
| float rough_index = (colors_length - 1) * t; | ||
| float lower_index = floor(rough_index); | ||
| float upper_index = ceil(rough_index); | ||
| float scale = rough_index - lower_index; | ||
|
|
||
| return vec3(lower_index, upper_index, scale); | ||
| } | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,20 @@ impeller_shaders("entity_shaders") { | |
| ] | ||
| } | ||
|
|
||
| impeller_shaders("modern_entity_shaders") { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This almost works, except that I fail to load the fixed_fill shaders at runtime. I suspect something somewhere is hard coded but I haven't found it. If I place these shaders in the entity shaders set (and force the gles_language version to 460 everywhere) it works as expected
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| name = "modern" | ||
|
|
||
| if (impeller_enable_opengles) { | ||
| gles_language_version = "460" | ||
| } | ||
|
|
||
| shaders = [ | ||
| "shaders/linear_gradient_ssbo_fill.frag", | ||
| "shaders/radial_gradient_ssbo_fill.frag", | ||
| "shaders/sweep_gradient_ssbo_fill.frag", | ||
| ] | ||
| } | ||
|
|
||
| impeller_component("entity") { | ||
| sources = [ | ||
| "contents/atlas_contents.cc", | ||
|
|
@@ -146,6 +160,7 @@ impeller_component("entity") { | |
|
|
||
| public_deps = [ | ||
| ":entity_shaders", | ||
| ":modern_entity_shaders", | ||
| "../archivist", | ||
| "../image", | ||
| "../renderer", | ||
|
|
||
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.
This assert appears to be invalid on windows hosts, which claim this always has a sizeof 4.
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.
Hmm, I suppose having platform specific differences here is possible. Was the shader name in the generated shaders correct though?