Hash :
c3a1cae4
Author :
Date :
2024-04-15T14:58:55
Use angle::SimpleMutex everywhere in libGLESv2 Only cases left that use std::mutex are: - Share group and the context ErrorSet mutexes as they need try_lock() - Anywhere mutexes are used in conjunction with std::condition_variables (as they explicitly require std::mutex) Bug: angleproject:8667 Change-Id: Ib6d68938b0886f9e7c43e023162557990ecfb300 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5453294 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
//
// Copyright 2002 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.
//
// debug.h: Debugging utilities. A lot of the logging code is adapted from Chromium's
// base/logging.h.
#ifndef COMMON_DEBUG_H_
#define COMMON_DEBUG_H_
#include <assert.h>
#include <stdio.h>
#include <iomanip>
#include <ios>
#include <mutex>
#include <sstream>
#include <string>
#include "common/SimpleMutex.h"
#include "common/angleutils.h"
#include "common/entry_points_enum_autogen.h"
#include "common/log_utils.h"
#include "common/platform.h"
#if defined(ANGLE_PLATFORM_WINDOWS)
# include <sal.h>
typedef unsigned long DWORD;
typedef _Return_type_success_(return >= 0) long HRESULT;
#endif
#if !defined(TRACE_OUTPUT_FILE)
# define TRACE_OUTPUT_FILE "angle_debug.txt"
#endif
namespace gl
{
class Context;
// Pairs a begin event with an end event.
class [[nodiscard]] ScopedPerfEventHelper : angle::NonCopyable
{
public:
ScopedPerfEventHelper(Context *context, angle::EntryPoint entryPoint);
~ScopedPerfEventHelper();
ANGLE_FORMAT_PRINTF(2, 3)
void begin(const char *format, ...);
private:
gl::Context *mContext;
const angle::EntryPoint mEntryPoint;
const char *mFunctionName;
bool mCalledBeginEvent;
};
// Wraps the API/Platform-specific debug annotation functions.
// Also handles redirecting logging destination.
class DebugAnnotator : angle::NonCopyable
{
public:
DebugAnnotator() {}
virtual ~DebugAnnotator() {}
virtual void beginEvent(gl::Context *context,
angle::EntryPoint entryPoint,
const char *eventName,
const char *eventMessage) = 0;
virtual void endEvent(gl::Context *context,
const char *eventName,
angle::EntryPoint entryPoint) = 0;
virtual void setMarker(gl::Context *context, const char *markerName) = 0;
virtual bool getStatus(const gl::Context *context) = 0;
// Log Message Handler that gets passed every log message,
// when debug annotations are initialized,
// replacing default handling by LogMessage.
virtual void logMessage(const LogMessage &msg) const = 0;
};
void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator);
void UninitializeDebugAnnotations();
bool DebugAnnotationsActive(const gl::Context *context);
bool DebugAnnotationsInitialized();
void InitializeDebugMutexIfNeeded();
angle::SimpleMutex &GetDebugMutex();
} // namespace gl
// The state tracked by ANGLE will be validated with the driver state before each call
#if defined(ANGLE_ENABLE_DEBUG_TRACE)
# define ANGLE_STATE_VALIDATION_ENABLED
#endif
#if defined(__GNUC__)
# define ANGLE_CRASH() __builtin_trap()
#else
# define ANGLE_CRASH() ((void)(*(volatile char *)0 = 0)), __assume(0)
#endif
#define ANGLE_UNUSED_VARIABLE(variable) (static_cast<void>(variable))
// Defining ANGLE_ENABLE_STRUCT_PADDING_WARNINGS will enable warnings when members are added to
// structs to enforce packing. This is helpful for diagnosing unexpected struct sizes when making
// fast cache variables.
#if defined(__clang__)
# define ANGLE_ENABLE_STRUCT_PADDING_WARNINGS \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic error \"-Wpadded\"")
# define ANGLE_DISABLE_STRUCT_PADDING_WARNINGS _Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define ANGLE_ENABLE_STRUCT_PADDING_WARNINGS \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic error \"-Wpadded\"")
# define ANGLE_DISABLE_STRUCT_PADDING_WARNINGS _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
# define ANGLE_ENABLE_STRUCT_PADDING_WARNINGS \
__pragma(warning(push)) __pragma(warning(error : 4820))
# define ANGLE_DISABLE_STRUCT_PADDING_WARNINGS __pragma(warning(pop))
#else
# define ANGLE_ENABLE_STRUCT_PADDING_WARNINGS
# define ANGLE_DISABLE_STRUCT_PADDING_WARNINGS
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_SUGGEST_OVERRIDE_WARNINGS \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wsuggest-destructor-override\"") \
_Pragma("clang diagnostic ignored \"-Wsuggest-override\"")
# define ANGLE_REENABLE_SUGGEST_OVERRIDE_WARNINGS _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_SUGGEST_OVERRIDE_WARNINGS
# define ANGLE_REENABLE_SUGGEST_OVERRIDE_WARNINGS
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_EXTRA_SEMI_WARNING \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wextra-semi\"")
# define ANGLE_REENABLE_EXTRA_SEMI_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_EXTRA_SEMI_WARNING
# define ANGLE_REENABLE_EXTRA_SEMI_WARNING
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_EXTRA_SEMI_STMT_WARNING \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wextra-semi-stmt\"")
# define ANGLE_REENABLE_EXTRA_SEMI_STMT_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_EXTRA_SEMI_STMT_WARNING
# define ANGLE_REENABLE_EXTRA_SEMI_STMT_WARNING
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_SHADOWING_WARNING \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow-field\"")
# define ANGLE_REENABLE_SHADOWING_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_SHADOWING_WARNING
# define ANGLE_REENABLE_SHADOWING_WARNING
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_DESTRUCTOR_OVERRIDE_WARNING \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winconsistent-missing-destructor-override\"")
# define ANGLE_REENABLE_DESTRUCTOR_OVERRIDE_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_DESTRUCTOR_OVERRIDE_WARNING
# define ANGLE_REENABLE_DESTRUCTOR_OVERRIDE_WARNING
#endif
#if defined(__clang__)
# define ANGLE_DISABLE_UNUSED_FUNCTION_WARNING \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-function\"")
# define ANGLE_REENABLE_UNUSED_FUNCTION_WARNING _Pragma("clang diagnostic pop")
#else
# define ANGLE_DISABLE_UNUSED_FUNCTION_WARNING
# define ANGLE_REENABLE_UNUSED_FUNCTION_WARNING
#endif
#endif // COMMON_DEBUG_H_