diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-09-17 09:18:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-17 09:18:57 -0400 |
| commit | 24ad492a98dc99abfbf7523b50bbdb13274c097e (patch) | |
| tree | a84e609f8bf2e5add2b5e009b42fa564149cefdd | |
| parent | 3c505c22673701339d35eb2151f01c16eb3c78c3 (diff) | |
Hotfix/fixing warnings (#636)
* * Remove dispose from IRInst
* Use MemoryArena instead of MemoryPool
* Make all IRInst not require Dtor - by having ref counted array store ptrs that need freeing
* Increase block size - typically compilation is 2Mb of IR space(!)
* Fix issues around StringRepresentation::equal because null has special meaning.
* Don't bother to construct as String to compare StringRepresentation, just used UnownedStringSlice.
* Added fromLiteral support to UnownedStringSlice and use instead of strlen version.
* Use more conventional way to test StringRepresentation against a String.
* Fix gcc/clang template problem with cast.
* Fix warnings.
| -rw-r--r-- | examples/model-viewer/main.cpp | 8 | ||||
| -rw-r--r-- | source/core/hash.h | 2 | ||||
| -rw-r--r-- | tools/gfx/model.cpp | 20 | ||||
| -rw-r--r-- | tools/gfx/render-d3d11.cpp | 50 | ||||
| -rw-r--r-- | tools/gfx/render-d3d12.cpp | 108 | ||||
| -rw-r--r-- | tools/gfx/render-gl.cpp | 14 | ||||
| -rw-r--r-- | tools/gfx/render-vk.cpp | 44 | ||||
| -rw-r--r-- | tools/gfx/window.cpp | 2 |
8 files changed, 124 insertions, 124 deletions
diff --git a/examples/model-viewer/main.cpp b/examples/model-viewer/main.cpp index be2e6878f..c1f7980cf 100644 --- a/examples/model-viewer/main.cpp +++ b/examples/model-viewer/main.cpp @@ -576,7 +576,7 @@ struct ParameterBlockEncoder { assert(slangTypeLayout->getKind() == slang::TypeReflection::Kind::Struct); - auto slangField = slangTypeLayout->getFieldByIndex(fieldIndex); + auto slangField = slangTypeLayout->getFieldByIndex((unsigned int)fieldIndex); auto fieldUniformOffset = slangField->getOffset(); // TODO: this type needs to be extended to handle resource fields. @@ -881,7 +881,7 @@ RefPtr<EffectVariant> createEffectVaraint( int translationUnitIndex = spAddTranslationUnit(slangRequest, SLANG_SOURCE_LANGUAGE_SLANG, nullptr); spAddTranslationUnitSourceFile(slangRequest, translationUnitIndex, program->shaderModule->inputPath.c_str()); - int entryPointCont = program->entryPoints.size(); + const int entryPointCont = int(program->entryPoints.size()); for(int ii = 0; ii < entryPointCont; ++ii) { auto entryPoint = program->entryPoints[ii]; @@ -895,7 +895,7 @@ RefPtr<EffectVariant> createEffectVaraint( translationUnitIndex, entryPoint->name.c_str(), entryPoint->slangStage, - genericArgs.size(), + int(genericArgs.size()), genericArgs.data()); } @@ -1877,7 +1877,7 @@ struct LightEnv : public RefObject // The more interesting case is when we have a `LightArray<L,N>`, // in which case we need to encode the first field (the light count)... // - lightTypeEncoder.writeField<int32_t>(0, lightTypeArray->lights.size()); + lightTypeEncoder.writeField<int32_t>(0, int32_t(lightTypeArray->lights.size())); // // ... followed by an array of values of type `L` in the second field. // We will only write to the first `lightCount` entries, which may be diff --git a/source/core/hash.h b/source/core/hash.h index 8ee5b088f..26450029d 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -57,7 +57,7 @@ namespace Slang template<typename TKey> static int GetHashCode(TKey & key) { - return key.GetHashCode(); + return int(key.GetHashCode()); } }; template<int IsPointer> diff --git a/tools/gfx/model.cpp b/tools/gfx/model.cpp index 0173ce950..62e6ec1fd 100644 --- a/tools/gfx/model.cpp +++ b/tools/gfx/model.cpp @@ -141,7 +141,7 @@ RefPtr<TextureResource> loadTextureImage( int prevExtentX = extentX; int prevExtentY = extentY; stbi_uc* prevData = data; - ptrdiff_t prevStride = stride; + int prevStride = int(stride); for(;;) { @@ -155,7 +155,7 @@ RefPtr<TextureResource> loadTextureImage( if(!newExtentY) newExtentY = 1; stbi_uc* newData = (stbi_uc*) malloc(newExtentX * newExtentY * channelCount * sizeof(stbi_uc)); - ptrdiff_t newStride = newExtentX * channelCount * sizeof(stbi_uc); + int newStride = int(newExtentX * channelCount * sizeof(stbi_uc)); stbir_resize_uint8_srgb( prevData, prevExtentX, prevExtentY, prevStride, @@ -303,8 +303,8 @@ Result ModelLoader::load( size_t objFaceCounter = 0; for(auto objFaceVertexCount : objShape.mesh.num_face_vertices) { - size_t flatFaceIndex = flatFaceCounter++; - size_t objFaceIndex = objFaceCounter++; + const size_t flatFaceIndex = flatFaceCounter++; + const size_t objFaceIndex = objFaceCounter++; size_t smoothingGroup = objShape.mesh.smoothing_group_ids[objFaceIndex]; if(!smoothingGroup) { @@ -330,7 +330,7 @@ Result ModelLoader::load( smoothedVertexNormals.insert(std::make_pair(smoothVertexID, normalID)); - objIndex.normal_index = normalID; + objIndex.normal_index = int(normalID); } } } @@ -348,9 +348,9 @@ Result ModelLoader::load( size_t objFaceCounter = 0; for(auto objFaceVertexCount : objShape.mesh.num_face_vertices) { - size_t flatFaceIndex = flatFaceCounter++; - size_t objFaceIndex = objFaceCounter++; - unsigned int smoothingGroup = objShape.mesh.smoothing_group_ids[objFaceIndex]; + const size_t flatFaceIndex = flatFaceCounter++; + const size_t objFaceIndex = objFaceCounter++; + size_t smoothingGroup = objShape.mesh.smoothing_group_ids[objFaceIndex]; if(!smoothingGroup) { smoothingGroup = ~flatFaceIndex; @@ -506,7 +506,7 @@ Result ModelLoader::load( objVertexAttributes.texcoords[2 * objIndex.texcoord_index + 1]); } - flatIndex = flatVertices.size(); + flatIndex = uint32_t(flatVertices.size()); mapObjIndexToFlatIndex.insert(std::make_pair(objIndexKey, flatIndex)); flatVertices.push_back(flatVertex); } @@ -528,7 +528,7 @@ Result ModelLoader::load( modelData.vertexCount = (int)flatVertices.size(); modelData.indexCount = (int)flatIndices.size(); - modelData.meshCount = meshes.size(); + modelData.meshCount = int(meshes.size()); modelData.meshes = meshes.data(); BufferResource::Desc vertexBufferDesc; diff --git a/tools/gfx/render-d3d11.cpp b/tools/gfx/render-d3d11.cpp index 7bf712216..6ce482c6f 100644 --- a/tools/gfx/render-d3d11.cpp +++ b/tools/gfx/render-d3d11.cpp @@ -1036,11 +1036,11 @@ Result D3D11Renderer::createBufferView(BufferResource* buffer, ResourceView::Des uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uavDesc.Format = D3DUtil::getMapFormat(desc.format); uavDesc.Buffer.FirstElement = 0; - uavDesc.Buffer.NumElements = resourceDesc.sizeInBytes; + uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes); if(resourceDesc.elementSize) { - uavDesc.Buffer.NumElements = resourceDesc.sizeInBytes / resourceDesc.elementSize; + uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize); } else if(desc.format == Format::Unknown) { @@ -1067,12 +1067,12 @@ Result D3D11Renderer::createBufferView(BufferResource* buffer, ResourceView::Des srvDesc.Buffer.ElementOffset = 0; srvDesc.Buffer.ElementWidth = 1; srvDesc.Buffer.FirstElement = 0; - srvDesc.Buffer.NumElements = resourceDesc.sizeInBytes; + srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes); if(resourceDesc.elementSize) { srvDesc.Buffer.ElementWidth = resourceDesc.elementSize; - srvDesc.Buffer.NumElements = resourceDesc.sizeInBytes / resourceDesc.elementSize; + srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize); } ComPtr<ID3D11ShaderResourceView> srv; @@ -1242,7 +1242,7 @@ void D3D11Renderer::setVertexBuffers(UInt startSlot, UInt slotCount, BufferResou void D3D11Renderer::setIndexBuffer(BufferResource* buffer, Format indexFormat, UInt offset) { DXGI_FORMAT dxFormat = D3DUtil::getMapFormat(indexFormat); - m_immediateContext->IASetIndexBuffer(((BufferResourceImpl*)buffer)->m_buffer, dxFormat, offset); + m_immediateContext->IASetIndexBuffer(((BufferResourceImpl*)buffer)->m_buffer, dxFormat, UINT(offset)); } void D3D11Renderer::setDepthStencilTarget(ResourceView* depthStencilView) @@ -1270,7 +1270,7 @@ void D3D11Renderer::setViewports(UInt count, Viewport const* viewports) dxViewport.MaxDepth = inViewport.maxZ; } - m_immediateContext->RSSetViewports(count, dxViewports); + m_immediateContext->RSSetViewports(UINT(count), dxViewports); } void D3D11Renderer::setScissorRects(UInt count, ScissorRect const* rects) @@ -1284,13 +1284,13 @@ void D3D11Renderer::setScissorRects(UInt count, ScissorRect const* rects) auto& inRect = rects[ii]; auto& dxRect = dxRects[ii]; - dxRect.left = inRect.minX; - dxRect.top = inRect.minY; - dxRect.right = inRect.maxX; - dxRect.bottom = inRect.maxY; + dxRect.left = LONG(inRect.minX); + dxRect.top = LONG(inRect.minY); + dxRect.right = LONG(inRect.maxX); + dxRect.bottom = LONG(inRect.maxY); } - m_immediateContext->RSSetScissorRects(count, dxRects); + m_immediateContext->RSSetScissorRects(UINT(count), dxRects); } @@ -1370,7 +1370,7 @@ void D3D11Renderer::draw(UInt vertexCount, UInt startVertex) void D3D11Renderer::drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex) { _flushGraphicsState(); - m_immediateContext->DrawIndexed((UINT)indexCount, (UINT)startIndex, (UInt)baseVertex); + m_immediateContext->DrawIndexed((UINT)indexCount, (UINT)startIndex, (INT)baseVertex); } Result D3D11Renderer::createProgram(const ShaderProgram::Desc& desc, ShaderProgram** outProgram) @@ -1653,7 +1653,7 @@ Result D3D11Renderer::createGraphicsPipelineState(const GraphicsPipelineStateDes state->m_blendState = blendState; state->m_pipelineLayout = (PipelineLayoutImpl*) desc.pipelineLayout; state->m_inputLayout = (InputLayoutImpl*) desc.inputLayout; - state->m_rtvCount = desc.renderTargetCount; + state->m_rtvCount = UINT(desc.renderTargetCount); state->m_blendColor[0] = 0; state->m_blendColor[1] = 0; state->m_blendColor[2] = 0; @@ -1782,7 +1782,7 @@ Result D3D11Renderer::createPipelineLayout(const PipelineLayout::Desc& desc, Pip pipelineLayoutImpl->m_descriptorSets.Add(setInfo); } - pipelineLayoutImpl->m_uavCount = counts[int(D3D11DescriptorSlotType::UnorderedAccessView)]; + pipelineLayoutImpl->m_uavCount = UINT(counts[int(D3D11DescriptorSlotType::UnorderedAccessView)]); *outLayout = pipelineLayoutImpl.detach(); return SLANG_OK; @@ -2226,11 +2226,11 @@ void D3D11Renderer::setDescriptorSet(PipelineType pipelineType, PipelineLayout* // for each stage. { - int slotType = int(D3D11DescriptorSlotType::ConstantBuffer); - UInt slotCount = setInfo.layout->m_counts[slotType]; + const int slotType = int(D3D11DescriptorSlotType::ConstantBuffer); + const UINT slotCount = UINT(setInfo.layout->m_counts[slotType]); if(slotCount) { - UInt startSlot = setInfo.baseIndices[slotType]; + const UINT startSlot = UINT(setInfo.baseIndices[slotType]); auto cbs = descriptorSetImpl->m_cbs[0].readRef(); @@ -2243,11 +2243,11 @@ void D3D11Renderer::setDescriptorSet(PipelineType pipelineType, PipelineLayout* } { - int slotType = int(D3D11DescriptorSlotType::ShaderResourceView); - UInt slotCount = setInfo.layout->m_counts[slotType]; + const int slotType = int(D3D11DescriptorSlotType::ShaderResourceView); + const UINT slotCount = UINT(setInfo.layout->m_counts[slotType]); if(slotCount) { - UInt startSlot = setInfo.baseIndices[slotType]; + const UINT startSlot = UINT(setInfo.baseIndices[slotType]); auto srvs = descriptorSetImpl->m_srvs[0].readRef(); @@ -2260,11 +2260,11 @@ void D3D11Renderer::setDescriptorSet(PipelineType pipelineType, PipelineLayout* } { - int slotType = int(D3D11DescriptorSlotType::Sampler); - UInt slotCount = setInfo.layout->m_counts[slotType]; + const int slotType = int(D3D11DescriptorSlotType::Sampler); + const UINT slotCount = UINT(setInfo.layout->m_counts[slotType]); if(slotCount) { - UInt startSlot = setInfo.baseIndices[slotType]; + const UINT startSlot = UINT(setInfo.baseIndices[slotType]); auto samplers = descriptorSetImpl->m_samplers[0].readRef(); @@ -2283,8 +2283,8 @@ void D3D11Renderer::setDescriptorSet(PipelineType pipelineType, PipelineLayout* // the UAV bindings with `m_uavBindings` and then flush them // as needed right before a draw/dispatch. // - int slotType = int(D3D11DescriptorSlotType::UnorderedAccessView); - UInt slotCount = setInfo.layout->m_counts[slotType]; + const int slotType = int(D3D11DescriptorSlotType::UnorderedAccessView); + const UInt slotCount = setInfo.layout->m_counts[slotType]; if(slotCount) { UInt startSlot = setInfo.baseIndices[slotType]; diff --git a/tools/gfx/render-d3d12.cpp b/tools/gfx/render-d3d12.cpp index 38ecaa5ef..360242dab 100644 --- a/tools/gfx/render-d3d12.cpp +++ b/tools/gfx/render-d3d12.cpp @@ -1239,36 +1239,36 @@ Result D3D12Renderer::_bindRenderState(PipelineStateImpl* pipelineStateImpl, ID3 if(auto descriptorCount = descriptorSetLayout->m_resourceCount) { auto& gpuHeap = m_viewHeap; - auto gpuDescriptorTable = gpuHeap.allocate(descriptorCount); + auto gpuDescriptorTable = gpuHeap.allocate(int(descriptorCount)); auto& cpuHeap = *descriptorSet->m_resourceHeap; auto cpuDescriptorTable = descriptorSet->m_resourceTable; m_device->CopyDescriptorsSimple( - descriptorCount, + UINT(descriptorCount), gpuHeap.getCpuHandle(gpuDescriptorTable), - cpuHeap.getCpuHandle(cpuDescriptorTable), + cpuHeap.getCpuHandle(int(cpuDescriptorTable)), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - submitter->setRootDescriptorTable(rootParameterIndex++, gpuHeap.getGpuHandle(gpuDescriptorTable)); + submitter->setRootDescriptorTable(int(rootParameterIndex++), gpuHeap.getGpuHandle(gpuDescriptorTable)); } } { if(auto descriptorCount = descriptorSetLayout->m_samplerCount) { auto& gpuHeap = m_samplerHeap; - auto gpuDescriptorTable = gpuHeap.allocate(descriptorCount); + auto gpuDescriptorTable = gpuHeap.allocate(int(descriptorCount)); auto& cpuHeap = *descriptorSet->m_samplerHeap; auto cpuDescriptorTable = descriptorSet->m_samplerTable; m_device->CopyDescriptorsSimple( - descriptorCount, + UINT(descriptorCount), gpuHeap.getCpuHandle(gpuDescriptorTable), - cpuHeap.getCpuHandle(cpuDescriptorTable), + cpuHeap.getCpuHandle(int(cpuDescriptorTable)), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - submitter->setRootDescriptorTable(rootParameterIndex++, gpuHeap.getGpuHandle(gpuDescriptorTable)); + submitter->setRootDescriptorTable(int(rootParameterIndex++), gpuHeap.getGpuHandle(gpuDescriptorTable)); } } } @@ -2244,12 +2244,12 @@ Result D3D12Renderer::createBufferView(BufferResource* buffer, ResourceView::Des uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; uavDesc.Format = D3DUtil::getMapFormat(desc.format); uavDesc.Buffer.FirstElement = 0; - uavDesc.Buffer.NumElements = resourceDesc.sizeInBytes; + uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes); if(resourceDesc.elementSize) { uavDesc.Buffer.StructureByteStride = resourceDesc.elementSize; - uavDesc.Buffer.NumElements = resourceDesc.sizeInBytes / resourceDesc.elementSize; + uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize); } else if(desc.format == Format::Unknown) { @@ -2273,12 +2273,12 @@ Result D3D12Renderer::createBufferView(BufferResource* buffer, ResourceView::Des srvDesc.Format = D3DUtil::getMapFormat(desc.format); srvDesc.Buffer.StructureByteStride = 0; srvDesc.Buffer.FirstElement = 0; - srvDesc.Buffer.NumElements = resourceDesc.sizeInBytes; + srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes); if(resourceDesc.elementSize) { srvDesc.Buffer.StructureByteStride = resourceDesc.elementSize; - srvDesc.Buffer.NumElements = resourceDesc.sizeInBytes / resourceDesc.elementSize; + srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize); } SLANG_RETURN_ON_FAIL(m_viewAllocator.allocate(&viewImpl->m_descriptor)); @@ -2540,7 +2540,7 @@ void D3D12Renderer::setIndexBuffer(BufferResource* buffer, Format indexFormat, U { m_boundIndexBuffer = (BufferResourceImpl*) buffer; m_boundIndexFormat = D3DUtil::getMapFormat(indexFormat); - m_boundIndexOffset = offset; + m_boundIndexOffset = UINT(offset); } void D3D12Renderer::setDepthStencilTarget(ResourceView* depthStencilView) @@ -2566,7 +2566,7 @@ void D3D12Renderer::setViewports(UInt count, Viewport const* viewports) dxViewport.MaxDepth = inViewport.maxZ; } - m_commandList->RSSetViewports(count, dxViewports); + m_commandList->RSSetViewports(UINT(count), dxViewports); } void D3D12Renderer::setScissorRects(UInt count, ScissorRect const* rects) @@ -2580,13 +2580,13 @@ void D3D12Renderer::setScissorRects(UInt count, ScissorRect const* rects) auto& inRect = rects[ii]; auto& dxRect = dxRects[ii]; - dxRect.left = inRect.minX; - dxRect.top = inRect.minY; - dxRect.right = inRect.maxX; - dxRect.bottom = inRect.maxY; + dxRect.left = LONG(inRect.minX); + dxRect.top = LONG(inRect.minY); + dxRect.right = LONG(inRect.maxX); + dxRect.bottom = LONG(inRect.maxY); } - m_commandList->RSSetScissorRects(count, dxRects); + m_commandList->RSSetScissorRects(UINT(count), dxRects); } void D3D12Renderer::setPipelineState(PipelineType pipelineType, PipelineState* state) @@ -2626,8 +2626,8 @@ void D3D12Renderer::draw(UInt vertexCount, UInt startVertex) D3D12_VERTEX_BUFFER_VIEW& vertexView = vertexViews[numVertexViews++]; vertexView.BufferLocation = buffer->m_resource.getResource()->GetGPUVirtualAddress() + boundVertexBuffer.m_offset; - vertexView.SizeInBytes = buffer->getDesc().sizeInBytes - boundVertexBuffer.m_offset; - vertexView.StrideInBytes = boundVertexBuffer.m_stride; + vertexView.SizeInBytes = UINT(buffer->getDesc().sizeInBytes - boundVertexBuffer.m_offset); + vertexView.StrideInBytes = UINT(boundVertexBuffer.m_stride); } } commandList->IASetVertexBuffers(0, numVertexViews, vertexViews); @@ -2639,7 +2639,7 @@ void D3D12Renderer::draw(UInt vertexCount, UInt startVertex) D3D12_INDEX_BUFFER_VIEW indexBufferView; indexBufferView.BufferLocation = m_boundIndexBuffer->m_resource.getResource()->GetGPUVirtualAddress() + m_boundIndexOffset; - indexBufferView.SizeInBytes = m_boundIndexBuffer->getDesc().sizeInBytes - m_boundIndexOffset; + indexBufferView.SizeInBytes = UINT(m_boundIndexBuffer->getDesc().sizeInBytes - m_boundIndexOffset); indexBufferView.Format = m_boundIndexFormat; commandList->IASetIndexBuffer(&indexBufferView); @@ -2849,7 +2849,7 @@ void D3D12Renderer::DescriptorSetImpl::setConstantBuffer(UInt range, UInt index, D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {}; cbvDesc.BufferLocation = resourceImpl->m_resource.getResource()->GetGPUVirtualAddress(); - cbvDesc.SizeInBytes = alignedSizeInBytes; + cbvDesc.SizeInBytes = UINT(alignedSizeInBytes); auto& rangeInfo = m_layout->m_ranges[range]; @@ -2872,7 +2872,7 @@ void D3D12Renderer::DescriptorSetImpl::setConstantBuffer(UInt range, UInt index, m_resourceObjects[arrayIndex] = resourceImpl; dxDevice->CreateConstantBufferView( &cbvDesc, - m_resourceHeap->getCpuHandle(descriptorIndex)); + m_resourceHeap->getCpuHandle(int(descriptorIndex))); } void D3D12Renderer::DescriptorSetImpl::setResource(UInt range, UInt index, ResourceView* view) @@ -2891,7 +2891,7 @@ void D3D12Renderer::DescriptorSetImpl::setResource(UInt range, UInt index, Resou m_resourceObjects[arrayIndex] = viewImpl; dxDevice->CopyDescriptorsSimple( 1, - m_resourceHeap->getCpuHandle(descriptorIndex), + m_resourceHeap->getCpuHandle(int(descriptorIndex)), viewImpl->m_descriptor.cpuHandle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); } @@ -2922,7 +2922,7 @@ void D3D12Renderer::DescriptorSetImpl::setSampler(UInt range, UInt index, Sample m_samplerObjects[arrayIndex] = samplerImpl; dxDevice->CopyDescriptorsSimple( 1, - m_samplerHeap->getCpuHandle(descriptorIndex), + m_samplerHeap->getCpuHandle(int(descriptorIndex)), samplerImpl->m_cpuHandle, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); } @@ -2959,14 +2959,14 @@ void D3D12Renderer::DescriptorSetImpl::setCombinedTextureSampler( m_resourceObjects[arrayIndex] = viewImpl; dxDevice->CopyDescriptorsSimple( 1, - m_resourceHeap->getCpuHandle(resourceDescriptorIndex), + m_resourceHeap->getCpuHandle(int(resourceDescriptorIndex)), viewImpl->m_descriptor.cpuHandle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); m_samplerObjects[arrayIndex] = samplerImpl; dxDevice->CopyDescriptorsSimple( 1, - m_samplerHeap->getCpuHandle(samplerDescriptorIndex), + m_samplerHeap->getCpuHandle(int(samplerDescriptorIndex)), samplerImpl->m_cpuHandle, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); } @@ -3085,14 +3085,14 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& { D3D12_ROOT_PARAMETER dxRootParameter = {}; dxRootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - dxRootParameter.DescriptorTable.NumDescriptorRanges = totalResourceRangeCount; + dxRootParameter.DescriptorTable.NumDescriptorRanges = UINT(totalResourceRangeCount); descriptorSetLayoutImpl->m_dxRootParameters.Add(dxRootParameter); } if( totalSamplerRangeCount ) { D3D12_ROOT_PARAMETER dxRootParameter = {}; dxRootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - dxRootParameter.DescriptorTable.NumDescriptorRanges = totalSamplerRangeCount; + dxRootParameter.DescriptorTable.NumDescriptorRanges = UINT(totalSamplerRangeCount); descriptorSetLayoutImpl->m_dxRootParameters.Add(dxRootParameter); } @@ -3221,9 +3221,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt bindingIndex = samplerCounter; samplerCounter += bindingCount; dxRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - dxRange.NumDescriptors = bindingCount; - dxRange.BaseShaderRegister = bindingIndex; - dxRange.RegisterSpace = bindingSpace; + dxRange.NumDescriptors = UINT(bindingCount); + dxRange.BaseShaderRegister = UINT(bindingIndex); + dxRange.RegisterSpace = UINT(bindingSpace); dxRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } break; @@ -3234,9 +3234,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt bindingIndex = srvCounter; srvCounter += bindingCount; dxRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - dxRange.NumDescriptors = bindingCount; - dxRange.BaseShaderRegister = bindingIndex; - dxRange.RegisterSpace = bindingSpace; + dxRange.NumDescriptors = UINT(bindingCount); + dxRange.BaseShaderRegister = UINT(bindingIndex); + dxRange.RegisterSpace = UINT(bindingSpace); dxRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } break; @@ -3252,9 +3252,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt bindingIndex = srvCounter; srvCounter += bindingCount; dxRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - dxRange.NumDescriptors = bindingCount; - dxRange.BaseShaderRegister = bindingIndex; - dxRange.RegisterSpace = bindingSpace; + dxRange.NumDescriptors = UINT(bindingCount); + dxRange.BaseShaderRegister = UINT(bindingIndex); + dxRange.RegisterSpace = UINT(bindingSpace); dxRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } @@ -3266,9 +3266,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt pairedSamplerBindingIndex = srvCounter; srvCounter += bindingCount; dxPairedSamplerRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - dxPairedSamplerRange.NumDescriptors = bindingCount; - dxPairedSamplerRange.BaseShaderRegister = pairedSamplerBindingIndex; - dxPairedSamplerRange.RegisterSpace = bindingSpace; + dxPairedSamplerRange.NumDescriptors = UINT(bindingCount); + dxPairedSamplerRange.BaseShaderRegister = UINT(pairedSamplerBindingIndex); + dxPairedSamplerRange.RegisterSpace = UINT(bindingSpace); dxPairedSamplerRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } @@ -3285,9 +3285,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt bindingIndex = uavCounter; uavCounter += bindingCount; dxRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - dxRange.NumDescriptors = bindingCount; - dxRange.BaseShaderRegister = bindingIndex; - dxRange.RegisterSpace = bindingSpace; + dxRange.NumDescriptors = UINT(bindingCount); + dxRange.BaseShaderRegister = UINT(bindingIndex); + dxRange.RegisterSpace = UINT(bindingSpace); dxRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } break; @@ -3298,9 +3298,9 @@ Result D3D12Renderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& UInt bindingIndex = cbvCounter; cbvCounter += bindingCount; dxRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_CBV; - dxRange.NumDescriptors = bindingCount; - dxRange.BaseShaderRegister = bindingIndex; - dxRange.RegisterSpace = bindingSpace; + dxRange.NumDescriptors = UINT(bindingCount); + dxRange.BaseShaderRegister = UINT(bindingIndex); + dxRange.RegisterSpace = UINT(bindingSpace); dxRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; } break; @@ -3357,7 +3357,7 @@ Result D3D12Renderer::createPipelineLayout(const PipelineLayout::Desc& desc, Pip { auto& range = ranges[rangeCount++]; range = setDescriptorRange; - range.RegisterSpace = bindingSpace; + range.RegisterSpace = UINT(bindingSpace); // HACK: in order to deal with SM5.0 shaders, `u` registers // in `space0` need to start with a number *after* the number @@ -3374,7 +3374,7 @@ Result D3D12Renderer::createPipelineLayout(const PipelineLayout::Desc& desc, Pip if( range.RegisterSpace == 0 && range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV ) { - range.BaseShaderRegister += desc.renderTargetCount; + range.BaseShaderRegister += UINT(desc.renderTargetCount); } } } @@ -3408,7 +3408,7 @@ Result D3D12Renderer::createPipelineLayout(const PipelineLayout::Desc& desc, Pip } D3D12_ROOT_SIGNATURE_DESC rootSignatureDesc = {}; - rootSignatureDesc.NumParameters = rootParameterCount; + rootSignatureDesc.NumParameters = UINT(rootParameterCount); rootSignatureDesc.pParameters = rootParameters; // TODO: static samplers should be reasonably easy to support... @@ -3462,7 +3462,7 @@ Result D3D12Renderer::createDescriptorSet(DescriptorSetLayout* layout, Descripto { auto resourceHeap = &m_cpuViewHeap; descriptorSetImpl->m_resourceHeap = resourceHeap; - descriptorSetImpl->m_resourceTable = resourceHeap->allocate(resourceCount); + descriptorSetImpl->m_resourceTable = resourceHeap->allocate(int(resourceCount)); descriptorSetImpl->m_resourceObjects.SetSize(resourceCount); } @@ -3471,7 +3471,7 @@ Result D3D12Renderer::createDescriptorSet(DescriptorSetLayout* layout, Descripto { auto samplerHeap = &m_cpuSamplerHeap; descriptorSetImpl->m_samplerHeap = samplerHeap; - descriptorSetImpl->m_samplerTable = samplerHeap->allocate(samplerCount); + descriptorSetImpl->m_samplerTable = samplerHeap->allocate(int(samplerCount)); descriptorSetImpl->m_samplerObjects.SetSize(samplerCount); } @@ -3497,7 +3497,7 @@ Result D3D12Renderer::createGraphicsPipelineState(const GraphicsPipelineStateDes psoDesc.PrimitiveTopologyType = m_primitiveTopologyType; { - const int numRenderTargets = desc.renderTargetCount; + const int numRenderTargets = int(desc.renderTargetCount); psoDesc.DSVFormat = m_depthStencilFormat; psoDesc.NumRenderTargets = numRenderTargets; diff --git a/tools/gfx/render-gl.cpp b/tools/gfx/render-gl.cpp index d77271702..879ff7a3c 100644 --- a/tools/gfx/render-gl.cpp +++ b/tools/gfx/render-gl.cpp @@ -490,7 +490,7 @@ void GLRenderer::flushStateForDraw() for(Int ii = 0; ii < count; ++ii) { auto bufferImpl = descriptorSet->m_constantBuffers[ii]; - glBindBufferBase(GL_UNIFORM_BUFFER, ii, bufferImpl->m_handle); + glBindBufferBase(GL_UNIFORM_BUFFER, GLuint(ii), bufferImpl->m_handle); } } @@ -511,10 +511,10 @@ void GLRenderer::flushStateForDraw() auto textureViewImpl = descriptorSet->m_textures[ii]; auto samplerImpl = descriptorSet->m_samplers[ii]; - glActiveTexture(GL_TEXTURE0 + ii); + glActiveTexture(GLuint(GL_TEXTURE0 + ii)); glBindTexture(GL_TEXTURE_2D, textureViewImpl->m_textureID); - glBindSampler(baseIndex + ii, samplerImpl->m_samplerID); + glBindSampler(GLuint(baseIndex + ii), samplerImpl->m_samplerID); } } } @@ -1059,10 +1059,10 @@ void GLRenderer::setScissorRects(UInt count, ScissorRect const* rects) // auto rect = rects[0]; glScissor( - rect.minX, - rect.minY, - rect.maxX - rect.minX, - rect.maxY - rect.minY); + GLint(rect.minX), + GLint(rect.minY), + GLsizei(rect.maxX - rect.minX), + GLsizei(rect.maxY - rect.minY)); glEnable(GL_SCISSOR_TEST); } diff --git a/tools/gfx/render-vk.cpp b/tools/gfx/render-vk.cpp index aee45a86e..f9b6d2a01 100644 --- a/tools/gfx/render-vk.cpp +++ b/tools/gfx/render-vk.cpp @@ -1899,7 +1899,7 @@ void VKRenderer::setViewports(UInt count, Viewport const* viewports) } VkCommandBuffer commandBuffer = m_deviceQueue.getCommandBuffer(); - m_api.vkCmdSetViewport(commandBuffer, 0, count, vkViewports); + m_api.vkCmdSetViewport(commandBuffer, 0, uint32_t(count), vkViewports); } void VKRenderer::setScissorRects(UInt count, ScissorRect const* rects) @@ -1913,14 +1913,14 @@ void VKRenderer::setScissorRects(UInt count, ScissorRect const* rects) auto& inRect = rects[ii]; auto& vkRect = vkRects[ii]; - vkRect.offset.x = inRect.minX; - vkRect.offset.y = inRect.minY; - vkRect.extent.width = inRect.maxX - inRect.minX; - vkRect.extent.height = inRect.maxY - inRect.minY; + vkRect.offset.x = int32_t(inRect.minX); + vkRect.offset.y = int32_t(inRect.minY); + vkRect.extent.width = uint32_t(inRect.maxX - inRect.minX); + vkRect.extent.height = uint32_t(inRect.maxY - inRect.minY); } VkCommandBuffer commandBuffer = m_deviceQueue.getCommandBuffer(); - m_api.vkCmdSetScissor(commandBuffer, 0, count, vkRects); + m_api.vkCmdSetScissor(commandBuffer, 0, uint32_t(count), vkRects); } void VKRenderer::setPipelineState(PipelineType pipelineType, PipelineState* state) @@ -1946,7 +1946,7 @@ void VKRenderer::draw(UInt vertexCount, UInt startVertex = 0) auto pipelineLayoutImpl = pipeline->m_pipelineLayout.Ptr(); m_api.vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayoutImpl->m_pipelineLayout, - 0, pipelineLayoutImpl->m_descriptorSetCount, + 0, uint32_t(pipelineLayoutImpl->m_descriptorSetCount), &m_currentDescriptorSets[0], 0, nullptr); @@ -1986,7 +1986,7 @@ void VKRenderer::dispatchCompute(int x, int y, int z) auto pipelineLayoutImpl = pipeline->m_pipelineLayout.Ptr(); m_api.vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipelineLayoutImpl->m_pipelineLayout, - 0, pipelineLayoutImpl->m_descriptorSetCount, + 0, uint32_t(pipelineLayoutImpl->m_descriptorSetCount), &m_currentDescriptorSets[0], 0, nullptr); @@ -2196,13 +2196,13 @@ Result VKRenderer::createDescriptorSetLayout(const DescriptorSetLayout::Desc& de VkDescriptorType dstDescriptorType = translateDescriptorType(srcRange.type); VkDescriptorSetLayoutBinding dstBinding; - dstBinding.binding = rr; + dstBinding.binding = uint32_t(rr); dstBinding.descriptorType = dstDescriptorType; - dstBinding.descriptorCount = srcRange.count; + dstBinding.descriptorCount = uint32_t(srcRange.count); dstBinding.stageFlags = VK_SHADER_STAGE_ALL; dstBinding.pImmutableSamplers = nullptr; - descriptorCountForTypes[dstDescriptorType] += srcRange.count; + descriptorCountForTypes[dstDescriptorType] += uint32_t(srcRange.count); dstBindings.Add(dstBinding); @@ -2259,7 +2259,7 @@ Result VKRenderer::createPipelineLayout(const PipelineLayout::Desc& desc, Pipeli } VkPipelineLayoutCreateInfo pipelineLayoutInfo = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; - pipelineLayoutInfo.setLayoutCount = desc.descriptorSetCount; + pipelineLayoutInfo.setLayoutCount = uint32_t(desc.descriptorSetCount); pipelineLayoutInfo.pSetLayouts = &descriptorSetLayouts[0]; VkPipelineLayout pipelineLayout; @@ -2303,8 +2303,8 @@ void VKRenderer::DescriptorSetImpl::setConstantBuffer(UInt range, UInt index, Bu VkWriteDescriptorSet writeInfo = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; writeInfo.dstSet = m_descriptorSet; - writeInfo.dstBinding = range; - writeInfo.dstArrayElement = index; + writeInfo.dstBinding = uint32_t(range); + writeInfo.dstArrayElement = uint32_t(index); writeInfo.descriptorCount = 1; writeInfo.descriptorType = m_layout->m_ranges[range].descriptorType; writeInfo.pBufferInfo = &bufferInfo; @@ -2327,8 +2327,8 @@ void VKRenderer::DescriptorSetImpl::setResource(UInt range, UInt index, Resource VkWriteDescriptorSet writeInfo = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; writeInfo.dstSet = m_descriptorSet; - writeInfo.dstBinding = range; - writeInfo.dstArrayElement = index; + writeInfo.dstBinding = uint32_t(range); + writeInfo.dstArrayElement = uint32_t(index); writeInfo.descriptorCount = 1; writeInfo.descriptorType = m_layout->m_ranges[range].descriptorType; writeInfo.pImageInfo = &imageInfo; @@ -2343,8 +2343,8 @@ void VKRenderer::DescriptorSetImpl::setResource(UInt range, UInt index, Resource VkWriteDescriptorSet writeInfo = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; writeInfo.dstSet = m_descriptorSet; - writeInfo.dstBinding = range; - writeInfo.dstArrayElement = index; + writeInfo.dstBinding = uint32_t(range); + writeInfo.dstArrayElement = uint32_t(index); writeInfo.descriptorCount = 1; writeInfo.descriptorType = m_layout->m_ranges[range].descriptorType; writeInfo.pTexelBufferView = &bufferViewImpl->m_view; @@ -2364,8 +2364,8 @@ void VKRenderer::DescriptorSetImpl::setResource(UInt range, UInt index, Resource VkWriteDescriptorSet writeInfo = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; writeInfo.dstSet = m_descriptorSet; - writeInfo.dstBinding = range; - writeInfo.dstArrayElement = index; + writeInfo.dstBinding = uint32_t(range); + writeInfo.dstArrayElement = uint32_t(index); writeInfo.descriptorCount = 1; writeInfo.descriptorType = m_layout->m_ranges[range].descriptorType; writeInfo.pBufferInfo = &bufferInfo; @@ -2441,8 +2441,8 @@ Result VKRenderer::createGraphicsPipelineState(const GraphicsPipelineStateDesc& auto pipelineLayoutImpl = (PipelineLayoutImpl*) desc.pipelineLayout; auto inputLayoutImpl = (InputLayoutImpl*) desc.inputLayout; - int width = desc.framebufferWidth; - int height = desc.framebufferHeight; + const int width = int(desc.framebufferWidth); + const int height = int(desc.framebufferHeight); // Shader Stages // diff --git a/tools/gfx/window.cpp b/tools/gfx/window.cpp index d777dc8a6..8456e1ead 100644 --- a/tools/gfx/window.cpp +++ b/tools/gfx/window.cpp @@ -174,7 +174,7 @@ static LRESULT CALLBACK windowProc( window = (Window*) createInfo->lpCreateParams; window->handle = windowHandle; - SetWindowLongPtrW(windowHandle, GWLP_USERDATA, (LONG)window); + SetWindowLongPtrW(windowHandle, GWLP_USERDATA, (LONG)size_t(window)); } break; |
