-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] order metal samplers according to declared order and not usage order #38115
Changes from 7 commits
7d7aa3b
3d8d5f8
8f41b7d
2fffb05
6ce0ca3
d089ef1
eb267f4
5f576e6
b487d0d
939f10e
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // 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. | ||
|
|
||
| // Declare samplers in different order than usage. | ||
| uniform sampler2D textureA; | ||
| uniform sampler2D textureB; | ||
|
|
||
| out vec4 frag_color; | ||
|
|
||
| void main() { | ||
| vec4 sample_1 = texture(textureB, vec2(1.0)); | ||
|
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. By default textureB ends up with offset 0 and textureA ends up with offset 1 |
||
| vec4 sample_2 = texture(textureA, vec2(1.0)); | ||
| frag_color = sample_1 + sample_2; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,6 +332,18 @@ void main() async { | |
| shader.dispose(); | ||
| }); | ||
|
|
||
| // This test can't rely on actual pixels rendered since it needs to run on a | ||
| // metal shader on iOS. instead parse the source code. | ||
| test('impellerc orders samplers in metal shader according to declaration and not usage', () async { | ||
| final Directory directory = shaderDirectory('iplr-remap'); | ||
| final String data = File(path.join(directory.path, 'shader_with_samplers.frag.iplr')).readAsStringSync(); | ||
|
Contributor
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. The
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. ah right. I need to either parse the flatbuffer or scan the raw bytes...
Contributor
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. When generating an
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. strings are encoded as utf8 strings in flatbuffer format, so there are a number of ways to pull that out of the file even without decoding it |
||
|
|
||
| const String expected = 'texture2d<float> textureA [[texture(0)]],' | ||
| ' texture2d<float> textureB [[texture(1)]]'; | ||
|
|
||
| expect(data, contains(expected)); | ||
| }); | ||
|
|
||
| // Test all supported GLSL ops. See lib/spirv/lib/src/constants.dart | ||
| final Map<String, FragmentProgram> iplrSupportedGLSLOpShaders = await _loadShaderAssets( | ||
| path.join('supported_glsl_op_shaders', 'iplr'), | ||
|
|
||
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.
Can this just be the default?
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.
There are still some compilation errors when using this on the flutter/engine shaders. I need to spend some more time tracking down why that is
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.
SGTM. I'm just catching up on the issue and the conversation in chat. Will take a closer look in the morning.
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.
I think this works if I also set
enable_decoration_bindingto true. that also fixes the issue with floats being out of order, but I need to verify that our bindings are still correct.