From 90ff85b04d1f7dfa996a44fd25ed44c8adb3893a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 4 Aug 2022 15:09:42 -0700 Subject: [PATCH] StencilState can now use designated initializers We just remove the custom default ctor. --- .../backend/include/backend/DriverEnums.h | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/filament/backend/include/backend/DriverEnums.h b/filament/backend/include/backend/DriverEnums.h index 5639a5dd78..7f03be53b0 100644 --- a/filament/backend/include/backend/DriverEnums.h +++ b/filament/backend/include/backend/DriverEnums.h @@ -960,15 +960,6 @@ struct PolygonOffset { struct StencilState { using StencilFunction = SamplerCompareFunc; - StencilState() noexcept : referenceValue(0u), stencilWrite(false), padding(0u) { - static_assert(sizeof(StencilOperations) == sizeof(uint32_t), "StencilOperations size not what was intended"); - static_assert(sizeof(StencilState) == 12u, "StencilState size not what was intended"); - front.u = back.u = 0u; - front.stencilFunc = back.stencilFunc = StencilFunction::A; - front.readMask = back.readMask = 0xFF; - front.writeMask = back.writeMask = 0xFF; - } - bool operator==(StencilState rhs) const noexcept { return front.u == rhs.front.u && back.u == rhs.back.u && @@ -996,29 +987,37 @@ struct StencilState { uint8_t padding1 : 2; // 16 //! Masks the bits of the stencil values participating in the stencil comparison test. - uint8_t readMask : 8; // 24 + uint8_t readMask; // 24 //! Masks the bits of the stencil values updated by the stencil test. - uint8_t writeMask : 8; // 32 + uint8_t writeMask; // 32 }; uint32_t u = 0; }; //! Stencil operations for front-facing polygons - StencilOperations front; + StencilOperations front = { + .stencilFunc = StencilFunction::A, .readMask = 0xff, .writeMask = 0xff }; //! Stencil operations for back-facing polygons - StencilOperations back; + StencilOperations back = { + .stencilFunc = StencilFunction::A, .readMask = 0xff, .writeMask = 0xff }; //! Reference value for stencil comparison tests - uint8_t referenceValue; + uint8_t referenceValue = 0; //! Whether stencil-buffer writes are enabled - bool stencilWrite; + bool stencilWrite = false; - uint16_t padding; + uint16_t padding = 0; }; +static_assert(sizeof(StencilState::StencilOperations) == sizeof(uint32_t), + "StencilOperations size not what was intended"); + +static_assert(sizeof(StencilState) == 12u, + "StencilState size not what was intended"); + using FrameScheduledCallback = void(*)(PresentCallable callable, void* user); using FrameCompletedCallback = void(*)(void* user);