Add initial base implementation for WebGPU rendering backend

This commit is contained in:
Wojtek Figat
2026-02-23 11:49:45 +01:00
parent 4ca10c7869
commit 6081ed35bc
29 changed files with 3565 additions and 2 deletions

View File

@@ -75,6 +75,11 @@ API_ENUM() enum class RendererType
/// </summary>
PS5 = 12,
/// <summary>
/// WebGPU
/// </summary>
WebGPU = 13,
API_ENUM(Attributes="HideInEditor")
MAX
};
@@ -131,6 +136,11 @@ API_ENUM() enum class ShaderProfile
/// </summary>
PS5 = 8,
/// <summary>
/// WebGPU
/// </summary>
WebGPU = 9,
API_ENUM(Attributes="HideInEditor")
MAX
};

View File

@@ -97,8 +97,7 @@ public class Graphics : EngineModule
Log.WarningOnce(string.Format("Building for {0} without Vulkan rendering backend (Vulkan SDK is missing)", options.Platform.Target), ref _logMissingVulkanSDK);
break;
case TargetPlatform.Web:
options.PrivateDependencies.Add("GraphicsDeviceNull");
// TODO: add WebGPU
options.PrivateDependencies.Add("GraphicsDeviceWebGPU");
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

View File

@@ -175,6 +175,11 @@ bool GraphicsService::Init()
extern GPUDevice* CreateGPUDevicePS5();
if (!device)
device = CreateGPUDevicePS5();
#endif
#if GRAPHICS_API_WEBGPU
extern GPUDevice* CreateGPUDeviceWebGPU();
if (!device)
device = CreateGPUDeviceWebGPU();
#endif
}

View File

@@ -58,6 +58,9 @@ const Char* ToString(RendererType value)
case RendererType::PS5:
result = TEXT("PS5");
break;
case RendererType::WebGPU:
result = TEXT("WebGPU");
break;
default:
result = TEXT("?");
}
@@ -96,6 +99,9 @@ const Char* ToString(ShaderProfile value)
case ShaderProfile::PS5:
result = TEXT("PS5");
break;
case ShaderProfile::WebGPU:
result = TEXT("WebGPU");
break;
default:
result = TEXT("?");
}
@@ -268,6 +274,7 @@ FeatureLevel RenderTools::GetFeatureLevel(ShaderProfile profile)
case ShaderProfile::GLSL_440:
case ShaderProfile::GLSL_410:
case ShaderProfile::Unknown:
case ShaderProfile::WebGPU:
return FeatureLevel::ES2;
default:
return FeatureLevel::ES2;

View File

@@ -27,6 +27,7 @@ const Char* ShaderProfileCacheDirNames[] =
TEXT("PS4"), // PS4
TEXT("DX_SM6"), // DirectX_SM6
TEXT("PS5"), // PS5
TEXT("WEB"), // WebGPU
// @formatter:on
};

View File

@@ -19,6 +19,7 @@ void GPUSamplerDescription::Clear()
{
Platform::MemoryClear(this, sizeof(GPUSamplerDescription));
MaxMipLevel = MAX_float;
MaxAnisotropy = 1.0f;
}
bool GPUSamplerDescription::Equals(const GPUSamplerDescription& other) const