Skip to content

Commit

Permalink
ANGLE mtl_render_utils.h various classes have uninitialised std::arra…
Browse files Browse the repository at this point in the history
…y<> members

https://bugs.webkit.org/show_bug.cgi?id=255865
rdar://90537480

Reviewed by Dean Jackson.

Initialize all needed std::array<>s via value initialization.
The default initialization does not initialize the array, leading to
uninitialized reads.

The std::array<>s in RenderUtils are value-initialized in the constructor.

* Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_render_utils.h:
(rx::mtl::RenderUtils::angle::EnumSize<PixelType>):

Canonical link: https://commits.webkit.org/259548.681@safari-7615-branch
  • Loading branch information
kkinnunen-apple committed Apr 25, 2023
1 parent 07d73d8 commit 1e04ec3
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ClearUtils final : angle::NonCopyable
const std::string mFragmentShaderName;

// Render pipeline cache for clear with draw:
std::array<RenderPipelineCache, kMaxRenderTargets + 1> mClearRenderPipelineCache;
std::array<RenderPipelineCache, kMaxRenderTargets + 1> mClearRenderPipelineCache { };
};

class ColorBlitUtils final : angle::NonCopyable
Expand Down Expand Up @@ -260,9 +260,9 @@ class ColorBlitUtils final : angle::NonCopyable
using ColorBlitRenderPipelineCacheArray =
std::array<std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount>,
kMaxRenderTargets>;
ColorBlitRenderPipelineCacheArray mBlitRenderPipelineCache;
ColorBlitRenderPipelineCacheArray mBlitPremultiplyAlphaRenderPipelineCache;
ColorBlitRenderPipelineCacheArray mBlitUnmultiplyAlphaRenderPipelineCache;
ColorBlitRenderPipelineCacheArray mBlitRenderPipelineCache {{}};
ColorBlitRenderPipelineCacheArray mBlitPremultiplyAlphaRenderPipelineCache {{}};
ColorBlitRenderPipelineCacheArray mBlitUnmultiplyAlphaRenderPipelineCache {{}};
};

class DepthStencilBlitUtils final : angle::NonCopyable
Expand Down Expand Up @@ -301,14 +301,14 @@ class DepthStencilBlitUtils final : angle::NonCopyable
ContextMtl *ctx,
const StencilBlitViaBufferParams &params);

std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount> mDepthBlitRenderPipelineCache;
std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount> mStencilBlitRenderPipelineCache;
std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount> mDepthBlitRenderPipelineCache {};
std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount> mStencilBlitRenderPipelineCache {};
std::array<std::array<RenderPipelineCache, mtl_shader::kTextureTypeCount>,
mtl_shader::kTextureTypeCount>
mDepthStencilBlitRenderPipelineCache;
mDepthStencilBlitRenderPipelineCache {{}};

std::array<AutoObjCPtr<id<MTLComputePipelineState>>, mtl_shader::kTextureTypeCount>
mStencilBlitToBufferComPipelineCache;
mStencilBlitToBufferComPipelineCache {};

// Intermediate buffer for storing copied stencil data. Used when device doesn't support
// writing stencil in shader.
Expand Down Expand Up @@ -418,12 +418,12 @@ class IndexGeneratorUtils final : angle::NonCopyable
const IndexGenerationParams &params,
size_t *indicesGenerated);

IndexConversionPipelineArray mIndexConversionPipelineCaches;
IndexConversionPipelineArray mIndexConversionPipelineCaches {{}};

IndexConversionPipelineArray mTriFanFromElemArrayGeneratorPipelineCaches;
IndexConversionPipelineArray mTriFanFromElemArrayGeneratorPipelineCaches {{}};
AutoObjCPtr<id<MTLComputePipelineState>> mTriFanFromArraysGeneratorPipeline;

IndexConversionPipelineArray mLineLoopFromElemArrayGeneratorPipelineCaches;
IndexConversionPipelineArray mLineLoopFromElemArrayGeneratorPipelineCaches {{}};
AutoObjCPtr<id<MTLComputePipelineState>> mLineLoopFromArraysGeneratorPipeline;
};

Expand All @@ -445,7 +445,7 @@ class VisibilityResultUtils final : angle::NonCopyable
// Visibility combination compute pipeline:
// - 0: This compute pipeline only combine the new values and discard old value.
// - 1: This compute pipeline keep the old value and combine with new values.
std::array<AutoObjCPtr<id<MTLComputePipelineState>>, 2> mVisibilityResultCombPipelines;
std::array<AutoObjCPtr<id<MTLComputePipelineState>>, 2> mVisibilityResultCombPipelines {};
};

// Util class for handling mipmap generation
Expand Down Expand Up @@ -501,7 +501,7 @@ class CopyPixelsUtils final : angle::NonCopyable
using PixelsCopyPipelineArray = std::array<
std::array<AutoObjCPtr<id<MTLComputePipelineState>>, mtl_shader::kTextureTypeCount * 2>,
angle::kNumANGLEFormats>;
PixelsCopyPipelineArray mPixelsCopyPipelineCaches;
PixelsCopyPipelineArray mPixelsCopyPipelineCaches {{}};

const std::string mReadShaderName;
const std::string mWriteShaderName;
Expand Down Expand Up @@ -567,8 +567,8 @@ class VertexFormatConversionUtils final : angle::NonCopyable
using ConvertToFloatRenderPipelineArray =
std::array<RenderPipelineCache, angle::kNumANGLEFormats>;

ConvertToFloatCompPipelineArray mConvertToFloatCompPipelineCaches;
ConvertToFloatRenderPipelineArray mConvertToFloatRenderPipelineCaches;
ConvertToFloatCompPipelineArray mConvertToFloatCompPipelineCaches {};
ConvertToFloatRenderPipelineArray mConvertToFloatRenderPipelineCaches {};

AutoObjCPtr<id<MTLComputePipelineState>> mComponentsExpandCompPipeline;
RenderPipelineCache mComponentsExpandRenderPipelineCache;
Expand Down

0 comments on commit 1e04ec3

Please sign in to comment.