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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ FILE: ../../../flutter/impeller/renderer/command_buffer.cc
FILE: ../../../flutter/impeller/renderer/command_buffer.h
FILE: ../../../flutter/impeller/renderer/context.cc
FILE: ../../../flutter/impeller/renderer/context.h
FILE: ../../../flutter/impeller/renderer/descriptor_set_layout.h
FILE: ../../../flutter/impeller/renderer/device_buffer.cc
FILE: ../../../flutter/impeller/renderer/device_buffer.h
FILE: ../../../flutter/impeller/renderer/device_buffer_unittests.cc
Expand Down
30 changes: 14 additions & 16 deletions impeller/compiler/code_gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ constexpr std::string_view kReflectionHeaderTemplate =
{# Note: The nogncheck decorations are only to make GN not mad at the template#}
{# this file is generated from. There are no GN rule violations in the generated#}
{# file itself and the no-check declarations will be stripped in generated files.#}
#include "impeller/renderer/buffer_view.h" {# // nogncheck #}
#include "impeller/renderer/buffer_view.h" {# // nogncheck #}

#include "impeller/renderer/command.h" {# // nogncheck #}
#include "impeller/renderer/command.h" {# // nogncheck #}

#include "impeller/renderer/sampler.h" {# // nogncheck #}
#include "impeller/renderer/descriptor_set_layout.h" {# // nogncheck #}

#include "impeller/renderer/shader_types.h" {# // nogncheck #}
#include "impeller/renderer/sampler.h" {# // nogncheck #}

#include "impeller/renderer/texture.h" {# // nogncheck #}
#include "impeller/renderer/shader_types.h" {# // nogncheck #}

#include "impeller/renderer/texture.h" {# // nogncheck #}


namespace impeller {
Expand Down Expand Up @@ -150,30 +152,26 @@ std::move({{ arg.argument_name }}){% if not loop.is_last %}, {% endif %}
// ===========================================================================
// Metadata for Vulkan =======================================================
// ===========================================================================
#ifdef IMPELLER_ENABLE_VULKAN_REFLECTION
{% if length(buffers)+length(sampled_images) > 0 %}
static constexpr std::array<VkDescriptorSetLayoutBinding,{{length(buffers)+length(sampled_images)}}> kDescriptorSetLayouts{
static constexpr std::array<DescriptorSetLayout,{{length(buffers)+length(sampled_images)}}> kDescriptorSetLayouts{
{% for buffer in buffers %}
VkDescriptorSetLayoutBinding{
DescriptorSetLayout{
{{buffer.binding}}, // binding = {{buffer.binding}}
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // descriptorType = Uniform Buffer
DescriptorType::kUniformBuffer, // descriptorType = Uniform Buffer
1, // descriptorCount = 1
{{to_vk_shader_stage_flag_bits(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
nullptr, // pImmutableSamplers = NULL
{{to_shader_stage(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
},
{% endfor %}
{% for sampled_image in sampled_images %}
VkDescriptorSetLayoutBinding{
DescriptorSetLayout{
{{sampled_image.binding}}, // binding = {{sampled_image.binding}}
VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, // descriptorType = Sampled Image
DescriptorType::kSampledImage, // descriptorType = Sampled Image
1, // descriptorCount = 1
{{to_vk_shader_stage_flag_bits(shader_stage)}},// stageFlags = {{to_shader_stage(shader_stage)}}
nullptr, // pImmutableSamplers = NULL
{{to_shader_stage(shader_stage)}}, // stageFlags = {{to_shader_stage(shader_stage)}}
},
{% endfor %}
};
{% endif %}
#endif

}; // struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Shader

Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impeller_component("renderer") {
"command_buffer.h",
"context.cc",
"context.h",
"descriptor_set_layout.h",
"device_buffer.cc",
"device_buffer.h",
"formats.cc",
Expand Down
27 changes: 27 additions & 0 deletions impeller/renderer/descriptor_set_layout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 <memory>
#include <string>

#include "flutter/fml/macros.h"
#include "impeller/renderer/shader_types.h"

namespace impeller {

enum class DescriptorType {
kSampledImage,
kUniformBuffer,
};

struct DescriptorSetLayout {
uint32_t binding;
DescriptorType descriptor_type;
uint32_t descriptor_count;
ShaderStage shader_stage;
};

} // namespace impeller
7 changes: 7 additions & 0 deletions impeller/renderer/pipeline_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ struct PipelineBuilder {
<< VertexShader::kLabel << "'.";
return false;
}
if (!vertex_descriptor->SetDescriptorSetLayouts(
VertexShader::kDescriptorSetLayouts)) {
VALIDATION_LOG << "Cound not configure vertex descriptor set layout for"
" pipeline named '"
<< VertexShader::kLabel << "'.";
return false;
}
desc.SetVertexDescriptor(std::move(vertex_descriptor));
}

Expand Down
15 changes: 15 additions & 0 deletions impeller/renderer/vertex_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ bool VertexDescriptor::SetStageInputs(
return true;
}

bool VertexDescriptor::SetDescriptorSetLayouts(
const DescriptorSetLayout desc_set_layout[],
size_t count) {
desc_set_layouts_.reserve(desc_set_layouts_.size() + count);
for (size_t i = 0; i < count; i++) {
desc_set_layouts_.emplace_back(desc_set_layout[i]);
}
return true;
}

// |Comparable<VertexDescriptor>|
size_t VertexDescriptor::GetHash() const {
auto seed = fml::HashCombine();
Expand All @@ -38,4 +48,9 @@ const std::vector<ShaderStageIOSlot>& VertexDescriptor::GetStageInputs() const {
return inputs_;
}

const std::vector<DescriptorSetLayout>&
VertexDescriptor::GetDescriptorSetLayouts() const {
return desc_set_layouts_;
}

} // namespace impeller
13 changes: 13 additions & 0 deletions impeller/renderer/vertex_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "flutter/fml/macros.h"
#include "impeller/base/comparable.h"
#include "impeller/renderer/descriptor_set_layout.h"
#include "impeller/renderer/shader_types.h"

namespace impeller {
Expand Down Expand Up @@ -36,11 +37,22 @@ class VertexDescriptor final : public Comparable<VertexDescriptor> {
return SetStageInputs(inputs.data(), inputs.size());
}

template <size_t Size>
bool SetDescriptorSetLayouts(
const std::array<DescriptorSetLayout, Size>& inputs) {
return SetDescriptorSetLayouts(inputs.data(), inputs.size());
}

bool SetStageInputs(const ShaderStageIOSlot* const stage_inputs[],
size_t count);

bool SetDescriptorSetLayouts(const DescriptorSetLayout desc_set_layout[],
size_t count);

const std::vector<ShaderStageIOSlot>& GetStageInputs() const;

const std::vector<DescriptorSetLayout>& GetDescriptorSetLayouts() const;

// |Comparable<VertexDescriptor>|
std::size_t GetHash() const override;

Expand All @@ -49,6 +61,7 @@ class VertexDescriptor final : public Comparable<VertexDescriptor> {

private:
std::vector<ShaderStageIOSlot> inputs_;
std::vector<DescriptorSetLayout> desc_set_layouts_;

FML_DISALLOW_COPY_AND_ASSIGN(VertexDescriptor);
};
Expand Down