Repository: google/filament
File: filament/backend/src/metal/MetalContext.h (C/C++)

Code before:
        return { mOffsets.size(), mOffsets.data() };
    }

private:
    std::array<uint32_t, MAX_DESCRIPTOR_SET_COUNT> mCounts = { 0 };
    std::vector<uint32_t> mOffsets;
    bool mDirty = false;
};

struct MetalContext {
    MetalDriver* driver;
    id<MTLDevice> device = nullptr;
    id<MTLCommandQueue> commandQueue = nullptr;

    // The ID of pendingCommandBuffer (or the next command buffer, if pendingCommandBuffer is nil).
    uint64_t pendingCommandBufferId = 1;
    // read from driver thread, set from completion handlers
    std::atomic<uint64_t> latestCompletedCommandBufferId = 0;
    id<MTLCommandBuffer> pendingCommandBuffer = nil;
    id<MTLRenderCommandEncoder> currentRenderPassEncoder = nil;
    uint32_t currentFrame = 0;
    MetalErrorQueue commandBufferErrors;

    // If zero, the next presentation should happen as soon as possible.
    // Otherwise, this is the timestamp when the present should happen.
    // Resetst to 0 after the present.
    int64_t presentationTimeNs = 0;

    std::atomic<bool> memorylessLimitsReached = false;

    // Supported features.
    bool supportsTextureSwizzling = false;
    bool supportsAutoDepthResolve = false;
    bool supportsMemorylessRenderTargets = false;
    bool supportsDepthClamp = false;
    uint8_t maxColorRenderTargets = 4;
    struct {
        uint8_t common;
        uint8_t apple;
        uint8_t mac;
    } highestSupportedGpuFamily;

    struct {
        bool staticTextureTargetError;
    } bugs;

    // sampleCountLookup[requestedSamples] gives a <= sample count supported by the device.
    std::array<uint8_t, MAX_SAMPLE_COUNT + 1> sampleCountLookup;

    // Tracks resources used by command buffers.
    MetalResourceTracker resourceTracker;

Review comment (suggestion):
```suggestion
    // Resets to 0 after the present.
```

Code after:
        return { mOffsets.size(), mOffsets.data() };
    }

private:
    std::array<uint32_t, MAX_DESCRIPTOR_SET_COUNT> mCounts = { 0 };
    std::vector<uint32_t> mOffsets;
    bool mDirty = false;
};

struct MetalContext {
    MetalDriver* driver;
    id<MTLDevice> device = nullptr;
    id<MTLCommandQueue> commandQueue = nullptr;

    // The ID of pendingCommandBuffer (or the next command buffer, if pendingCommandBuffer is nil).
    uint64_t pendingCommandBufferId = 1;
    // read from driver thread, set from completion handlers
    std::atomic<uint64_t> latestCompletedCommandBufferId = 0;
    id<MTLCommandBuffer> pendingCommandBuffer = nil;
    id<MTLRenderCommandEncoder> currentRenderPassEncoder = nil;
    uint32_t currentFrame = 0;
    MetalErrorQueue commandBufferErrors;

    std::atomic<bool> memorylessLimitsReached = false;

    // Supported features.
    bool supportsTextureSwizzling = false;
    bool supportsAutoDepthResolve = false;
    bool supportsMemorylessRenderTargets = false;
    bool supportsDepthClamp = false;
    uint8_t maxColorRenderTargets = 4;
    struct {
        uint8_t common;
        uint8_t apple;
        uint8_t mac;
    } highestSupportedGpuFamily;

    struct {
        bool staticTextureTargetError;
    } bugs;

    // sampleCountLookup[requestedSamples] gives a <= sample count supported by the device.
    std::array<uint8_t, MAX_SAMPLE_COUNT + 1> sampleCountLookup;

    // Tracks resources used by command buffers.
    MetalResourceTracker resourceTracker;

    RenderPassFlags currentRenderPassFlags;
    MetalRenderTarget* currentRenderTarget = nullptr;
    bool validPipelineBound = false;
    bool currentRenderPassAbandoned = false;