chromium/third_party/angle/src/libANGLE/renderer/serial_utils.h

//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// serial_utils:
//   Utilities for generating unique IDs for resources in ANGLE.
//

#ifndef LIBANGLE_RENDERER_SERIAL_UTILS_H_
#define LIBANGLE_RENDERER_SERIAL_UTILS_H_

#include <array>
#include <atomic>
#include <limits>

#include "common/angleutils.h"
#include "common/debug.h"

namespace rx
{
class ResourceSerial
{};

// Class UniqueSerial defines unique serial number for object identification. It has only
// equal/unequal comparison but no greater/smaller comparison. The default constructor creates an
// invalid value.
class UniqueSerial final
{};

class UniqueSerialFactory final : angle::NonCopyable
{};

// Class Serial defines a monotonically increasing serial number that indicates the timeline of
// execution.
class Serial final
{};

// Defines class to track the queue serial that can be load/store from multiple threads atomically.
class alignas(8) AtomicQueueSerial final
{};

// Used as default/initial serial
static constexpr Serial kZeroSerial =;

// The factory to generate a serial number within the range [mSerial, mSerial+mCount}
class RangedSerialFactory final : angle::NonCopyable
{};

class AtomicSerialFactory final : angle::NonCopyable
{};

// For backend that supports multiple queue serials, QueueSerial includes a Serial and an index.
SerialIndex;
static constexpr SerialIndex kInvalidQueueSerialIndex =;

class QueueSerial;
// Because we release queue index when context becomes non-current, in order to use up all index
// count, you will need to have 256 threads each has a context current. This is not a reasonable
// usage case.
constexpr size_t kMaxQueueSerialIndexCount =;
// Fixed array of queue serials
class AtomicQueueSerialFixedArray final
{};
std::ostream &operator<<(std::ostream &os, const AtomicQueueSerialFixedArray &serials);

class QueueSerial final
{};
std::ostream &operator<<(std::ostream &os, const QueueSerial &queueSerial);

ANGLE_INLINE void AtomicQueueSerialFixedArray::setQueueSerial(SerialIndex index, Serial serial)
{}

ANGLE_INLINE void AtomicQueueSerialFixedArray::setQueueSerial(const QueueSerial &queueSerial)
{}

ANGLE_INLINE std::ostream &operator<<(std::ostream &os, const AtomicQueueSerialFixedArray &serials)
{}

ANGLE_INLINE std::ostream &operator<<(std::ostream &os, const QueueSerial &queueSerial)
{}
}  // namespace rx

#endif  // LIBANGLE_RENDERER_SERIAL_UTILS_H_