[Impeller] Compute shader support (flutter/engine#35750)
This commit is contained in:
@@ -768,6 +768,10 @@ FILE: ../../../flutter/impeller/renderer/backend/metal/blit_pass_mtl.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/blit_pass_mtl.mm
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/command_buffer_mtl.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/command_buffer_mtl.mm
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/compute_pass_mtl.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/compute_pass_mtl.mm
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/compute_pipeline_mtl.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/compute_pipeline_mtl.mm
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/context_mtl.h
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/context_mtl.mm
|
||||
FILE: ../../../flutter/impeller/renderer/backend/metal/device_buffer_mtl.h
|
||||
@@ -849,6 +853,14 @@ FILE: ../../../flutter/impeller/renderer/command.cc
|
||||
FILE: ../../../flutter/impeller/renderer/command.h
|
||||
FILE: ../../../flutter/impeller/renderer/command_buffer.cc
|
||||
FILE: ../../../flutter/impeller/renderer/command_buffer.h
|
||||
FILE: ../../../flutter/impeller/renderer/compute_command.cc
|
||||
FILE: ../../../flutter/impeller/renderer/compute_command.h
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pass.cc
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pass.h
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pipeline_builder.cc
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pipeline_builder.h
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.cc
|
||||
FILE: ../../../flutter/impeller/renderer/compute_pipeline_descriptor.h
|
||||
FILE: ../../../flutter/impeller/renderer/context.cc
|
||||
FILE: ../../../flutter/impeller/renderer/context.h
|
||||
FILE: ../../../flutter/impeller/renderer/descriptor_set_layout.h
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace impeller.fb;
|
||||
enum Stage:byte {
|
||||
kVertex,
|
||||
kFragment,
|
||||
kCompute,
|
||||
}
|
||||
|
||||
table Blob {
|
||||
|
||||
@@ -18,6 +18,8 @@ constexpr BlobShaderType ToShaderType(fb::Stage stage) {
|
||||
return BlobShaderType::kVertex;
|
||||
case fb::Stage::kFragment:
|
||||
return BlobShaderType::kFragment;
|
||||
case fb::Stage::kCompute:
|
||||
return BlobShaderType::kCompute;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace impeller {
|
||||
enum class BlobShaderType {
|
||||
kVertex,
|
||||
kFragment,
|
||||
kCompute,
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -22,6 +22,8 @@ std::optional<BlobShaderType> InferShaderTypefromFileExtension(
|
||||
return BlobShaderType::kVertex;
|
||||
} else if (path == ".frag") {
|
||||
return BlobShaderType::kFragment;
|
||||
} else if (path == ".comp") {
|
||||
return BlobShaderType::kCompute;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -88,6 +90,8 @@ constexpr fb::Stage ToStage(BlobShaderType type) {
|
||||
return fb::Stage::kVertex;
|
||||
case BlobShaderType::kFragment:
|
||||
return fb::Stage::kFragment;
|
||||
case BlobShaderType::kCompute:
|
||||
return fb::Stage::kCompute;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ constexpr std::string_view kReflectionHeaderTemplate =
|
||||
|
||||
#include "impeller/renderer/command.h" {# // nogncheck #}
|
||||
|
||||
#include "impeller/renderer/compute_command.h" {# // nogncheck #}
|
||||
|
||||
#include "impeller/renderer/descriptor_set_layout.h" {# // nogncheck #}
|
||||
|
||||
#include "impeller/renderer/sampler.h" {# // nogncheck #}
|
||||
|
||||
@@ -84,6 +84,21 @@ static std::string ExecutionModelToString(spv::ExecutionModel model) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string ExecutionModelToCommandTypeName(
|
||||
spv::ExecutionModel execution_model) {
|
||||
switch (execution_model) {
|
||||
case spv::ExecutionModel::ExecutionModelVertex:
|
||||
case spv::ExecutionModel::ExecutionModelFragment:
|
||||
case spv::ExecutionModel::ExecutionModelTessellationControl:
|
||||
case spv::ExecutionModel::ExecutionModelTessellationEvaluation:
|
||||
return "Command&";
|
||||
case spv::ExecutionModel::ExecutionModelGLCompute:
|
||||
return "ComputeCommand&";
|
||||
default:
|
||||
return "unsupported";
|
||||
}
|
||||
}
|
||||
|
||||
static std::string StringToShaderStage(std::string str) {
|
||||
if (str == "vertex") {
|
||||
return "ShaderStage::kVertex";
|
||||
@@ -209,11 +224,11 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto execution_model = entrypoints.front().execution_model;
|
||||
{
|
||||
root["entrypoint"] = options_.entry_point_name;
|
||||
root["shader_name"] = options_.shader_name;
|
||||
root["shader_stage"] =
|
||||
ExecutionModelToString(entrypoints.front().execution_model);
|
||||
root["shader_stage"] = ExecutionModelToString(execution_model);
|
||||
root["header_file_name"] = options_.header_file_name;
|
||||
}
|
||||
|
||||
@@ -315,7 +330,8 @@ std::optional<nlohmann::json> Reflector::GenerateTemplateArguments() const {
|
||||
});
|
||||
}
|
||||
|
||||
root["bind_prototypes"] = EmitBindPrototypes(shader_resources);
|
||||
root["bind_prototypes"] =
|
||||
EmitBindPrototypes(shader_resources, execution_model);
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -887,7 +903,8 @@ std::string Reflector::GetMemberNameAtIndex(
|
||||
}
|
||||
|
||||
std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
|
||||
const spirv_cross::ShaderResources& resources) const {
|
||||
const spirv_cross::ShaderResources& resources,
|
||||
spv::ExecutionModel execution_model) const {
|
||||
std::vector<BindPrototype> prototypes;
|
||||
for (const auto& uniform_buffer : resources.uniform_buffers) {
|
||||
auto& proto = prototypes.emplace_back(BindPrototype{});
|
||||
@@ -900,7 +917,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
|
||||
proto.docstring = stream.str();
|
||||
}
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
.type_name = "Command&",
|
||||
.type_name = ExecutionModelToCommandTypeName(execution_model),
|
||||
.argument_name = "command",
|
||||
});
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
@@ -919,7 +936,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
|
||||
proto.docstring = stream.str();
|
||||
}
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
.type_name = "Command&",
|
||||
.type_name = ExecutionModelToCommandTypeName(execution_model),
|
||||
.argument_name = "command",
|
||||
});
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
@@ -938,7 +955,7 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
|
||||
proto.docstring = stream.str();
|
||||
}
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
.type_name = "Command&",
|
||||
.type_name = ExecutionModelToCommandTypeName(execution_model),
|
||||
.argument_name = "command",
|
||||
});
|
||||
proto.args.push_back(BindPrototypeArgument{
|
||||
@@ -992,8 +1009,9 @@ std::vector<Reflector::BindPrototype> Reflector::ReflectBindPrototypes(
|
||||
}
|
||||
|
||||
nlohmann::json::array_t Reflector::EmitBindPrototypes(
|
||||
const spirv_cross::ShaderResources& resources) const {
|
||||
const auto prototypes = ReflectBindPrototypes(resources);
|
||||
const spirv_cross::ShaderResources& resources,
|
||||
spv::ExecutionModel execution_model) const {
|
||||
const auto prototypes = ReflectBindPrototypes(resources, execution_model);
|
||||
nlohmann::json::array_t result;
|
||||
for (const auto& res : prototypes) {
|
||||
auto& item = result.emplace_back(nlohmann::json::object_t{});
|
||||
|
||||
@@ -118,10 +118,12 @@ class Reflector {
|
||||
const spirv_cross::TypeID& type_id) const;
|
||||
|
||||
std::vector<BindPrototype> ReflectBindPrototypes(
|
||||
const spirv_cross::ShaderResources& resources) const;
|
||||
const spirv_cross::ShaderResources& resources,
|
||||
spv::ExecutionModel execution_model) const;
|
||||
|
||||
nlohmann::json::array_t EmitBindPrototypes(
|
||||
const spirv_cross::ShaderResources& resources) const;
|
||||
const spirv_cross::ShaderResources& resources,
|
||||
spv::ExecutionModel execution_model) const;
|
||||
|
||||
std::optional<StructDefinition> ReflectPerVertexStructDefinition(
|
||||
const spirv_cross::SmallVector<spirv_cross::Resource>& stage_inputs)
|
||||
|
||||
@@ -63,78 +63,95 @@
|
||||
#include "impeller/entity/vertices.frag.h"
|
||||
#include "impeller/entity/vertices.vert.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
using LinearGradientFillPipeline =
|
||||
PipelineT<GradientFillVertexShader, LinearGradientFillFragmentShader>;
|
||||
RenderPipelineT<GradientFillVertexShader, LinearGradientFillFragmentShader>;
|
||||
using SolidFillPipeline =
|
||||
PipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
RenderPipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
using RadialGradientFillPipeline =
|
||||
PipelineT<GradientFillVertexShader, RadialGradientFillFragmentShader>;
|
||||
RenderPipelineT<GradientFillVertexShader, RadialGradientFillFragmentShader>;
|
||||
using SweepGradientFillPipeline =
|
||||
PipelineT<GradientFillVertexShader, SweepGradientFillFragmentShader>;
|
||||
using BlendPipeline = PipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
RenderPipelineT<GradientFillVertexShader, SweepGradientFillFragmentShader>;
|
||||
using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
using RRectBlurPipeline =
|
||||
PipelineT<RrectBlurVertexShader, RrectBlurFragmentShader>;
|
||||
using BlendPipeline = PipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
using BlendColorPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendColorFragmentShader>;
|
||||
RenderPipelineT<RrectBlurVertexShader, RrectBlurFragmentShader>;
|
||||
using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
using BlendColorPipeline = RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendColorFragmentShader>;
|
||||
using BlendColorBurnPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendColorburnFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendColorburnFragmentShader>;
|
||||
using BlendColorDodgePipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendColordodgeFragmentShader>;
|
||||
using BlendDarkenPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendDarkenFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendColordodgeFragmentShader>;
|
||||
using BlendDarkenPipeline = RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendDarkenFragmentShader>;
|
||||
using BlendDifferencePipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendDifferenceFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendDifferenceFragmentShader>;
|
||||
using BlendExclusionPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendExclusionFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendExclusionFragmentShader>;
|
||||
using BlendHardLightPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendHardlightFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendHardlightFragmentShader>;
|
||||
using BlendHuePipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendHueFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader, AdvancedBlendHueFragmentShader>;
|
||||
using BlendLightenPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendLightenFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendLightenFragmentShader>;
|
||||
using BlendLuminosityPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendLuminosityFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendLuminosityFragmentShader>;
|
||||
using BlendMultiplyPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendMultiplyFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendMultiplyFragmentShader>;
|
||||
using BlendOverlayPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendOverlayFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendOverlayFragmentShader>;
|
||||
using BlendSaturationPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendSaturationFragmentShader>;
|
||||
using BlendScreenPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendScreenFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendSaturationFragmentShader>;
|
||||
using BlendScreenPipeline = RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendScreenFragmentShader>;
|
||||
using BlendSoftLightPipeline =
|
||||
PipelineT<AdvancedBlendVertexShader, AdvancedBlendSoftlightFragmentShader>;
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendSoftlightFragmentShader>;
|
||||
using TexturePipeline =
|
||||
PipelineT<TextureFillVertexShader, TextureFillFragmentShader>;
|
||||
using TiledTexturePipeline =
|
||||
PipelineT<TiledTextureFillVertexShader, TiledTextureFillFragmentShader>;
|
||||
RenderPipelineT<TextureFillVertexShader, TextureFillFragmentShader>;
|
||||
using TiledTexturePipeline = RenderPipelineT<TiledTextureFillVertexShader,
|
||||
TiledTextureFillFragmentShader>;
|
||||
using GaussianBlurPipeline =
|
||||
PipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
|
||||
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
|
||||
using BorderMaskBlurPipeline =
|
||||
PipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
|
||||
RenderPipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
|
||||
using MorphologyFilterPipeline =
|
||||
PipelineT<MorphologyFilterVertexShader, MorphologyFilterFragmentShader>;
|
||||
RenderPipelineT<MorphologyFilterVertexShader,
|
||||
MorphologyFilterFragmentShader>;
|
||||
using ColorMatrixColorFilterPipeline =
|
||||
PipelineT<ColorMatrixColorFilterVertexShader,
|
||||
ColorMatrixColorFilterFragmentShader>;
|
||||
RenderPipelineT<ColorMatrixColorFilterVertexShader,
|
||||
ColorMatrixColorFilterFragmentShader>;
|
||||
using LinearToSrgbFilterPipeline =
|
||||
PipelineT<LinearToSrgbFilterVertexShader, LinearToSrgbFilterFragmentShader>;
|
||||
RenderPipelineT<LinearToSrgbFilterVertexShader,
|
||||
LinearToSrgbFilterFragmentShader>;
|
||||
using SrgbToLinearFilterPipeline =
|
||||
PipelineT<SrgbToLinearFilterVertexShader, SrgbToLinearFilterFragmentShader>;
|
||||
RenderPipelineT<SrgbToLinearFilterVertexShader,
|
||||
SrgbToLinearFilterFragmentShader>;
|
||||
using SolidStrokePipeline =
|
||||
PipelineT<SolidStrokeVertexShader, SolidStrokeFragmentShader>;
|
||||
RenderPipelineT<SolidStrokeVertexShader, SolidStrokeFragmentShader>;
|
||||
using GlyphAtlasPipeline =
|
||||
PipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
using VerticesPipeline =
|
||||
PipelineT<VerticesVertexShader, VerticesFragmentShader>;
|
||||
using AtlasPipeline = PipelineT<AtlasFillVertexShader, AtlasFillFragmentShader>;
|
||||
RenderPipelineT<VerticesVertexShader, VerticesFragmentShader>;
|
||||
using AtlasPipeline =
|
||||
RenderPipelineT<AtlasFillVertexShader, AtlasFillFragmentShader>;
|
||||
// Instead of requiring new shaders for clips, the solid fill stages are used
|
||||
// to redirect writing to the stencil instead of color attachments.
|
||||
using ClipPipeline = PipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
using ClipPipeline =
|
||||
RenderPipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
|
||||
struct ContentContextOptions {
|
||||
SampleCount sample_count = SampleCount::kCount1;
|
||||
@@ -170,170 +187,173 @@ class ContentContext {
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
std::shared_ptr<Pipeline> GetLinearGradientFillPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearGradientFillPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(linear_gradient_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetRadialGradientFillPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(radial_gradient_fill_pipelines_, opts);
|
||||
}
|
||||
std::shared_ptr<Pipeline> GetRRectBlurPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(rrect_blur_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetSweepGradientFillPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSweepGradientFillPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(sweep_gradient_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetSolidFillPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidFillPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(solid_fill_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendPipeline(ContentContextOptions opts) const {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(texture_blend_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetTexturePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(texture_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetTiledTexturePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTexturePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(tiled_texture_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetGaussianBlurPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(gaussian_blur_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBorderMaskBlurPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(border_mask_blur_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetMorphologyFilterPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetMorphologyFilterPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(morphology_filter_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetColorMatrixColorFilterPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(color_matrix_color_filter_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetLinearToSrgbFilterPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearToSrgbFilterPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetSrgbToLinearFilterPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSrgbToLinearFilterPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetSolidStrokePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidStrokePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(solid_stroke_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetClipPipeline(ContentContextOptions opts) const {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(clip_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetGlyphAtlasPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(glyph_atlas_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetVerticesPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetVerticesPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(vertices_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetAtlasPipeline(ContentContextOptions opts) const {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetAtlasPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(atlas_pipelines_, opts);
|
||||
}
|
||||
|
||||
// Advanced blends.
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendColorPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_color_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendColorBurnPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorBurnPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_colorburn_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendColorDodgePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorDodgePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_colordodge_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendDarkenPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDarkenPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_darken_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendDifferencePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDifferencePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_difference_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendExclusionPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendExclusionPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_exclusion_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendHardLightPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHardLightPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_hardlight_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendHuePipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHuePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_hue_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendLightenPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLightenPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_lighten_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendLuminosityPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_luminosity_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendMultiplyPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendMultiplyPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_multiply_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendOverlayPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendOverlayPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_overlay_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendSaturationPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSaturationPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_saturation_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendScreenPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendScreenPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_screen_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline> GetBlendSoftLightPipeline(
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSoftLightPipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_softlight_pipelines_, opts);
|
||||
}
|
||||
@@ -398,8 +418,9 @@ class ContentContext {
|
||||
mutable Variants<BlendSoftLightPipeline> blend_softlight_pipelines_;
|
||||
|
||||
template <class TypedPipeline>
|
||||
std::shared_ptr<Pipeline> GetPipeline(Variants<TypedPipeline>& container,
|
||||
ContentContextOptions opts) const {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
|
||||
Variants<TypedPipeline>& container,
|
||||
ContentContextOptions opts) const {
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ BlendFilterContents::BlendFilterContents() {
|
||||
|
||||
BlendFilterContents::~BlendFilterContents() = default;
|
||||
|
||||
using PipelineProc =
|
||||
std::shared_ptr<Pipeline> (ContentContext::*)(ContentContextOptions) const;
|
||||
using PipelineProc = std::shared_ptr<Pipeline<PipelineDescriptor>> (
|
||||
ContentContext::*)(ContentContextOptions) const;
|
||||
|
||||
template <typename TPipeline>
|
||||
static std::optional<Snapshot> AdvancedBlend(
|
||||
@@ -93,7 +93,7 @@ static std::optional<Snapshot> AdvancedBlend(
|
||||
auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer);
|
||||
|
||||
auto options = OptionsFromPassAndEntity(pass, entity);
|
||||
std::shared_ptr<Pipeline> pipeline =
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
|
||||
std::invoke(pipeline_proc, renderer, options);
|
||||
|
||||
Command cmd;
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class Pipeline;
|
||||
|
||||
class FilterContents : public Contents {
|
||||
public:
|
||||
enum class BlurStyle {
|
||||
|
||||
@@ -18,10 +18,15 @@ impeller_shaders("shader_fixtures") {
|
||||
"instanced_draw.vert",
|
||||
"mipmaps.frag",
|
||||
"mipmaps.vert",
|
||||
"sample.comp",
|
||||
"simple.vert",
|
||||
"test_texture.frag",
|
||||
"test_texture.vert",
|
||||
]
|
||||
|
||||
if (impeller_enable_opengles) {
|
||||
gles_exclusions = [ "sample.comp" ]
|
||||
}
|
||||
}
|
||||
|
||||
impellerc("runtime_stages") {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
layout (local_size_x = 16, local_size_y = 16) in;
|
||||
layout(local_size_x = 128) in;
|
||||
layout(std430) buffer;
|
||||
|
||||
void main(void) {
|
||||
// Do nothing.
|
||||
layout(binding = 0) writeonly buffer Output {
|
||||
vec4 elements[];
|
||||
} output_data;
|
||||
|
||||
layout(binding = 1) readonly buffer Input0 {
|
||||
vec4 elements[];
|
||||
} input_data0;
|
||||
|
||||
layout(binding = 2) readonly buffer Input1 {
|
||||
vec4 elements[];
|
||||
} input_data1;
|
||||
|
||||
void main()
|
||||
{
|
||||
uint ident = gl_GlobalInvocationID.x;
|
||||
output_data.elements[ident] = input_data0.elements[ident] * input_data1.elements[ident];
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/pipeline_builder.h"
|
||||
#include "impeller/renderer/pipeline_descriptor.h"
|
||||
#include "impeller/renderer/pipeline_library.h"
|
||||
#include "impeller/renderer/range.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
@@ -36,7 +37,7 @@
|
||||
struct ImGui_ImplImpeller_Data {
|
||||
std::shared_ptr<impeller::Context> context;
|
||||
std::shared_ptr<impeller::Texture> font_texture;
|
||||
std::shared_ptr<impeller::Pipeline> pipeline;
|
||||
std::shared_ptr<impeller::Pipeline<impeller::PipelineDescriptor>> pipeline;
|
||||
std::shared_ptr<const impeller::Sampler> sampler;
|
||||
};
|
||||
|
||||
@@ -101,7 +102,7 @@ bool ImGui_ImplImpeller_Init(std::shared_ptr<impeller::Context> context) {
|
||||
}
|
||||
|
||||
bd->pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
IM_ASSERT(bd->pipeline != nullptr && "Could not create ImGui pipeline.");
|
||||
|
||||
bd->sampler = context->GetSamplerLibrary()->GetSampler({});
|
||||
|
||||
@@ -20,6 +20,14 @@ impeller_component("renderer") {
|
||||
"command.h",
|
||||
"command_buffer.cc",
|
||||
"command_buffer.h",
|
||||
"compute_command.cc",
|
||||
"compute_command.h",
|
||||
"compute_pass.cc",
|
||||
"compute_pass.h",
|
||||
"compute_pipeline_builder.cc",
|
||||
"compute_pipeline_builder.h",
|
||||
"compute_pipeline_descriptor.cc",
|
||||
"compute_pipeline_descriptor.h",
|
||||
"context.cc",
|
||||
"context.h",
|
||||
"descriptor_set_layout.h",
|
||||
|
||||
@@ -64,4 +64,11 @@ std::shared_ptr<BlitPass> CommandBufferGLES::OnCreateBlitPass() const {
|
||||
return pass;
|
||||
}
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<ComputePass> CommandBufferGLES::OnCreateComputePass() const {
|
||||
// Compute passes aren't supported until GLES 3.2, at which point Vulkan is
|
||||
// available anyway.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -41,6 +41,9 @@ class CommandBufferGLES final : public CommandBuffer {
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<BlitPass> OnCreateBlitPass() const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<ComputePass> OnCreateComputePass() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBufferGLES);
|
||||
};
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ namespace impeller {
|
||||
|
||||
class PipelineLibraryGLES;
|
||||
|
||||
class PipelineGLES final : public Pipeline,
|
||||
public BackendCast<PipelineGLES, Pipeline> {
|
||||
class PipelineGLES final
|
||||
: public Pipeline<PipelineDescriptor>,
|
||||
public BackendCast<PipelineGLES, Pipeline<PipelineDescriptor>> {
|
||||
public:
|
||||
// |Pipeline|
|
||||
~PipelineGLES() override;
|
||||
|
||||
@@ -172,14 +172,15 @@ bool PipelineLibraryGLES::IsValid() const {
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture PipelineLibraryGLES::GetRenderPipeline(
|
||||
PipelineFuture<PipelineDescriptor> PipelineLibraryGLES::GetPipeline(
|
||||
PipelineDescriptor descriptor) {
|
||||
if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
if (!reactor_) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<PipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
auto vert_function = descriptor.GetEntrypointForStage(ShaderStage::kVertex);
|
||||
@@ -188,11 +189,13 @@ PipelineFuture PipelineLibraryGLES::GetRenderPipeline(
|
||||
if (!vert_function || !frag_function) {
|
||||
VALIDATION_LOG
|
||||
<< "Could not find stage entrypoint functions in pipeline descriptor.";
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<PipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
auto promise = std::make_shared<std::promise<std::shared_ptr<Pipeline>>>();
|
||||
auto future = PipelineFuture{promise->get_future()};
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<PipelineDescriptor>>>>();
|
||||
auto future = PipelineFuture<PipelineDescriptor>{promise->get_future()};
|
||||
pipelines_[descriptor] = future;
|
||||
auto weak_this = weak_from_this();
|
||||
|
||||
@@ -242,6 +245,18 @@ PipelineFuture PipelineLibraryGLES::GetRenderPipeline(
|
||||
return future;
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture<ComputePipelineDescriptor> PipelineLibraryGLES::GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) {
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>>();
|
||||
auto future =
|
||||
PipelineFuture<ComputePipelineDescriptor>{promise->get_future()};
|
||||
// TODO(dnfield): implement compute for GLES.
|
||||
promise->set_value(nullptr);
|
||||
return future;
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineLibraryGLES::~PipelineLibraryGLES() = default;
|
||||
|
||||
|
||||
@@ -29,7 +29,12 @@ class PipelineLibraryGLES final : public PipelineLibrary {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor) override;
|
||||
PipelineFuture<PipelineDescriptor> GetPipeline(
|
||||
PipelineDescriptor descriptor) override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture<ComputePipelineDescriptor> GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineLibraryGLES);
|
||||
};
|
||||
|
||||
@@ -20,6 +20,8 @@ static ShaderStage ToShaderStage(BlobShaderType type) {
|
||||
return ShaderStage::kVertex;
|
||||
case BlobShaderType::kFragment:
|
||||
return ShaderStage::kFragment;
|
||||
case BlobShaderType::kCompute:
|
||||
return ShaderStage::kCompute;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ impeller_component("metal") {
|
||||
"blit_pass_mtl.mm",
|
||||
"command_buffer_mtl.h",
|
||||
"command_buffer_mtl.mm",
|
||||
"compute_pass_mtl.h",
|
||||
"compute_pass_mtl.mm",
|
||||
"compute_pipeline_mtl.h",
|
||||
"compute_pipeline_mtl.mm",
|
||||
"context_mtl.h",
|
||||
"context_mtl.mm",
|
||||
"device_buffer_mtl.h",
|
||||
|
||||
@@ -40,6 +40,9 @@ class CommandBufferMTL final : public CommandBuffer {
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<BlitPass> OnCreateBlitPass() const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<ComputePass> OnCreateComputePass() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBufferMTL);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "impeller/renderer/backend/metal/command_buffer_mtl.h"
|
||||
|
||||
#include "impeller/renderer/backend/metal/blit_pass_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/compute_pass_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/render_pass_mtl.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -196,4 +197,18 @@ std::shared_ptr<BlitPass> CommandBufferMTL::OnCreateBlitPass() const {
|
||||
return pass;
|
||||
}
|
||||
|
||||
std::shared_ptr<ComputePass> CommandBufferMTL::OnCreateComputePass() const {
|
||||
if (!buffer_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto pass =
|
||||
std::shared_ptr<ComputePassMTL>(new ComputePassMTL(context_, buffer_));
|
||||
if (!pass->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/compute_pass.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ComputePassMTL final : public ComputePass {
|
||||
public:
|
||||
// |RenderPass|
|
||||
~ComputePassMTL() override;
|
||||
|
||||
private:
|
||||
friend class CommandBufferMTL;
|
||||
|
||||
id<MTLCommandBuffer> buffer_ = nil;
|
||||
std::string label_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
ComputePassMTL(std::weak_ptr<const Context> context,
|
||||
id<MTLCommandBuffer> buffer);
|
||||
|
||||
// |ComputePass|
|
||||
bool IsValid() const override;
|
||||
|
||||
// |ComputePass|
|
||||
void OnSetLabel(std::string label) override;
|
||||
|
||||
// |ComputePass|
|
||||
bool OnEncodeCommands(const Context& context) const override;
|
||||
|
||||
bool EncodeCommands(const std::shared_ptr<Allocator>& allocator,
|
||||
id<MTLComputeCommandEncoder> pass) const;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ComputePassMTL);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,252 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/backend/metal/compute_pass_mtl.h"
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
|
||||
#include "flutter/fml/backtrace.h"
|
||||
#include "flutter/fml/closure.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/base/backend_cast.h"
|
||||
#include "impeller/renderer/backend/metal/compute_pipeline_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/device_buffer_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/formats_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/sampler_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/texture_mtl.h"
|
||||
#include "impeller/renderer/compute_command.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/host_buffer.h"
|
||||
#include "impeller/renderer/shader_types.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ComputePassMTL::ComputePassMTL(std::weak_ptr<const Context> context,
|
||||
id<MTLCommandBuffer> buffer)
|
||||
: ComputePass(std::move(context)), buffer_(buffer) {
|
||||
if (!buffer_) {
|
||||
return;
|
||||
}
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
ComputePassMTL::~ComputePassMTL() = default;
|
||||
|
||||
bool ComputePassMTL::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
void ComputePassMTL::OnSetLabel(std::string label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
label_ = std::move(label);
|
||||
}
|
||||
|
||||
bool ComputePassMTL::OnEncodeCommands(const Context& context) const {
|
||||
TRACE_EVENT0("impeller", "ComputePassMTL::EncodeCommands");
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO(dnfield): Support non-serial dispatch type on higher iOS versions.
|
||||
auto compute_command_encoder = [buffer_ computeCommandEncoder];
|
||||
|
||||
if (!compute_command_encoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!label_.empty()) {
|
||||
[compute_command_encoder setLabel:@(label_.c_str())];
|
||||
}
|
||||
|
||||
// Success or failure, the pass must end. The buffer can only process one pass
|
||||
// at a time.
|
||||
fml::ScopedCleanupClosure auto_end(
|
||||
[compute_command_encoder]() { [compute_command_encoder endEncoding]; });
|
||||
|
||||
return EncodeCommands(context.GetResourceAllocator(),
|
||||
compute_command_encoder);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// @brief Ensures that bindings on the pass are not redundantly set or
|
||||
/// updated. Avoids making the driver do additional checks and makes
|
||||
/// the frame insights during profiling and instrumentation not
|
||||
/// complain about the same.
|
||||
///
|
||||
/// There should be no change to rendering if this caching was
|
||||
/// absent.
|
||||
///
|
||||
struct ComputePassBindingsCache {
|
||||
explicit ComputePassBindingsCache(id<MTLComputeCommandEncoder> encoder)
|
||||
: encoder_(encoder) {}
|
||||
|
||||
ComputePassBindingsCache(const ComputePassBindingsCache&) = delete;
|
||||
|
||||
ComputePassBindingsCache(ComputePassBindingsCache&&) = delete;
|
||||
|
||||
void SetComputePipelineState(id<MTLComputePipelineState> pipeline) {
|
||||
if (pipeline == pipeline_) {
|
||||
return;
|
||||
}
|
||||
pipeline_ = pipeline;
|
||||
[encoder_ setComputePipelineState:pipeline_];
|
||||
}
|
||||
|
||||
void SetBuffer(uint64_t index, uint64_t offset, id<MTLBuffer> buffer) {
|
||||
auto found = buffers_.find(index);
|
||||
if (found != buffers_.end() && found->second.buffer == buffer) {
|
||||
// The right buffer is bound. Check if its offset needs to be updated.
|
||||
if (found->second.offset == offset) {
|
||||
// Buffer and its offset is identical. Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
// Only the offset needs to be updated.
|
||||
found->second.offset = offset;
|
||||
|
||||
[encoder_ setBufferOffset:offset atIndex:index];
|
||||
return;
|
||||
}
|
||||
|
||||
buffers_[index] = {buffer, static_cast<size_t>(offset)};
|
||||
[encoder_ setBuffer:buffer offset:offset atIndex:index];
|
||||
}
|
||||
|
||||
void SetTexture(uint64_t index, id<MTLTexture> texture) {
|
||||
auto found = textures_.find(index);
|
||||
if (found != textures_.end() && found->second == texture) {
|
||||
// Already bound.
|
||||
return;
|
||||
}
|
||||
textures_[index] = texture;
|
||||
[encoder_ setTexture:texture atIndex:index];
|
||||
return;
|
||||
}
|
||||
|
||||
void SetSampler(uint64_t index, id<MTLSamplerState> sampler) {
|
||||
auto found = samplers_.find(index);
|
||||
if (found != samplers_.end() && found->second == sampler) {
|
||||
// Already bound.
|
||||
return;
|
||||
}
|
||||
samplers_[index] = sampler;
|
||||
[encoder_ setSamplerState:sampler atIndex:index];
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
struct BufferOffsetPair {
|
||||
id<MTLBuffer> buffer = nullptr;
|
||||
size_t offset = 0u;
|
||||
};
|
||||
using BufferMap = std::map<uint64_t, BufferOffsetPair>;
|
||||
using TextureMap = std::map<uint64_t, id<MTLTexture>>;
|
||||
using SamplerMap = std::map<uint64_t, id<MTLSamplerState>>;
|
||||
|
||||
const id<MTLComputeCommandEncoder> encoder_;
|
||||
id<MTLComputePipelineState> pipeline_ = nullptr;
|
||||
BufferMap buffers_;
|
||||
TextureMap textures_;
|
||||
SamplerMap samplers_;
|
||||
};
|
||||
|
||||
static bool Bind(ComputePassBindingsCache& pass,
|
||||
Allocator& allocator,
|
||||
size_t bind_index,
|
||||
const BufferView& view) {
|
||||
if (!view.buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto device_buffer = view.buffer->GetDeviceBuffer(allocator);
|
||||
if (!device_buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto buffer = DeviceBufferMTL::Cast(*device_buffer).GetMTLBuffer();
|
||||
// The Metal call is a void return and we don't want to make it on nil.
|
||||
if (!buffer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pass.SetBuffer(bind_index, view.range.offset, buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Bind(ComputePassBindingsCache& pass,
|
||||
size_t bind_index,
|
||||
const Texture& texture) {
|
||||
if (!texture.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pass.SetTexture(bind_index, TextureMTL::Cast(texture).GetMTLTexture());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Bind(ComputePassBindingsCache& pass,
|
||||
size_t bind_index,
|
||||
const Sampler& sampler) {
|
||||
if (!sampler.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pass.SetSampler(bind_index, SamplerMTL::Cast(sampler).GetMTLSamplerState());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputePassMTL::EncodeCommands(
|
||||
const std::shared_ptr<Allocator>& allocator,
|
||||
id<MTLComputeCommandEncoder> encoder) const {
|
||||
ComputePassBindingsCache pass_bindings(encoder);
|
||||
|
||||
fml::closure pop_debug_marker = [encoder]() { [encoder popDebugGroup]; };
|
||||
for (const auto& command : commands_) {
|
||||
fml::ScopedCleanupClosure auto_pop_debug_marker(pop_debug_marker);
|
||||
if (!command.label.empty()) {
|
||||
[encoder pushDebugGroup:@(command.label.c_str())];
|
||||
} else {
|
||||
auto_pop_debug_marker.Release();
|
||||
}
|
||||
|
||||
// TODO(dnfield): update the compute pipeline descriptor so that it can set
|
||||
// things like workgroup size etc.
|
||||
// https://github.com/flutter/flutter/issues/110618
|
||||
pass_bindings.SetComputePipelineState(
|
||||
ComputePipelineMTL::Cast(*command.pipeline)
|
||||
.GetMTLComputePipelineState());
|
||||
|
||||
for (const auto& buffer : command.bindings.buffers) {
|
||||
if (!Bind(pass_bindings, *allocator, buffer.first,
|
||||
buffer.second.resource)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& texture : command.bindings.textures) {
|
||||
if (!Bind(pass_bindings, texture.first, *texture.second.resource)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (const auto& sampler : command.bindings.samplers) {
|
||||
if (!Bind(pass_bindings, sampler.first, *sampler.second.resource)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO(dnfield): use feature detection to support non-uniform threadgroup
|
||||
// sizes.
|
||||
// https://github.com/flutter/flutter/issues/110619
|
||||
[encoder dispatchThreadgroups:MTLSizeMake(32, 32, 1)
|
||||
threadsPerThreadgroup:MTLSizeMake(32, 32, 1)];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/base/backend_cast.h"
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ComputePipelineMTL final
|
||||
: public Pipeline<ComputePipelineDescriptor>,
|
||||
public BackendCast<ComputePipelineMTL,
|
||||
Pipeline<ComputePipelineDescriptor>> {
|
||||
public:
|
||||
// |Pipeline|
|
||||
~ComputePipelineMTL() override;
|
||||
|
||||
id<MTLComputePipelineState> GetMTLComputePipelineState() const;
|
||||
|
||||
private:
|
||||
friend class PipelineLibraryMTL;
|
||||
|
||||
id<MTLComputePipelineState> pipeline_state_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
ComputePipelineMTL(std::weak_ptr<PipelineLibrary> library,
|
||||
ComputePipelineDescriptor desc,
|
||||
id<MTLComputePipelineState> state);
|
||||
|
||||
// |Pipeline|
|
||||
bool IsValid() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ComputePipelineMTL);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/backend/metal/compute_pipeline_mtl.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ComputePipelineMTL::ComputePipelineMTL(std::weak_ptr<PipelineLibrary> library,
|
||||
ComputePipelineDescriptor desc,
|
||||
id<MTLComputePipelineState> state)
|
||||
: Pipeline(std::move(library), std::move(desc)), pipeline_state_(state) {
|
||||
if (!pipeline_state_) {
|
||||
return;
|
||||
}
|
||||
is_valid_ = true;
|
||||
}
|
||||
|
||||
ComputePipelineMTL::~ComputePipelineMTL() = default;
|
||||
|
||||
bool ComputePipelineMTL::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
id<MTLComputePipelineState> ComputePipelineMTL::GetMTLComputePipelineState()
|
||||
const {
|
||||
return pipeline_state_;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -25,6 +25,7 @@ class PipelineLibraryMTL final : public PipelineLibrary {
|
||||
|
||||
id<MTLDevice> device_ = nullptr;
|
||||
PipelineMap pipelines_;
|
||||
ComputePipelineMap compute_pipelines_;
|
||||
|
||||
PipelineLibraryMTL(id<MTLDevice> device);
|
||||
|
||||
@@ -32,7 +33,12 @@ class PipelineLibraryMTL final : public PipelineLibrary {
|
||||
bool IsValid() const override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor) override;
|
||||
PipelineFuture<PipelineDescriptor> GetPipeline(
|
||||
PipelineDescriptor descriptor) override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture<ComputePipelineDescriptor> GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineLibraryMTL);
|
||||
};
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/renderer/backend/metal/pipeline_library_mtl.h"
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include "impeller/base/promise.h"
|
||||
#include "impeller/renderer/backend/metal/compute_pipeline_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/formats_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/pipeline_mtl.h"
|
||||
#include "impeller/renderer/backend/metal/shader_function_mtl.h"
|
||||
@@ -56,6 +58,15 @@ static MTLRenderPipelineDescriptor* GetMTLRenderPipelineDescriptor(
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
static MTLComputePipelineDescriptor* GetMTLComputePipelineDescriptor(
|
||||
const ComputePipelineDescriptor& desc) {
|
||||
auto descriptor = [[MTLComputePipelineDescriptor alloc] init];
|
||||
descriptor.label = @(desc.GetLabel().c_str());
|
||||
descriptor.computeFunction =
|
||||
ShaderFunctionMTL::Cast(*desc.GetStageEntrypoint()).GetMTLFunction();
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
// TODO(csg): Make PipelineDescriptor a struct and move this to formats_mtl.
|
||||
static id<MTLDepthStencilState> CreateDepthStencilDescriptor(
|
||||
const PipelineDescriptor& desc,
|
||||
@@ -74,18 +85,20 @@ bool PipelineLibraryMTL::IsValid() const {
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture PipelineLibraryMTL::GetRenderPipeline(
|
||||
PipelineFuture<PipelineDescriptor> PipelineLibraryMTL::GetPipeline(
|
||||
PipelineDescriptor descriptor) {
|
||||
if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
if (!IsValid()) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<PipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
auto promise = std::make_shared<std::promise<std::shared_ptr<Pipeline>>>();
|
||||
auto future = PipelineFuture{promise->get_future()};
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<PipelineDescriptor>>>>();
|
||||
auto future = PipelineFuture<PipelineDescriptor>{promise->get_future()};
|
||||
pipelines_[descriptor] = future;
|
||||
auto weak_this = weak_from_this();
|
||||
|
||||
@@ -121,4 +134,57 @@ PipelineFuture PipelineLibraryMTL::GetRenderPipeline(
|
||||
return future;
|
||||
}
|
||||
|
||||
PipelineFuture<ComputePipelineDescriptor> PipelineLibraryMTL::GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) {
|
||||
if (auto found = compute_pipelines_.find(descriptor);
|
||||
found != compute_pipelines_.end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
if (!IsValid()) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>>();
|
||||
auto future =
|
||||
PipelineFuture<ComputePipelineDescriptor>{promise->get_future()};
|
||||
compute_pipelines_[descriptor] = future;
|
||||
auto weak_this = weak_from_this();
|
||||
|
||||
auto completion_handler =
|
||||
^(id<MTLComputePipelineState> _Nullable compute_pipeline_state,
|
||||
MTLComputePipelineReflection* _Nullable reflection,
|
||||
NSError* _Nullable error) {
|
||||
if (error != nil) {
|
||||
VALIDATION_LOG << "Could not create compute pipeline: "
|
||||
<< error.localizedDescription.UTF8String;
|
||||
promise->set_value(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto strong_this = weak_this.lock();
|
||||
if (!strong_this) {
|
||||
VALIDATION_LOG << "Library was collected before a pending pipeline "
|
||||
"creation could finish.";
|
||||
promise->set_value(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto new_pipeline = std::shared_ptr<ComputePipelineMTL>(
|
||||
new ComputePipelineMTL(weak_this,
|
||||
descriptor, //
|
||||
compute_pipeline_state //
|
||||
));
|
||||
promise->set_value(new_pipeline);
|
||||
};
|
||||
[device_
|
||||
newComputePipelineStateWithDescriptor:GetMTLComputePipelineDescriptor(
|
||||
descriptor)
|
||||
options:MTLPipelineOptionNone
|
||||
completionHandler:completion_handler];
|
||||
return future;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PipelineMTL final : public Pipeline,
|
||||
public BackendCast<PipelineMTL, Pipeline> {
|
||||
class PipelineMTL final
|
||||
: public Pipeline<PipelineDescriptor>,
|
||||
public BackendCast<PipelineMTL, Pipeline<PipelineDescriptor>> {
|
||||
public:
|
||||
// |Pipeline|
|
||||
~PipelineMTL() override;
|
||||
|
||||
@@ -133,4 +133,10 @@ std::shared_ptr<BlitPass> CommandBufferVK::OnCreateBlitPass() const {
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
std::shared_ptr<ComputePass> CommandBufferVK::OnCreateComputePass() const {
|
||||
// TODO(dnfield): https://github.com/flutter/flutter/issues/110622
|
||||
VALIDATION_LOG << "ComputePasses unimplemented for Vulkan";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -51,6 +51,9 @@ class CommandBufferVK final : public CommandBuffer {
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<BlitPass> OnCreateBlitPass() const override;
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<ComputePass> OnCreateComputePass() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBufferVK);
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ bool PipelineLibraryVK::IsValid() const {
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture PipelineLibraryVK::GetRenderPipeline(
|
||||
PipelineFuture<PipelineDescriptor> PipelineLibraryVK::GetPipeline(
|
||||
PipelineDescriptor descriptor) {
|
||||
Lock lock(pipelines_mutex_);
|
||||
if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) {
|
||||
@@ -59,11 +59,13 @@ PipelineFuture PipelineLibraryVK::GetRenderPipeline(
|
||||
}
|
||||
|
||||
if (!IsValid()) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<PipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
auto promise = std::make_shared<std::promise<std::shared_ptr<Pipeline>>>();
|
||||
auto future = PipelineFuture{promise->get_future()};
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<PipelineDescriptor>>>>();
|
||||
auto future = PipelineFuture<PipelineDescriptor>{promise->get_future()};
|
||||
pipelines_[descriptor] = future;
|
||||
|
||||
auto weak_this = weak_from_this();
|
||||
@@ -85,6 +87,18 @@ PipelineFuture PipelineLibraryVK::GetRenderPipeline(
|
||||
return future;
|
||||
}
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture<ComputePipelineDescriptor> PipelineLibraryVK::GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) {
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>>();
|
||||
auto future =
|
||||
PipelineFuture<ComputePipelineDescriptor>{promise->get_future()};
|
||||
// TODO(dnfield): implement compute for GLES.
|
||||
promise->set_value(nullptr);
|
||||
return future;
|
||||
}
|
||||
|
||||
static vk::AttachmentDescription CreatePlaceholderAttachmentDescription(
|
||||
vk::Format format,
|
||||
SampleCount sample_count) {
|
||||
|
||||
@@ -51,7 +51,12 @@ class PipelineLibraryVK final
|
||||
bool IsValid() const override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor) override;
|
||||
PipelineFuture<PipelineDescriptor> GetPipeline(
|
||||
PipelineDescriptor descriptor) override;
|
||||
|
||||
// |PipelineLibrary|
|
||||
PipelineFuture<ComputePipelineDescriptor> GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) override;
|
||||
|
||||
std::unique_ptr<PipelineCreateInfoVK> CreatePipeline(
|
||||
const PipelineDescriptor& desc);
|
||||
|
||||
@@ -30,8 +30,9 @@ class PipelineCreateInfoVK {
|
||||
vk::UniqueRenderPass render_pass_;
|
||||
};
|
||||
|
||||
class PipelineVK final : public Pipeline,
|
||||
public BackendCast<PipelineVK, Pipeline> {
|
||||
class PipelineVK final
|
||||
: public Pipeline<PipelineDescriptor>,
|
||||
public BackendCast<PipelineVK, Pipeline<PipelineDescriptor>> {
|
||||
public:
|
||||
PipelineVK(std::weak_ptr<PipelineLibrary> library,
|
||||
PipelineDescriptor desc,
|
||||
|
||||
@@ -17,6 +17,8 @@ static ShaderStage ToShaderStage(BlobShaderType type) {
|
||||
return ShaderStage::kVertex;
|
||||
case BlobShaderType::kFragment:
|
||||
return ShaderStage::kFragment;
|
||||
case BlobShaderType::kCompute:
|
||||
return ShaderStage::kCompute;
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -48,9 +48,10 @@ bool Command::BindResource(ShaderStage stage,
|
||||
case ShaderStage::kFragment:
|
||||
fragment_bindings.buffers[slot.binding] = {&metadata, view};
|
||||
return true;
|
||||
case ShaderStage::kCompute:
|
||||
VALIDATION_LOG << "Use ComputeCommands for compute shader stages.";
|
||||
case ShaderStage::kTessellationControl:
|
||||
case ShaderStage::kTessellationEvaluation:
|
||||
case ShaderStage::kCompute:
|
||||
case ShaderStage::kUnknown:
|
||||
return false;
|
||||
}
|
||||
@@ -77,9 +78,10 @@ bool Command::BindResource(ShaderStage stage,
|
||||
case ShaderStage::kFragment:
|
||||
fragment_bindings.textures[slot.texture_index] = {&metadata, texture};
|
||||
return true;
|
||||
case ShaderStage::kCompute:
|
||||
VALIDATION_LOG << "Use ComputeCommands for compute shader stages.";
|
||||
case ShaderStage::kTessellationControl:
|
||||
case ShaderStage::kTessellationEvaluation:
|
||||
case ShaderStage::kCompute:
|
||||
case ShaderStage::kUnknown:
|
||||
return false;
|
||||
}
|
||||
@@ -106,10 +108,11 @@ bool Command::BindResource(ShaderStage stage,
|
||||
case ShaderStage::kFragment:
|
||||
fragment_bindings.samplers[slot.sampler_index] = {&metadata, sampler};
|
||||
return true;
|
||||
case ShaderStage::kCompute:
|
||||
VALIDATION_LOG << "Use ComputeCommands for compute shader stages.";
|
||||
case ShaderStage::kUnknown:
|
||||
case ShaderStage::kTessellationControl:
|
||||
case ShaderStage::kTessellationEvaluation:
|
||||
case ShaderStage::kCompute:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ struct Command {
|
||||
//----------------------------------------------------------------------------
|
||||
/// The pipeline to use for this command.
|
||||
///
|
||||
std::shared_ptr<Pipeline> pipeline;
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline;
|
||||
//----------------------------------------------------------------------------
|
||||
/// The buffer, texture, and sampler bindings used by the vertex pipeline
|
||||
/// stage.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "impeller/renderer/command_buffer.h"
|
||||
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/renderer/compute_pass.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/render_target.h"
|
||||
|
||||
@@ -50,4 +51,16 @@ std::shared_ptr<BlitPass> CommandBuffer::CreateBlitPass() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ComputePass> CommandBuffer::CreateComputePass() const {
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto pass = OnCreateComputePass();
|
||||
if (pass && pass->IsValid()) {
|
||||
pass->SetLabel("ComputePass");
|
||||
return pass;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/blit_pass.h"
|
||||
#include "impeller/renderer/compute_pass.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ComputePass;
|
||||
class Context;
|
||||
class RenderPass;
|
||||
class RenderTarget;
|
||||
@@ -81,6 +83,13 @@ class CommandBuffer {
|
||||
///
|
||||
std::shared_ptr<BlitPass> CreateBlitPass() const;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Create a compute pass to record compute commands into.
|
||||
///
|
||||
/// @return A valid compute pass or null.
|
||||
///
|
||||
std::shared_ptr<ComputePass> CreateComputePass() const;
|
||||
|
||||
protected:
|
||||
std::weak_ptr<const Context> context_;
|
||||
|
||||
@@ -93,6 +102,8 @@ class CommandBuffer {
|
||||
|
||||
[[nodiscard]] virtual bool OnSubmitCommands(CompletionCallback callback) = 0;
|
||||
|
||||
virtual std::shared_ptr<ComputePass> OnCreateComputePass() const = 0;
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
|
||||
};
|
||||
|
||||
82
engine/src/flutter/impeller/renderer/compute_command.cc
Normal file
82
engine/src/flutter/impeller/renderer/compute_command.cc
Normal file
@@ -0,0 +1,82 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/compute_command.h"
|
||||
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/vertex_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
bool ComputeCommand::BindResource(ShaderStage stage,
|
||||
const ShaderUniformSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
BufferView view) {
|
||||
if (stage != ShaderStage::kCompute) {
|
||||
VALIDATION_LOG << "Use Command for non-compute shader stages.";
|
||||
return false;
|
||||
}
|
||||
if (!view) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bindings.buffers[slot.binding] = {&metadata, view};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputeCommand::BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Texture> texture) {
|
||||
if (stage != ShaderStage::kCompute) {
|
||||
VALIDATION_LOG << "Use Command for non-compute shader stages.";
|
||||
return false;
|
||||
}
|
||||
if (!texture || !texture->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!slot.HasTexture()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bindings.textures[slot.texture_index] = {&metadata, texture};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputeCommand::BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Sampler> sampler) {
|
||||
if (stage != ShaderStage::kCompute) {
|
||||
VALIDATION_LOG << "Use Command for non-compute shader stages.";
|
||||
return false;
|
||||
}
|
||||
if (!sampler || !sampler->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!slot.HasSampler()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bindings.samplers[slot.sampler_index] = {&metadata, sampler};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputeCommand::BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Texture> texture,
|
||||
std::shared_ptr<const Sampler> sampler) {
|
||||
if (stage != ShaderStage::kCompute) {
|
||||
VALIDATION_LOG << "Use Command for non-compute shader stages.";
|
||||
return false;
|
||||
}
|
||||
return BindResource(stage, slot, metadata, texture) &&
|
||||
BindResource(stage, slot, metadata, sampler);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
81
engine/src/flutter/impeller/renderer/compute_command.h
Normal file
81
engine/src/flutter/impeller/renderer/compute_command.h
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/geometry/rect.h"
|
||||
#include "impeller/renderer/buffer_view.h"
|
||||
#include "impeller/renderer/command.h"
|
||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
#include "impeller/renderer/sampler.h"
|
||||
#include "impeller/renderer/shader_types.h"
|
||||
#include "impeller/renderer/texture.h"
|
||||
#include "impeller/renderer/vertex_buffer.h"
|
||||
#include "impeller/renderer/vertex_buffer_builder.h"
|
||||
#include "impeller/tessellator/tessellator.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief An object used to specify compute work to the GPU along with
|
||||
/// references to resources the GPU will used when doing said work.
|
||||
///
|
||||
/// To construct a valid command, follow these steps:
|
||||
/// * Specify a valid pipeline.
|
||||
/// * (Optional) Specify a debug label.
|
||||
///
|
||||
/// Command are very lightweight objects and can be created
|
||||
/// frequently and on demand. The resources referenced in commands
|
||||
/// views into buffers managed by other allocators and resource
|
||||
/// managers.
|
||||
///
|
||||
struct ComputeCommand {
|
||||
//----------------------------------------------------------------------------
|
||||
/// The pipeline to use for this command.
|
||||
///
|
||||
std::shared_ptr<Pipeline<ComputePipelineDescriptor>> pipeline;
|
||||
//----------------------------------------------------------------------------
|
||||
/// The buffer, texture, and sampler bindings used by the compute pipeline
|
||||
/// stage.
|
||||
///
|
||||
Bindings bindings;
|
||||
//----------------------------------------------------------------------------
|
||||
/// The debugging label to use for the command.
|
||||
///
|
||||
std::string label;
|
||||
|
||||
bool BindResource(ShaderStage stage,
|
||||
const ShaderUniformSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
BufferView view);
|
||||
|
||||
bool BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Texture> texture);
|
||||
|
||||
bool BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Sampler> sampler);
|
||||
|
||||
bool BindResource(ShaderStage stage,
|
||||
const SampledImageSlot& slot,
|
||||
const ShaderMetadata& metadata,
|
||||
std::shared_ptr<const Texture> texture,
|
||||
std::shared_ptr<const Sampler> sampler);
|
||||
|
||||
constexpr operator bool() const { return pipeline && pipeline->IsValid(); }
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
50
engine/src/flutter/impeller/renderer/compute_pass.cc
Normal file
50
engine/src/flutter/impeller/renderer/compute_pass.cc
Normal file
@@ -0,0 +1,50 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/compute_pass.h"
|
||||
#include <memory>
|
||||
|
||||
#include "impeller/base/strings.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/renderer/host_buffer.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ComputePass::ComputePass(std::weak_ptr<const Context> context)
|
||||
: context_(std::move(context)), transients_buffer_(HostBuffer::Create()) {}
|
||||
|
||||
ComputePass::~ComputePass() = default;
|
||||
|
||||
HostBuffer& ComputePass::GetTransientsBuffer() {
|
||||
return *transients_buffer_;
|
||||
}
|
||||
|
||||
void ComputePass::SetLabel(std::string label) {
|
||||
if (label.empty()) {
|
||||
return;
|
||||
}
|
||||
transients_buffer_->SetLabel(SPrintF("%s Transients", label.c_str()));
|
||||
OnSetLabel(std::move(label));
|
||||
}
|
||||
|
||||
bool ComputePass::AddCommand(ComputeCommand command) {
|
||||
if (!command) {
|
||||
VALIDATION_LOG << "Attempted to add an invalid command to the render pass.";
|
||||
return false;
|
||||
}
|
||||
|
||||
commands_.emplace_back(std::move(command));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputePass::EncodeCommands() const {
|
||||
auto context = context_.lock();
|
||||
// The context could have been collected in the meantime.
|
||||
if (!context) {
|
||||
return false;
|
||||
}
|
||||
return OnEncodeCommands(*context);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
72
engine/src/flutter/impeller/renderer/compute_pass.h
Normal file
72
engine/src/flutter/impeller/renderer/compute_pass.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include "command_buffer.h"
|
||||
#include "impeller/renderer/compute_command.h"
|
||||
#include "impeller/renderer/device_buffer.h"
|
||||
#include "impeller/renderer/texture.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class HostBuffer;
|
||||
class Allocator;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Compute passes encode compute shader into the underlying command
|
||||
/// buffer.
|
||||
///
|
||||
/// @see `CommandBuffer`
|
||||
///
|
||||
class ComputePass {
|
||||
public:
|
||||
virtual ~ComputePass();
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
void SetLabel(std::string label);
|
||||
|
||||
HostBuffer& GetTransientsBuffer();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Record a command for subsequent encoding to the underlying
|
||||
/// command buffer. No work is encoded into the command buffer at
|
||||
/// this time.
|
||||
///
|
||||
/// @param[in] command The command
|
||||
///
|
||||
/// @return If the command was valid for subsequent commitment.
|
||||
///
|
||||
bool AddCommand(ComputeCommand command);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Encode the recorded commands to the underlying command buffer.
|
||||
///
|
||||
/// @param transients_allocator The transients allocator.
|
||||
///
|
||||
/// @return If the commands were encoded to the underlying command
|
||||
/// buffer.
|
||||
///
|
||||
bool EncodeCommands() const;
|
||||
|
||||
protected:
|
||||
const std::weak_ptr<const Context> context_;
|
||||
std::shared_ptr<HostBuffer> transients_buffer_;
|
||||
std::vector<ComputeCommand> commands_;
|
||||
|
||||
explicit ComputePass(std::weak_ptr<const Context> context);
|
||||
|
||||
virtual void OnSetLabel(std::string label) = 0;
|
||||
|
||||
virtual bool OnEncodeCommands(const Context& context) const = 0;
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ComputePass);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/compute_pipeline_builder.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,78 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/base/strings.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/shader_library.h"
|
||||
#include "impeller/renderer/vertex_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief An optional (but highly recommended) utility for creating
|
||||
/// pipelines from reflected shader information.
|
||||
///
|
||||
/// @tparam Compute_Shader The reflected compute shader information. Found
|
||||
/// in a generated header file called
|
||||
/// <shader_name>.comp.h.
|
||||
///
|
||||
template <class ComputeShader_>
|
||||
struct ComputePipelineBuilder {
|
||||
public:
|
||||
using ComputeShader = ComputeShader_;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Create a default pipeline descriptor using the combination
|
||||
/// reflected shader information. The descriptor can be configured
|
||||
/// further before a pipeline state object is created using it.
|
||||
///
|
||||
/// @param[in] context The context
|
||||
///
|
||||
/// @return If the combination of reflected shader information is
|
||||
/// compatible and the requisite functions can be found in the
|
||||
/// context, a pipeline descriptor.
|
||||
///
|
||||
static std::optional<ComputePipelineDescriptor> MakeDefaultPipelineDescriptor(
|
||||
const Context& context) {
|
||||
ComputePipelineDescriptor desc;
|
||||
if (InitializePipelineDescriptorDefaults(context, desc)) {
|
||||
return {std::move(desc)};
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool InitializePipelineDescriptorDefaults(
|
||||
const Context& context,
|
||||
ComputePipelineDescriptor& desc) {
|
||||
// Setup debug instrumentation.
|
||||
desc.SetLabel(SPrintF("%s Pipeline", ComputeShader::kLabel.data()));
|
||||
|
||||
// Resolve pipeline entrypoints.
|
||||
{
|
||||
auto compute_function = context.GetShaderLibrary()->GetFunction(
|
||||
ComputeShader::kEntrypointName, ShaderStage::kCompute);
|
||||
|
||||
if (!compute_function) {
|
||||
VALIDATION_LOG << "Could not resolve compute pipeline entrypoint '"
|
||||
<< ComputeShader::kEntrypointName
|
||||
<< "' for pipeline named '" << ComputeShader::kLabel
|
||||
<< "'.";
|
||||
return false;
|
||||
}
|
||||
|
||||
desc.SetStageEntrypoint(std::move(compute_function));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,66 @@
|
||||
// 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.
|
||||
|
||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/shader_function.h"
|
||||
#include "impeller/renderer/shader_library.h"
|
||||
#include "impeller/renderer/vertex_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ComputePipelineDescriptor::ComputePipelineDescriptor() = default;
|
||||
|
||||
ComputePipelineDescriptor::~ComputePipelineDescriptor() = default;
|
||||
|
||||
// Comparable<ComputePipelineDescriptor>
|
||||
std::size_t ComputePipelineDescriptor::GetHash() const {
|
||||
auto seed = fml::HashCombine();
|
||||
fml::HashCombineSeed(seed, label_);
|
||||
if (entrypoint_) {
|
||||
fml::HashCombineSeed(seed, entrypoint_->GetHash());
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
|
||||
// Comparable<ComputePipelineDescriptor>
|
||||
bool ComputePipelineDescriptor::IsEqual(
|
||||
const ComputePipelineDescriptor& other) const {
|
||||
return label_ == other.label_ &&
|
||||
DeepComparePointer(entrypoint_, other.entrypoint_);
|
||||
}
|
||||
|
||||
ComputePipelineDescriptor& ComputePipelineDescriptor::SetLabel(
|
||||
std::string label) {
|
||||
label_ = std::move(label);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ComputePipelineDescriptor& ComputePipelineDescriptor::SetStageEntrypoint(
|
||||
std::shared_ptr<const ShaderFunction> function) {
|
||||
FML_DCHECK(!function || function->GetStage() == ShaderStage::kCompute);
|
||||
if (!function || function->GetStage() != ShaderStage::kCompute) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (function->GetStage() == ShaderStage::kUnknown) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
entrypoint_ = std::move(function);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::shared_ptr<const ShaderFunction>
|
||||
ComputePipelineDescriptor::GetStageEntrypoint() const {
|
||||
return entrypoint_;
|
||||
}
|
||||
|
||||
const std::string& ComputePipelineDescriptor::GetLabel() const {
|
||||
return label_;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "flutter/fml/hash_combine.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/base/comparable.h"
|
||||
#include "impeller/renderer/formats.h"
|
||||
#include "impeller/renderer/shader_types.h"
|
||||
#include "impeller/tessellator/tessellator.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class ShaderFunction;
|
||||
template <typename T>
|
||||
class Pipeline;
|
||||
|
||||
class ComputePipelineDescriptor final
|
||||
: public Comparable<ComputePipelineDescriptor> {
|
||||
public:
|
||||
ComputePipelineDescriptor();
|
||||
|
||||
~ComputePipelineDescriptor();
|
||||
|
||||
ComputePipelineDescriptor& SetLabel(std::string label);
|
||||
|
||||
const std::string& GetLabel() const;
|
||||
|
||||
ComputePipelineDescriptor& SetStageEntrypoint(
|
||||
std::shared_ptr<const ShaderFunction> function);
|
||||
|
||||
std::shared_ptr<const ShaderFunction> GetStageEntrypoint() const;
|
||||
|
||||
// Comparable<ComputePipelineDescriptor>
|
||||
std::size_t GetHash() const override;
|
||||
|
||||
// Comparable<PipelineDescriptor>
|
||||
bool IsEqual(const ComputePipelineDescriptor& other) const override;
|
||||
|
||||
private:
|
||||
std::string label_;
|
||||
std::shared_ptr<const ShaderFunction> entrypoint_;
|
||||
};
|
||||
|
||||
using ComputePipelineMap = std::unordered_map<
|
||||
ComputePipelineDescriptor,
|
||||
std::shared_future<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>,
|
||||
ComparableHash<ComputePipelineDescriptor>,
|
||||
ComparableEqual<ComputePipelineDescriptor>>;
|
||||
|
||||
} // namespace impeller
|
||||
@@ -4,35 +4,54 @@
|
||||
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
|
||||
#include "compute_pipeline_descriptor.h"
|
||||
#include "impeller/base/promise.h"
|
||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/pipeline_library.h"
|
||||
#include "pipeline_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Pipeline::Pipeline(std::weak_ptr<PipelineLibrary> library,
|
||||
PipelineDescriptor desc)
|
||||
template <typename T>
|
||||
Pipeline<T>::Pipeline(std::weak_ptr<PipelineLibrary> library, T desc)
|
||||
: library_(std::move(library)), desc_(std::move(desc)) {}
|
||||
|
||||
Pipeline::~Pipeline() = default;
|
||||
template <typename T>
|
||||
Pipeline<T>::~Pipeline() = default;
|
||||
|
||||
PipelineFuture CreatePipelineFuture(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc) {
|
||||
PipelineFuture<PipelineDescriptor> CreatePipelineFuture(
|
||||
const Context& context,
|
||||
std::optional<PipelineDescriptor> desc) {
|
||||
if (!context.IsValid()) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<PipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
return context.GetPipelineLibrary()->GetRenderPipeline(std::move(desc));
|
||||
return context.GetPipelineLibrary()->GetPipeline(std::move(desc));
|
||||
}
|
||||
|
||||
const PipelineDescriptor& Pipeline::GetDescriptor() const {
|
||||
PipelineFuture<ComputePipelineDescriptor> CreatePipelineFuture(
|
||||
const Context& context,
|
||||
std::optional<ComputePipelineDescriptor> desc) {
|
||||
if (!context.IsValid()) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>(
|
||||
nullptr);
|
||||
}
|
||||
|
||||
return context.GetPipelineLibrary()->GetPipeline(std::move(desc));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& Pipeline<T>::GetDescriptor() const {
|
||||
return desc_;
|
||||
}
|
||||
|
||||
PipelineFuture Pipeline::CreateVariant(
|
||||
std::function<void(PipelineDescriptor& desc)> descriptor_callback) const {
|
||||
template <typename T>
|
||||
PipelineFuture<T> Pipeline<T>::CreateVariant(
|
||||
std::function<void(T& desc)> descriptor_callback) const {
|
||||
if (!descriptor_callback) {
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<T>>>(nullptr);
|
||||
}
|
||||
|
||||
auto copied_desc = desc_;
|
||||
@@ -43,10 +62,13 @@ PipelineFuture Pipeline::CreateVariant(
|
||||
if (!library) {
|
||||
VALIDATION_LOG << "The library from which this pipeline was created was "
|
||||
"already collected.";
|
||||
return RealizedFuture<std::shared_ptr<Pipeline>>(nullptr);
|
||||
return RealizedFuture<std::shared_ptr<Pipeline<T>>>(nullptr);
|
||||
}
|
||||
|
||||
return library->GetRenderPipeline(std::move(copied_desc));
|
||||
return library->GetPipeline(std::move(copied_desc));
|
||||
}
|
||||
|
||||
template class Pipeline<PipelineDescriptor>;
|
||||
template class Pipeline<ComputePipelineDescriptor>;
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -6,13 +6,18 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
#include "compute_pipeline_descriptor.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/compute_pipeline_builder.h"
|
||||
#include "impeller/renderer/compute_pipeline_descriptor.h"
|
||||
#include "impeller/renderer/context.h"
|
||||
#include "impeller/renderer/pipeline_builder.h"
|
||||
#include "impeller/renderer/pipeline_descriptor.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PipelineLibrary;
|
||||
template <typename PipelineDescriptor_>
|
||||
class Pipeline;
|
||||
|
||||
// TODO(csg): Using a simple future is sub-optimal since callers that want to
|
||||
@@ -21,7 +26,8 @@ class Pipeline;
|
||||
// would be a concurrency pessimization.
|
||||
//
|
||||
// Use a struct that stores the future and the descriptor separately.
|
||||
using PipelineFuture = std::shared_future<std::shared_ptr<Pipeline>>;
|
||||
template <class T>
|
||||
using PipelineFuture = std::shared_future<std::shared_ptr<Pipeline<T>>>;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Describes the fixed function and programmable aspects of
|
||||
@@ -37,6 +43,7 @@ using PipelineFuture = std::shared_future<std::shared_ptr<Pipeline>>;
|
||||
/// Impeller offline shader compiler to generate a typed pipeline
|
||||
/// object.
|
||||
///
|
||||
template <typename T>
|
||||
class Pipeline {
|
||||
public:
|
||||
virtual ~Pipeline();
|
||||
@@ -50,44 +57,52 @@ class Pipeline {
|
||||
///
|
||||
/// @return The descriptor.
|
||||
///
|
||||
const PipelineDescriptor& GetDescriptor() const;
|
||||
const T& GetDescriptor() const;
|
||||
|
||||
PipelineFuture CreateVariant(
|
||||
std::function<void(PipelineDescriptor& desc)> descriptor_callback) const;
|
||||
PipelineFuture<T> CreateVariant(
|
||||
std::function<void(T& desc)> descriptor_callback) const;
|
||||
|
||||
protected:
|
||||
Pipeline(std::weak_ptr<PipelineLibrary> library, PipelineDescriptor desc);
|
||||
Pipeline(std::weak_ptr<PipelineLibrary> library, T desc);
|
||||
|
||||
private:
|
||||
const std::weak_ptr<PipelineLibrary> library_;
|
||||
const PipelineDescriptor desc_;
|
||||
const T desc_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Pipeline);
|
||||
};
|
||||
|
||||
PipelineFuture CreatePipelineFuture(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc);
|
||||
extern template class Pipeline<PipelineDescriptor>;
|
||||
extern template class Pipeline<ComputePipelineDescriptor>;
|
||||
|
||||
PipelineFuture<PipelineDescriptor> CreatePipelineFuture(
|
||||
const Context& context,
|
||||
std::optional<PipelineDescriptor> desc);
|
||||
|
||||
PipelineFuture<ComputePipelineDescriptor> CreatePipelineFuture(
|
||||
const Context& context,
|
||||
std::optional<ComputePipelineDescriptor> desc);
|
||||
|
||||
template <class VertexShader_, class FragmentShader_>
|
||||
class PipelineT {
|
||||
class RenderPipelineT {
|
||||
public:
|
||||
using VertexShader = VertexShader_;
|
||||
using FragmentShader = FragmentShader_;
|
||||
using Builder = PipelineBuilder<VertexShader, FragmentShader>;
|
||||
|
||||
explicit PipelineT(const Context& context)
|
||||
: PipelineT(CreatePipelineFuture(
|
||||
explicit RenderPipelineT(const Context& context)
|
||||
: RenderPipelineT(CreatePipelineFuture(
|
||||
context,
|
||||
Builder::MakeDefaultPipelineDescriptor(context))) {}
|
||||
|
||||
explicit PipelineT(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc)
|
||||
: PipelineT(CreatePipelineFuture(context, desc)) {}
|
||||
explicit RenderPipelineT(const Context& context,
|
||||
std::optional<PipelineDescriptor> desc)
|
||||
: RenderPipelineT(CreatePipelineFuture(context, desc)) {}
|
||||
|
||||
explicit PipelineT(PipelineFuture future)
|
||||
explicit RenderPipelineT(PipelineFuture<PipelineDescriptor> future)
|
||||
: pipeline_future_(std::move(future)) {}
|
||||
|
||||
std::shared_ptr<Pipeline> WaitAndGet() {
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> WaitAndGet() {
|
||||
if (did_wait_) {
|
||||
return pipeline_;
|
||||
}
|
||||
@@ -99,11 +114,49 @@ class PipelineT {
|
||||
}
|
||||
|
||||
private:
|
||||
PipelineFuture pipeline_future_;
|
||||
std::shared_ptr<Pipeline> pipeline_;
|
||||
PipelineFuture<PipelineDescriptor> pipeline_future_;
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline_;
|
||||
bool did_wait_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(PipelineT);
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(RenderPipelineT);
|
||||
};
|
||||
|
||||
template <class ComputeShader_>
|
||||
class ComputePipelineT {
|
||||
public:
|
||||
using ComputeShader = ComputeShader_;
|
||||
using Builder = ComputePipelineBuilder<ComputeShader>;
|
||||
|
||||
explicit ComputePipelineT(const Context& context)
|
||||
: ComputePipelineT(CreatePipelineFuture(
|
||||
context,
|
||||
Builder::MakeDefaultPipelineDescriptor(context))) {}
|
||||
|
||||
explicit ComputePipelineT(
|
||||
const Context& context,
|
||||
std::optional<ComputePipelineDescriptor> compute_desc)
|
||||
: ComputePipelineT(CreatePipelineFuture(context, compute_desc)) {}
|
||||
|
||||
explicit ComputePipelineT(PipelineFuture<ComputePipelineDescriptor> future)
|
||||
: pipeline_future_(std::move(future)) {}
|
||||
|
||||
std::shared_ptr<Pipeline<ComputePipelineDescriptor>> WaitAndGet() {
|
||||
if (did_wait_) {
|
||||
return pipeline_;
|
||||
}
|
||||
did_wait_ = true;
|
||||
if (pipeline_future_.valid()) {
|
||||
pipeline_ = pipeline_future_.get();
|
||||
}
|
||||
return pipeline_;
|
||||
}
|
||||
|
||||
private:
|
||||
PipelineFuture<ComputePipelineDescriptor> pipeline_future_;
|
||||
std::shared_ptr<Pipeline<ComputePipelineDescriptor>> pipeline_;
|
||||
bool did_wait_ = false;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(ComputePipelineT);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace impeller {
|
||||
|
||||
class ShaderFunction;
|
||||
class VertexDescriptor;
|
||||
template <typename T>
|
||||
class Pipeline;
|
||||
|
||||
class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
@@ -132,10 +133,10 @@ class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
|
||||
back_stencil_attachment_descriptor_;
|
||||
};
|
||||
|
||||
using PipelineMap =
|
||||
std::unordered_map<PipelineDescriptor,
|
||||
std::shared_future<std::shared_ptr<Pipeline>>,
|
||||
ComparableHash<PipelineDescriptor>,
|
||||
ComparableEqual<PipelineDescriptor>>;
|
||||
using PipelineMap = std::unordered_map<
|
||||
PipelineDescriptor,
|
||||
std::shared_future<std::shared_ptr<Pipeline<PipelineDescriptor>>>,
|
||||
ComparableHash<PipelineDescriptor>,
|
||||
ComparableEqual<PipelineDescriptor>>;
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -10,12 +10,24 @@ PipelineLibrary::PipelineLibrary() = default;
|
||||
|
||||
PipelineLibrary::~PipelineLibrary() = default;
|
||||
|
||||
PipelineFuture PipelineLibrary::GetRenderPipeline(
|
||||
PipelineFuture<PipelineDescriptor> PipelineLibrary::GetPipeline(
|
||||
std::optional<PipelineDescriptor> descriptor) {
|
||||
if (descriptor.has_value()) {
|
||||
return GetRenderPipeline(std::move(descriptor.value()));
|
||||
return GetPipeline(std::move(descriptor.value()));
|
||||
}
|
||||
auto promise = std::make_shared<std::promise<std::shared_ptr<Pipeline>>>();
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<PipelineDescriptor>>>>();
|
||||
promise->set_value(nullptr);
|
||||
return promise->get_future();
|
||||
}
|
||||
|
||||
PipelineFuture<ComputePipelineDescriptor> PipelineLibrary::GetPipeline(
|
||||
std::optional<ComputePipelineDescriptor> descriptor) {
|
||||
if (descriptor.has_value()) {
|
||||
return GetPipeline(std::move(descriptor.value()));
|
||||
}
|
||||
auto promise = std::make_shared<
|
||||
std::promise<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>>();
|
||||
promise->set_value(nullptr);
|
||||
return promise->get_future();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "compute_pipeline_descriptor.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/renderer/pipeline.h"
|
||||
#include "impeller/renderer/pipeline_descriptor.h"
|
||||
@@ -18,12 +19,19 @@ class PipelineLibrary : public std::enable_shared_from_this<PipelineLibrary> {
|
||||
public:
|
||||
virtual ~PipelineLibrary();
|
||||
|
||||
PipelineFuture GetRenderPipeline(
|
||||
PipelineFuture<PipelineDescriptor> GetPipeline(
|
||||
std::optional<PipelineDescriptor> descriptor);
|
||||
|
||||
PipelineFuture<ComputePipelineDescriptor> GetPipeline(
|
||||
std::optional<ComputePipelineDescriptor> descriptor);
|
||||
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
virtual PipelineFuture GetRenderPipeline(PipelineDescriptor descriptor) = 0;
|
||||
virtual PipelineFuture<PipelineDescriptor> GetPipeline(
|
||||
PipelineDescriptor descriptor) = 0;
|
||||
|
||||
virtual PipelineFuture<ComputePipelineDescriptor> GetPipeline(
|
||||
ComputePipelineDescriptor descriptor) = 0;
|
||||
|
||||
protected:
|
||||
PipelineLibrary();
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "impeller/fixtures/instanced_draw.vert.h"
|
||||
#include "impeller/fixtures/mipmaps.frag.h"
|
||||
#include "impeller/fixtures/mipmaps.vert.h"
|
||||
#if IMPELLER_ENABLE_METAL || IMPELLER_ENABLE_VULKAN
|
||||
#include "impeller/fixtures/sample.comp.h"
|
||||
#endif
|
||||
#include "impeller/fixtures/test_texture.frag.h"
|
||||
#include "impeller/fixtures/test_texture.vert.h"
|
||||
#include "impeller/geometry/path_builder.h"
|
||||
@@ -51,7 +54,7 @@ TEST_P(RendererTest, CanCreateBoxPrimitive) {
|
||||
ASSERT_TRUE(desc.has_value());
|
||||
desc->SetSampleCount(SampleCount::kCount4);
|
||||
auto box_pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_TRUE(box_pipeline);
|
||||
|
||||
// Vertex buffer.
|
||||
@@ -117,7 +120,7 @@ TEST_P(RendererTest, CanRenderPerspectiveCube) {
|
||||
desc->SetCullMode(CullMode::kBackFace);
|
||||
desc->SetSampleCount(SampleCount::kCount4);
|
||||
auto pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_TRUE(pipeline);
|
||||
|
||||
struct Cube {
|
||||
@@ -215,7 +218,7 @@ TEST_P(RendererTest, CanRenderMultiplePrimitives) {
|
||||
ASSERT_TRUE(desc.has_value());
|
||||
desc->SetSampleCount(SampleCount::kCount4);
|
||||
auto box_pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_TRUE(box_pipeline);
|
||||
|
||||
// Vertex buffer.
|
||||
@@ -288,7 +291,7 @@ TEST_P(RendererTest, CanRenderToTexture) {
|
||||
BoxPipelineBuilder::MakeDefaultPipelineDescriptor(*context);
|
||||
ASSERT_TRUE(pipeline_desc.has_value());
|
||||
auto box_pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(pipeline_desc).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).get();
|
||||
ASSERT_TRUE(box_pipeline);
|
||||
|
||||
VertexBufferBuilder<VS::PerVertexData> vertex_builder;
|
||||
@@ -410,10 +413,9 @@ TEST_P(RendererTest, CanRenderInstanced) {
|
||||
auto pipeline =
|
||||
GetContext()
|
||||
->GetPipelineLibrary()
|
||||
->GetRenderPipeline(
|
||||
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(
|
||||
*GetContext())
|
||||
->SetSampleCount(SampleCount::kCount4))
|
||||
->GetPipeline(PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(
|
||||
*GetContext())
|
||||
->SetSampleCount(SampleCount::kCount4))
|
||||
.get();
|
||||
ASSERT_TRUE(pipeline && pipeline->IsValid());
|
||||
|
||||
@@ -456,7 +458,7 @@ TEST_P(RendererTest, CanBlitTextureToTexture) {
|
||||
ASSERT_TRUE(desc.has_value());
|
||||
desc->SetSampleCount(SampleCount::kCount4);
|
||||
auto mipmaps_pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_TRUE(mipmaps_pipeline);
|
||||
|
||||
TextureDescriptor texture_desc;
|
||||
@@ -566,7 +568,7 @@ TEST_P(RendererTest, CanGenerateMipmaps) {
|
||||
ASSERT_TRUE(desc.has_value());
|
||||
desc->SetSampleCount(SampleCount::kCount4);
|
||||
auto mipmaps_pipeline =
|
||||
context->GetPipelineLibrary()->GetRenderPipeline(std::move(desc)).get();
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_TRUE(mipmaps_pipeline);
|
||||
|
||||
auto boston = CreateTextureForFixture("boston.jpg", true);
|
||||
@@ -686,9 +688,8 @@ TEST_P(RendererTest, TheImpeller) {
|
||||
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(*context);
|
||||
ASSERT_TRUE(pipeline_descriptor.has_value());
|
||||
pipeline_descriptor->SetSampleCount(SampleCount::kCount4);
|
||||
auto pipeline = context->GetPipelineLibrary()
|
||||
->GetRenderPipeline(pipeline_descriptor)
|
||||
.get();
|
||||
auto pipeline =
|
||||
context->GetPipelineLibrary()->GetPipeline(pipeline_descriptor).get();
|
||||
ASSERT_TRUE(pipeline && pipeline->IsValid());
|
||||
|
||||
auto blue_noise = CreateTextureForFixture("blue_noise.png");
|
||||
@@ -738,5 +739,50 @@ TEST_P(RendererTest, TheImpeller) {
|
||||
OpenPlaygroundHere(callback);
|
||||
}
|
||||
|
||||
#if IMPELLER_ENABLE_METAL || IMPELLER_ENABLE_VULKAN
|
||||
TEST_P(RendererTest, CanCreateComputePass) {
|
||||
if (GetParam() == PlaygroundBackend::kOpenGLES) {
|
||||
GTEST_SKIP_("Compute is not supported on GL.");
|
||||
}
|
||||
if (GetParam() == PlaygroundBackend::kVulkan) {
|
||||
GTEST_SKIP_("Compute is not supported on Vulkan yet.");
|
||||
}
|
||||
|
||||
using CS = SampleComputeShader;
|
||||
auto context = GetContext();
|
||||
ASSERT_TRUE(context);
|
||||
using SamplePipelineBuilder = ComputePipelineBuilder<CS>;
|
||||
auto pipeline_desc =
|
||||
SamplePipelineBuilder::MakeDefaultPipelineDescriptor(*context);
|
||||
ASSERT_TRUE(pipeline_desc.has_value());
|
||||
auto compute_pipeline =
|
||||
context->GetPipelineLibrary()->GetPipeline(pipeline_desc).get();
|
||||
ASSERT_TRUE(compute_pipeline);
|
||||
|
||||
auto cmd_buffer = context->CreateCommandBuffer();
|
||||
auto pass = cmd_buffer->CreateComputePass();
|
||||
ASSERT_TRUE(pass && pass->IsValid());
|
||||
|
||||
ComputeCommand cmd;
|
||||
cmd.label = "Compute";
|
||||
cmd.pipeline = compute_pipeline;
|
||||
|
||||
std::vector<CS::Input0> input_0;
|
||||
std::vector<CS::Input1> input_1;
|
||||
input_0.push_back(CS::Input0{Vector4(2.0, 3.0, 4.0, 5.0)});
|
||||
input_1.push_back(CS::Input1{Vector4(6.0, 7.0, 8.0, 9.0)});
|
||||
|
||||
std::vector<CS::Output> output(5);
|
||||
CS::BindInput0(cmd,
|
||||
pass->GetTransientsBuffer().EmplaceStorageBuffer(input_0));
|
||||
CS::BindInput1(cmd,
|
||||
pass->GetTransientsBuffer().EmplaceStorageBuffer(input_1));
|
||||
CS::BindOutput(cmd, pass->GetTransientsBuffer().EmplaceStorageBuffer(output));
|
||||
|
||||
ASSERT_TRUE(pass->AddCommand(std::move(cmd)));
|
||||
ASSERT_TRUE(pass->EncodeCommands());
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
@@ -237,10 +237,8 @@ TEST_P(RuntimeStageTest, CanCreatePipelineFromRuntimeStage) {
|
||||
desc.SetColorAttachmentDescriptor(0u, color0);
|
||||
desc.SetStencilAttachmentDescriptors(stencil0);
|
||||
desc.SetStencilPixelFormat(PixelFormat::kDefaultStencil);
|
||||
auto pipeline = GetContext()
|
||||
->GetPipelineLibrary()
|
||||
->GetRenderPipeline(std::move(desc))
|
||||
.get();
|
||||
auto pipeline =
|
||||
GetContext()->GetPipelineLibrary()->GetPipeline(std::move(desc)).get();
|
||||
ASSERT_NE(pipeline, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -562,7 +562,11 @@ template("impeller_shaders") {
|
||||
gles_shaders = "gles_$target_name"
|
||||
impeller_shaders_gles(gles_shaders) {
|
||||
name = invoker.name
|
||||
shaders = invoker.shaders
|
||||
if (defined(invoker.gles_exclusions)) {
|
||||
shaders = invoker.shaders - invoker.gles_exclusions
|
||||
} else {
|
||||
shaders = invoker.shaders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user