Silence some warnings about casting from one enum type to another

* Reported by Coverity Scan - I don't think any of these were actually
  a problem since the enum definitions all matched.
This commit is contained in:
baldurk committed 2017-11-22 19:11:19 +00:00
1 parent 3e95356d9b
commit 203f6b5255
15 files changed
+81 -79

No files matched your search

+10
View File
@@ -61,6 +61,16 @@ QString ToQStr(const ResourceUsage usage, const GraphicsAPI apitype);
// overload for a couple of things that need to know the pipeline type when converting
QString ToQStr(const ShaderStage stage, const GraphicsAPI apitype);
inline QMetaType::Type GetVariantMetatype(const QVariant &v)
{
// this is explicitly called out by the documentation as the recommended process:
// "Although this function is declared as returning QVariant::Type, the return value should be
// interpreted as QMetaType::Type."
// Suppress static analysis complaints about the enums mismatching:
// coverity[mixed_enums]
return (QMetaType::Type)v.type();
}
struct FormatElement
{
Q_DECLARE_TR_FUNCTIONS(FormatElement);
+4 -3
View File
@@ -31,6 +31,7 @@
#include <QScrollBar>
#include <QTimer>
#include <QtMath>
#include "Code/QRDUtils.h"
#include "Code/Resources.h"
#include "ui_BufferViewer.h"
@@ -527,7 +528,7 @@ public:
if(!list.isEmpty())
{
QMetaType::Type vt = (QMetaType::Type)list[0].type();
QMetaType::Type vt = GetVariantMetatype(list[0]);
QColor rgb;
@@ -875,7 +876,7 @@ private:
{
QString ret;
QMetaType::Type vt = (QMetaType::Type)v.type();
QMetaType::Type vt = GetVariantMetatype(v);
if(vt == QMetaType::Double)
{
@@ -1885,7 +1886,7 @@ void BufferViewer::calcBoundingData(CalcBoundingBoxData &bbox)
{
const QVariant &v = list[comp];
QMetaType::Type vt = (QMetaType::Type)v.type();
QMetaType::Type vt = GetVariantMetatype(v);
float fval = 0.0f;
@@ -384,9 +384,7 @@ void PipelineStateViewer::exportHTMLTable(QXmlStreamWriter &xml, const QStringLi
{
xml.writeStartElement(lit("td"));
QMetaType::Type type = (QMetaType::Type)el.type();
if(type == QMetaType::Bool)
if(el.canConvert<bool>())
xml.writeCharacters(el.toBool() ? tr("True") : tr("False"));
else
xml.writeCharacters(el.toString());
+5 -6
View File
@@ -849,19 +849,18 @@ void D3D11DebugManager::CreateShaderGlobalState(ShaderDebug::GlobalState &global
for(const DXBC::ShaderInputBind &bind : dxbc->m_SRVs)
{
if(bind.reg == (uint32_t)i && bind.dimension == DXBC::ShaderInputBind::DIM_BUFFER &&
bind.retType < DXBC::ShaderInputBind::RETTYPE_MIXED &&
bind.retType != DXBC::ShaderInputBind::RETTYPE_UNKNOWN)
bind.retType < DXBC::RETURN_TYPE_MIXED && bind.retType != DXBC::RETURN_TYPE_UNKNOWN)
{
global.srvs[i].format.byteWidth = 4;
global.srvs[i].format.numComps = bind.numSamples;
if(bind.retType == DXBC::ShaderInputBind::RETTYPE_UNORM)
if(bind.retType == DXBC::RETURN_TYPE_UNORM)
global.srvs[i].format.fmt = CompType::UNorm;
else if(bind.retType == DXBC::ShaderInputBind::RETTYPE_SNORM)
else if(bind.retType == DXBC::RETURN_TYPE_SNORM)
global.srvs[i].format.fmt = CompType::SNorm;
else if(bind.retType == DXBC::ShaderInputBind::RETTYPE_UINT)
else if(bind.retType == DXBC::RETURN_TYPE_UINT)
global.srvs[i].format.fmt = CompType::UInt;
else if(bind.retType == DXBC::ShaderInputBind::RETTYPE_SINT)
else if(bind.retType == DXBC::RETURN_TYPE_SINT)
global.srvs[i].format.fmt = CompType::SInt;
else
global.srvs[i].format.fmt = CompType::Float;
+1 -1
View File
@@ -4716,7 +4716,7 @@ void D3D11DebugManager::InitPostVSBuffers(uint32_t eventID)
if(decl.declaration == DXBC::OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY)
{
topo = (D3D11_PRIMITIVE_TOPOLOGY) int(decl.outTopology); // enums match
topo = decl.outTopology;
break;
}
}
+20
View File
@@ -298,6 +298,26 @@ TextureFilter MakeFilter(D3D12_FILTER filter)
return ret;
}
D3DBufferViewFlags MakeBufferFlags(D3D12_BUFFER_SRV_FLAGS flags)
{
D3DBufferViewFlags ret = D3DBufferViewFlags::NoFlags;
if(flags & D3D12_BUFFER_SRV_FLAG_RAW)
ret |= D3DBufferViewFlags::Raw;
return ret;
}
D3DBufferViewFlags MakeBufferFlags(D3D12_BUFFER_UAV_FLAGS flags)
{
D3DBufferViewFlags ret = D3DBufferViewFlags::NoFlags;
if(flags & D3D12_BUFFER_UAV_FLAG_RAW)
ret |= D3DBufferViewFlags::Raw;
return ret;
}
LogicOp MakeLogicOp(D3D12_LOGIC_OP op)
{
switch(op)
+2
View File
@@ -64,6 +64,8 @@ TextureDim MakeTextureDim(D3D12_UAV_DIMENSION dim);
AddressMode MakeAddressMode(D3D12_TEXTURE_ADDRESS_MODE addr);
CompareFunc MakeCompareFunc(D3D12_COMPARISON_FUNC func);
TextureFilter MakeFilter(D3D12_FILTER filter);
D3DBufferViewFlags MakeBufferFlags(D3D12_BUFFER_SRV_FLAGS flags);
D3DBufferViewFlags MakeBufferFlags(D3D12_BUFFER_UAV_FLAGS flags);
LogicOp MakeLogicOp(D3D12_LOGIC_OP op);
BlendMultiplier MakeBlendMultiplier(D3D12_BLEND blend, bool alpha);
BlendOp MakeBlendOp(D3D12_BLEND_OP op);
+1 -1
View File
@@ -4908,7 +4908,7 @@ void D3D12DebugManager::InitPostVSBuffers(uint32_t eventID)
if(decl.declaration == DXBC::OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY)
{
topo = (D3D_PRIMITIVE_TOPOLOGY) int(decl.outTopology); // enums match
topo = decl.outTopology;
break;
}
}
+1 -1
View File
@@ -415,7 +415,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
D3D12_UNORDERED_ACCESS_VIEW_DESC uavdesc = nonsamp.uav.desc.AsDesc();
D3D12_UNORDERED_ACCESS_VIEW_DESC *desc = &uavdesc;
if(uavdesc.ViewDimension == D3D12_SRV_DIMENSION_UNKNOWN)
if(uavdesc.ViewDimension == D3D12_UAV_DIMENSION_UNKNOWN)
{
desc = nonsamp.resource ? NULL : defaultUAV();
+2 -2
View File
@@ -438,7 +438,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.FirstElement = desc->nonsamp.srv.Buffer.FirstElement;
view.NumElements = desc->nonsamp.srv.Buffer.NumElements;
view.BufferFlags = D3DBufferViewFlags(desc->nonsamp.srv.Buffer.Flags);
view.BufferFlags = MakeBufferFlags(desc->nonsamp.srv.Buffer.Flags);
if(desc->nonsamp.srv.Buffer.StructureByteStride > 0)
view.ElementSize = desc->nonsamp.srv.Buffer.StructureByteStride;
}
@@ -498,7 +498,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.FirstElement = uav.Buffer.FirstElement;
view.NumElements = uav.Buffer.NumElements;
view.BufferFlags = D3DBufferViewFlags(uav.Buffer.Flags);
view.BufferFlags = MakeBufferFlags(uav.Buffer.Flags);
if(uav.Buffer.StructureByteStride > 0)
view.ElementSize = uav.Buffer.StructureByteStride;
@@ -172,7 +172,7 @@ static MaskedElement<TessellatorPartitioning, 0x00003800> TessPartitioning;
static MaskedElement<PrimitiveType, 0x0001F800> InputPrimitive;
// OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY
static MaskedElement<PrimitiveTopology, 0x0001F800> OutputPrimitiveTopology;
static MaskedElement<D3D_PRIMITIVE_TOPOLOGY, 0x0001F800> OutputPrimitiveTopology;
// OPCODE_DCL_TESS_OUTPUT_PRIMITIVE
static MaskedElement<TessellatorOutputPrimitive, 0x00003800> OutputPrimitive;
@@ -1979,23 +1979,23 @@ bool DXBCFile::ExtractDecl(uint32_t *&tokenStream, ASMDecl &retDecl, bool friend
retDecl.outTopology = Declaration::OutputPrimitiveTopology.Get(OpcodeToken0);
retDecl.str += " ";
if(retDecl.outTopology == TOPOLOGY_POINTLIST)
if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_POINTLIST)
retDecl.str += "point";
else if(retDecl.outTopology == TOPOLOGY_LINELIST)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_LINELIST)
retDecl.str += "linelist";
else if(retDecl.outTopology == TOPOLOGY_LINESTRIP)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_LINESTRIP)
retDecl.str += "linestrip";
else if(retDecl.outTopology == TOPOLOGY_TRIANGLELIST)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST)
retDecl.str += "trianglelist";
else if(retDecl.outTopology == TOPOLOGY_TRIANGLESTRIP)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP)
retDecl.str += "trianglestrip";
else if(retDecl.outTopology == TOPOLOGY_LINELIST_ADJ)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ)
retDecl.str += "linelist_adj";
else if(retDecl.outTopology == TOPOLOGY_LINESTRIP_ADJ)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ)
retDecl.str += "linestrip_adj";
else if(retDecl.outTopology == TOPOLOGY_TRIANGLELIST_ADJ)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ)
retDecl.str += "trianglelist_adj";
else if(retDecl.outTopology == TOPOLOGY_TRIANGLESTRIP_ADJ)
else if(retDecl.outTopology == D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ)
retDecl.str += "trianglestrip_adj";
else
RDCERR("Unexpected primitive topology");
@@ -29,6 +29,7 @@
#include <string>
#include <vector>
#include "api/replay/renderdoc_replay.h"
#include "driver/dx/official/d3dcommon.h"
using std::vector;
using std::string;
@@ -562,22 +563,6 @@ enum InterpolationMode
NUM_INTERPOLATIONS,
};
enum PrimitiveTopology
{
TOPOLOGY_UNDEFINED = 0,
TOPOLOGY_POINTLIST,
TOPOLOGY_LINELIST,
TOPOLOGY_LINESTRIP,
TOPOLOGY_TRIANGLELIST,
TOPOLOGY_TRIANGLESTRIP,
TOPOLOGY_LINELIST_ADJ,
TOPOLOGY_LINESTRIP_ADJ,
TOPOLOGY_TRIANGLELIST_ADJ,
TOPOLOGY_TRIANGLESTRIP_ADJ,
NUM_TOPOLOGYS,
};
enum PrimitiveType
{
PRIMITIVE_UNDEFINED = 0,
@@ -672,6 +657,7 @@ enum ResourceDimension
enum ResourceRetType
{
RETURN_TYPE_UNKNOWN = 0,
RETURN_TYPE_UNORM = 1,
RETURN_TYPE_SNORM,
RETURN_TYPE_SINT,
@@ -845,7 +831,7 @@ struct ASMDecl
partition = PARTITIONING_UNDEFINED;
outPrim = OUTPUT_PRIMITIVE_UNDEFINED;
inPrim = PRIMITIVE_UNDEFINED;
outTopology = TOPOLOGY_UNDEFINED;
outTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
instanceCount = 0;
indexRange = 0;
maxTessFactor = 0.0f;
@@ -938,7 +924,7 @@ struct ASMDecl
PrimitiveType inPrim;
// OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY
PrimitiveTopology outTopology;
D3D_PRIMITIVE_TOPOLOGY outTopology;
// OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT
// OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
@@ -1006,4 +992,4 @@ struct ASMOperation
vector<ASMOperand> operands;
};
}; // DXBC
}; // DXBC
+10 -11
View File
@@ -631,13 +631,12 @@ DXBCFile::DXBCFile(const void *ByteCode, size_t ByteCodeLength)
desc.reg = res->bindPoint;
desc.bindCount = res->bindCount;
desc.flags = res->flags;
desc.retType = (ShaderInputBind::RetType)res->retType;
desc.retType = (ResourceRetType)res->retType;
desc.dimension = (ShaderInputBind::Dimension)res->dimension;
desc.numSamples = res->sampleCount;
if(desc.numSamples == ~0 && desc.retType != ShaderInputBind::RETTYPE_MIXED &&
desc.retType != ShaderInputBind::RETTYPE_UNKNOWN &&
desc.retType != ShaderInputBind::RETTYPE_CONTINUED)
if(desc.numSamples == ~0 && desc.retType != RETURN_TYPE_MIXED &&
desc.retType != RETURN_TYPE_UNKNOWN && desc.retType != RETURN_TYPE_CONTINUED)
{
// uint, uint2, uint3, uint4 seem to be in these bits of flags.
desc.numSamples = 1 + ((desc.flags & 0xC) >> 2);
@@ -1093,7 +1092,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = dcl.samplerMode == SAMPLER_MODE_COMPARISON ? 2 : 0;
desc.retType = ShaderInputBind::RETTYPE_UNKNOWN;
desc.retType = RETURN_TYPE_UNKNOWN;
desc.dimension = ShaderInputBind::DIM_UNKNOWN;
desc.numSamples = 0;
@@ -1126,7 +1125,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 0;
desc.retType = (ShaderInputBind::RetType)dcl.resType[0];
desc.retType = dcl.resType[0];
switch(dcl.dim)
{
@@ -1195,7 +1194,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 0;
desc.retType = ShaderInputBind::RETTYPE_MIXED;
desc.retType = RETURN_TYPE_MIXED;
desc.dimension = ShaderInputBind::DIM_BUFFER;
desc.numSamples = 0;
@@ -1231,7 +1230,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 0;
desc.retType = ShaderInputBind::RETTYPE_MIXED;
desc.retType = RETURN_TYPE_MIXED;
desc.dimension = ShaderInputBind::DIM_BUFFER;
desc.numSamples = dcl.stride;
@@ -1268,7 +1267,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 0;
desc.retType = ShaderInputBind::RETTYPE_MIXED;
desc.retType = RETURN_TYPE_MIXED;
desc.dimension = ShaderInputBind::DIM_BUFFER;
desc.numSamples = dcl.stride;
@@ -1301,7 +1300,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 0;
desc.retType = (ShaderInputBind::RetType) int(dcl.resType[0]); // enums match
desc.retType = dcl.resType[0];
switch(dcl.dim)
{
@@ -1361,7 +1360,7 @@ void DXBCFile::GuessResources()
desc.reg = idx;
desc.bindCount = 1;
desc.flags = 1;
desc.retType = ShaderInputBind::RETTYPE_UNKNOWN;
desc.retType = RETURN_TYPE_UNKNOWN;
desc.dimension = ShaderInputBind::DIM_UNKNOWN;
desc.numSamples = 0;
+1 -13
View File
@@ -156,19 +156,7 @@ struct ShaderInputBind
uint32_t bindCount;
uint32_t flags;
enum RetType
{
RETTYPE_UNKNOWN = 0,
RETTYPE_UNORM = 1,
RETTYPE_SNORM,
RETTYPE_SINT,
RETTYPE_UINT,
RETTYPE_FLOAT,
RETTYPE_MIXED,
RETTYPE_DOUBLE,
RETTYPE_CONTINUED,
} retType;
ResourceRetType retType;
enum Dimension
{
@@ -147,9 +147,8 @@ static void MakeResourceList(bool srv, DXBC::DXBCFile *dxbc, const vector<DXBC::
break;
}
if(r.retType != DXBC::ShaderInputBind::RETTYPE_UNKNOWN &&
r.retType != DXBC::ShaderInputBind::RETTYPE_MIXED &&
r.retType != DXBC::ShaderInputBind::RETTYPE_CONTINUED)
if(r.retType != DXBC::RETURN_TYPE_UNKNOWN && r.retType != DXBC::RETURN_TYPE_MIXED &&
r.retType != DXBC::RETURN_TYPE_CONTINUED)
{
res.variableType.descriptor.rows = 1;
res.variableType.descriptor.cols = (uint8_t)r.numSamples;
@@ -159,12 +158,12 @@ static void MakeResourceList(bool srv, DXBC::DXBCFile *dxbc, const vector<DXBC::
switch(r.retType)
{
case DXBC::ShaderInputBind::RETTYPE_UNORM: name = "unorm float"; break;
case DXBC::ShaderInputBind::RETTYPE_SNORM: name = "snorm float"; break;
case DXBC::ShaderInputBind::RETTYPE_SINT: name = "int"; break;
case DXBC::ShaderInputBind::RETTYPE_UINT: name = "uint"; break;
case DXBC::ShaderInputBind::RETTYPE_FLOAT: name = "float"; break;
case DXBC::ShaderInputBind::RETTYPE_DOUBLE: name = "double"; break;
case DXBC::RETURN_TYPE_UNORM: name = "unorm float"; break;
case DXBC::RETURN_TYPE_SNORM: name = "snorm float"; break;
case DXBC::RETURN_TYPE_SINT: name = "int"; break;
case DXBC::RETURN_TYPE_UINT: name = "uint"; break;
case DXBC::RETURN_TYPE_FLOAT: name = "float"; break;
case DXBC::RETURN_TYPE_DOUBLE: name = "double"; break;
default: name = "unknown"; break;
}