Add several more shader warning messages, add utility function

This commit is contained in:
baldurk
2015-01-11 00:44:37 +00:00
parent 04f1d4a378
commit 43f55a7cdc
3 changed files with 61 additions and 25 deletions
+12
View File
@@ -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<DebugMessage> WrappedID3D11Device::GetDebugMessages()
{
vector<DebugMessage> ret;
+1
View File
@@ -253,6 +253,7 @@ public:
vector<DebugMessage> GetDebugMessages();
void AddDebugMessage(DebugMessage msg) { m_DebugMessages.push_back(msg); }
void AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, std::string d);
const vector<D3D11_INPUT_ELEMENT_DESC> &GetLayoutDesc(ID3D11InputLayout *layout) { return m_LayoutDescs[layout]; }
ShaderReflection *GetLayoutDXBC(ID3D11InputLayout *layout) { return m_LayoutDXBC[layout]; }
+48 -25
View File
@@ -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));
}
}