Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -5572,20 +5572,39 @@ ORIGIN: ../../../flutter/impeller/typographer/typeface.cc + ../../../flutter/LIC
ORIGIN: ../../../flutter/impeller/typographer/typeface.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/typographer/typographer_context.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/typographer/typographer_context.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/command_buffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/command_buffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/context.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/context.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/device_buffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/device_buffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/export.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/export.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/fixtures.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/fixtures.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/formats.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/formats.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/host_buffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/host_buffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/gpu.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/buffer.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/command_buffer.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/context.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/formats.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/render_pass.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/render_pipeline.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/shader.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/shader_library.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/smoketest.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/lib/src/texture.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/render_pass.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/render_pass.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/render_pipeline.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/render_pipeline.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/shader.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/shader.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/shader_library.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/shader_library.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/smoketest.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/smoketest.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/gpu/texture.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -8348,20 +8367,39 @@ FILE: ../../../flutter/impeller/typographer/typeface.cc
FILE: ../../../flutter/impeller/typographer/typeface.h
FILE: ../../../flutter/impeller/typographer/typographer_context.cc
FILE: ../../../flutter/impeller/typographer/typographer_context.h
FILE: ../../../flutter/lib/gpu/command_buffer.cc
FILE: ../../../flutter/lib/gpu/command_buffer.h
FILE: ../../../flutter/lib/gpu/context.cc
FILE: ../../../flutter/lib/gpu/context.h
FILE: ../../../flutter/lib/gpu/device_buffer.cc
FILE: ../../../flutter/lib/gpu/device_buffer.h
FILE: ../../../flutter/lib/gpu/export.cc
FILE: ../../../flutter/lib/gpu/export.h
FILE: ../../../flutter/lib/gpu/fixtures.cc
FILE: ../../../flutter/lib/gpu/fixtures.h
FILE: ../../../flutter/lib/gpu/formats.cc
FILE: ../../../flutter/lib/gpu/formats.h
FILE: ../../../flutter/lib/gpu/host_buffer.cc
FILE: ../../../flutter/lib/gpu/host_buffer.h
FILE: ../../../flutter/lib/gpu/lib/gpu.dart
FILE: ../../../flutter/lib/gpu/lib/src/buffer.dart
FILE: ../../../flutter/lib/gpu/lib/src/command_buffer.dart
FILE: ../../../flutter/lib/gpu/lib/src/context.dart
FILE: ../../../flutter/lib/gpu/lib/src/formats.dart
FILE: ../../../flutter/lib/gpu/lib/src/render_pass.dart
FILE: ../../../flutter/lib/gpu/lib/src/render_pipeline.dart
FILE: ../../../flutter/lib/gpu/lib/src/shader.dart
FILE: ../../../flutter/lib/gpu/lib/src/shader_library.dart
FILE: ../../../flutter/lib/gpu/lib/src/smoketest.dart
FILE: ../../../flutter/lib/gpu/lib/src/texture.dart
FILE: ../../../flutter/lib/gpu/render_pass.cc
FILE: ../../../flutter/lib/gpu/render_pass.h
FILE: ../../../flutter/lib/gpu/render_pipeline.cc
FILE: ../../../flutter/lib/gpu/render_pipeline.h
FILE: ../../../flutter/lib/gpu/shader.cc
FILE: ../../../flutter/lib/gpu/shader.h
FILE: ../../../flutter/lib/gpu/shader_library.cc
FILE: ../../../flutter/lib/gpu/shader_library.h
FILE: ../../../flutter/lib/gpu/smoketest.cc
FILE: ../../../flutter/lib/gpu/smoketest.h
FILE: ../../../flutter/lib/gpu/texture.cc
Expand Down
6 changes: 2 additions & 4 deletions impeller/compiler/impellerc_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
#include "flutter/fml/backtrace.h"
#include "flutter/fml/command_line.h"
#include "flutter/fml/file.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/mapping.h"
#include "impeller/base/strings.h"
#include "impeller/compiler/compiler.h"
#include "impeller/compiler/source_options.h"
#include "impeller/compiler/switches.h"
#include "impeller/compiler/types.h"
#include "impeller/compiler/utilities.h"
#include "third_party/shaderc/libshaderc/include/shaderc/shaderc.hpp"

