Skip to content

Commit 687f189

Browse files
chinmaygardednfield
authored andcommitted
Don't waste space on an unnecessary depth buffer.
1 parent 86c91dc commit 687f189

10 files changed

+23
-4
lines changed

impeller/aiks/canvas.cc

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ void Canvas::Concat(const Matrix& xformation) {
5353
xformation_stack_.back().xformation = xformation * GetCurrentTransformation();
5454
}
5555

56+
void Canvas::ResetTransform() {
57+
xformation_stack_.back().xformation = {};
58+
}
59+
5660
void Canvas::Transform(const Matrix& xformation) {
5761
Concat(xformation);
5862
}

impeller/aiks/canvas.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class Canvas {
4141

4242
const Matrix& GetCurrentTransformation() const;
4343

44+
void ResetTransform();
45+
4446
void Transform(const Matrix& xformation);
4547

4648
void Concat(const Matrix& xformation);

impeller/display_list/display_list_dispatcher.cc

+5
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ void DisplayListDispatcher::transformFullPerspective(SkScalar mxx,
206206
canvas_.Transform(xformation);
207207
}
208208

209+
// |flutter::Dispatcher|
210+
void DisplayListDispatcher::transformReset() {
211+
canvas_.ResetTransform();
212+
}
213+
209214
static Rect ToRect(const SkRect& rect) {
210215
return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
211216
}

impeller/display_list/display_list_dispatcher.h

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class DisplayListDispatcher final : public flutter::Dispatcher {
118118
SkScalar mwz,
119119
SkScalar mwt) override;
120120

121+
// |flutter::Dispatcher|
122+
void transformReset() override;
123+
121124
// |flutter::Dispatcher|
122125
void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) override;
123126

impeller/renderer/backend/metal/formats_mtl.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format) {
2929
return MTLPixelFormatDepth32Float_Stencil8;
3030
case PixelFormat::kR8G8B8A8UNormInt:
3131
return MTLPixelFormatRGBA8Unorm;
32+
case PixelFormat::kS8UInt:
33+
return MTLPixelFormatStencil8;
3234
case PixelFormat::kR8G8B8A8UNormIntSRGB:
3335
return MTLPixelFormatRGBA8Unorm_sRGB;
3436
}

impeller/renderer/backend/metal/surface_mtl.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
TextureDescriptor stencil0_tex;
6262
stencil0_tex.type = TextureType::k2DMultisample;
6363
stencil0_tex.sample_count = SampleCount::kCount4;
64-
stencil0_tex.format = PixelFormat::kD32FloatS8UNormInt;
64+
stencil0_tex.format = PixelFormat::kS8UInt;
6565
stencil0_tex.size = msaa_tex_desc.size;
6666
stencil0_tex.usage =
6767
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);

impeller/renderer/formats.h

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum class PixelFormat {
5050
kR8G8B8A8UNormIntSRGB,
5151
kB8G8R8A8UNormInt,
5252
kB8G8R8A8UNormIntSRGB,
53+
kS8UInt,
5354
// Esoteric formats only used as render targets.
5455
kD32FloatS8UNormInt,
5556
};
@@ -166,6 +167,8 @@ constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format) {
166167
switch (format) {
167168
case PixelFormat::kUnknown:
168169
return 0u;
170+
case PixelFormat::kS8UInt:
171+
return 1u;
169172
case PixelFormat::kR8G8B8A8UNormInt:
170173
case PixelFormat::kR8G8B8A8UNormIntSRGB:
171174
case PixelFormat::kB8G8R8A8UNormInt:

impeller/renderer/pipeline_builder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct PipelineBuilder {
109109
StencilAttachmentDescriptor stencil0;
110110
stencil0.stencil_compare = CompareFunction::kLessEqual;
111111
desc.SetStencilAttachmentDescriptors(stencil0);
112-
desc.SetStencilPixelFormat(PixelFormat::kD32FloatS8UNormInt);
112+
desc.SetStencilPixelFormat(PixelFormat::kS8UInt);
113113
}
114114

115115
return true;

impeller/renderer/render_target.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ RenderTarget RenderTarget::CreateOffscreen(const Context& context,
188188
static_cast<uint64_t>(TextureUsage::kShaderRead);
189189

190190
TextureDescriptor stencil_tex0;
191-
stencil_tex0.format = PixelFormat::kD32FloatS8UNormInt;
191+
stencil_tex0.format = PixelFormat::kS8UInt;
192192
stencil_tex0.size = size;
193193
stencil_tex0.usage =
194194
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);

impeller/renderer/renderer_unittests.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ TEST_F(RendererTest, CanRenderToTexture) {
224224
stencil0.store_action = StoreAction::kDontCare;
225225
TextureDescriptor stencil_texture_desc;
226226
stencil_texture_desc.size = texture_descriptor.size;
227-
stencil_texture_desc.format = PixelFormat::kD32FloatS8UNormInt;
227+
stencil_texture_desc.format = PixelFormat::kS8UInt;
228228
stencil_texture_desc.usage =
229229
static_cast<TextureUsageMask>(TextureUsage::kRenderTarget);
230230
stencil0.texture = context->GetPermanentsAllocator()->CreateTexture(

0 commit comments

Comments
 (0)