Skip to content

Commit

Permalink
Don't waste space on an unnecessary depth buffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored and dnfield committed Apr 27, 2022
1 parent 86c91dc commit 687f189
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ void Canvas::Concat(const Matrix& xformation) {
xformation_stack_.back().xformation = xformation * GetCurrentTransformation();
}

void Canvas::ResetTransform() {
xformation_stack_.back().xformation = {};
}

void Canvas::Transform(const Matrix& xformation) {
Concat(xformation);
}
Expand Down
2 changes: 2 additions & 0 deletions impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Canvas {

const Matrix& GetCurrentTransformation() const;

void ResetTransform();

void Transform(const Matrix& xformation);

void Concat(const Matrix& xformation);
Expand Down
5 changes: 5 additions & 0 deletions impeller/display_list/display_list_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ void DisplayListDispatcher::transformFullPerspective(SkScalar mxx,
canvas_.Transform(xformation);
}

// |flutter::Dispatcher|
void DisplayListDispatcher::transformReset() {
canvas_.ResetTransform();
}

static Rect ToRect(const SkRect& rect) {
return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
}
Expand Down
3 changes: 3 additions & 0 deletions impeller/display_list/display_list_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
SkScalar mwz,
SkScalar mwt) override;

// |flutter::Dispatcher|
void transformReset() override;

// |flutter::Dispatcher|
void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) override;

Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/backend/metal/formats_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format) {
return MTLPixelFormatDepth32Float_Stencil8;
case PixelFormat::kR8G8B8A8UNormInt:
return MTLPixelFormatRGBA8Unorm;
case PixelFormat::kS8UInt:
return MTLPixelFormatStencil8;
case PixelFormat::kR8G8B8A8UNormIntSRGB:
return MTLPixelFormatRGBA8Unorm_sRGB;
}
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/metal/surface_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
TextureDescriptor stencil0_tex;
stencil0_tex.type = TextureType::k2DMultisample;
stencil0_tex.sample_count = SampleCount::kCount4;
stencil0_tex.format = PixelFormat::kD32FloatS8UNormInt;
stencil0_tex.format = PixelFormat::kS8UInt;
stencil0_tex.size = msaa_tex_desc.size;
stencil0_tex.usage =
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);
Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum class PixelFormat {
kR8G8B8A8UNormIntSRGB,
kB8G8R8A8UNormInt,
kB8G8R8A8UNormIntSRGB,
kS8UInt,
// Esoteric formats only used as render targets.
kD32FloatS8UNormInt,
};
Expand Down Expand Up @@ -166,6 +167,8 @@ constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format) {
switch (format) {
case PixelFormat::kUnknown:
return 0u;
case PixelFormat::kS8UInt:
return 1u;
case PixelFormat::kR8G8B8A8UNormInt:
case PixelFormat::kR8G8B8A8UNormIntSRGB:
case PixelFormat::kB8G8R8A8UNormInt:
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/pipeline_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct PipelineBuilder {
StencilAttachmentDescriptor stencil0;
stencil0.stencil_compare = CompareFunction::kLessEqual;
desc.SetStencilAttachmentDescriptors(stencil0);
desc.SetStencilPixelFormat(PixelFormat::kD32FloatS8UNormInt);
desc.SetStencilPixelFormat(PixelFormat::kS8UInt);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/render_target.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ RenderTarget RenderTarget::CreateOffscreen(const Context& context,
static_cast<uint64_t>(TextureUsage::kShaderRead);

TextureDescriptor stencil_tex0;
stencil_tex0.format = PixelFormat::kD32FloatS8UNormInt;
stencil_tex0.format = PixelFormat::kS8UInt;
stencil_tex0.size = size;
stencil_tex0.usage =
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/renderer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ TEST_F(RendererTest, CanRenderToTexture) {
stencil0.store_action = StoreAction::kDontCare;
TextureDescriptor stencil_texture_desc;
stencil_texture_desc.size = texture_descriptor.size;
stencil_texture_desc.format = PixelFormat::kD32FloatS8UNormInt;
stencil_texture_desc.format = PixelFormat::kS8UInt;
stencil_texture_desc.usage =
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);
stencil0.texture = context->GetPermanentsAllocator()->CreateTexture(
Expand Down

0 comments on commit 687f189

Please sign in to comment.