| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <cstdint> |
| 4 |
|
| 5 |
#include <Containers/StringView.h> |
| 6 |
|
| 7 |
using namespace Death::Containers; |
| 8 |
|
| 9 |
namespace nCine::RHI |
| 10 |
{ |
| 11 |
class IRhiCapabilities; |
| 12 |
} |
| 13 |
|
| 14 |
namespace nCine::RHI::GXM |
| 15 |
{ |
| 16 |
/** |
| 17 |
@brief Debug-output and object-labelling facade of the sceGxm backend |
| 18 |
|
| 19 |
The render pipeline's debug groups map onto sceGxm's own user markers, which the Razor GPU capture |
| 20 |
tools and Vita3K's command tracing both display, so a capture is annotated with the same pass names |
| 21 |
the OpenGL backend pushes through `glPushDebugGroup`. Object labels have no sceGxm counterpart (its |
| 22 |
resources are plain structures in user memory, not driver-side named objects) and are dropped. |
| 23 |
|
| 24 |
The markers are only emitted between @ref GxmDevice::CreateSwapchain() and its teardown, because |
| 25 |
`sceGxmPushUserMarker()` needs the context; before that they are silently dropped. |
| 26 |
*/ |
| 27 |
class GxmDebug |
| 28 |
{ |
| 29 |
public: |
| 30 |
/** @brief Object types that can be labelled (values are irrelevant for the sceGxm backend) */ |
| 31 |
enum class LabelTypes |
| 32 |
{ |
| 33 |
Buffer, |
| 34 |
Shader, |
| 35 |
Program, |
| 36 |
VertexArray, |
| 37 |
Query, |
| 38 |
ProgramPipeline, |
| 39 |
TransformFeedback, |
| 40 |
Sampler, |
| 41 |
Texture, |
| 42 |
RenderBuffer, |
| 43 |
FrameBuffer |
| 44 |
}; |
| 45 |
|
| 46 |
/** |
| 47 |
@brief RAII scope for a debug message group (a `sceGxmPushUserMarker()` / `sceGxmPopUserMarker()` pair) |
| 48 |
*/ |
| 49 |
class ScopedGroup |
| 50 |
{ |
| 51 |
public: |
| 52 |
explicit ScopedGroup(StringView message) { |
| 53 |
PushGroup(message); |
| 54 |
} |
| 55 |
~ScopedGroup() { |
| 56 |
PopGroup(); |
| 57 |
} |
| 58 |
|
| 59 |
ScopedGroup(const ScopedGroup&) = delete; |
| 60 |
ScopedGroup& operator=(const ScopedGroup&) = delete; |
| 61 |
}; |
| 62 |
|
| 63 |
static void Init(const IRhiCapabilities& caps) { |
| 64 |
static_cast<void>(caps); |
| 65 |
} |
| 66 |
static inline void Reset() {} |
| 67 |
|
| 68 |
static inline bool IsAvailable() { |
| 69 |
return true; |
| 70 |
} |
| 71 |
|
| 72 |
/** @brief Opens a user marker on the sceGxm context */ |
| 73 |
static void PushGroup(StringView message); |
| 74 |
/** @brief Closes the innermost user marker */ |
| 75 |
static void PopGroup(); |
| 76 |
/** @brief Inserts a standalone user marker */ |
| 77 |
static void MessageInsert(StringView message); |
| 78 |
|
| 79 |
static void SetObjectLabel(LabelTypes identifier, std::uint32_t name, StringView label) { |
| 80 |
static_cast<void>(identifier); |
| 81 |
static_cast<void>(name); |
| 82 |
static_cast<void>(label); |
| 83 |
} |
| 84 |
static void GetObjectLabel(LabelTypes identifier, std::uint32_t name, std::int32_t bufSize, std::int32_t* length, char* label) { |
| 85 |
static_cast<void>(identifier); |
| 86 |
static_cast<void>(name); |
| 87 |
static_cast<void>(bufSize); |
| 88 |
if (length != nullptr) { |
| 89 |
*length = 0; |
| 90 |
} |
| 91 |
if (label != nullptr && bufSize > 0) { |
| 92 |
label[0] = '\0'; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
static inline std::int32_t GetMaxLabelLength() { |
| 97 |
return 0; |
| 98 |
} |
| 99 |
}; |
| 100 |
} |