diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 1711ef519..9124b17fd 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -661,6 +661,18 @@ void WrappedID3D11Device::LazyInit() } } +void WrappedID3D11Device::AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, std::string d) +{ + DebugMessage msg; + msg.eventID = m_pImmediateContext->GetEventID(); + msg.messageID = 0; + msg.source = eDbgSource_RuntimeWarning; + msg.category = c; + msg.severity = sv; + msg.description = d; + m_DebugMessages.push_back(msg); +} + vector WrappedID3D11Device::GetDebugMessages() { vector ret; diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 5f7257c0c..f98287267 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -253,6 +253,7 @@ public: vector GetDebugMessages(); void AddDebugMessage(DebugMessage msg) { m_DebugMessages.push_back(msg); } + void AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, std::string d); const vector &GetLayoutDesc(ID3D11InputLayout *layout) { return m_LayoutDescs[layout]; } ShaderReflection *GetLayoutDXBC(ID3D11InputLayout *layout) { return m_LayoutDXBC[layout]; } diff --git a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp index 138b3518f..84398e665 100644 --- a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp +++ b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp @@ -2305,11 +2305,20 @@ State State::GetNext(GlobalState &global, State quad[4]) const // try depth first - both should match sample count though to be valid if(dsv) + { dsv->GetResource(&res); + } else if(rtv) + { rtv->GetResource(&res); + } else + { RDCWARN("No targets bound for sampleinfo on rasterizer"); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nNo targets bound for sampleinfo on rasterizer", s.nextInstruction-1, op.str)); + } SAFE_RELEASE(rtv); SAFE_RELEASE(dsv); @@ -2336,9 +2345,16 @@ State State::GetNext(GlobalState &global, State quad[4]) const context->CSGetShaderResources(slot, 1, &srv); if(srv) + { srv->GetResource(&res); + } else + { RDCWARN("SRV is NULL being queried by sampleinfo"); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nSRV is NULL being queried by sampleinfo", s.nextInstruction-1, op.str)); + } SAFE_RELEASE(srv); } @@ -2367,6 +2383,9 @@ State State::GetNext(GlobalState &global, State quad[4]) const else { RDCWARN("Non multisampled resource provided to sample_info"); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nSRV is NULL being queried by sampleinfo", s.nextInstruction-1, op.str)); } // "If there is no resource bound to the specified slot, 0 is returned." @@ -2395,6 +2414,9 @@ State State::GetNext(GlobalState &global, State quad[4]) const { RDCWARN("Non-multisampled texture being passed to sample_pos"); + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nNon-multisampled texture being passed to sample_pos", s.nextInstruction-1, op.str)); + sample_pattern = NULL; } else if(sampleCount == 2) @@ -2531,12 +2553,10 @@ State State::GetNext(GlobalState &global, State quad[4]) const if(op.operands[1].type == TYPE_UNORDERED_ACCESS_VIEW) { ID3D11UnorderedAccessView *uav = NULL; - if(s.dxbc->m_Type == D3D11_SHVER_PIXEL_SHADER) - context->OMGetRenderTargetsAndUnorderedAccessViews(0, NULL, NULL, slot, 1, &uav); - else if(s.dxbc->m_Type == D3D11_SHVER_COMPUTE_SHADER) + if(s.dxbc->m_Type == D3D11_SHVER_COMPUTE_SHADER) context->CSGetUnorderedAccessViews(slot, 1, &uav); else - RDCERR("Trying to get UAV bufinfo in shader other than pixel and compute!"); + context->OMGetRenderTargetsAndUnorderedAccessViews(0, NULL, NULL, slot, 1, &uav); if(uav) { @@ -2550,30 +2570,18 @@ State State::GetNext(GlobalState &global, State quad[4]) const } else { - RDCERR("Unexpected UAV dimension %d passed to bufinfo", uavDesc.ViewDimension); - - DebugMessage msg = {0}; - msg.source = eDbgSource_RuntimeWarning; - msg.category = eDbgCategory_Shaders; - msg.severity = eDbgSeverity_Medium; - char time[512] = {0}; - StringFormat::sntimef(time, 511, "%H:%M:%S"); - msg.description = StringFormat::Fmt("%s- Shader debugging %d: %s\nUAV being queried by bufinfo is not a buffer", time, s.nextInstruction, op.str); - device->AddDebugMessage(msg); + RDCWARN("Unexpected UAV dimension %d passed to bufinfo", uavDesc.ViewDimension); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_High, + StringFormat::Fmt("Shader debugging %d: %s\nUAV being queried by bufinfo is not a buffer", s.nextInstruction-1, op.str)); } } else { - RDCERR("UAV is NULL being queried by bufinfo"); + RDCWARN("UAV is NULL being queried by bufinfo"); - DebugMessage msg = {0}; - msg.source = eDbgSource_RuntimeWarning; - msg.category = eDbgCategory_Shaders; - msg.severity = eDbgSeverity_Medium; - char time[512] = {0}; - StringFormat::sntimef(time, 511, "%H:%M:%S"); - msg.description = StringFormat::Fmt("%s- Shader debugging %d: %s\nUAV being queried by bufinfo is NULL", time, s.nextInstruction, op.str); - device->AddDebugMessage(msg); + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nUAV being queried by bufinfo is NULL", s.nextInstruction-1, op.str)); } SAFE_RELEASE(uav); @@ -2611,12 +2619,18 @@ State State::GetNext(GlobalState &global, State quad[4]) const } else { - RDCERR("Unexpected SRV dimension %d passed to bufinfo", srvDesc.ViewDimension); + RDCWARN("Unexpected SRV dimension %d passed to bufinfo", srvDesc.ViewDimension); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_High, + StringFormat::Fmt("Shader debugging %d: %s\nSRV being queried by bufinfo is not a buffer", s.nextInstruction-1, op.str)); } } else { - RDCERR("SRV is NULL being queried by bufinfo"); + RDCWARN("SRV is NULL being queried by bufinfo"); + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_Medium, + StringFormat::Fmt("Shader debugging %d: %s\nSRV being queried by bufinfo is NULL", s.nextInstruction-1, op.str)); } SAFE_RELEASE(srv); @@ -3554,16 +3568,25 @@ State State::GetNext(GlobalState &global, State quad[4]) const { RDCWARN("NaN or Inf in texlookup"); ddxCalc.value.fv[i] = 0.0f; + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_High, + StringFormat::Fmt("Shader debugging %d: %s\nNaN or Inf found in texture lookup - using 0.0 instead", s.nextInstruction-1, op.str)); } if(_isnan(ddyCalc.value.fv[i]) || !_finite(ddyCalc.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); ddyCalc.value.fv[i] = 0.0f; + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_High, + StringFormat::Fmt("Shader debugging %d: %s\nNaN or Inf found in texture lookup - using 0.0 instead", s.nextInstruction-1, op.str)); } if(_isnan(uv.value.fv[i]) || !_finite(uv.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); uv.value.fv[i] = 0.0f; + + device->AddDebugMessage(eDbgCategory_Shaders, eDbgSeverity_High, + StringFormat::Fmt("Shader debugging %d: %s\nNaN or Inf found in texture lookup - using 0.0 instead", s.nextInstruction-1, op.str)); } }