Skip to content

Commit 34a2c85

Browse files
EngineFactoryWebGPU: don't use auto where not needed
1 parent c2788d4 commit 34a2c85

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

Graphics/GraphicsEngineWebGPU/src/EngineFactoryWebGPU.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Diligent Graphics LLC
2+
* Copyright 2023-2025 Diligent Graphics LLC
33
*
44
* You may not use this file except in compliance with the License (see License.txt).
55
*
@@ -156,10 +156,10 @@ std::vector<WebGPUAdapterWrapper> FindCompatibleAdapters(WGPUInstance wgpuInstan
156156
auto OnAdapterRequestEnded = [](WGPURequestAdapterStatus Status, WGPUAdapter Adapter, WGPUStringView Message, void* pCallbackUserData) {
157157
if (pCallbackUserData != nullptr)
158158
{
159-
auto* pUserData = static_cast<CallbackUserData*>(pCallbackUserData);
160-
pUserData->Adapter = Adapter;
161-
pUserData->RequestStatus = Status;
162-
pUserData->IsReady = true;
159+
CallbackUserData* pUserData = static_cast<CallbackUserData*>(pCallbackUserData);
160+
pUserData->Adapter = Adapter;
161+
pUserData->RequestStatus = Status;
162+
pUserData->IsReady = true;
163163
if (WGPUStringViewValid(Message))
164164
pUserData->Message = WGPUStringViewToString(Message);
165165
}
@@ -169,7 +169,7 @@ std::vector<WebGPUAdapterWrapper> FindCompatibleAdapters(WGPUInstance wgpuInstan
169169
WGPUPowerPreference_HighPerformance,
170170
WGPUPowerPreference_LowPower};
171171

172-
for (const auto& powerPreference : PowerPreferences)
172+
for (const WGPUPowerPreference& powerPreference : PowerPreferences)
173173
{
174174
CallbackUserData UserData{};
175175

@@ -295,10 +295,10 @@ WebGPUDeviceWrapper CreateDeviceForAdapter(EngineWebGPUCreateInfo const& EngineC
295295
auto OnDeviceRequestEnded = [](WGPURequestDeviceStatus Status, WGPUDevice Device, WGPUStringView Message, void* pCallbackUserData) {
296296
if (pCallbackUserData != nullptr)
297297
{
298-
auto* pUserData = static_cast<CallbackUserData*>(pCallbackUserData);
299-
pUserData->Device = Device;
300-
pUserData->RequestStatus = Status;
301-
pUserData->IsReady = true;
298+
CallbackUserData* pUserData = static_cast<CallbackUserData*>(pCallbackUserData);
299+
pUserData->Device = Device;
300+
pUserData->RequestStatus = Status;
301+
pUserData->IsReady = true;
302302
if (WGPUStringViewValid(Message))
303303
pUserData->Message = WGPUStringViewToString(Message);
304304
}
@@ -385,7 +385,7 @@ GraphicsAdapterInfo GetGraphicsAdapterInfo(WGPUAdapter wgpuAdapter, WGPUDevice w
385385
// Enable features
386386
{
387387
//TODO
388-
auto& Features{AdapterInfo.Features};
388+
DeviceFeatures& Features{AdapterInfo.Features};
389389
Features.SeparablePrograms = DEVICE_FEATURE_STATE_ENABLED;
390390
Features.ShaderResourceQueries = DEVICE_FEATURE_STATE_ENABLED;
391391
Features.ComputeShaders = DEVICE_FEATURE_STATE_ENABLED;
@@ -436,14 +436,14 @@ GraphicsAdapterInfo GetGraphicsAdapterInfo(WGPUAdapter wgpuAdapter, WGPUDevice w
436436

437437
// Set adapter memory info
438438
{
439-
auto& DrawCommandInfo = AdapterInfo.Memory;
439+
AdapterMemoryInfo& DrawCommandInfo{AdapterInfo.Memory};
440440
DrawCommandInfo.UnifiedMemoryCPUAccess = CPU_ACCESS_NONE;
441441
DrawCommandInfo.UnifiedMemory = 0;
442442
}
443443

444444
// Draw command properties
445445
{
446-
auto& DrawCommandInfo = AdapterInfo.DrawCommand;
446+
DrawCommandProperties& DrawCommandInfo{AdapterInfo.DrawCommand};
447447
DrawCommandInfo.MaxDrawIndirectCount = ~0u;
448448
DrawCommandInfo.CapFlags = DRAW_COMMAND_CAP_FLAG_DRAW_INDIRECT;
449449

@@ -463,7 +463,7 @@ GraphicsAdapterInfo GetGraphicsAdapterInfo(WGPUAdapter wgpuAdapter, WGPUDevice w
463463

464464
// Set compute shader info
465465
{
466-
auto& ComputeShaderInfo = AdapterInfo.ComputeShader;
466+
ComputeShaderProperties& ComputeShaderInfo{AdapterInfo.ComputeShader};
467467

468468
ComputeShaderInfo.MaxThreadGroupSizeX = wgpuSupportedLimits.limits.maxComputeWorkgroupSizeX;
469469
ComputeShaderInfo.MaxThreadGroupSizeY = wgpuSupportedLimits.limits.maxComputeWorkgroupSizeY;
@@ -479,7 +479,7 @@ GraphicsAdapterInfo GetGraphicsAdapterInfo(WGPUAdapter wgpuAdapter, WGPUDevice w
479479

480480
// Set texture info
481481
{
482-
auto& TextureInfo = AdapterInfo.Texture;
482+
TextureProperties& TextureInfo{AdapterInfo.Texture};
483483

484484
TextureInfo.MaxTexture1DArraySlices = 0; // Not supported in WebGPU
485485
TextureInfo.MaxTexture2DArraySlices = wgpuSupportedLimits.limits.maxTextureArrayLayers;
@@ -497,16 +497,14 @@ GraphicsAdapterInfo GetGraphicsAdapterInfo(WGPUAdapter wgpuAdapter, WGPUDevice w
497497

498498
// Set buffer info
499499
{
500-
auto& BufferInfo = AdapterInfo.Buffer;
501-
500+
BufferProperties& BufferInfo{AdapterInfo.Buffer};
502501
BufferInfo.ConstantBufferOffsetAlignment = wgpuSupportedLimits.limits.minUniformBufferOffsetAlignment;
503502
BufferInfo.StructuredBufferOffsetAlignment = wgpuSupportedLimits.limits.minStorageBufferOffsetAlignment;
504503
}
505504

506505
// Set sampler info
507506
{
508-
auto& BufferInfo = AdapterInfo.Sampler;
509-
507+
SamplerProperties& BufferInfo{AdapterInfo.Sampler};
510508
BufferInfo.MaxAnisotropy = 16;
511509
}
512510

@@ -520,8 +518,8 @@ void EngineFactoryWebGPUImpl::EnumerateAdapters(Version MinVersion,
520518
Uint32& NumAdapters,
521519
GraphicsAdapterInfo* Adapters) const
522520
{
523-
auto wgpuInstance = InitializeWebGPUInstance(true);
524-
auto wgpuAdapters = FindCompatibleAdapters(wgpuInstance.Get(), MinVersion);
521+
WebGPUInstanceWrapper wgpuInstance = InitializeWebGPUInstance(true);
522+
std::vector<WebGPUAdapterWrapper> wgpuAdapters = FindCompatibleAdapters(wgpuInstance.Get(), MinVersion);
525523

526524
if (Adapters == nullptr)
527525
NumAdapters = static_cast<Uint32>(wgpuAdapters.size());
@@ -530,7 +528,7 @@ void EngineFactoryWebGPUImpl::EnumerateAdapters(Version MinVersion,
530528
NumAdapters = (std::min)(NumAdapters, static_cast<Uint32>(wgpuAdapters.size()));
531529
for (Uint32 AdapterId = 0; AdapterId < NumAdapters; ++AdapterId)
532530
{
533-
auto& wgpuAdapter = wgpuAdapters[AdapterId];
531+
WebGPUAdapterWrapper& wgpuAdapter{wgpuAdapters[AdapterId]};
534532
Adapters[AdapterId] = GetGraphicsAdapterInfo(wgpuAdapter.Get());
535533
}
536534
}
@@ -555,8 +553,8 @@ void EngineFactoryWebGPUImpl::CreateDeviceAndContextsWebGPU(const EngineWebGPUCr
555553

556554
try
557555
{
558-
auto wgpuInstance = InitializeWebGPUInstance(true);
559-
auto wgpuAdapters = FindCompatibleAdapters(wgpuInstance.Get(), EngineCI.GraphicsAPIVersion);
556+
WebGPUInstanceWrapper wgpuInstance = InitializeWebGPUInstance(true);
557+
std::vector<WebGPUAdapterWrapper> wgpuAdapters = FindCompatibleAdapters(wgpuInstance.Get(), EngineCI.GraphicsAPIVersion);
560558

561559
WebGPUAdapterWrapper SpecificAdapter{};
562560
if (EngineCI.AdapterId != DEFAULT_ADAPTER_ID)
@@ -593,11 +591,11 @@ void EngineFactoryWebGPUImpl::CreateSwapChainWebGPU(IRenderDevice* pDevice
593591

594592
try
595593
{
596-
auto* pDeviceWebGPU = ClassPtrCast<RenderDeviceWebGPUImpl>(pDevice);
597-
auto* pDeviceContextWebGPU = ClassPtrCast<DeviceContextWebGPUImpl>(pImmediateContext);
598-
auto& RawMemAllocator = GetRawAllocator();
594+
RenderDeviceWebGPUImpl* pDeviceWebGPU = ClassPtrCast<RenderDeviceWebGPUImpl>(pDevice);
595+
DeviceContextWebGPUImpl* pDeviceContextWebGPU = ClassPtrCast<DeviceContextWebGPUImpl>(pImmediateContext);
596+
IMemoryAllocator& RawMemAllocator = GetRawAllocator();
599597

600-
auto* pSwapChainWebGPU = NEW_RC_OBJ(RawMemAllocator, "SwapChainWebGPUImpl instance", SwapChainWebGPUImpl)(SCDesc, pDeviceWebGPU, pDeviceContextWebGPU, Window);
598+
SwapChainWebGPUImpl* pSwapChainWebGPU = NEW_RC_OBJ(RawMemAllocator, "SwapChainWebGPUImpl instance", SwapChainWebGPUImpl)(SCDesc, pDeviceWebGPU, pDeviceContextWebGPU, Window);
601599
pSwapChainWebGPU->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain));
602600
}
603601
catch (const std::runtime_error&)
@@ -646,11 +644,11 @@ void EngineFactoryWebGPUImpl::AttachToWebGPUDevice(void*
646644

647645
try
648646
{
649-
const auto AdapterInfo = GetGraphicsAdapterInfo(static_cast<WGPUAdapter>(wgpuAdapter), static_cast<WGPUDevice>(wgpuDevice));
647+
const GraphicsAdapterInfo AdapterInfo = GetGraphicsAdapterInfo(static_cast<WGPUAdapter>(wgpuAdapter), static_cast<WGPUDevice>(wgpuDevice));
650648
VerifyEngineCreateInfo(EngineCI, AdapterInfo);
651649

652650
SetRawAllocator(EngineCI.pRawMemAllocator);
653-
auto& RawMemAllocator = GetRawAllocator();
651+
IMemoryAllocator& RawMemAllocator = GetRawAllocator();
654652

655653
RenderDeviceWebGPUImpl* pRenderDeviceWebGPU{
656654
NEW_RC_OBJ(RawMemAllocator, "RenderDeviceWebGPUImpl instance", RenderDeviceWebGPUImpl)(

0 commit comments

Comments
 (0)