warnings cleanup

cleanup and some warning fixes
This commit is contained in:
marauder2k7 2024-03-14 08:28:11 +00:00
parent 9dc5ae833b
commit e6c653c441
8 changed files with 55 additions and 42 deletions

View file

@ -469,6 +469,12 @@ void GFXD3D11ShaderConstBuffer::addBuffer(U32 bufBindingPoint, GFXShaderStage sh
} }
} }
// no shaderstage defined? cannot be!!!
if (shaderStageID == -1)
{
AssertFatal(false, "DX Const buffer requires a shaderStage flag.");
}
const BufferKey bufKey(bufBindingPoint, shaderStageID); const BufferKey bufKey(bufBindingPoint, shaderStageID);
// doesnt matter if its already added. // doesnt matter if its already added.
U8* buf = new U8[size]; U8* buf = new U8[size];
@ -572,8 +578,8 @@ void GFXD3D11ShaderConstBuffer::activate( GFXD3D11ShaderConstBuffer *prevShaderB
D3D11DEVICECONTEXT->GSSetConstantBuffers(bufStartSlot, numBufs, psBuffers); D3D11DEVICECONTEXT->GSSetConstantBuffers(bufStartSlot, numBufs, psBuffers);
} }
mWasLost = false; mWasLost = false;
} }
void GFXD3D11ShaderConstBuffer::onShaderReload( GFXD3D11Shader *shader ) void GFXD3D11ShaderConstBuffer::onShaderReload( GFXD3D11Shader *shader )
@ -1091,6 +1097,8 @@ GFXShaderConstType GFXD3D11Shader::convertConstType(const D3D11_SHADER_TYPE_DESC
} }
} }
return GFXSCT_Uknown;
} }
void GFXD3D11Shader::_buildShaderConstantHandles() void GFXD3D11Shader::_buildShaderConstantHandles()

View file

@ -34,6 +34,9 @@
#define STBIWDEF static inline #define STBIWDEF static inline
#endif #endif
#pragma warning( push )
#pragma warning( disable : 4505 ) // unreferenced function removed.
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC #define STB_IMAGE_STATIC
#include "stb_image.h" #include "stb_image.h"
@ -42,6 +45,8 @@
#define STB_IMAGE_WRITE_STATIC #define STB_IMAGE_WRITE_STATIC
#include "stb_image_write.h" #include "stb_image_write.h"
#pragma warning(pop)
static bool sReadSTB(const Torque::Path& path, GBitmap* bitmap); static bool sReadSTB(const Torque::Path& path, GBitmap* bitmap);
static bool sReadStreamSTB(Stream& stream, GBitmap* bitmap, U32 len); static bool sReadStreamSTB(Stream& stream, GBitmap* bitmap, U32 len);
@ -147,7 +152,7 @@ bool sReadSTB(const Torque::Path& path, GBitmap* bitmap)
U32 buffSize = readIes->getStreamSize(); U32 buffSize = readIes->getStreamSize();
char* buffer = new char[buffSize]; char* buffer = new char[buffSize];
readIes->read(buffSize, buffer); readIes->read(buffSize, buffer);
IESFileInfo info; IESFileInfo info;
IESLoadHelper IESLoader; IESLoadHelper IESLoader;
@ -399,8 +404,6 @@ bool sWriteSTB(const Torque::Path& path, GBitmap* bitmap, U32 compressionLevel)
String ext = path.getExtension(); String ext = path.getExtension();
U32 stride = width * bytes;
// we always have at least 1 // we always have at least 1
U32 comp = 1; U32 comp = 1;
@ -554,7 +557,6 @@ void DeferredPNGWriter::append(GBitmap* bitmap, U32 rows)
mData->channels = bitmap->getBytesPerPixel(); mData->channels = bitmap->getBytesPerPixel();
} }
const U32 height = getMin(bitmap->getHeight(), rows);
const dsize_t dataChuckSize = bitmap->getByteSize(); const dsize_t dataChuckSize = bitmap->getByteSize();
const U8* pSrcData = bitmap->getBits(); const U8* pSrcData = bitmap->getBits();

View file

