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
12 changes: 12 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions impeller/blobcat/blob.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace impeller.fb;
enum Stage:byte {
kVertex,
kFragment,
kCompute,
}

table Blob {
Expand Down
2 changes: 2 additions & 0 deletions impeller/blobcat/blob_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions impeller/blobcat/blob_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace impeller {
enum class BlobShaderType {
kVertex,
kFragment,
kCompute,
};

} // namespace impeller
4 changes: 4 additions & 0 deletions impeller/blobcat/blob_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions impeller/compiler/code_gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down
36 changes: 27 additions & 9 deletions impeller/compiler/reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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{});
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{});
Expand Down
6 changes: 4 additions & 2 deletions impeller/compiler/reflector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading