Add cull mode to command (flutter/engine#13)

This commit is contained in:
Brandon DeRosier
2022-02-17 10:46:55 -08:00
committed by Dan Field
parent 6fa7495680
commit 75460b68be
4 changed files with 21 additions and 2 deletions

View File

@@ -116,6 +116,18 @@ constexpr MTLIndexType ToMTLIndexType(IndexType type) {
}
}
constexpr MTLCullMode ToMTLCullMode(CullMode mode) {
switch (mode) {
case CullMode::kNone:
return MTLCullModeNone;
case CullMode::kBackFace:
return MTLCullModeBack;
case CullMode::kFrontFace:
return MTLCullModeFront;
}
return MTLCullModeNone;
}
constexpr MTLBlendOperation ToMTLBlendOperation(BlendOperation type) {
switch (type) {
case BlendOperation::kAdd:

View File

@@ -426,7 +426,7 @@ bool RenderPassMTL::EncodeCommands(Allocator& allocator,
[encoder setFrontFacingWinding:command.winding == WindingOrder::kClockwise
? MTLWindingClockwise
: MTLWindingCounterClockwise];
[encoder setCullMode:MTLCullModeNone];
[encoder setCullMode:ToMTLCullMode(command.cull_mode)];
[encoder setStencilReferenceValue:command.stencil_reference];
if (command.viewport.has_value()) {
auto v = command.viewport.value();

View File

@@ -70,6 +70,7 @@ struct Command {
std::string label;
PrimitiveType primitive_type = PrimitiveType::kTriangle;
WindingOrder winding = WindingOrder::kClockwise;
CullMode cull_mode = CullMode::kNone;
uint32_t stencil_reference = 0u;
//----------------------------------------------------------------------------
/// The viewport coordinates that the rasterizer linearly maps normalized

View File

@@ -11,9 +11,9 @@
#include "flutter/fml/hash_combine.h"
#include "flutter/fml/macros.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/rect.h"
#include "impeller/geometry/scalar.h"
#include "impeller/geometry/color.h"
namespace impeller {
@@ -135,6 +135,12 @@ enum class WindingOrder {
kCounterClockwise,
};
enum class CullMode {
kNone,
kFrontFace,
kBackFace,
};
enum class IndexType {
kUnknown,
k16bit,