Don't waste space on an unnecessary depth buffer.

This commit is contained in:
Chinmay Garde
2022-01-05 14:08:36 -08:00
committed by Dan Field
parent 6984d32f56
commit b65ff957d1
10 changed files with 23 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -41,6 +41,8 @@ class Canvas {
const Matrix& GetCurrentTransformation() const;
void ResetTransform();
void Transform(const Matrix& xformation);
void Concat(const Matrix& xformation);

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -61,7 +61,7 @@ std::unique_ptr<Surface> SurfaceMTL::WrapCurrentMetalLayerDrawable(
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);

View File

@@ -50,6 +50,7 @@ enum class PixelFormat {
kR8G8B8A8UNormIntSRGB,
kB8G8R8A8UNormInt,
kB8G8R8A8UNormIntSRGB,
kS8UInt,
// Esoteric formats only used as render targets.
kD32FloatS8UNormInt,
};
@@ -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:

View File

@@ -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;

View File

@@ -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);

View File

@@ -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(