From 90e7fe679160ac7ddeaaf549b8c0ded423865ffd Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Fri, 20 Apr 2018 00:10:58 +0100 Subject: [PATCH] Make hashes use correct types and fix narrowing warnings in spirv module. (#307) * Fix narrowing warnings in spirv_module relating to enum's default width on x64 * Make hashes of states use correct types without casting. * Fix narrowing conversion in d3d11_sampler.cpp --- src/d3d11/d3d11_sampler.cpp | 2 +- src/d3d11/d3d11_state.cpp | 8 +++++--- src/spirv/spirv_module.cpp | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/d3d11/d3d11_sampler.cpp b/src/d3d11/d3d11_sampler.cpp index cf0fce54..9e427254 100644 --- a/src/d3d11/d3d11_sampler.cpp +++ b/src/d3d11/d3d11_sampler.cpp @@ -25,7 +25,7 @@ namespace dxvk { info.mipmapLodBias = desc.MipLODBias; info.mipmapLodMin = desc.MinLOD; info.mipmapLodMax = desc.MaxLOD; - info.maxAnisotropy = desc.MaxAnisotropy; + info.maxAnisotropy = static_cast(desc.MaxAnisotropy); info.addressModeU = DecodeAddressMode(desc.AddressU); info.addressModeV = DecodeAddressMode(desc.AddressV); info.addressModeW = DecodeAddressMode(desc.AddressW); diff --git a/src/d3d11/d3d11_state.cpp b/src/d3d11/d3d11_state.cpp index 941cff80..a64c6d85 100644 --- a/src/d3d11/d3d11_state.cpp +++ b/src/d3d11/d3d11_state.cpp @@ -47,13 +47,15 @@ namespace dxvk { size_t D3D11StateDescHash::operator () ( const D3D11_RASTERIZER_DESC1& desc) const { + std::hash fhash; + DxvkHashState hash; hash.add(desc.FillMode); hash.add(desc.CullMode); hash.add(desc.FrontCounterClockwise); hash.add(desc.DepthBias); - hash.add(desc.SlopeScaledDepthBias); - hash.add(desc.DepthBiasClamp); + hash.add(fhash(desc.SlopeScaledDepthBias)); + hash.add(fhash(desc.DepthBiasClamp)); hash.add(desc.DepthClipEnable); hash.add(desc.ScissorEnable); hash.add(desc.MultisampleEnable); @@ -90,7 +92,7 @@ namespace dxvk { hash.add(desc.AddressV); hash.add(desc.AddressW); hash.add(fhash(desc.MipLODBias)); - hash.add(fhash(desc.MaxAnisotropy)); + hash.add(desc.MaxAnisotropy); hash.add(desc.ComparisonFunc); for (uint32_t i = 0; i < 4; i++) hash.add(fhash(desc.BorderColor[i])); diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index a14e4cad..73d51a14 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -569,7 +569,7 @@ namespace dxvk { uint32_t variableType, spv::StorageClass storageClass) { std::array args = {{ - storageClass, + static_cast(storageClass), variableType, }}; @@ -593,11 +593,11 @@ namespace dxvk { spv::ImageFormat format) { std::array args = {{ sampledType, - dimensionality, + static_cast(dimensionality), depth, arrayed, multisample, sampled, - format + static_cast(format) }}; return this->defType(spv::OpTypeImage,