@ -64,7 +64,7 @@ enum GFXTexCallbackCode
GFXResurrect, GFXResurrect,
}; };
enum GFXPrimitiveType enum GFXPrimitiveType
{ {
GFXPT_FIRST = 0, GFXPT_FIRST = 0,
GFXPointList = 0, GFXPointList = 0,
@ -75,7 +75,7 @@ enum GFXPrimitiveType
GFXPT_COUNT GFXPT_COUNT
}; };
enum GFXBitmapFlip enum GFXBitmapFlip
{ {
GFXBitmapFlip_None = 0, GFXBitmapFlip_None = 0,
GFXBitmapFlip_X = 1 << 0, GFXBitmapFlip_X = 1 << 0,
@ -83,7 +83,7 @@ enum GFXBitmapFlip
GFXBitmapFlip_XY = GFXBitmapFlip_X | GFXBitmapFlip_Y GFXBitmapFlip_XY = GFXBitmapFlip_X | GFXBitmapFlip_Y
}; };
enum GFXTextureAddressMode enum GFXTextureAddressMode
{ {
GFXAddress_FIRST = 0, GFXAddress_FIRST = 0,
GFXAddressWrap = 0, GFXAddressWrap = 0,
@ -94,7 +94,7 @@ enum GFXTextureAddressMode
GFXAddress_COUNT GFXAddress_COUNT
}; };
enum GFXTextureFilterType enum GFXTextureFilterType
{ {
GFXTextureFilter_FIRST = 0, GFXTextureFilter_FIRST = 0,
GFXTextureFilterNone = 0, GFXTextureFilterNone = 0,
@ -104,7 +104,7 @@ enum GFXTextureFilterType
GFXTextureFilter_COUNT GFXTextureFilter_COUNT
}; };
enum GFXFillMode enum GFXFillMode
{ {
GFXFill_FIRST = 1, GFXFill_FIRST = 1,
GFXFillPoint = 1, GFXFillPoint = 1,
@ -113,7 +113,7 @@ enum GFXFillMode
GFXFill_COUNT GFXFill_COUNT
}; };
enum GFXFormat enum GFXFormat
{ {
// when adding formats make sure to place // when adding formats make sure to place
// them in the correct group! // them in the correct group!
@ -152,7 +152,7 @@ enum GFXFormat
GFXFormatR11G11B10, GFXFormatR11G11B10,
GFXFormatD32, GFXFormatD32,
GFXFormatD24X8, GFXFormatD24X8,
GFXFormatD24S8, GFXFormatD24S8,
GFXFormatD24FS8, GFXFormatD24FS8,
// Guaranteed RGBA8 (for apis which really dont like bgr) // Guaranteed RGBA8 (for apis which really dont like bgr)
@ -172,7 +172,7 @@ enum GFXFormat
GFXFormatBC3, //dxt4/5 GFXFormatBC3, //dxt4/5
GFXFormatBC4, //3dc+ / ati1 GFXFormatBC4, //3dc+ / ati1
GFXFormatBC5, //3dc / ati2 GFXFormatBC5, //3dc / ati2
// compressed sRGB formats // compressed sRGB formats
GFXFormatBC1_SRGB, GFXFormatBC1_SRGB,
GFXFormatBC2_SRGB, GFXFormatBC2_SRGB,
GFXFormatBC3_SRGB, GFXFormatBC3_SRGB,
@ -191,7 +191,7 @@ enum GFXFormat
/// Returns the byte size of the pixel for non-compressed formats. /// Returns the byte size of the pixel for non-compressed formats.
inline U32 GFXFormat_getByteSize( GFXFormat format ) inline U32 GFXFormat_getByteSize( GFXFormat format )
{ {
AssertFatal( format < GFXFormat_UNKNOWNSIZE, AssertFatal( format < GFXFormat_UNKNOWNSIZE,
"GFXDevice::formatByteSize - Cannot size a compressed format!" ); "GFXDevice::formatByteSize - Cannot size a compressed format!" );
if ( format < GFXFormat_16BIT ) if ( format < GFXFormat_16BIT )
@ -205,12 +205,12 @@ inline U32 GFXFormat_getByteSize( GFXFormat format )
else if ( format < GFXFormat_128BIT ) else if ( format < GFXFormat_128BIT )
return 8;// 64 bit... return 8;// 64 bit...
// This should be 128bits... else its a DDS and // This should be 128bits... else its a DDS and
// the assert should have gone off above. // the assert should have gone off above.
return 16; return 16;
} }
enum GFXClearFlags enum GFXClearFlags
{ {
GFXClearTarget = 1 << 0, GFXClearTarget = 1 << 0,
GFXClearZBuffer = 1 << 1, GFXClearZBuffer = 1 << 1,
@ -218,7 +218,7 @@ enum GFXClearFlags
}; };
/// The supported blend modes. /// The supported blend modes.
enum GFXBlend enum GFXBlend
{ {
GFXBlend_FIRST = 0, GFXBlend_FIRST = 0,
GFXBlendZero = 0, /// (0, 0, 0, 0) GFXBlendZero = 0, /// (0, 0, 0, 0)
@ -238,7 +238,7 @@ enum GFXBlend
/// Constants that name each GFXDevice type. Any new GFXDevice subclass must be /// Constants that name each GFXDevice type. Any new GFXDevice subclass must be
/// added to this enum. A string representing its name must also be added to /// added to this enum. A string representing its name must also be added to
/// GFXInit::getAdapterNameFromType(). /// GFXInit::getAdapterNameFromType().
enum GFXAdapterType enum GFXAdapterType
{ {
OpenGL = 0, OpenGL = 0,
Direct3D11, Direct3D11,
@ -255,7 +255,7 @@ enum GFXCullMode
GFXCull_COUNT GFXCull_COUNT
}; };
enum GFXCmpFunc enum GFXCmpFunc
{ {
GFXCmp_FIRST = 0, GFXCmp_FIRST = 0,
GFXCmpNever = 0, GFXCmpNever = 0,
@ -269,7 +269,7 @@ enum GFXCmpFunc
GFXCmp_COUNT GFXCmp_COUNT
}; };
enum GFXStencilOp enum GFXStencilOp
{ {
GFXStencilOp_FIRST = 0, GFXStencilOp_FIRST = 0,
GFXStencilOpKeep = 0, GFXStencilOpKeep = 0,
@ -283,8 +283,8 @@ enum GFXStencilOp
GFXStencilOp_COUNT GFXStencilOp_COUNT
}; };
enum GFXBlendOp enum GFXBlendOp
{ {
GFXBlendOp_FIRST = 0, GFXBlendOp_FIRST = 0,
GFXBlendOpAdd = 0, GFXBlendOpAdd = 0,
GFXBlendOpSubtract, GFXBlendOpSubtract,
@ -294,7 +294,7 @@ enum GFXBlendOp
GFXBlendOp_COUNT GFXBlendOp_COUNT
}; };
enum GFXMatrixType enum GFXMatrixType
{ {
GFXMatrixWorld = 256, GFXMatrixWorld = 256,
GFXMatrixView = 2, GFXMatrixView = 2,
@ -312,6 +312,7 @@ enum GFXMatrixType
enum GFXShaderConstType enum GFXShaderConstType
{ {
GFXSCT_Uknown,
/// GFX"S"hader"C"onstant"T"ype /// GFX"S"hader"C"onstant"T"ype
GFXSCT_ConstBuffer, GFXSCT_ConstBuffer,
// Scalar // Scalar
@ -365,7 +366,7 @@ enum GFXDeclType
/// @see Point2F /// @see Point2F
GFXDeclType_Float2, GFXDeclType_Float2,
/// A three-component F32. /// A three-component F32.
/// @see Point3F /// @see Point3F
GFXDeclType_Float3, GFXDeclType_Float3,

View file

@ -79,14 +79,14 @@ enum GFXShaderStage
struct GFXShaderConstDesc struct GFXShaderConstDesc
{ {
public: public:
String name; String name = String::EmptyString;
GFXShaderConstType constType; GFXShaderConstType constType = GFXSCT_Uknown;
U32 arraySize = 0; // > 1 means it is an array! U32 arraySize = 0; // > 1 means it is an array!
S32 bindPoint = -1; // bind point used for ubo/cb S32 bindPoint = -1; // bind point used for ubo/cb
S32 samplerReg = -1; // sampler register. S32 samplerReg = -1; // sampler register.
U32 offset = 0; // offset for vars U32 offset = 0; // offset for vars
U32 size = 0; // size of buffer/type U32 size = 0; // size of buffer/type
GFXShaderStage shaderStage; // only used dx side. GFXShaderStage shaderStage = VERTEX_SHADER; // only used dx side.not wasting a bit for an unknown?
}; };
/// This is an opaque handle used by GFXShaderConstBuffer clients to set individual shader constants. /// This is an opaque handle used by GFXShaderConstBuffer clients to set individual shader constants.

View file

@ -868,10 +868,12 @@ GFXShaderConstType GFXGLShader::convertConstType(GLenum constType)
return GFXSCT_SamplerTextureArray; return GFXSCT_SamplerTextureArray;
break; break;
default: default:
AssertFatal(false, "GFXGLShader::initConstantDescs - unrecognized uniform type"); AssertFatal(false, "Unknown shader constant class enum, maybe you could add it?");
// If we don't recognize the constant don't add its description. // If we don't recognize the constant don't add its description.
break; break;
} }
return GFXSCT_Uknown;
} }
void GFXGLShader::initHandles() void GFXGLShader::initHandles()

View file

@ -598,7 +598,7 @@ bool GuiShaderEditor::onMouseWheelUp(const GuiEvent& event)
if (!mActive || !mAwake || !mVisible) if (!mActive || !mAwake || !mVisible)
return Parent::onMouseWheelUp(event); return Parent::onMouseWheelUp(event);
mZoomScale *= 1.1; mZoomScale *= 1.1f;
return true; return true;
} }
@ -608,7 +608,7 @@ bool GuiShaderEditor::onMouseWheelDown(const GuiEvent& event)
if (!mActive || !mAwake || !mVisible) if (!mActive || !mAwake || !mVisible)
return Parent::onMouseWheelDown(event); return Parent::onMouseWheelDown(event);
mZoomScale *= 0.9; mZoomScale *= 0.9f;
return true; return true;
} }

