diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:11:01 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-06 11:18:09 -0700 |
| commit | 03de737f0d18526b99b59a1810c7e290b66f4be2 (patch) | |
| tree | d0e75b2524d9b7e666de0ca9fa13f3a086bf02dc /tools/render-test | |
| parent | 21a14cb4e0d578bc4f8a460016269a1199cac0da (diff) | |
Fix many warnings-as-errors issues.
The code should now compile cleanly with warnings as errors for VS2015 with `W3`.
Most of the changes had to do with propagating a real pointer-sized integer type through code that had been using `int`.
Diffstat (limited to 'tools/render-test')
| -rw-r--r-- | tools/render-test/main.cpp | 4 | ||||
| -rw-r--r-- | tools/render-test/render-d3d11.cpp | 33 | ||||
| -rw-r--r-- | tools/render-test/render-gl.cpp | 16 |
3 files changed, 33 insertions, 20 deletions
diff --git a/tools/render-test/main.cpp b/tools/render-test/main.cpp index aeff565c6..f2688d275 100644 --- a/tools/render-test/main.cpp +++ b/tools/render-test/main.cpp @@ -15,6 +15,10 @@ #undef WIN32_LEAN_AND_MEAN #undef NOMINMAX +#ifdef _MSC_VER +#pragma warning(disable: 4996) +#endif + namespace renderer_test { // diff --git a/tools/render-test/render-d3d11.cpp b/tools/render-test/render-d3d11.cpp index 5b25714c0..2627d7b1f 100644 --- a/tools/render-test/render-d3d11.cpp +++ b/tools/render-test/render-d3d11.cpp @@ -8,6 +8,9 @@ #include <Slang.h> +#ifdef _MSC_VER +#pragma warning(disable: 4996) +#endif #define STB_IMAGE_WRITE_IMPLEMENTATION #include "external/stb/stb_image_write.h" @@ -660,7 +663,7 @@ public: virtual Buffer* createBuffer(BufferDesc const& desc) override { D3D11_BUFFER_DESC dxBufferDesc = { 0 }; - dxBufferDesc.ByteWidth = desc.size; + dxBufferDesc.ByteWidth = (UINT) desc.size; switch( desc.flavor ) { @@ -715,10 +718,10 @@ public: for( UInt ii = 0; ii < inputElementCount; ++ii ) { dxInputElements[ii].SemanticName = inputElements[ii].semanticName; - dxInputElements[ii].SemanticIndex = inputElements[ii].semanticIndex; + dxInputElements[ii].SemanticIndex = (UINT) inputElements[ii].semanticIndex; dxInputElements[ii].Format = mapFormat(inputElements[ii].format); dxInputElements[ii].InputSlot = 0; - dxInputElements[ii].AlignedByteOffset = inputElements[ii].offset; + dxInputElements[ii].AlignedByteOffset = (UINT) inputElements[ii].offset; dxInputElements[ii].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; dxInputElements[ii].InstanceDataStepRate = 0; @@ -738,9 +741,11 @@ public: return nullptr; } - hlslCursor+= sprintf(hlslCursor, "%s a%d : %s%d", typeName, ii, + hlslCursor+= sprintf(hlslCursor, "%s a%d : %s%d", + typeName, + (int) ii, inputElements[ii].semanticName, - inputElements[ii].semanticIndex); + (int) inputElements[ii].semanticIndex); } hlslCursor += sprintf(hlslCursor, "\n) : SV_Position { return 0; }"); @@ -752,7 +757,7 @@ public: ID3D11InputLayout* dxInputLayout = nullptr; HRESULT hr = dxDevice->CreateInputLayout( &dxInputElements[0], - inputElementCount, + (UINT) inputElementCount, dxVertexShaderBlob->GetBufferPointer(), dxVertexShaderBlob->GetBufferSize(), &dxInputLayout); @@ -839,13 +844,15 @@ public: for( UInt ii = 0; ii < slotCount; ++ii ) { - dxVertexStrides[ii] = strides[ii]; - dxVertexOffsets[ii] = offsets[ii]; + dxVertexStrides[ii] = (UINT) strides[ii]; + dxVertexOffsets[ii] = (UINT) offsets[ii]; } auto dxVertexBuffers = (ID3D11Buffer* const*) buffers; - dxContext->IASetVertexBuffers(startSlot, slotCount, &dxVertexBuffers[0], &dxVertexStrides[0], &dxVertexOffsets[0]); + dxContext->IASetVertexBuffers( + (UINT) startSlot, + (UINT) slotCount, &dxVertexBuffers[0], &dxVertexStrides[0], &dxVertexOffsets[0]); } virtual void setShaderProgram(ShaderProgram* inProgram) override @@ -866,8 +873,10 @@ public: auto dxConstantBuffers = (ID3D11Buffer* const*) buffers; - dxContext->VSSetConstantBuffers(startSlot, slotCount, &dxConstantBuffers[0]); - dxContext->VSSetConstantBuffers(startSlot, slotCount, &dxConstantBuffers[0]); + dxContext->VSSetConstantBuffers( + (UINT) startSlot, (UINT) slotCount, &dxConstantBuffers[0]); + dxContext->VSSetConstantBuffers( + (UINT) startSlot, (UINT) slotCount, &dxConstantBuffers[0]); } @@ -875,7 +884,7 @@ public: { auto dxContext = dxImmediateContext; - dxContext->Draw(vertexCount, startVertex); + dxContext->Draw((UINT) vertexCount, (UINT) startVertex); } diff --git a/tools/render-test/render-gl.cpp b/tools/render-test/render-gl.cpp index d6166fc3c..f02ac36c4 100644 --- a/tools/render-test/render-gl.cpp +++ b/tools/render-test/render-gl.cpp @@ -297,7 +297,7 @@ public: glAttr.streamIndex = 0; glAttr.format = getVertexAttributeFormat(inputAttr.format); - glAttr.offset = inputAttr.offset; + glAttr.offset = (GLsizei) inputAttr.offset; } return (InputLayout*)inputLayout; @@ -388,7 +388,7 @@ public: assert(!offsets || !offsets[ii]); - glBindBufferBase(GL_UNIFORM_BUFFER, slot, bufferID); + glBindBufferBase(GL_UNIFORM_BUFFER, (GLuint) slot, bufferID); } } @@ -405,18 +405,18 @@ public: glBindBuffer(GL_ARRAY_BUFFER, boundVertexStreamBuffers[streamIndex]); glVertexAttribPointer( - ii, - attr.format.componentCount, + (GLuint) ii, + attr.format.componentCount, attr.format.componentType, attr.format.normalized, - boundVertexStreamStrides[streamIndex], + (GLsizei) boundVertexStreamStrides[streamIndex], (GLvoid*)(attr.offset + boundVertexStreamOffsets[streamIndex])); - glEnableVertexAttribArray(ii); + glEnableVertexAttribArray((GLuint)ii); } for (UInt ii = attrCount; ii < kMaxVertexStreams; ++ii) { - glDisableVertexAttribArray(ii); + glDisableVertexAttribArray((GLuint)ii); } } @@ -424,7 +424,7 @@ public: { flushStateForDraw(); - glDrawArrays(boundPrimitiveTopology, startVertex, vertexCount); + glDrawArrays(boundPrimitiveTopology, (GLint) startVertex, (GLsizei) vertexCount); } // ShaderCompiler interface |
