🔇 Log each Metal bundle failure once a process
The Metal bundle logged a line per call where a guest app repeats the same failure: a sampler, ICB or argument encoder not made, an argument written with no buffer set, a refused or foreign pipeline, an ICB message not posted, a command buffer failing for want of region room, a nil texture over each new IOSurface, and a nil creator answer per shape asked. The inline-bytes and foreign-event lines logged their first 16 and then every power of two. RgfxLogOnce.hpp's rgfxLogFirst lets a site log each kind once in a process (the site, and its status, selector or reason where it has several), and each of those sites now goes through it: a nil texture logs once per cause and pixel format (each surface's count and line are kept for the tests), and a nil answer once per creator and cause. The surface copies' summary and a ring's room line come at most once a minute, not every 10 s and 1 s.
This commit is contained in:
1 parent
beb91ccd4e
commit
f064fbf699
15 files changed
+167
-71
No files matched your search
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxArgumentEncoder.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxFunction.h"
|
||||
#import "RgfxMetalError.h"
|
||||
@@ -185,7 +186,9 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
serializer:(RgfxSerializer *)serializer
|
||||
{
|
||||
if (region == nullptr || serializer == nullptr || arguments.count > UINT32_MAX) {
|
||||
NSLog(@"RGFX: newArgumentEncoderWithArguments: no encoder: no device region");
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: newArgumentEncoderWithArguments: no encoder: no device region");
|
||||
return nil;
|
||||
}
|
||||
std::vector<RgfxArgumentDescriptor> wire;
|
||||
@@ -202,8 +205,10 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
},
|
||||
&why);
|
||||
if (!layout) {
|
||||
NSLog(@"RGFX: newArgumentEncoderWithArguments: (%lu arguments): no encoder: %s",
|
||||
static_cast<unsigned long>(arguments.count), why);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, rgfxLogKindOf(why)))
|
||||
NSLog(@"RGFX: newArgumentEncoderWithArguments: (%lu arguments): no encoder: %s",
|
||||
static_cast<unsigned long>(arguments.count), why);
|
||||
return nil;
|
||||
}
|
||||
return [[self alloc] initWithLayout:layout device:device serializer:serializer];
|
||||
@@ -233,9 +238,11 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
}
|
||||
if (region == nullptr || serializer == nullptr || bufferIndex > UINT32_MAX ||
|
||||
function.rgfxLibraryObjId == RGFX_OBJ_NONE) {
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferIndex:%lu: no encoder: no device region or "
|
||||
@"library",
|
||||
static_cast<unsigned long>(bufferIndex));
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferIndex:%lu: no encoder: no device region or "
|
||||
@"library",
|
||||
static_cast<unsigned long>(bufferIndex));
|
||||
return nil;
|
||||
}
|
||||
const char *why = "";
|
||||
@@ -249,8 +256,10 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
},
|
||||
&why);
|
||||
if (!layout) {
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferIndex:%lu of %s: no encoder: %s",
|
||||
static_cast<unsigned long>(bufferIndex), function.rgfxEntryPointUTF8, why);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, rgfxLogKindOf(why)))
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferIndex:%lu of %s: no encoder: %s",
|
||||
static_cast<unsigned long>(bufferIndex), function.rgfxEntryPointUTF8, why);
|
||||
return nil;
|
||||
}
|
||||
return [[self alloc] initWithLayout:layout device:device serializer:serializer];
|
||||
@@ -273,9 +282,11 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
serializer:serializer];
|
||||
NSArray<MTLArgumentDescriptor *> *arguments = RgfxDescriptorsOfArguments(binding.bufferStructType);
|
||||
if (arguments == nil) {
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferBinding: %@: no encoder: a member is a struct, "
|
||||
@"which no argument descriptor names",
|
||||
binding.name);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: newArgumentEncoderWithBufferBinding: %@: no encoder: a member is a "
|
||||
@"struct, which no argument descriptor names",
|
||||
binding.name);
|
||||
return nil;
|
||||
}
|
||||
return [self encoderOfArguments:arguments region:region device:device serializer:serializer];
|
||||
@@ -319,8 +330,10 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
- (uint8_t *)rgfxAt:(NSUInteger)index size:(uint64_t)size cmd:(SEL)cmd
|
||||
{
|
||||
if (_argumentBuffer == nil) {
|
||||
NSLog(@"RGFX: -[MTLArgumentEncoder %s]: no argument buffer set; nothing written",
|
||||
sel_getName(cmd));
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, reinterpret_cast<uintptr_t>(cmd)))
|
||||
NSLog(@"RGFX: -[MTLArgumentEncoder %s]: no argument buffer set; nothing written",
|
||||
sel_getName(cmd));
|
||||
return nullptr;
|
||||
}
|
||||
uint8_t *contents = static_cast<uint8_t *>(_argumentBuffer.contents);
|
||||
@@ -331,9 +344,11 @@ NSArray<MTLArgumentDescriptor *> *RgfxDescriptorsOfArguments(MTLStructType *type
|
||||
const uint64_t start = _offset + at;
|
||||
if (contents == nullptr || start < _offset || start + size < start ||
|
||||
start + size > _argumentBuffer.length) {
|
||||
NSLog(@"RGFX: -[MTLArgumentEncoder %s]: index %lu lies past the argument buffer, or "
|
||||
@"in one the CPU cannot write; nothing written",
|
||||
sel_getName(cmd), static_cast<unsigned long>(index));
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, reinterpret_cast<uintptr_t>(cmd)))
|
||||
NSLog(@"RGFX: -[MTLArgumentEncoder %s]: index %lu lies past the argument buffer, "
|
||||
@"or in one the CPU cannot write; nothing written",
|
||||
sel_getName(cmd), static_cast<unsigned long>(index));
|
||||
return nullptr;
|
||||
}
|
||||
return contents + start;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxCommandObjects.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
#import "RgfxBuffer.h"
|
||||
#import "RgfxComputePipelineState.h"
|
||||
#import "RgfxEvent.h"
|
||||
@@ -111,12 +112,12 @@ namespace {
|
||||
// no mesh pipeline can be made, so it draws nothing.
|
||||
constexpr const char *kNoMeshes = "mesh shading (the host makes no mesh pipeline)";
|
||||
|
||||
/// Whether the `n`th (from 0) occurrence of a repeated log line is logged: the first 16, then
|
||||
/// every power of two, so a frame loop's stays visible without flooding the log.
|
||||
/// Whether the `n`th (from 0) occurrence of a repeated log line is logged: the first alone, as
|
||||
/// for every degradation (docs/conventions.md); `count` counts them all.
|
||||
bool logEventOp(std::atomic<uint64_t> &count, uint64_t *n)
|
||||
{
|
||||
*n = count.fetch_add(1, std::memory_order_relaxed);
|
||||
return *n < 16 || (*n & (*n - 1)) == 0;
|
||||
return *n == 0;
|
||||
}
|
||||
|
||||
std::atomic<uint64_t> g_foreignEvents{0};
|
||||
@@ -135,8 +136,8 @@ bool rgfxPutBytes(RgfxUploadArena *uploads, const void *bytes, NSUInteger length
|
||||
uint64_t n = 0;
|
||||
if (logEventOp(g_bytesDropped, &n)) {
|
||||
NSLog(@"RGFX: %lu inline bytes have no upload chunk (no region room): their binding is "
|
||||
@"not made, and the command buffer fails (so far: %llu)",
|
||||
(unsigned long)length, (unsigned long long)(n + 1));
|
||||
@"not made, and the command buffer fails",
|
||||
(unsigned long)length);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2200,9 +2201,11 @@ enum RgfxStage : unsigned {
|
||||
if (!posted) {
|
||||
// No block for it: the buffer fails as Metal's does when memory runs out, and its
|
||||
// handlers run off the committing thread.
|
||||
NSLog(@"RGFX: command buffer 0x%llx: no region block for its %llu bytes: it fails "
|
||||
@"with MTLCommandBufferErrorOutOfMemory",
|
||||
(unsigned long long)[self rgfxObjId], (unsigned long long)messageBytes);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: command buffer 0x%llx: no region block for its %llu bytes: it fails "
|
||||
@"with MTLCommandBufferErrorOutOfMemory",
|
||||
(unsigned long long)[self rgfxObjId], (unsigned long long)messageBytes);
|
||||
RgfxCbComplete failed = {};
|
||||
failed.header.type = RGFX_EVT_CB_COMPLETE;
|
||||
failed.cb_obj_id = [self rgfxObjId];
|
||||
@@ -2464,8 +2467,10 @@ static NSError *rgfxCommandBufferError(NSInteger code)
|
||||
// A buffer some of whose inline bytes found no chunk ran without those bindings, so it fails.
|
||||
if (msg->status == RGFX_CB_OK && _uploadsFailed) {
|
||||
// It ran without some of its bindings, so it fails as Metal's does when memory runs out.
|
||||
NSLog(@"RGFX: a command buffer's inline bytes (set*Bytes:) found no room in the "
|
||||
@"device's memory; it fails as out of memory");
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: a command buffer's inline bytes (set*Bytes:) found no room in the "
|
||||
@"device's memory; it fails as out of memory");
|
||||
_cbError = rgfxCommandBufferError(MTLCommandBufferErrorOutOfMemory);
|
||||
_status.store(MTLCommandBufferStatusError);
|
||||
} else if (msg->status == RGFX_CB_OK) {
|
||||
@@ -2685,9 +2690,8 @@ static NSError *rgfxCommandBufferError(NSInteger code)
|
||||
uint64_t n = 0;
|
||||
if (logEventOp(g_foreignEvents, &n)) {
|
||||
NSLog(@"RGFX: command buffer 0x%llx: %s an event %@ that no device of ours made, value "
|
||||
@"%llu: not carried (so far: %llu)",
|
||||
(unsigned long long)[self rgfxObjId], op, event, (unsigned long long)value,
|
||||
(unsigned long long)(n + 1));
|
||||
@"%llu: not carried",
|
||||
(unsigned long long)[self rgfxObjId], op, event, (unsigned long long)value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxComputePipelineState.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import <objc/message.h>
|
||||
|
||||
@@ -62,7 +63,9 @@ NSError *foreignFunctionError(NSString *what, id<MTLFunction> fn)
|
||||
{
|
||||
NSString *msg = [NSString stringWithFormat:@"compute pipeline: %@ %@ (%@) is not from a library of this device",
|
||||
what, fn.name, NSStringFromClass([(id)fn class])];
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
return RgfxMakeError(RgfxMetalErrorInvalidDescriptor, msg);
|
||||
}
|
||||
|
||||
@@ -349,7 +352,8 @@ NSError *foreignFunctionError(NSString *what, id<MTLFunction> fn)
|
||||
- (void)rgfxTakeAnswer:(const RgfxPipelineReflection *)r
|
||||
{
|
||||
_answer.take(*r);
|
||||
if (r->status != RGFX_PIPELINE_OK)
|
||||
static char site;
|
||||
if (r->status != RGFX_PIPELINE_OK && rgfxLogFirst(&site, r->status))
|
||||
NSLog(@"RGFX: the device refused compute pipeline %llu, made as an equal one it accepted",
|
||||
static_cast<unsigned long long>(self.rgfxObjId));
|
||||
}
|
||||
|
||||
@@ -45,8 +45,9 @@
|
||||
* every plane. Where the kext gives no shared block, the process keeps a block of its own for the
|
||||
* surface. The kext gives a surface's blocks in one mode, so every holder of a surface copied
|
||||
* copies it. Each view made, in place or a copy and why, and each copy's block, shared or the
|
||||
* process's own, is counted in the "surface copies" line the process logs (os_log, info) every
|
||||
* 10 s while views are made or copied; the kext logs why it first refused a shared block.
|
||||
* process's own, is counted in the "surface copies" line the process logs (os_log, info) once a
|
||||
* minute at most while views are made or copied; the kext logs why it first refused a shared
|
||||
* block.
|
||||
*
|
||||
* The copy holds the planes in plane order, each from a kShadowRowAlign multiple, its rows
|
||||
* kShadowRowAlign apart, as the surface's own memory holds them one after another; a header past
|
||||
@@ -111,8 +112,9 @@
|
||||
*
|
||||
* A texture the creator cannot make is nil, as Metal answers one, and never silently: each cause
|
||||
* (no view in place and no room for a copy, a plane past the surface's, no texture resource id
|
||||
* left, ...) logs one "RGFX:" line per surface naming the surface and the checks that refused,
|
||||
* however often the texture is asked for (rgfxIOSurfaceNilLog).
|
||||
* left, ...) logs one "RGFX:" line per cause and pixel format in the process, naming the first
|
||||
* surface and the checks that refused, however often and over however many surfaces the texture
|
||||
* is asked for; each surface's count and line are kept (rgfxIOSurfaceNilLog).
|
||||
*
|
||||
* Left for later, for a copy: syncing the pages at the CPU's lock instead of at every GPU
|
||||
* write's completion (the device cache's sync); CPU writes made without a lock. In either
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxIOSurface.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxBuffer.h"
|
||||
|
||||
@@ -259,8 +260,9 @@ NilLog &nilLog()
|
||||
}
|
||||
|
||||
/// newTextureWithDescriptor:iosurface:plane: answers nil for `surface`, as Metal does a texture
|
||||
/// it cannot make, for `cause`, which `detail` says more of: logged once per surface and cause,
|
||||
/// so a texture asked for every frame logs once.
|
||||
/// it cannot make, for `cause`, which `detail` says more of: counted per surface and cause, and
|
||||
/// logged once per cause and pixel format in the process (docs/conventions.md), so a texture
|
||||
/// asked for every frame, over a surface new each frame or not, logs once.
|
||||
void logNoTexture(IOSurfaceRef surface, const char *cause, const std::string &detail)
|
||||
{
|
||||
std::string line = describe(surface) + ": no texture (" + cause + "): " + detail;
|
||||
@@ -277,7 +279,10 @@ void logNoTexture(IOSurfaceRef surface, const char *cause, const std::string &de
|
||||
}
|
||||
entry.second = line;
|
||||
}
|
||||
NSLog(@"RGFX: %s", line.c_str());
|
||||
static char site;
|
||||
const uint32_t format = surface != nullptr ? IOSurfaceGetPixelFormat(surface) : 0;
|
||||
if (rgfxLogFirst(&site, rgfxLogKindOf(cause) ^ format))
|
||||
NSLog(@"RGFX: %s", line.c_str());
|
||||
}
|
||||
|
||||
/// The surface's YCbCr matrix as one of RGFX_YCBCR_MATRIX_*. CoreVideo keeps a pixel buffer's
|
||||
@@ -415,7 +420,8 @@ std::atomic<uint64_t> gCopiedRefused{0}; // the kext gave no block in place
|
||||
std::atomic<uint64_t> gCopyShared{0};
|
||||
std::atomic<uint64_t> gCopyOwn{0};
|
||||
|
||||
const uint64_t kCopyReportNs = 10ull * 1000 * 1000 * 1000;
|
||||
// A summary, at most once a minute (docs/conventions.md).
|
||||
const uint64_t kCopyReportNs = 60ull * 1000 * 1000 * 1000;
|
||||
|
||||
uint64_t nowNs()
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxIndirectCommandBuffer.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
#import "RgfxInterop.h"
|
||||
|
||||
#import "RgfxResource.h" // RgfxResolveHazardTracking
|
||||
@@ -200,9 +201,11 @@ NSRange RgfxIcbClamp(id icb, NSRange range)
|
||||
// A create the device never got, one the host refused, or one not answered made no buffer:
|
||||
// nil, as Metal answers one it cannot make. One the kext timed out on is destroyed behind.
|
||||
if (serializer->refused(created) || created.status != RGFX_STATUS_OK) {
|
||||
NSLog(@"RGFX: newIndirectCommandBufferWithDescriptor: no buffer of %lu commands (status "
|
||||
@"0x%x)",
|
||||
(unsigned long)maxCount, created.status);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, created.status))
|
||||
NSLog(@"RGFX: newIndirectCommandBufferWithDescriptor: no buffer of %lu commands "
|
||||
@"(status 0x%x)",
|
||||
(unsigned long)maxCount, created.status);
|
||||
return nil;
|
||||
}
|
||||
RgfxIndirectCommandBuffer *icb = [[RgfxIndirectCommandBuffer alloc] initWithObjId:created.obj_id
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxLibrary.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
#import "RgfxArgumentEncoder.h"
|
||||
#import "RgfxBlockCall.h"
|
||||
#import "RgfxUnsupported.h"
|
||||
@@ -698,7 +699,8 @@ bool rgfxAirUnreadFirstLog(const std::string &name)
|
||||
if (entries == nullptr)
|
||||
why = "its module declares no such entry point";
|
||||
}
|
||||
if (entries == nullptr && why != nullptr)
|
||||
static char site;
|
||||
if (entries == nullptr && why != nullptr && rgfxLogFirst(&site, rgfxLogKindOf(why)))
|
||||
NSLog(@"RGFX: %s: its nodes were not read (%s): pipelines of it answer no reflection",
|
||||
name.c_str(), why);
|
||||
_entries.emplace(name, entries);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// RgfxLogOnce: a gate that lets a site log each kind of failure once in a process
|
||||
// (docs/conventions.md, "once per kind"): a caller that meets the same failure each frame, draw
|
||||
// or command buffer logs one line for it, not one per call.
|
||||
//
|
||||
// A kind is the site (the address of something of the site's own, a `static char`) and, where
|
||||
// the site has more than one, a key: a status, a selector, or a reason's text
|
||||
// (rgfxLogKindOf). A site with one kind passes none.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
// The kinds a process keeps; a kind past them is never logged.
|
||||
constexpr std::size_t kRgfxLogKindsKept = 256;
|
||||
|
||||
// Whether this is the first call of `kind` at `site` in this process.
|
||||
inline bool rgfxLogFirst(const void *site, uint64_t kind = 0)
|
||||
{
|
||||
static std::mutex lock;
|
||||
// Never destroyed: a thread may log while the process exits.
|
||||
static auto *seen = new std::set<std::pair<const void *, uint64_t>>();
|
||||
std::lock_guard<std::mutex> hold(lock);
|
||||
if (seen->size() >= kRgfxLogKindsKept)
|
||||
return false;
|
||||
return seen->emplace(site, kind).second;
|
||||
}
|
||||
|
||||
// A key for a reason's text, for rgfxLogFirst (FNV-1a), as the kext's rgfxKeyOf.
|
||||
inline uint64_t rgfxLogKindOf(const char *s)
|
||||
{
|
||||
uint64_t h = 0xcbf29ce484222325ull;
|
||||
for (; s && *s; s++)
|
||||
h = (h ^ static_cast<uint8_t>(*s)) * 0x100000001b3ull;
|
||||
return h;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxMetalDevice+Pipelines.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxArgumentEncoder.h"
|
||||
#import "RgfxBinaryArchive.h"
|
||||
@@ -191,7 +192,8 @@ bool fileIdentity(const char *path, RgfxFileIdentity &out)
|
||||
{
|
||||
NSError *error = nil;
|
||||
id<MTLLibrary> lib = [super newLibraryWithData:data error:&error];
|
||||
if (lib == nil)
|
||||
static char site;
|
||||
if (lib == nil && rgfxLogFirst(&site, static_cast<uint64_t>(error.code)))
|
||||
NSLog(@"RGFX: Metal's own library over %zu bytes: %@", dispatch_data_get_size(data),
|
||||
error.localizedDescription);
|
||||
return lib;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxMetalDevice+Resources.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxBlockCall.h"
|
||||
#import "RgfxBuffer.h"
|
||||
@@ -30,22 +31,16 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// A nil the device's creator `creator` answers for `cause`, asked for `asked`: logged once at the
|
||||
// info level (`log show --info`), by creator, cause and what was asked, so a process that ends at
|
||||
// a nil it was given (14.6.1's WindowServer ends at a texture's, in SkyLight's
|
||||
// MetalBacking::AbortWithTextureInfo) has the device's answer named beside it. A creator asked
|
||||
// the same every frame logs once; the set is bounded, as a long session asks many shapes.
|
||||
// A nil the device's creator `creator` answers for `cause`, asked for `asked`: logged at the info
|
||||
// level (`log show --info`) once per creator and cause in the process (docs/conventions.md), what
|
||||
// was asked the first time named, so a process that ends at a nil it was given (14.6.1's
|
||||
// WindowServer ends at a texture's, in SkyLight's MetalBacking::AbortWithTextureInfo) has the
|
||||
// device's answer named beside it. A creator asked every frame, the same or not, logs once.
|
||||
void noteNil(const char *creator, const char *cause, const std::string &asked)
|
||||
{
|
||||
static std::mutex lock;
|
||||
static std::set<std::string> *seen = new std::set<std::string>(); // never destroyed
|
||||
{
|
||||
std::lock_guard<std::mutex> g(lock);
|
||||
if (seen->size() >= 4096)
|
||||
seen->clear();
|
||||
if (!seen->insert(std::string(creator) + "|" + cause + "|" + asked).second)
|
||||
return;
|
||||
}
|
||||
static char site;
|
||||
if (!rgfxLogFirst(&site, rgfxLogKindOf(creator) ^ (rgfxLogKindOf(cause) * 31)))
|
||||
return;
|
||||
os_log_info(OS_LOG_DEFAULT,
|
||||
"RGFX: the device answers nil at %{public}s (%{public}s): %{public}s", creator,
|
||||
cause, asked.c_str());
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxMetalDevice.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxBuffer.h"
|
||||
#import "RgfxInterop.h"
|
||||
@@ -564,8 +565,10 @@ uint32_t rgfxKextShareEvent(void *context, RgfxObjId event)
|
||||
uint32_t outCount = 1;
|
||||
kr = IOConnectCallScalarMethod(port, kRgfxSharedEventMethodExport, in, 3, &status, &outCount);
|
||||
if (kr != KERN_SUCCESS || outCount != 1 || status != RGFX_STATUS_OK) {
|
||||
os_log_error(OS_LOG_DEFAULT, "RGFX: shared event 0x%llx: no port (kr=0x%x status %llu)",
|
||||
(unsigned long long)event, kr, (unsigned long long)status);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, (static_cast<uint64_t>(kr) << 32) ^ status))
|
||||
os_log_error(OS_LOG_DEFAULT, "RGFX: shared event 0x%llx: no port (kr=0x%x status %llu)",
|
||||
(unsigned long long)event, kr, (unsigned long long)status);
|
||||
IOServiceClose(port);
|
||||
return MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxRenderPipelineState.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
#import "RgfxUnsupported.h"
|
||||
|
||||
#import <objc/message.h>
|
||||
@@ -333,7 +334,9 @@ RgfxRenderPipelinePrivateState privateStateOf(MTLRenderPipelineDescriptor *d)
|
||||
NSString *msg = [NSString
|
||||
stringWithFormat:@"render pipeline: function %@ (%@) is not from a library of this device",
|
||||
foreign.name, NSStringFromClass([(id)foreign class])];
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
if (error)
|
||||
*error = RgfxMakeError(RgfxMetalErrorInvalidDescriptor, msg);
|
||||
return nil;
|
||||
@@ -351,7 +354,9 @@ RgfxRenderPipelinePrivateState privateStateOf(MTLRenderPipelineDescriptor *d)
|
||||
NSString *msg = [NSString
|
||||
stringWithFormat:@"render pipeline: linked function %@ (%@) is not from a library of this device",
|
||||
foreignLinked.name, NSStringFromClass([(id)foreignLinked class])];
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
if (error)
|
||||
*error = RgfxMakeError(RgfxMetalErrorInvalidDescriptor, msg);
|
||||
return nil;
|
||||
@@ -531,7 +536,9 @@ RgfxRenderPipelinePrivateState privateStateOf(MTLRenderPipelineDescriptor *d)
|
||||
NSString *msg = [NSString
|
||||
stringWithFormat:@"render pipeline: function %@ (%@) is not from a library of this device",
|
||||
foreign.name, NSStringFromClass([(id)foreign class])];
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
if (error)
|
||||
*error = RgfxMakeError(RgfxMetalErrorInvalidDescriptor, msg);
|
||||
return nil;
|
||||
@@ -557,7 +564,9 @@ RgfxRenderPipelinePrivateState privateStateOf(MTLRenderPipelineDescriptor *d)
|
||||
NSString *msg = [NSString
|
||||
stringWithFormat:@"render pipeline: linked function %@ (%@) is not from a library of this device",
|
||||
foreignLinked.name, NSStringFromClass([(id)foreignLinked class])];
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
NSLog(@"RGFX: %@", msg);
|
||||
if (error)
|
||||
*error = RgfxMakeError(RgfxMetalErrorInvalidDescriptor, msg);
|
||||
return nil;
|
||||
@@ -744,7 +753,8 @@ RgfxRenderPipelinePrivateState privateStateOf(MTLRenderPipelineDescriptor *d)
|
||||
- (void)rgfxTakeAnswer:(const RgfxPipelineReflection *)r
|
||||
{
|
||||
_answer.take(*r);
|
||||
if (r->status != RGFX_PIPELINE_OK)
|
||||
static char site;
|
||||
if (r->status != RGFX_PIPELINE_OK && rgfxLogFirst(&site, r->status))
|
||||
NSLog(@"RGFX: the device refused render pipeline %llu, made as an equal one it accepted",
|
||||
static_cast<unsigned long long>(self.rgfxObjId));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "RgfxRingWriter.hpp"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -25,8 +26,9 @@ constexpr uint32_t kProducerWaiting = __builtin_offsetof(RgfxRingHeader, produce
|
||||
// before it looks again: a backstop only.
|
||||
constexpr uint32_t kRoomBackstopUs = 20000;
|
||||
|
||||
// How often a writer's room line is logged at most, while its posts sleep for room.
|
||||
constexpr uint64_t kSleepsLogNs = 1000000000;
|
||||
// How often a writer's room line is logged at most, while its posts sleep for room: a summary,
|
||||
// once a minute (docs/conventions.md).
|
||||
constexpr uint64_t kSleepsLogNs = 60ull * 1000000000;
|
||||
|
||||
// A message's header is 16 bytes; sizes are a multiple of 8.
|
||||
constexpr uint32_t kHeaderBytes = sizeof(RgfxMsgHeader);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#import "RgfxSampler.h"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#import "RgfxMetalPrivate.h"
|
||||
|
||||
@@ -56,7 +57,10 @@ RgfxSamplerParams RgfxSamplerParamsOf(MTLSamplerDescriptor *d)
|
||||
// (kRgfxNoAnswer), made no sampler: nil, as Metal answers a sampler it cannot make. One the
|
||||
// kext timed out on is followed by its destroy there, so nothing is left to let go.
|
||||
if (serializer->refused(created) || created.status != RGFX_STATUS_OK) {
|
||||
NSLog(@"RGFX: newSamplerStateWithDescriptor: no sampler (status 0x%x)", created.status);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site, created.status))
|
||||
NSLog(@"RGFX: newSamplerStateWithDescriptor: no sampler (status 0x%x)",
|
||||
created.status);
|
||||
return nil;
|
||||
}
|
||||
RgfxSampler *sampler = [[RgfxSampler alloc] initWithObjId:created.obj_id
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "RgfxSerializer.hpp"
|
||||
#include "RgfxLogOnce.hpp"
|
||||
|
||||
#include "RgfxIcbSlotTable.hpp"
|
||||
|
||||
@@ -756,8 +757,10 @@ void RgfxSerializer::postIcbMessage(IcbMessage &message, RgfxIcbFlush *flush)
|
||||
if (!m_control.tryPost(RGFX_CMD_ICB_WRITE, message.bytes.data(), size, nullptr)) {
|
||||
// The kext refused it, or the ring had no room: the buffer's commands keep what they
|
||||
// had, as a lost encode.
|
||||
std::fprintf(stderr, "RGFX: ICB_WRITE of %u bytes into 0x%llx was not posted\n", size,
|
||||
static_cast<unsigned long long>(message.icb));
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
std::fprintf(stderr, "RGFX: ICB_WRITE of %u bytes into 0x%llx was not posted\n",
|
||||
size, static_cast<unsigned long long>(message.icb));
|
||||
}
|
||||
if (flush != nullptr) {
|
||||
flush->messages++;
|
||||
@@ -786,7 +789,9 @@ void RgfxSerializer::postIcbSlots(const std::vector<RgfxIcbSlotRun> &runs, RgfxI
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
if (!m_control.tryPost(RGFX_CMD_ICB_SLOTS, bytes.data(), size, nullptr)) {
|
||||
// As a lost ICB_WRITE: the commands keep what they had.
|
||||
std::fprintf(stderr, "RGFX: ICB_SLOTS of %zu runs was not posted\n", n);
|
||||
static char site;
|
||||
if (rgfxLogFirst(&site))
|
||||
std::fprintf(stderr, "RGFX: ICB_SLOTS of %zu runs was not posted\n", n);
|
||||
}
|
||||
if (flush != nullptr) {
|
||||
flush->messages++;
|
||||
|
||||
Reference in new issue
Block a user