View file

@ -5,7 +5,7 @@
/// allows it to return the appropriate geometry. /// allows it to return the appropriate geometry.
enum PolyListContext enum PolyListContext
{ {
/// A hint that the polyist is intended /// A hint that the polyist is intended
/// for collision testing. /// for collision testing.
PLC_Collision, PLC_Collision,
@ -24,7 +24,7 @@ enum PolyListContext
/// A hint that the polyist will be used /// A hint that the polyist will be used
/// to export geometry and would like to have /// to export geometry and would like to have
/// texture coords and materials. /// texture coords and materials.
PLC_Export PLC_Export
}; };
@ -71,7 +71,7 @@ struct SceneBinRange
inline bool isGlobal() const inline bool isGlobal() const
{ {
return minCoord[0] == 0 && return minCoord[0] == 0 &&
minCoord[0] == 0 && minCoord[1] == 0 &&
maxCoord[0] == 0xFFFF && maxCoord[0] == 0xFFFF &&
maxCoord[1] == 0xFFFF; maxCoord[1] == 0xFFFF;
} }

View file

@ -122,13 +122,13 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
if (fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit]) if (fd.features[MFT_LightMap] || fd.features[MFT_ToneMap] || fd.features[MFT_VertLit])
return; return;
MultiLine* meta = new MultiLine; MultiLine* newMeta = new MultiLine;
// Now the wsPosition and wsView. // Now the wsPosition and wsView.
Var* worldToTangent = getInWorldToTangent(componentList); Var* worldToTangent = getInWorldToTangent(componentList);
Var* wsNormal = getInWorldNormal(componentList); Var* wsNormal = getInWorldNormal(componentList);
Var* wsPosition = getInWsPosition(componentList); Var* wsPosition = getInWsPosition(componentList);
Var* wsView = getWsView(wsPosition, meta); Var* wsView = getWsView(wsPosition, newMeta);
//Reflection Probe WIP //Reflection Probe WIP
U32 MAX_FORWARD_PROBES = 4; U32 MAX_FORWARD_PROBES = 4;
@ -153,32 +153,32 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
Var* showAttenVar = new Var("showAttenVar", "int"); Var* showAttenVar = new Var("showAttenVar", "int");
char buf[64]; char buf[64];
dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showAtten); dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showAtten);
meta->addStatement(new GenOp(buf, new DecOp(showAttenVar))); newMeta->addStatement(new GenOp(buf, new DecOp(showAttenVar)));
Var* showContribVar = new Var("showContribVar", "int"); Var* showContribVar = new Var("showContribVar", "int");
dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showContrib); dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showContrib);
meta->addStatement(new GenOp(buf, new DecOp(showContribVar))); newMeta->addStatement(new GenOp(buf, new DecOp(showContribVar)));
Var* showSpecVar = new Var("showSpecVar", "int"); Var* showSpecVar = new Var("showSpecVar", "int");
dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showSpec); dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showSpec);
meta->addStatement(new GenOp(buf, new DecOp(showSpecVar))); newMeta->addStatement(new GenOp(buf, new DecOp(showSpecVar)));
Var* showDiffVar = new Var("showDiffVar", "int"); Var* showDiffVar = new Var("showDiffVar", "int");
dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showDiff); dSprintf(buf, sizeof(buf), " @ = %s;\r\n", showDiff);
meta->addStatement(new GenOp(buf, new DecOp(showDiffVar))); newMeta->addStatement(new GenOp(buf, new DecOp(showDiffVar)));
String computeForwardProbes = String(" @ = debugVizForwardProbes(@,@,@,@,@,@,@,@,\r\n\t\t"); String computeForwardProbes = String(" @ = debugVizForwardProbes(@,@,@,@,@,@,@,@,\r\n\t\t");
computeForwardProbes += String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t"); computeForwardProbes += String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@), @, @, @, @).rgb; \r\n"); computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@), @, @, @, @).rgb; \r\n");
meta->addStatement(new GenOp(computeForwardProbes.c_str(), ibl, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, newMeta->addStatement(new GenOp(computeForwardProbes.c_str(), ibl, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray,
skylightCubemapIdx, BRDFTexture, skylightCubemapIdx, BRDFTexture,
irradianceCubemapAR, specularCubemapAR, irradianceCubemapAR, specularCubemapAR,
showAttenVar, showContribVar, showSpecVar, showDiffVar)); showAttenVar, showContribVar, showSpecVar, showDiffVar));
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", color, ibl)); newMeta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", color, ibl));
output = meta; output = newMeta;
return; return;
} }
} }