Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs-d3d11: Allow for arbitrary marker name lengths #11328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion libobs-d3d11/d3d11-subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3262,10 +3262,30 @@ extern "C" EXPORT void device_debug_marker_begin(gs_device_t *,
(DWORD)(255.0f * color[1]),
(DWORD)(255.0f * color[2]));

#if _CPPUNWIND
// Allocate the correct buffer size on the stack to allow for arbitrary
// size strings. On some platforms, this will automatically swap to heap
// once a certain threshold is exceeded. Same performance as before, but
// much more versatile this way.
__try {
size_t len = os_utf8_to_wcs(markername, 0, nullptr, 0);
// This has a warning that is nonsense on MSVC.
wchar_t *wide = reinterpret_cast<wchar_t *>(
_malloca((len + 1) * sizeof(wchar_t)));
os_utf8_to_wcs(markername, 0, wide, len);

D3DPERF_BeginEvent(bgra, wide);

_freea(reinterpret_cast<void *>(wide));
} __except (GetExceptionCode() == STATUS_STACK_OVERFLOW) {
// Handle the stack overflow gracefully.
D3DPERF_BeginEvent(bgra, L"(stack overflow)");
}
#else
wchar_t wide[64];
os_utf8_to_wcs(markername, 0, wide, _countof(wide));

D3DPERF_BeginEvent(bgra, wide);
#endif
}

extern "C" EXPORT void device_debug_marker_end(gs_device_t *)
Expand Down
Loading