diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index 371b19ac2..fe837ef83 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -792,8 +792,7 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12CommandQueue::Present( WrappedID3D12GraphicsCommandList *list = (WrappedID3D12GraphicsCommandList *)pOpenCommandList; // add a marker - const char str[] = "ID3D12CommandQueueDownlevel::Present()"; - list->SetMarker(PIX_EVENT_ANSI_VERSION, str, sizeof(str) - 1); + D3D12MarkerRegion::Set(list, "ID3D12CommandQueueDownlevel::Present()"); // the list is implicitly closed, serialise that D3D12ResourceRecord *listRecord = GetRecord(list); diff --git a/renderdoc/driver/d3d12/d3d12_common.cpp b/renderdoc/driver/d3d12/d3d12_common.cpp index f67988fbe..2de05362c 100644 --- a/renderdoc/driver/d3d12/d3d12_common.cpp +++ b/renderdoc/driver/d3d12/d3d12_common.cpp @@ -56,8 +56,13 @@ void D3D12MarkerRegion::Begin(ID3D12GraphicsCommandList *list, const std::string { if(list) { + // Some debuggers (but not all) will assume the event string is null-terminated, and + // display one less character than specified by the size. Append a space to pad the + // output without visibly changing the event marker for other debuggers. std::wstring text = StringFormat::UTF82Wide(marker); - list->BeginEvent(0, text.c_str(), (UINT)text.size()); + text.append(L" "); + UINT size = (UINT)text.size() * sizeof(wchar_t); + list->BeginEvent(0, text.c_str(), size); } } @@ -66,7 +71,9 @@ void D3D12MarkerRegion::Begin(ID3D12CommandQueue *queue, const std::string &mark if(queue) { std::wstring text = StringFormat::UTF82Wide(marker); - queue->BeginEvent(0, text.c_str(), (UINT)text.size()); + text.append(L" "); + UINT size = (UINT)text.size() * sizeof(wchar_t); + queue->BeginEvent(0, text.c_str(), size); } } @@ -75,7 +82,9 @@ void D3D12MarkerRegion::Set(ID3D12GraphicsCommandList *list, const std::string & if(list) { std::wstring text = StringFormat::UTF82Wide(marker); - list->SetMarker(0, text.c_str(), (UINT)text.size()); + text.append(L" "); + UINT size = (UINT)text.size() * sizeof(wchar_t); + list->SetMarker(0, text.c_str(), size); } } @@ -84,7 +93,9 @@ void D3D12MarkerRegion::Set(ID3D12CommandQueue *queue, const std::string &marker if(queue) { std::wstring text = StringFormat::UTF82Wide(marker); - queue->SetMarker(0, text.c_str(), (UINT)text.size()); + text.append(L" "); + UINT size = (UINT)text.size() * sizeof(wchar_t); + queue->SetMarker(0, text.c_str(), size); } } diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 01b13c475..af137edbf 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -75,15 +75,21 @@ inline std::string DecodeMarkerString(UINT Metadata, const void *pData, UINT Siz { std::string MarkerText = ""; + // There may be a space appended to the marker string - see D3D12MarkerRegion::Begin + // If we encounter this extra space (or a null terminator), remove it. if(Metadata == PIX_EVENT_UNICODE_VERSION) { const wchar_t *w = (const wchar_t *)pData; - MarkerText = StringFormat::Wide2UTF8(std::wstring(w, w + Size)); + MarkerText = StringFormat::Wide2UTF8(std::wstring(w, w + Size / sizeof(wchar_t))); + if(!MarkerText.empty() && (MarkerText.back() == ' ' || MarkerText.back() == 0)) + MarkerText.pop_back(); } else if(Metadata == PIX_EVENT_ANSI_VERSION) { const char *c = (const char *)pData; MarkerText = std::string(c, c + Size); + if(!MarkerText.empty() && (MarkerText.back() == ' ' || MarkerText.back() == 0)) + MarkerText.pop_back(); } else if(Metadata == PIX_EVENT_PIX3BLOB_VERSION) {