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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Impeller] add support for specialization constants.
  • Loading branch information
jonahwilliams committed Oct 29, 2023
commit f0b499de5dade1019b7ad8fbd060cc5ee75656a2
22 changes: 22 additions & 0 deletions impeller/base/comparable.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ bool DeepCompareMap(const std::map<Key, std::shared_ptr<ComparableType>>& lhs,
return true;
}

template <class Key, class Value, class Hash, class Eq>
bool CompareUnorderedMap(const std::unordered_map<Key, Value, Hash, Eq>& lhs,
const std::unordered_map<Key, Value, Hash, Eq>& rhs) {
if (lhs.size() != rhs.size()) {
return false;
}
for (const auto& [key, value] : lhs) {
auto found = rhs.find(key);
if (found == rhs.end() || found->second != value) {
return false;
}
}
for (const auto& [key, value] : rhs) {
auto found = lhs.find(key);
if (found == rhs.end() || found->second != value) {
return false;
}
}

return true;
}

} // namespace impeller

namespace std {
Expand Down
34 changes: 3 additions & 31 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,7 @@ impeller_shaders("entity_shaders") {

shaders = [
"shaders/blending/advanced_blend.vert",
"shaders/blending/advanced_blend_color.frag",
"shaders/blending/advanced_blend_colorburn.frag",
"shaders/blending/advanced_blend_colordodge.frag",
"shaders/blending/advanced_blend_darken.frag",
"shaders/blending/advanced_blend_difference.frag",
"shaders/blending/advanced_blend_exclusion.frag",
"shaders/blending/advanced_blend_hardlight.frag",
"shaders/blending/advanced_blend_hue.frag",
"shaders/blending/advanced_blend_lighten.frag",
"shaders/blending/advanced_blend_luminosity.frag",
"shaders/blending/advanced_blend_multiply.frag",
"shaders/blending/advanced_blend_overlay.frag",
"shaders/blending/advanced_blend_saturation.frag",
"shaders/blending/advanced_blend_screen.frag",
"shaders/blending/advanced_blend_softlight.frag",
"shaders/blending/advanced_blend.frag",
"shaders/blending/blend.frag",
"shaders/blending/blend.vert",
"shaders/border_mask_blur.frag",
Expand Down Expand Up @@ -115,22 +101,8 @@ impeller_shaders("framebuffer_blend_entity_shaders") {
}

shaders = [
"shaders/blending/ios/framebuffer_blend.vert",
"shaders/blending/ios/framebuffer_blend_color.frag",
"shaders/blending/ios/framebuffer_blend_colorburn.frag",
"shaders/blending/ios/framebuffer_blend_colordodge.frag",
"shaders/blending/ios/framebuffer_blend_darken.frag",
"shaders/blending/ios/framebuffer_blend_difference.frag",
"shaders/blending/ios/framebuffer_blend_exclusion.frag",
"shaders/blending/ios/framebuffer_blend_hardlight.frag",
"shaders/blending/ios/framebuffer_blend_hue.frag",
"shaders/blending/ios/framebuffer_blend_lighten.frag",
"shaders/blending/ios/framebuffer_blend_luminosity.frag",
"shaders/blending/ios/framebuffer_blend_multiply.frag",
"shaders/blending/ios/framebuffer_blend_overlay.frag",
"shaders/blending/ios/framebuffer_blend_saturation.frag",
"shaders/blending/ios/framebuffer_blend_screen.frag",
"shaders/blending/ios/framebuffer_blend_softlight.frag",
"shaders/blending/framebuffer_blend.vert",
"shaders/blending/framebuffer_blend.frag",
]
}

Expand Down
137 changes: 92 additions & 45 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include "impeller/entity/contents/content_context.h"

#include <memory>
#include <sstream>

#include "impeller/base/strings.h"
#include "impeller/core/formats.h"
#include "impeller/entity/contents/framebuffer_blend_contents.h"
#include "impeller/entity/entity.h"
#include "impeller/entity/render_target_cache.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/pipeline_descriptor.h"
#include "impeller/renderer/pipeline_library.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/render_target.h"
#include "impeller/tessellator/tessellator.h"
#include "impeller/typographer/typographer_context.h"
Expand Down Expand Up @@ -155,8 +155,10 @@ void ContentContextOptions::ApplyToPipelineDescriptor(

template <typename PipelineT>
static std::unique_ptr<PipelineT> CreateDefaultPipeline(
const Context& context) {
auto desc = PipelineT::Builder::MakeDefaultPipelineDescriptor(context);
const Context& context,
const std::map<SpecializationConstant, uint64_t>& constants = {}) {
auto desc =
PipelineT::Builder::MakeDefaultPipelineDescriptor(context, constants);
if (!desc.has_value()) {
return nullptr;
}
Expand Down Expand Up @@ -217,53 +219,98 @@ ContentContext::ContentContext(
}

if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
framebuffer_blend_color_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_colorburn_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_color_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColor)});
framebuffer_blend_colorburn_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColorBurn)});
framebuffer_blend_colordodge_pipelines_.CreateDefault(
*context_, options_trianglestrip);
framebuffer_blend_darken_pipelines_.CreateDefault(*context_,
options_trianglestrip);
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColorDodge)});
framebuffer_blend_darken_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kDarken)});
framebuffer_blend_difference_pipelines_.CreateDefault(
*context_, options_trianglestrip);
framebuffer_blend_exclusion_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_hardlight_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_hue_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_lighten_pipelines_.CreateDefault(*context_,
options_trianglestrip);
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kDifference)});
framebuffer_blend_exclusion_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kExclusion)});
framebuffer_blend_hardlight_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kHardLight)});
framebuffer_blend_hue_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kHue)});
framebuffer_blend_lighten_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kLighten)});
framebuffer_blend_luminosity_pipelines_.CreateDefault(
*context_, options_trianglestrip);
framebuffer_blend_multiply_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_overlay_pipelines_.CreateDefault(*context_,
options_trianglestrip);
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kLuminosity)});
framebuffer_blend_multiply_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kMultiply)});
framebuffer_blend_overlay_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kOverlay)});
framebuffer_blend_saturation_pipelines_.CreateDefault(
*context_, options_trianglestrip);
framebuffer_blend_screen_pipelines_.CreateDefault(*context_,
options_trianglestrip);
framebuffer_blend_softlight_pipelines_.CreateDefault(*context_,
options_trianglestrip);
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kSaturation)});
framebuffer_blend_screen_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kScreen)});
framebuffer_blend_softlight_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kSoftLight)});
}

blend_color_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_colorburn_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_colordodge_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_darken_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_difference_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_exclusion_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_hardlight_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_hue_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_lighten_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_luminosity_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_multiply_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_overlay_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_saturation_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_screen_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_softlight_pipelines_.CreateDefault(*context_, options_trianglestrip);
blend_color_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColor)});
blend_colorburn_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColorBurn)});
blend_colordodge_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kColorDodge)});
blend_darken_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kDarken)});
blend_difference_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kDifference)});
blend_exclusion_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kExclusion)});
blend_hardlight_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kHardLight)});
blend_hue_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kHue)});
blend_lighten_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kLighten)});
blend_luminosity_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kLuminosity)});
blend_multiply_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kMultiply)});
blend_overlay_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kOverlay)});
blend_saturation_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kSaturation)});
blend_screen_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kScreen)});
blend_softlight_pipelines_.CreateDefault(
*context_, options_trianglestrip,
{static_cast<int>(BlendSelectValues::kSoftLight)});

rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
texture_blend_pipelines_.CreateDefault(*context_, options);
Expand Down
Loading