diff --git a/samples/translator/translator.cpp b/samples/translator/translator.cpp index c284eb02c..0b198912b 100644 --- a/samples/translator/translator.cpp +++ b/samples/translator/translator.cpp @@ -369,7 +369,7 @@ static bool ReadShaderSource(const char* fileName, ShaderSource& source) { // Obtain file size. fseek(in, 0, SEEK_END); - int count = ftell(in); + size_t count = ftell(in); rewind(in); int len = (int)ceil((float)count / (float)NUM_SOURCE_STRINGS); @@ -379,7 +379,7 @@ static bool ReadShaderSource(const char* fileName, ShaderSource& source) { // string is added to vector. do { char* data = new char[len + 1]; - int nread = fread(data, 1, len, in); + size_t nread = fread(data, 1, len, in); data[nread] = '\0'; source.push_back(data); diff --git a/src/compiler/translator/BlockLayoutEncoder.cpp b/src/compiler/translator/BlockLayoutEncoder.cpp index 26d7ba2c5..b8d14e2c1 100644 --- a/src/compiler/translator/BlockLayoutEncoder.cpp +++ b/src/compiler/translator/BlockLayoutEncoder.cpp @@ -79,7 +79,7 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is void BlockLayoutEncoder::nextRegister() { - mCurrentOffset = rx::roundUp(mCurrentOffset, ComponentsPerRegister); + mCurrentOffset = rx::roundUp(mCurrentOffset, ComponentsPerRegister); } Std140BlockEncoder::Std140BlockEncoder(std::vector *blockInfoOut) diff --git a/src/compiler/translator/HLSLLayoutEncoder.cpp b/src/compiler/translator/HLSLLayoutEncoder.cpp index 31656f9ba..7868fb908 100644 --- a/src/compiler/translator/HLSLLayoutEncoder.cpp +++ b/src/compiler/translator/HLSLLayoutEncoder.cpp @@ -147,7 +147,7 @@ unsigned int HLSLVariableRegisterCount(const Varying &variable) HLSLVariableRegisterCount(variable, &encoder); const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); - return rx::roundUp(encoder.getBlockSize(), registerBytes) / registerBytes; + return static_cast(rx::roundUp(encoder.getBlockSize(), registerBytes) / registerBytes); } unsigned int HLSLVariableRegisterCount(const Uniform &variable) @@ -156,7 +156,7 @@ unsigned int HLSLVariableRegisterCount(const Uniform &variable) HLSLVariableRegisterCount(variable, &encoder); const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); - return rx::roundUp(encoder.getBlockSize(), registerBytes) / registerBytes; + return static_cast(rx::roundUp(encoder.getBlockSize(), registerBytes) / registerBytes); } } diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp index e2311b0d1..404ed3921 100644 --- a/src/compiler/translator/OutputHLSL.cpp +++ b/src/compiler/translator/OutputHLSL.cpp @@ -23,10 +23,13 @@ namespace sh { // Integer to TString conversion -TString str(int i) +template +TString str(T i) { - char buffer[20]; - snprintf(buffer, sizeof(buffer), "%d", i); + ASSERT(std::numeric_limits::is_integer); + char buffer[(CHAR_BIT * sizeof(T) / 3) + 3]; + const char *formatStr = std::numeric_limits::is_signed ? "%d" : "%u"; + snprintf(buffer, sizeof(buffer), formatStr, i); return buffer; } diff --git a/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp b/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp index b4a38a68d..afa21f506 100644 --- a/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp +++ b/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp @@ -94,7 +94,7 @@ PixelTransfer11::PixelTransfer11(Renderer11 *renderer) ASSERT(SUCCEEDED(result)); D3D11_BUFFER_DESC constantBufferDesc = { 0 }; - constantBufferDesc.ByteWidth = rx::roundUp(sizeof(CopyShaderParams), 32u); + constantBufferDesc.ByteWidth = rx::roundUp(sizeof(CopyShaderParams), 32u); constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC; constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;