Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 292a921

Browse files
authored
[Flutter GPU] Texture binding, index binding, attachments, depth state. (#48386)
Now rendering textured 3D models! * Combined depth+stencil attachment. * Allow for multiple color attachments. * Add blend mode configuration. * Fix uniform ordering for vertex shaders. * Texture binding and sampling options. * Index buffer binding. * Depth configuration.
1 parent 10c0ba2 commit 292a921

19 files changed

+1177
-133
lines changed

impeller/compiler/compiler.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,24 @@ static CompilerBackend CreateMSLCompiler(
7171
// metal backend of spirv-cross will order uniforms according to usage. To fix
7272
// this, we use the sorted order and the add_msl_resource_binding API to force
7373
// the ordering to match the declared order. Note that while this code runs
74-
// for all compiled shaders, it will only affect fragment shaders due to the
75-
// specified stage.
74+
// for all compiled shaders, it will only affect vertex and fragment shaders
75+
// due to the specified stage.
7676
auto floats =
7777
SortUniforms(&ir, sl_compiler.get(), spirv_cross::SPIRType::Float);
7878
auto images =
7979
SortUniforms(&ir, sl_compiler.get(), spirv_cross::SPIRType::SampledImage);
8080

81+
spv::ExecutionModel execution_model =
82+
spv::ExecutionModel::ExecutionModelFragment;
83+
if (source_options.type == SourceType::kVertexShader) {
84+
execution_model = spv::ExecutionModel::ExecutionModelVertex;
85+
}
86+
8187
uint32_t buffer_offset = 0;
8288
uint32_t sampler_offset = 0;
8389
for (auto& float_id : floats) {
8490
sl_compiler->add_msl_resource_binding(
85-
{.stage = spv::ExecutionModel::ExecutionModelFragment,
91+
{.stage = execution_model,
8692
.basetype = spirv_cross::SPIRType::BaseType::Float,
8793
.desc_set = sl_compiler->get_decoration(float_id,
8894
spv::DecorationDescriptorSet),
@@ -94,7 +100,7 @@ static CompilerBackend CreateMSLCompiler(
94100
}
95101
for (auto& image_id : images) {
96102
sl_compiler->add_msl_resource_binding({
97-
.stage = spv::ExecutionModel::ExecutionModelFragment,
103+
.stage = execution_model,
98104
.basetype = spirv_cross::SPIRType::BaseType::SampledImage,
99105
.desc_set =
100106
sl_compiler->get_decoration(image_id, spv::DecorationDescriptorSet),

impeller/core/formats.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ enum class PixelFormat {
110110
kD32FloatS8UInt,
111111
};
112112

113+
constexpr bool IsDepthWritable(PixelFormat format) {
114+
switch (format) {
115+
case PixelFormat::kD24UnormS8Uint:
116+
case PixelFormat::kD32FloatS8UInt:
117+
return true;
118+
default:
119+
return false;
120+
}
121+
}
122+
123+
constexpr bool IsStencilWritable(PixelFormat format) {
124+
switch (format) {
125+
case PixelFormat::kS8UInt:
126+
case PixelFormat::kD24UnormS8Uint:
127+
case PixelFormat::kD32FloatS8UInt:
128+
return true;
129+
default:
130+
return false;
131+
}
132+
}
133+
113134
constexpr const char* PixelFormatToString(PixelFormat format) {
114135
switch (format) {
115136
case PixelFormat::kUnknown:

impeller/fixtures/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ impellerc("flutter_gpu_shaders") {
119119
# Temporarily build Flutter GPU test shaders as runtime stages.
120120
"flutter_gpu_unlit.frag",
121121
"flutter_gpu_unlit.vert",
122+
"flutter_gpu_texture.frag",
123+
"flutter_gpu_texture.vert",
122124
]
123125
sl_file_extension = "iplr"
124126
shader_target_flag = "--runtime-stage-metal"

impeller/fixtures/dart_tests.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,19 @@ void canCreateRenderPassAndSubmit() {
189189
assert(renderTexture != null);
190190

191191
final gpu.CommandBuffer commandBuffer = gpu.gpuContext.createCommandBuffer();
192-
final gpu.RenderPass encoder = commandBuffer.createRenderPass(
193-
colorAttachment: gpu.ColorAttachment(texture: renderTexture!));
192+
193+
final gpu.RenderTarget renderTarget = gpu.RenderTarget.singleColor(
194+
gpu.ColorAttachment(texture: renderTexture!),
195+
);
196+
final gpu.RenderPass encoder = commandBuffer.createRenderPass(renderTarget);
194197

195198
final gpu.RenderPipeline pipeline = createUnlitRenderPipeline();
196199
encoder.bindPipeline(pipeline);
197200

201+
// Configure blending with defaults (just to test the bindings).
202+
encoder.setColorBlendEnable(true);
203+
encoder.setColorBlendEquation(gpu.ColorBlendEquation());
204+
198205
final gpu.HostBuffer transients = gpu.HostBuffer();
199206
final gpu.BufferView vertices = transients.emplace(float32(<double>[
200207
-0.5, -0.5, //
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
uniform sampler2D tex;
6+
7+
in vec2 v_texture_coords;
8+
in vec4 v_color;
9+
out vec4 frag_color;
10+
11+
void main() {
12+
frag_color = v_color * texture(tex, v_texture_coords);
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
uniform mat4 mvp;
6+
7+
in vec3 position;
8+
in vec2 texture_coords;
9+
in vec4 color;
10+
out vec2 v_texture_coords;
11+
out vec4 v_color;
12+
13+
void main() {
14+
v_texture_coords = texture_coords;
15+
v_color = color;
16+
gl_Position = mvp * vec4(position, 1.0);
17+
}

lib/gpu/device_buffer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ bool InternalFlutterGpu_DeviceBuffer_Initialize(
5454
int storage_mode,
5555
int size_in_bytes) {
5656
impeller::DeviceBufferDescriptor desc;
57-
desc.storage_mode = flutter::gpu::ToImpellerStorageMode(
58-
static_cast<flutter::gpu::FlutterGPUStorageMode>(storage_mode));
57+
desc.storage_mode = flutter::gpu::ToImpellerStorageMode(storage_mode);
5958
desc.size = size_in_bytes;
6059
auto device_buffer =
6160
gpu_context->GetContext()->GetResourceAllocator()->CreateBuffer(desc);

lib/gpu/fixtures.cc

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,151 @@ unsigned char kFlutterGPUUnlitFragIPLR[] = {
130130
0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x75, 0x6e, 0x6c, 0x69,
131131
0x74, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d,
132132
0x61, 0x69, 0x6e, 0x00};
133+
134+
unsigned char kFlutterGPUTextureVertIPLR[] = {
135+
0x18, 0x00, 0x00, 0x00, 0x49, 0x50, 0x4c, 0x52, 0x00, 0x00, 0x0e, 0x00,
136+
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00,
137+
0x0e, 0x00, 0x00, 0x00, 0x58, 0x03, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00,
138+
0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x23, 0x69, 0x6e, 0x63,
139+
0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f,
140+
0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63,
141+
0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73,
142+
0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e,
143+
0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20,
144+
0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75,
145+
0x63, 0x74, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67,
146+
0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x76,
147+
0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f,
148+
0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
149+
0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
150+
0x65, 0x5f, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x20, 0x5b, 0x5b, 0x75,
151+
0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d,
152+
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34,
153+
0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x75,
154+
0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, 0x5d, 0x5d,
155+
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34,
156+
0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
157+
0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d,
158+
0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63,
159+
0x74, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70,
160+
0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x76, 0x65,
161+
0x72, 0x74, 0x65, 0x78, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e,
162+
0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
163+
0x33, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b,
164+
0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30,
165+
0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
166+
0x61, 0x74, 0x32, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f,
167+
0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74,
168+
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b,
169+
0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20,
170+
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72,
171+
0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, 0x3b, 0x0a,
172+
0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x66,
173+
0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74,
174+
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65,
175+
0x78, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x66,
176+
0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74,
177+
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65,
178+
0x78, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x66, 0x6c, 0x75, 0x74, 0x74,
179+
0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75,
180+
0x72, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x6d, 0x61,
181+
0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73,
182+
0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63,
183+
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61,
184+
0x74, 0x34, 0x78, 0x34, 0x26, 0x20, 0x6d, 0x76, 0x70, 0x20, 0x5b, 0x5b,
185+
0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29,
186+
0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74,
187+
0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75,
188+
0x72, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x6d, 0x61,
189+
0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d,
190+
0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
191+
0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x63,
192+
0x6f, 0x6f, 0x72, 0x64, 0x73, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x74,
193+
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6f, 0x72, 0x64,
194+
0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x76,
195+
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e,
196+
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
197+
0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
198+
0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x6d, 0x76, 0x70, 0x20, 0x2a, 0x20, 0x66,
199+
0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x69, 0x6e, 0x2e, 0x70, 0x6f, 0x73,
200+
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b,
201+
0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
202+
0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x01, 0x00, 0x00, 0x00,
203+
0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x28, 0x00, 0x04, 0x00, 0x00, 0x00,
204+
0x08, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x10, 0x00, 0x00, 0x00,
205+
0x24, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
206+
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207+
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208+
0x03, 0x00, 0x00, 0x00, 0x6d, 0x76, 0x70, 0x00, 0x1f, 0x00, 0x00, 0x00,
209+
0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f,
210+
0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x74,
211+
0x65, 0x78, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x00};
212+
213+
unsigned char kFlutterGPUTextureFragIPLR[] = {
214+
0x1c, 0x00, 0x00, 0x00, 0x49, 0x50, 0x4c, 0x52, 0x00, 0x00, 0x00, 0x00,
215+
0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00,
216+
0x0c, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
217+
0xd4, 0x02, 0x00, 0x00, 0x94, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
218+
0x85, 0x02, 0x00, 0x00, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65,
219+
0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c,
220+
0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65,
221+
0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e,
222+
0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61,
223+
0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61,
224+
0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x66,
225+
0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74,
226+
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d,
227+
0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74,
228+
0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
229+
0x34, 0x20, 0x66, 0x72, 0x61, 0x67, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
230+
0x20, 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d,
231+
0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63,
232+
0x74, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70,
233+
0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x66, 0x72,
234+
0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f,
235+
0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
236+
0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
237+
0x65, 0x5f, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x20, 0x5b, 0x5b, 0x75,
238+
0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d,
239+
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34,
240+
0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x75,
241+
0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, 0x5d, 0x5d,
242+
0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65,
243+
0x6e, 0x74, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67,
244+
0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x66,
245+
0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61, 0x69, 0x6e,
246+
0x5f, 0x6f, 0x75, 0x74, 0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72,
247+
0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
248+
0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61,
249+
0x69, 0x6e, 0x28, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67,
250+
0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x66,
251+
0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61, 0x69, 0x6e,
252+
0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61,
253+
0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x74, 0x65, 0x78,
254+
0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74,
255+
0x3e, 0x20, 0x74, 0x65, 0x78, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74,
256+
0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61,
257+
0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x74, 0x65, 0x78, 0x53, 0x6d, 0x70,
258+
0x6c, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
259+
0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20,
260+
0x20, 0x66, 0x6c, 0x75, 0x74, 0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75,
261+
0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x66, 0x72, 0x61,
262+
0x67, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f,
263+
0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b,
264+
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x66, 0x72, 0x61,
265+
0x67, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x6e,
266+
0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x2a, 0x20, 0x74,
267+
0x65, 0x78, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65,
268+
0x78, 0x53, 0x6d, 0x70, 0x6c, 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x76,
269+
0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6f,
270+
0x72, 0x64, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
271+
0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a,
272+
0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
273+
0x10, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
274+
0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
275+
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276+
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
277+
0x74, 0x65, 0x78, 0x00, 0x21, 0x00, 0x00, 0x00, 0x66, 0x6c, 0x75, 0x74,
278+
0x74, 0x65, 0x72, 0x5f, 0x67, 0x70, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x74,
279+
0x75, 0x72, 0x65, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74,
280+
0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00};

lib/gpu/fixtures.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,70 @@ extern unsigned char kFlutterGPUUnlitVertIPLR[];
4040

4141
constexpr unsigned int kFlutterGPUUnlitFragIPLRLength = 556;
4242
extern unsigned char kFlutterGPUUnlitFragIPLR[];
43+
44+
struct FlutterGPUTextureVertexShader {
45+
struct PerVertexData {
46+
impeller::Vector3 position; // (offset 0, size 12)
47+
impeller::Point texture_coords; // (offset 12, size 8)
48+
impeller::Vector4 color; // (offset 20, size 16)
49+
}; // struct PerVertexData (size 36)
50+
51+
static constexpr auto kInputTextureCoords = impeller::ShaderStageIOSlot{
52+
// texture_coords
53+
"texture_coords", // name
54+
1u, // attribute location
55+
0u, // attribute set
56+
0u, // attribute binding
57+
impeller::ShaderType::kFloat, // type
58+
32u, // bit width of type
59+
2u, // vec size
60+
1u, // number of columns
61+
12u, // offset for interleaved layout
62+
};
63+
64+
static constexpr auto kInputColor = impeller::ShaderStageIOSlot{
65+
// color
66+
"color", // name
67+
2u, // attribute location
68+
0u, // attribute set
69+
0u, // attribute binding
70+
impeller::ShaderType::kFloat, // type
71+
32u, // bit width of type
72+
4u, // vec size
73+
1u, // number of columns
74+
20u, // offset for interleaved layout
75+
};
76+
77+
static constexpr auto kInputPosition = impeller::ShaderStageIOSlot{
78+
// position
79+
"position", // name
80+
0u, // attribute location
81+
0u, // attribute set
82+
0u, // attribute binding
83+
impeller::ShaderType::kFloat, // type
84+
32u, // bit width of type
85+
3u, // vec size
86+
1u, // number of columns
87+
0u, // offset for interleaved layout
88+
};
89+
90+
static constexpr std::array<const impeller::ShaderStageIOSlot*, 3>
91+
kAllShaderStageInputs = {
92+
&kInputTextureCoords, // texture_coords
93+
&kInputColor, // color
94+
&kInputPosition, // position
95+
};
96+
97+
static constexpr auto kInterleavedLayout = impeller::ShaderStageBufferLayout{
98+
sizeof(PerVertexData), // stride for interleaved layout
99+
0u, // attribute binding
100+
};
101+
static constexpr std::array<const impeller::ShaderStageBufferLayout*, 1>
102+
kInterleavedBufferLayout = {&kInterleavedLayout};
103+
};
104+
105+
constexpr unsigned int kFlutterGPUTextureVertIPLRLength = 920;
106+
extern unsigned char kFlutterGPUTextureVertIPLR[];
107+
108+
constexpr unsigned int kFlutterGPUTextureFragIPLRLength = 800;
109+
extern unsigned char kFlutterGPUTextureFragIPLR[];

0 commit comments

Comments
 (0)