1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 04:29:15 +01:00

[d3d9] More or less minor static analysis nits

This commit is contained in:
WinterSnowfall 2025-03-07 14:51:25 +02:00
parent b1c0ea1ba0
commit c900424d66
No known key found for this signature in database
13 changed files with 61 additions and 81 deletions

View File

@ -64,20 +64,15 @@ namespace dxvk {
D3D9CommonTexture* srcTextureInfo = src->GetCommonTexture();
D3D9CommonTexture* dstTextureInfo = dst->GetCommonTexture();
VkOffset3D srcOffset = { 0u, 0u, 0u };
VkOffset3D dstOffset = { 0u, 0u, 0u };
VkExtent3D texLevelExtent = srcTextureInfo->GetExtentMip(src->GetSubresource());
VkExtent3D extent = texLevelExtent;
VkOffset3D srcOffset = { pSrcRect->left,
pSrcRect->top,
0u };
srcOffset = { pSrcRect->left,
pSrcRect->top,
0u };
VkExtent3D extent = { uint32_t(pSrcRect->right - pSrcRect->left), uint32_t(pSrcRect->bottom - pSrcRect->top), 1 };
extent = { uint32_t(pSrcRect->right - pSrcRect->left), uint32_t(pSrcRect->bottom - pSrcRect->top), 1 };
dstOffset = { pDestPoint->x,
pDestPoint->y,
0u };
VkOffset3D dstOffset = { pDestPoint->x,
pDestPoint->y,
0u };
m_device->UpdateTextureFromBuffer(
srcTextureInfo, dstTextureInfo,

View File

@ -357,7 +357,6 @@ namespace dxvk {
imageInfo.sharing.mode = (*pSharedHandle == INVALID_HANDLE_VALUE || *pSharedHandle == nullptr)
? DxvkSharedHandleMode::Export
: DxvkSharedHandleMode::Import;
imageInfo.sharing.type = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT;
imageInfo.sharing.handle = *pSharedHandle;
imageInfo.shared = true;
// TODO: validate metadata?
@ -556,7 +555,7 @@ namespace dxvk {
return VK_IMAGE_LAYOUT_GENERAL;
// Otherwise, pick a layout that can be used for reading.
return Usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
return (Usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}

View File

@ -4831,7 +4831,7 @@ namespace dxvk {
// which need to be block aligned, must be validated for mip level 0.
if (MipLevel == 0 && isBlockAlignedFormat
&& (type == D3DRTYPE_VOLUMETEXTURE ||
(type != D3DRTYPE_VOLUMETEXTURE && desc.Pool == D3DPOOL_DEFAULT))
desc.Pool == D3DPOOL_DEFAULT)
&& (isNotLeftAligned || isNotTopAligned ||
isNotRightAligned || isNotBottomAligned))
return D3DERR_INVALIDCALL;
@ -6021,7 +6021,7 @@ namespace dxvk {
void D3D9DeviceEx::UpdatePushConstant(const void* pData) {
struct ConstantData { uint8_t Data[Length]; };
auto* constData = reinterpret_cast<const ConstantData*>(pData);
const ConstantData* constData = reinterpret_cast<const ConstantData*>(pData);
EmitCs([
cData = *constData
@ -7230,7 +7230,7 @@ namespace dxvk {
UINT InstanceCount) {
D3D9DrawInfo drawInfo;
drawInfo.vertexCount = GetVertexCount(PrimitiveType, PrimitiveCount);
drawInfo.instanceCount = m_iaState.streamsInstanced & m_iaState.streamsUsed
drawInfo.instanceCount = (m_iaState.streamsInstanced & m_iaState.streamsUsed)
? InstanceCount
: 1u;
return drawInfo;

View File

@ -776,8 +776,8 @@ namespace dxvk {
std::vector
<DxvkBindingInfo> m_bindings;
uint32_t m_inputMask = 0u;
uint32_t m_outputMask = 0u;
uint32_t m_inputMask = 0u;
uint32_t m_outputMask = 0u;
uint32_t m_flatShadingMask = 0u;
DxsoProgramType m_programType;
@ -790,19 +790,19 @@ namespace dxvk {
DxsoIsgn m_isgn;
DxsoIsgn m_osgn;
uint32_t m_floatType;
uint32_t m_uint32Type;
uint32_t m_vec4Type;
uint32_t m_vec3Type;
uint32_t m_vec2Type;
uint32_t m_mat3Type;
uint32_t m_mat4Type;
uint32_t m_floatType = 0u;
uint32_t m_uint32Type = 0u;
uint32_t m_vec4Type = 0u;
uint32_t m_vec3Type = 0u;
uint32_t m_vec2Type = 0u;
uint32_t m_mat3Type = 0u;
uint32_t m_mat4Type = 0u;
uint32_t m_entryPointId;
uint32_t m_entryPointId = 0u;
uint32_t m_rsBlock;
uint32_t m_specUbo;
uint32_t m_mainFuncLabel;
uint32_t m_rsBlock = 0u;
uint32_t m_specUbo = 0u;
uint32_t m_mainFuncLabel = 0u;
D3D9FixedFunctionOptions m_options;
@ -814,11 +814,11 @@ namespace dxvk {
const D3D9FFShaderKeyVS& Key,
const std::string& Name,
D3D9FixedFunctionOptions Options)
: m_module(spvVersion(1, 3)), m_options(Options) {
m_programType = DxsoProgramTypes::VertexShader;
m_vsKey = Key;
m_filename = Name;
}
: m_filename ( Name )
, m_module ( spvVersion(1, 3) )
, m_programType ( DxsoProgramTypes::VertexShader )
, m_vsKey ( Key )
, m_options ( Options ) { }
D3D9FFShaderCompiler::D3D9FFShaderCompiler(
@ -826,11 +826,11 @@ namespace dxvk {
const D3D9FFShaderKeyFS& Key,
const std::string& Name,
D3D9FixedFunctionOptions Options)
: m_module(spvVersion(1, 3)), m_options(Options) {
m_programType = DxsoProgramTypes::PixelShader;
m_fsKey = Key;
m_filename = Name;
}
: m_filename ( Name )
, m_module ( spvVersion(1, 3) )
, m_programType ( DxsoProgramTypes::PixelShader )
, m_fsKey ( Key )
, m_options ( Options ) { }
Rc<DxvkShader> D3D9FFShaderCompiler::compile() {

View File

@ -514,7 +514,7 @@ namespace dxvk {
return D3D9_VK_FORMAT_MAPPING();
if (!m_d24s8Support && mapping.FormatColor == VK_FORMAT_D24_UNORM_S8_UINT)
mapping.FormatColor = mapping.Aspect & VK_IMAGE_ASPECT_STENCIL_BIT ? VK_FORMAT_D32_SFLOAT_S8_UINT : VK_FORMAT_D32_SFLOAT;
mapping.FormatColor = (mapping.Aspect & VK_IMAGE_ASPECT_STENCIL_BIT) ? VK_FORMAT_D32_SFLOAT_S8_UINT : VK_FORMAT_D32_SFLOAT;
if (!m_d16s8Support && mapping.FormatColor == VK_FORMAT_D16_UNORM_S8_UINT)
mapping.FormatColor = m_d24s8Support ? VK_FORMAT_D24_UNORM_S8_UINT : VK_FORMAT_D32_SFLOAT_S8_UINT;

View File

@ -96,9 +96,8 @@ namespace dxvk {
uint32_t BytecodeLength)
: D3D9DeviceChild<Base>( pDevice )
, m_shader ( CommonShader )
, m_bytecode ( pAllocator->Alloc(BytecodeLength) )
, m_bytecodeLength ( BytecodeLength ) {
m_bytecode = pAllocator->Alloc(BytecodeLength);
m_bytecode.Map();
std::memcpy(m_bytecode.Ptr(), pShaderBytecode, BytecodeLength);
m_bytecode.Unmap();

View File

@ -190,7 +190,7 @@ namespace dxvk {
const DWORD* pInstr,
DWORD InstrLength,
D3D9ShaderValidatorMessage MessageID,
std::string Message) {
const std::string& Message) {
if (m_callback)
m_callback(pFile, Line, Unknown, MessageID, Message.c_str(), m_userData);

View File

@ -89,7 +89,7 @@ namespace dxvk {
const DWORD* pInstr,
DWORD InstrLength,
D3D9ShaderValidatorMessage MessageID,
std::string Message);
const std::string& Message);
bool m_isPixelShader = false;
uint32_t m_majorVersion = 0;

View File

@ -81,24 +81,20 @@ namespace dxvk {
};
struct D3D9Light {
D3D9Light(const D3DLIGHT9& light, Matrix4 viewMtx) {
Diffuse = Vector4(light.Diffuse.r, light.Diffuse.g, light.Diffuse.b, light.Diffuse.a);
Specular = Vector4(light.Specular.r, light.Specular.g, light.Specular.b, light.Specular.a);
Ambient = Vector4(light.Ambient.r, light.Ambient.g, light.Ambient.b, light.Ambient.a);
Position = viewMtx * Vector4(light.Position.x, light.Position.y, light.Position.z, 1.0f);
Direction = Vector4(light.Direction.x, light.Direction.y, light.Direction.z, 0.0f);
Direction = normalize(viewMtx * Direction);
Type = light.Type;
Range = light.Range;
Falloff = light.Falloff;
Attenuation0 = light.Attenuation0;
Attenuation1 = light.Attenuation1;
Attenuation2 = light.Attenuation2;
Theta = cosf(light.Theta / 2.0f);
Phi = cosf(light.Phi / 2.0f);
}
D3D9Light(const D3DLIGHT9& light, Matrix4 viewMtx)
: Diffuse ( Vector4(light.Diffuse.r, light.Diffuse.g, light.Diffuse.b, light.Diffuse.a) )
, Specular ( Vector4(light.Specular.r, light.Specular.g, light.Specular.b, light.Specular.a) )
, Ambient ( Vector4(light.Ambient.r, light.Ambient.g, light.Ambient.b, light.Ambient.a) )
, Position ( viewMtx * Vector4(light.Position.x, light.Position.y, light.Position.z, 1.0f) )
, Direction ( normalize(viewMtx * Vector4(light.Direction.x, light.Direction.y, light.Direction.z, 0.0f)) )
, Type ( light.Type )
, Range ( light.Range )
, Falloff ( light.Falloff )
, Attenuation0 ( light.Attenuation0 )
, Attenuation1 ( light.Attenuation1 )
, Attenuation2 ( light.Attenuation2 )
, Theta ( cosf(light.Theta / 2.0f) )
, Phi ( cosf(light.Phi / 2.0f) ) { }
Vector4 Diffuse;
Vector4 Specular;
@ -236,8 +232,6 @@ namespace dxvk {
};
struct D3D9SamplerInfo {
D3D9SamplerInfo() = default;
D3D9SamplerInfo(const std::array<DWORD, SamplerStateCount>& state)
: addressU(D3DTEXTUREADDRESS(state[D3DSAMP_ADDRESSU]))
, addressV(D3DTEXTUREADDRESS(state[D3DSAMP_ADDRESSV]))
@ -309,8 +303,8 @@ namespace dxvk {
std::array<DWORD, caps::MaxEnabledLights> enabledLightIndices;
bool IsLightEnabled(DWORD Index) const {
const auto& indices = enabledLightIndices;
return std::find(indices.begin(), indices.end(), Index) != indices.end();
const auto& enabledIndices = enabledLightIndices;
return std::find(enabledIndices.begin(), enabledIndices.end(), Index) != enabledIndices.end();
}
};

View File

@ -277,7 +277,7 @@ namespace dxvk {
for (uint32_t consts : bit::BitMask(m_captures.vsConsts.fConsts.dword(i))) {
uint32_t idx = i * 32 + consts;
dst->SetVertexShaderConstantF(idx, (float*)&src->vsConsts->fConsts[idx], 1);
dst->SetVertexShaderConstantF(idx, reinterpret_cast<const float*>(&src->vsConsts->fConsts[idx]), 1);
}
}
@ -285,7 +285,7 @@ namespace dxvk {
for (uint32_t consts : bit::BitMask(m_captures.vsConsts.iConsts.dword(i))) {
uint32_t idx = i * 32 + consts;
dst->SetVertexShaderConstantI(idx, (int*)&src->vsConsts->iConsts[idx], 1);
dst->SetVertexShaderConstantI(idx, reinterpret_cast<const int*>(&src->vsConsts->iConsts[idx]), 1);
}
}
@ -300,7 +300,7 @@ namespace dxvk {
for (uint32_t consts : bit::BitMask(m_captures.psConsts.fConsts.dword(i))) {
uint32_t idx = i * 32 + consts;
dst->SetPixelShaderConstantF(idx, (float*)&src->psConsts->fConsts[idx], 1);
dst->SetPixelShaderConstantF(idx, reinterpret_cast<const float*>(&src->psConsts->fConsts[idx]), 1);
}
}
@ -308,7 +308,7 @@ namespace dxvk {
for (uint32_t consts : bit::BitMask(m_captures.psConsts.iConsts.dword(i))) {
uint32_t idx = i * 32 + consts;
dst->SetPixelShaderConstantI(idx, (int*)&src->psConsts->iConsts[idx], 1);
dst->SetPixelShaderConstantI(idx, reinterpret_cast<const int*>(&src->psConsts->iConsts[idx]), 1);
}
}

View File

@ -13,13 +13,6 @@ namespace dxvk {
return uint16_t(65535.0f * x);
}
struct D3D9PresentInfo {
float scale[2];
float offset[2];
};
D3D9SwapChainEx::D3D9SwapChainEx(
D3D9DeviceEx* pDevice,
D3DPRESENT_PARAMETERS* pPresentParams,
@ -745,7 +738,7 @@ namespace dxvk {
m_blitter->setCursorTexture(
cursorSize,
VK_FORMAT_B8G8R8A8_SRGB,
(void *) pCursorBitmap);
reinterpret_cast<void*>(pCursorBitmap));
}

View File

@ -19,7 +19,7 @@ namespace dxvk {
private:
HWND m_window;
bool m_filter;
bool m_filter = false;
};

View File

@ -31,7 +31,7 @@ namespace dxvk {
*/
DxvkShaderKey(
VkShaderStageFlagBits stage,
Sha1Hash hash)
const Sha1Hash& hash)
: m_type(stage), m_sha1(hash) { }
/**