namespace impeller {
namespace compiler {
Expand Down Expand Up @@ -88,7 +85,8 @@ bool Main(const fml::CommandLine& command_line) {

// Generate SkSL if needed.
std::shared_ptr<fml::Mapping> sksl_mapping;
if (switches.iplr && TargetPlatformBundlesSkSL(switches.target_platform)) {
if (switches.iplr && TargetPlatformBundlesSkSL(switches.target_platform) &&
switches.iplr_bundle.empty()) {
SourceOptions sksl_options = options;
sksl_options.target_platform = TargetPlatform::kSkSL;

Expand Down
2 changes: 1 addition & 1 deletion impeller/compiler/runtime_stage_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ std::shared_ptr<fml::Mapping> RuntimeStageData::CreateMapping() const {
shader_->GetMapping() + shader_->GetSize()};
}
// It is not an error for the SkSL to be ommitted.
if (sksl_->GetSize() > 0u) {
if (sksl_ && sksl_->GetSize() > 0u) {
runtime_stage.sksl = {sksl_->GetMapping(),
sksl_->GetMapping() + sksl_->GetSize()};
}
Expand Down
4 changes: 4 additions & 0 deletions impeller/compiler/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ void Switches::PrintHelp(std::ostream& stream) {
<< std::endl;
stream << "[optional] --iplr (causes --sl file to be emitted in iplr format)"
<< std::endl;
stream << "[optional] --iplr-bundle=<bundle_spec> (causes --sl file to be "
"emitted in the iplr bundle format)"
<< std::endl;
stream << "[optional] --reflection-json=<reflection_json_file>" << std::endl;
stream << "[optional] --reflection-header=<reflection_header_file>"
<< std::endl;
Expand Down Expand Up @@ -121,6 +124,7 @@ Switches::Switches(const fml::CommandLine& command_line)
input_type(SourceTypeFromCommandLine(command_line)),
sl_file_name(command_line.GetOptionValueWithDefault("sl", "")),
iplr(command_line.HasOption("iplr")),
iplr_bundle(command_line.GetOptionValueWithDefault("iplr-bundle", "")),
spirv_file_name(command_line.GetOptionValueWithDefault("spirv", "")),
reflection_json_name(
command_line.GetOptionValueWithDefault("reflection-json", "")),
Expand Down
1 change: 1 addition & 0 deletions impeller/compiler/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct Switches {
SourceType input_type = SourceType::kUnknown;
std::string sl_file_name = "";
bool iplr = false;
std::string iplr_bundle = "";
std::string spirv_file_name = "";
std::string reflection_json_name = "";
std::string reflection_header_name = "";
Expand Down
1 change: 0 additions & 1 deletion impeller/entity/contents/runtime_effect_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include <functional>
#include <memory>
#include <vector>

Expand Down
21 changes: 21 additions & 0 deletions impeller/fixtures/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ test_fixtures("file_fixtures") {
]
}

impellerc("flutter_gpu_shaders") {
shaders = [
# Temporarily build Flutter GPU test shaders as runtime stages.
"flutter_gpu_unlit.frag",
"flutter_gpu_unlit.vert",
]
sl_file_extension = "iplr"
shader_target_flag = "--runtime-stage-metal"
iplr = true
iplr_bundle = "temporary"
}

test_fixtures("flutter_gpu_fixtures") {
dart_main = "dart_tests.dart"

fixtures =
filter_include(get_target_outputs(":flutter_gpu_shaders"), [ "*.iplr" ])

deps = [ ":flutter_gpu_shaders" ]
}

group("fixtures") {
testonly = true

Expand Down
61 changes: 61 additions & 0 deletions impeller/fixtures/dart_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,64 @@ void textureAsImageThrowsWhenNotShaderReadable() {
assert(exception!.contains(
'Only shader readable Flutter GPU textures can be used as UI Images'));
}

@pragma('vm:entry-point')
void canCreateShaderLibrary() {
final gpu.ShaderLibrary? library = gpu.ShaderLibrary.fromAsset('playground');
assert(library != null);
final gpu.Shader? shader = library!['UnlitVertex'];
assert(shader != null);
}

gpu.RenderPipeline createUnlitRenderPipeline() {
final gpu.ShaderLibrary? library = gpu.ShaderLibrary.fromAsset('playground');
assert(library != null);
final gpu.Shader? vertex = library!['UnlitVertex'];
assert(vertex != null);
final gpu.Shader? fragment = library['UnlitFragment'];
assert(fragment != null);
return gpu.gpuContext.createRenderPipeline(vertex!, fragment!);
}

ByteData float32(List<double> values) {
return Float32List.fromList(values).buffer.asByteData();
}

@pragma('vm:entry-point')
void canCreateRenderPassAndSubmit() {
final gpu.Texture? renderTexture =
gpu.gpuContext.createTexture(gpu.StorageMode.devicePrivate, 100, 100);
assert(renderTexture != null);

final gpu.CommandBuffer commandBuffer = gpu.gpuContext.createCommandBuffer();
final gpu.RenderPass encoder = commandBuffer.createRenderPass(
colorAttachment: gpu.ColorAttachment(texture: renderTexture!));

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

final gpu.HostBuffer transients = gpu.HostBuffer();
final gpu.BufferView vertices = transients.emplace(float32(<double>[
-0.5, -0.5, //
0.5, 0.5, //
0.5, -0.5, //
]));
final gpu.BufferView color =
transients.emplace(float32(<double>[0, 1, 0, 1])); // rgba
final gpu.BufferView mvp = transients.emplace(float32(<double>[
1, 0, 0, 0, //
0, 1, 0, 0, //
0, 0, 1, 0, //
0, 0, 0, 1, //
]));
encoder.bindVertexBuffer(vertices, 3);

final gpu.UniformSlot? colorSlot =
pipeline.vertexShader.getUniformSlot('color');
final gpu.UniformSlot? mvpSlot = pipeline.vertexShader.getUniformSlot('mvp');
encoder.bindUniform(mvpSlot!, mvp);
encoder.bindUniform(colorSlot!, color);
encoder.draw();

commandBuffer.submit();
}
10 changes: 10 additions & 0 deletions impeller/fixtures/flutter_gpu_unlit.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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.

in vec4 v_color;
out vec4 frag_color;

void main() {
frag_color = v_color;
}
16 changes: 16 additions & 0 deletions impeller/fixtures/flutter_gpu_unlit.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

#version 320 es

layout(location = 0) uniform mat4 mvp;
layout(location = 1) uniform vec4 color;

in vec2 position;
out vec4 v_color;

void main() {
v_color = color;
gl_Position = mvp * vec4(position, 0.0, 1.0);
}
13 changes: 2 additions & 11 deletions impeller/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,15 @@ impeller_component("renderer_unittests") {
}
}

test_fixtures("renderer_dart_fixtures") {
dart_main = "../fixtures/dart_tests.dart"

fixtures = [
"../fixtures/bay_bridge.jpg",
"../fixtures/boston.jpg",
]
}

impeller_component("renderer_dart_unittests") {
testonly = true

sources = [ "renderer_dart_unittests.cc" ]

deps = [
":renderer",
":renderer_dart_fixtures",
"../fixtures:shader_fixtures",
"../fixtures:flutter_gpu_fixtures",
"../fixtures:flutter_gpu_shaders",
"../playground:playground_test",
"//flutter/lib/gpu",
"//flutter/runtime:runtime",
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/render_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class RenderPass {
public:
virtual ~RenderPass();

const std::weak_ptr<const Context>& GetContext() const;

const RenderTarget& GetRenderTarget() const;

ISize GetRenderTargetSize() const;
Expand Down Expand Up @@ -101,8 +103,6 @@ class RenderPass {

RenderPass(std::weak_ptr<const Context> context, const RenderTarget& target);

const std::weak_ptr<const Context>& GetContext() const;

virtual void OnSetLabel(std::string label) = 0;

virtual bool OnEncodeCommands(const Context& context) const = 0;
Expand Down
Loading