aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiza Burakova <liza@chromium.org>2024-04-15 13:42:17 -0400
committerAngle LUCI CQ <angle-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-15 20:19:18 +0000
commit041b0a4d543465225050c6ea4d27674af4687100 (patch)
tree5ab564add5890b89f62ac77a962a3cd369c48ba8
parent2218db2b3bc3a17a679280247ede9cd1febabd0a (diff)
downloadangle-041b0a4d543465225050c6ea4d27674af4687100.tar.gz
Begin initializing caps for webgpu
Bug: angleproject:8457 Change-Id: Idde0673297ec675a13bd3e4fd4d220ec47392153 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5391987 Reviewed-by: Matthew Denton <mpdenton@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Liza Burakova <liza@chromium.org>
-rw-r--r--src/libANGLE/renderer/renderer_utils.h11
-rw-r--r--src/libANGLE/renderer/vulkan/vk_caps_utils.cpp141
-rw-r--r--src/libANGLE/renderer/wgpu/ContextWgpu.cpp2
-rw-r--r--src/libANGLE/renderer/wgpu/wgpu_utils.cpp25
-rw-r--r--src/libANGLE/renderer/wgpu/wgpu_utils.h2
5 files changed, 106 insertions, 75 deletions
diff --git a/src/libANGLE/renderer/renderer_utils.h b/src/libANGLE/renderer/renderer_utils.h
index 6375a06c96..9e17a6b8b0 100644
--- a/src/libANGLE/renderer/renderer_utils.h
+++ b/src/libANGLE/renderer/renderer_utils.h
@@ -453,6 +453,17 @@ const gl::ColorGeneric AdjustBorderColor(const angle::ColorGeneric &borderColorG
const angle::Format &format,
bool stencilMode);
+template <typename LargerInt>
+GLint LimitToInt(const LargerInt physicalDeviceValue)
+{
+ static_assert(sizeof(LargerInt) >= sizeof(int32_t), "Incorrect usage of LimitToInt");
+
+ // Limit to INT_MAX / 2 instead of INT_MAX. If the limit is queried as float, the imprecision
+ // in floating point can cause the value to exceed INT_MAX. This trips dEQP up.
+ return static_cast<GLint>(std::min(
+ physicalDeviceValue, static_cast<LargerInt>(std::numeric_limits<int32_t>::max() / 2)));
+}
+
enum class PipelineType
{
Graphics = 0,
diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
index 21211772ef..d5499b6074 100644
--- a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
@@ -221,17 +221,6 @@ uint32_t GetTimestampValidBits(const std::vector<VkQueueFamilyProperties> &queue
} // namespace
} // namespace vk
-template <typename LargerInt>
-GLint LimitToInt(const LargerInt physicalDeviceValue)
-{
- static_assert(sizeof(LargerInt) >= sizeof(int32_t), "Incorrect usage of LimitToInt");
-
- // Limit to INT_MAX / 2 instead of INT_MAX. If the limit is queried as float, the imprecision
- // in floating point can cause the value to exceed INT_MAX. This trips dEQP up.
- return static_cast<GLint>(std::min(
- physicalDeviceValue, static_cast<LargerInt>(std::numeric_limits<int32_t>::max() / 2)));
-}
-
void vk::Renderer::ensureCapsInitialized() const
{
if (mCapsInitialized)
@@ -534,12 +523,12 @@ void vk::Renderer::ensureCapsInitialized() const
// https://vulkan.lunarg.com/doc/view/1.0.30.0/linux/vkspec.chunked/ch31s02.html
mNativeCaps.maxElementIndex = std::numeric_limits<GLuint>::max() - 1;
- mNativeCaps.max3DTextureSize = LimitToInt(limitsVk.maxImageDimension3D);
+ mNativeCaps.max3DTextureSize = rx::LimitToInt(limitsVk.maxImageDimension3D);
mNativeCaps.max2DTextureSize =
std::min(limitsVk.maxFramebufferWidth, limitsVk.maxImageDimension2D);
- mNativeCaps.maxArrayTextureLayers = LimitToInt(limitsVk.maxImageArrayLayers);
+ mNativeCaps.maxArrayTextureLayers = rx::LimitToInt(limitsVk.maxImageArrayLayers);
mNativeCaps.maxLODBias = limitsVk.maxSamplerLodBias;
- mNativeCaps.maxCubeMapTextureSize = LimitToInt(limitsVk.maxImageDimensionCube);
+ mNativeCaps.maxCubeMapTextureSize = rx::LimitToInt(limitsVk.maxImageDimensionCube);
mNativeCaps.maxRenderbufferSize =
std::min({limitsVk.maxImageDimension2D, limitsVk.maxFramebufferWidth,
limitsVk.maxFramebufferHeight});
@@ -559,12 +548,12 @@ void vk::Renderer::ensureCapsInitialized() const
mNativeCaps.maxDrawBuffers =
std::min(limitsVk.maxColorAttachments, limitsVk.maxFragmentOutputAttachments);
- mNativeCaps.maxFramebufferWidth = LimitToInt(limitsVk.maxFramebufferWidth);
- mNativeCaps.maxFramebufferHeight = LimitToInt(limitsVk.maxFramebufferHeight);
- mNativeCaps.maxColorAttachments = LimitToInt(limitsVk.maxColorAttachments);
- mNativeCaps.maxViewportWidth = LimitToInt(limitsVk.maxViewportDimensions[0]);
- mNativeCaps.maxViewportHeight = LimitToInt(limitsVk.maxViewportDimensions[1]);
- mNativeCaps.maxSampleMaskWords = LimitToInt(limitsVk.maxSampleMaskWords);
+ mNativeCaps.maxFramebufferWidth = rx::LimitToInt(limitsVk.maxFramebufferWidth);
+ mNativeCaps.maxFramebufferHeight = rx::LimitToInt(limitsVk.maxFramebufferHeight);
+ mNativeCaps.maxColorAttachments = rx::LimitToInt(limitsVk.maxColorAttachments);
+ mNativeCaps.maxViewportWidth = rx::LimitToInt(limitsVk.maxViewportDimensions[0]);
+ mNativeCaps.maxViewportHeight = rx::LimitToInt(limitsVk.maxViewportDimensions[1]);
+ mNativeCaps.maxSampleMaskWords = rx::LimitToInt(limitsVk.maxSampleMaskWords);
mNativeCaps.maxColorTextureSamples =
vk_gl::GetMaxSampleCount(limitsVk.sampledImageColorSampleCounts);
mNativeCaps.maxDepthTextureSamples =
@@ -572,8 +561,8 @@ void vk::Renderer::ensureCapsInitialized() const
mNativeCaps.maxIntegerSamples =
vk_gl::GetMaxSampleCount(limitsVk.sampledImageIntegerSampleCounts);
- mNativeCaps.maxVertexAttributes = LimitToInt(limitsVk.maxVertexInputAttributes);
- mNativeCaps.maxVertexAttribBindings = LimitToInt(limitsVk.maxVertexInputBindings);
+ mNativeCaps.maxVertexAttributes = rx::LimitToInt(limitsVk.maxVertexInputAttributes);
+ mNativeCaps.maxVertexAttribBindings = rx::LimitToInt(limitsVk.maxVertexInputBindings);
// Offset and stride are stored as uint16_t in PackedAttribDesc.
mNativeCaps.maxVertexAttribRelativeOffset =
std::min((1u << kAttributeOffsetMaxBits) - 1, limitsVk.maxVertexInputAttributeOffset);
@@ -602,15 +591,15 @@ void vk::Renderer::ensureCapsInitialized() const
mNativeCaps.fragmentLowpInt.setTwosComplementInt(16);
// Compute shader limits.
- mNativeCaps.maxComputeWorkGroupCount[0] = LimitToInt(limitsVk.maxComputeWorkGroupCount[0]);
- mNativeCaps.maxComputeWorkGroupCount[1] = LimitToInt(limitsVk.maxComputeWorkGroupCount[1]);
- mNativeCaps.maxComputeWorkGroupCount[2] = LimitToInt(limitsVk.maxComputeWorkGroupCount[2]);
- mNativeCaps.maxComputeWorkGroupSize[0] = LimitToInt(limitsVk.maxComputeWorkGroupSize[0]);
- mNativeCaps.maxComputeWorkGroupSize[1] = LimitToInt(limitsVk.maxComputeWorkGroupSize[1]);
- mNativeCaps.maxComputeWorkGroupSize[2] = LimitToInt(limitsVk.maxComputeWorkGroupSize[2]);
+ mNativeCaps.maxComputeWorkGroupCount[0] = rx::LimitToInt(limitsVk.maxComputeWorkGroupCount[0]);
+ mNativeCaps.maxComputeWorkGroupCount[1] = rx::LimitToInt(limitsVk.maxComputeWorkGroupCount[1]);
+ mNativeCaps.maxComputeWorkGroupCount[2] = rx::LimitToInt(limitsVk.maxComputeWorkGroupCount[2]);
+ mNativeCaps.maxComputeWorkGroupSize[0] = rx::LimitToInt(limitsVk.maxComputeWorkGroupSize[0]);
+ mNativeCaps.maxComputeWorkGroupSize[1] = rx::LimitToInt(limitsVk.maxComputeWorkGroupSize[1]);
+ mNativeCaps.maxComputeWorkGroupSize[2] = rx::LimitToInt(limitsVk.maxComputeWorkGroupSize[2]);
mNativeCaps.maxComputeWorkGroupInvocations =
- LimitToInt(limitsVk.maxComputeWorkGroupInvocations);
- mNativeCaps.maxComputeSharedMemorySize = LimitToInt(limitsVk.maxComputeSharedMemorySize);
+ rx::LimitToInt(limitsVk.maxComputeWorkGroupInvocations);
+ mNativeCaps.maxComputeSharedMemorySize = rx::LimitToInt(limitsVk.maxComputeSharedMemorySize);
GLuint maxUniformBlockSize = limitsVk.maxUniformBufferRange;
@@ -631,7 +620,7 @@ void vk::Renderer::ensureCapsInitialized() const
}
mNativeCaps.maxUniformLocations = maxUniformVectors;
- const int32_t maxPerStageUniformBuffers = LimitToInt(
+ const int32_t maxPerStageUniformBuffers = rx::LimitToInt(
limitsVk.maxPerStageDescriptorUniformBuffers - kReservedPerStageDefaultUniformBindingCount);
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
@@ -641,7 +630,7 @@ void vk::Renderer::ensureCapsInitialized() const
// Reserved uniform buffer count depends on number of stages. Vertex and fragment shaders are
// always supported. The limit needs to be adjusted based on whether geometry and tessellation
// is supported.
- int32_t maxCombinedUniformBuffers = LimitToInt(limitsVk.maxDescriptorSetUniformBuffers) -
+ int32_t maxCombinedUniformBuffers = rx::LimitToInt(limitsVk.maxDescriptorSetUniformBuffers) -
2 * kReservedPerStageDefaultUniformBindingCount;
mNativeCaps.maxUniformBlockSize = maxUniformBlockSize;
@@ -656,9 +645,9 @@ void vk::Renderer::ensureCapsInitialized() const
std::min(limitsVk.maxDescriptorSetSamplers, limitsVk.maxDescriptorSetSampledImages);
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
- mNativeCaps.maxShaderTextureImageUnits[shaderType] = LimitToInt(maxPerStageTextures);
+ mNativeCaps.maxShaderTextureImageUnits[shaderType] = rx::LimitToInt(maxPerStageTextures);
}
- mNativeCaps.maxCombinedTextureImageUnits = LimitToInt(maxCombinedTextures);
+ mNativeCaps.maxCombinedTextureImageUnits = rx::LimitToInt(maxCombinedTextures);
uint32_t maxPerStageStorageBuffers = limitsVk.maxPerStageDescriptorStorageBuffers;
uint32_t maxVertexStageStorageBuffers = maxPerStageStorageBuffers;
@@ -721,36 +710,36 @@ void vk::Renderer::ensureCapsInitialized() const
mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Vertex] =
mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics
- ? LimitToInt(maxVertexStageStorageBuffers)
+ ? rx::LimitToInt(maxVertexStageStorageBuffers)
: 0;
mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Fragment] =
- mPhysicalDeviceFeatures.fragmentStoresAndAtomics ? LimitToInt(maxPerStageStorageBuffers)
+ mPhysicalDeviceFeatures.fragmentStoresAndAtomics ? rx::LimitToInt(maxPerStageStorageBuffers)
: 0;
mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Compute] =
- LimitToInt(maxPerStageStorageBuffers);
- mNativeCaps.maxCombinedShaderStorageBlocks = LimitToInt(maxCombinedStorageBuffers);
+ rx::LimitToInt(maxPerStageStorageBuffers);
+ mNativeCaps.maxCombinedShaderStorageBlocks = rx::LimitToInt(maxCombinedStorageBuffers);
- mNativeCaps.maxShaderStorageBufferBindings = LimitToInt(maxCombinedStorageBuffers);
+ mNativeCaps.maxShaderStorageBufferBindings = rx::LimitToInt(maxCombinedStorageBuffers);
mNativeCaps.maxShaderStorageBlockSize = limitsVk.maxStorageBufferRange;
mNativeCaps.shaderStorageBufferOffsetAlignment =
- LimitToInt(static_cast<uint32_t>(limitsVk.minStorageBufferOffsetAlignment));
+ rx::LimitToInt(static_cast<uint32_t>(limitsVk.minStorageBufferOffsetAlignment));
mNativeCaps.maxShaderAtomicCounterBuffers[gl::ShaderType::Vertex] =
mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics
- ? LimitToInt(maxVertexStageAtomicCounterBuffers)
+ ? rx::LimitToInt(maxVertexStageAtomicCounterBuffers)
: 0;
mNativeCaps.maxShaderAtomicCounterBuffers[gl::ShaderType::Fragment] =
mPhysicalDeviceFeatures.fragmentStoresAndAtomics
- ? LimitToInt(maxPerStageAtomicCounterBuffers)
+ ? rx::LimitToInt(maxPerStageAtomicCounterBuffers)
: 0;
mNativeCaps.maxShaderAtomicCounterBuffers[gl::ShaderType::Compute] =
- LimitToInt(maxPerStageAtomicCounterBuffers);
- mNativeCaps.maxCombinedAtomicCounterBuffers = LimitToInt(maxCombinedAtomicCounterBuffers);
+ rx::LimitToInt(maxPerStageAtomicCounterBuffers);
+ mNativeCaps.maxCombinedAtomicCounterBuffers = rx::LimitToInt(maxCombinedAtomicCounterBuffers);
- mNativeCaps.maxAtomicCounterBufferBindings = LimitToInt(maxCombinedAtomicCounterBuffers);
+ mNativeCaps.maxAtomicCounterBufferBindings = rx::LimitToInt(maxCombinedAtomicCounterBuffers);
// Emulated as storage buffers, atomic counter buffers have the same size limit. However, the
// limit is a signed integer and values above int max will end up as a negative size.
- mNativeCaps.maxAtomicCounterBufferSize = LimitToInt(limitsVk.maxStorageBufferRange);
+ mNativeCaps.maxAtomicCounterBufferSize = rx::LimitToInt(limitsVk.maxStorageBufferRange);
// There is no particular limit to how many atomic counters there can be, other than the size of
// a storage buffer. We nevertheless limit this to something reasonable (4096 arbitrarily).
@@ -777,8 +766,8 @@ void vk::Renderer::ensureCapsInitialized() const
mNativeCaps.maxCombinedAtomicCounters = maxAtomicCounters;
// GL Images correspond to Vulkan Storage Images.
- const int32_t maxPerStageImages = LimitToInt(limitsVk.maxPerStageDescriptorStorageImages);
- const int32_t maxCombinedImages = LimitToInt(limitsVk.maxDescriptorSetStorageImages);
+ const int32_t maxPerStageImages = rx::LimitToInt(limitsVk.maxPerStageDescriptorStorageImages);
+ const int32_t maxCombinedImages = rx::LimitToInt(limitsVk.maxDescriptorSetStorageImages);
const int32_t maxVertexPipelineImages =
mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics ? maxPerStageImages : 0;
@@ -828,7 +817,7 @@ void vk::Renderer::ensureCapsInitialized() const
// in applications that take the value as signed int (including dEQP).
const uint32_t maxPerStageResources = limitsVk.maxPerStageResources;
mNativeCaps.maxCombinedShaderOutputResources =
- LimitToInt(maxPerStageResources - kReservedPerStageBindingCount);
+ rx::LimitToInt(maxPerStageResources - kReservedPerStageBindingCount);
// Reserve 1 extra varying for transform feedback capture of gl_Position.
constexpr GLint kReservedVaryingComponentsForTransformFeedbackExtension = 4;
@@ -860,10 +849,10 @@ void vk::Renderer::ensureCapsInitialized() const
const GLint maxVaryingCount =
std::min(limitsVk.maxVertexOutputComponents, limitsVk.maxFragmentInputComponents);
mNativeCaps.maxVaryingVectors =
- LimitToInt((maxVaryingCount / kComponentsPerVector) - reservedVaryingVectorCount);
+ rx::LimitToInt((maxVaryingCount / kComponentsPerVector) - reservedVaryingVectorCount);
mNativeCaps.maxVertexOutputComponents =
- LimitToInt(limitsVk.maxVertexOutputComponents) - reservedVaryingComponentCount;
- mNativeCaps.maxFragmentInputComponents = LimitToInt(limitsVk.maxFragmentInputComponents);
+ rx::LimitToInt(limitsVk.maxVertexOutputComponents) - reservedVaryingComponentCount;
+ mNativeCaps.maxFragmentInputComponents = rx::LimitToInt(limitsVk.maxFragmentInputComponents);
mNativeCaps.maxTransformFeedbackInterleavedComponents =
gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS;
@@ -873,13 +862,13 @@ void vk::Renderer::ensureCapsInitialized() const
gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS;
mNativeCaps.minProgramTexelOffset = limitsVk.minTexelOffset;
- mNativeCaps.maxProgramTexelOffset = LimitToInt(limitsVk.maxTexelOffset);
+ mNativeCaps.maxProgramTexelOffset = rx::LimitToInt(limitsVk.maxTexelOffset);
const uint32_t sampleCounts =
limitsVk.framebufferColorSampleCounts & limitsVk.framebufferDepthSampleCounts &
limitsVk.framebufferStencilSampleCounts & vk_gl::kSupportedSampleCounts;
- mNativeCaps.maxSamples = LimitToInt(vk_gl::GetMaxSampleCount(sampleCounts));
+ mNativeCaps.maxSamples = rx::LimitToInt(vk_gl::GetMaxSampleCount(sampleCounts));
mNativeCaps.maxFramebufferSamples = mNativeCaps.maxSamples;
mNativeCaps.subPixelBits = limitsVk.subPixelPrecisionBits;
@@ -975,10 +964,11 @@ void vk::Renderer::ensureCapsInitialized() const
// GL_RGBA32F Y Y
// GL_RGBA32I Y Y
// GL_RGBA32UI Y Y
- mNativeExtensions.textureBufferOES = true;
- mNativeExtensions.textureBufferEXT = true;
- mNativeCaps.maxTextureBufferSize = LimitToInt(limitsVk.maxTexelBufferElements);
- mNativeCaps.textureBufferOffsetAlignment = LimitToInt(limitsVk.minTexelBufferOffsetAlignment);
+ mNativeExtensions.textureBufferOES = true;
+ mNativeExtensions.textureBufferEXT = true;
+ mNativeCaps.maxTextureBufferSize = rx::LimitToInt(limitsVk.maxTexelBufferElements);
+ mNativeCaps.textureBufferOffsetAlignment =
+ rx::LimitToInt(limitsVk.minTexelBufferOffsetAlignment);
// Atomic image operations in the vertex and fragment shaders require the
// vertexPipelineStoresAndAtomics and fragmentStoresAndAtomics Vulkan features respectively.
@@ -1002,27 +992,27 @@ void vk::Renderer::ensureCapsInitialized() const
(mFeatures.supportsPrimitivesGeneratedQuery.enabled ||
mFeatures.exposeNonConformantExtensionsAndVersions.enabled);
mNativeExtensions.tessellationShaderEXT = tessellationShaderEnabled;
- mNativeCaps.maxPatchVertices = LimitToInt(limitsVk.maxTessellationPatchSize);
+ mNativeCaps.maxPatchVertices = rx::LimitToInt(limitsVk.maxTessellationPatchSize);
mNativeCaps.maxTessPatchComponents =
- LimitToInt(limitsVk.maxTessellationControlPerPatchOutputComponents);
- mNativeCaps.maxTessGenLevel = LimitToInt(limitsVk.maxTessellationGenerationLevel);
+ rx::LimitToInt(limitsVk.maxTessellationControlPerPatchOutputComponents);
+ mNativeCaps.maxTessGenLevel = rx::LimitToInt(limitsVk.maxTessellationGenerationLevel);
mNativeCaps.maxTessControlInputComponents =
- LimitToInt(limitsVk.maxTessellationControlPerVertexInputComponents);
+ rx::LimitToInt(limitsVk.maxTessellationControlPerVertexInputComponents);
mNativeCaps.maxTessControlOutputComponents =
- LimitToInt(limitsVk.maxTessellationControlPerVertexOutputComponents);
+ rx::LimitToInt(limitsVk.maxTessellationControlPerVertexOutputComponents);
mNativeCaps.maxTessControlTotalOutputComponents =
- LimitToInt(limitsVk.maxTessellationControlTotalOutputComponents);
+ rx::LimitToInt(limitsVk.maxTessellationControlTotalOutputComponents);
mNativeCaps.maxTessEvaluationInputComponents =
- LimitToInt(limitsVk.maxTessellationEvaluationInputComponents);
+ rx::LimitToInt(limitsVk.maxTessellationEvaluationInputComponents);
mNativeCaps.maxTessEvaluationOutputComponents =
- LimitToInt(limitsVk.maxTessellationEvaluationOutputComponents) -
+ rx::LimitToInt(limitsVk.maxTessellationEvaluationOutputComponents) -
reservedVaryingComponentCount;
// There is 1 default uniform binding used per tessellation stages.
- mNativeCaps.maxCombinedUniformBlocks = LimitToInt(
+ mNativeCaps.maxCombinedUniformBlocks = rx::LimitToInt(
mNativeCaps.maxCombinedUniformBlocks + kReservedTessellationDefaultUniformBindingCount);
- mNativeCaps.maxUniformBufferBindings = LimitToInt(
+ mNativeCaps.maxUniformBufferBindings = rx::LimitToInt(
mNativeCaps.maxUniformBufferBindings + kReservedTessellationDefaultUniformBindingCount);
if (mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics)
@@ -1053,17 +1043,18 @@ void vk::Renderer::ensureCapsInitialized() const
mFeatures.exposeNonConformantExtensionsAndVersions.enabled);
mNativeExtensions.geometryShaderEXT = geometryShaderEnabled;
mNativeExtensions.geometryShaderOES = geometryShaderEnabled;
- mNativeCaps.maxFramebufferLayers = LimitToInt(limitsVk.maxFramebufferLayers);
+ mNativeCaps.maxFramebufferLayers = rx::LimitToInt(limitsVk.maxFramebufferLayers);
// Use "undefined" which means APP would have to set gl_Layer identically.
mNativeCaps.layerProvokingVertex = GL_UNDEFINED_VERTEX_EXT;
- mNativeCaps.maxGeometryInputComponents = LimitToInt(limitsVk.maxGeometryInputComponents);
+ mNativeCaps.maxGeometryInputComponents =
+ rx::LimitToInt(limitsVk.maxGeometryInputComponents);
mNativeCaps.maxGeometryOutputComponents =
- LimitToInt(limitsVk.maxGeometryOutputComponents) - reservedVaryingComponentCount;
- mNativeCaps.maxGeometryOutputVertices = LimitToInt(limitsVk.maxGeometryOutputVertices);
+ rx::LimitToInt(limitsVk.maxGeometryOutputComponents) - reservedVaryingComponentCount;
+ mNativeCaps.maxGeometryOutputVertices = rx::LimitToInt(limitsVk.maxGeometryOutputVertices);
mNativeCaps.maxGeometryTotalOutputComponents =
- LimitToInt(limitsVk.maxGeometryTotalOutputComponents);
+ rx::LimitToInt(limitsVk.maxGeometryTotalOutputComponents);
if (mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics)
{
mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Geometry] =
@@ -1072,7 +1063,7 @@ void vk::Renderer::ensureCapsInitialized() const
maxCombinedAtomicCounterBuffers;
}
mNativeCaps.maxGeometryShaderInvocations =
- LimitToInt(limitsVk.maxGeometryShaderInvocations);
+ rx::LimitToInt(limitsVk.maxGeometryShaderInvocations);
// Cap maxGeometryInputComponents by maxVertexOutputComponents and
// maxTessellationEvaluationOutputComponents; there can't be more inputs than there are
@@ -1127,7 +1118,7 @@ void vk::Renderer::ensureCapsInitialized() const
// GL_EXT_blend_func_extended
mNativeExtensions.blendFuncExtendedEXT = mPhysicalDeviceFeatures.dualSrcBlend == VK_TRUE;
- mNativeCaps.maxDualSourceDrawBuffers = LimitToInt(limitsVk.maxFragmentDualSrcAttachments);
+ mNativeCaps.maxDualSourceDrawBuffers = rx::LimitToInt(limitsVk.maxFragmentDualSrcAttachments);
// GL_ANGLE_relaxed_vertex_attribute_type
mNativeExtensions.relaxedVertexAttributeTypeANGLE = true;
diff --git a/src/libANGLE/renderer/wgpu/ContextWgpu.cpp b/src/libANGLE/renderer/wgpu/ContextWgpu.cpp
index 8c4faaa204..7cea882dfe 100644
--- a/src/libANGLE/renderer/wgpu/ContextWgpu.cpp
+++ b/src/libANGLE/renderer/wgpu/ContextWgpu.cpp
@@ -158,6 +158,8 @@ ContextWgpu::ContextWgpu(const gl::State &state, gl::ErrorSet *errorSet, Display
InitMinimumTextureCapsMap(maxClientVersion, mExtensions, &mTextureCaps);
+ webgpu::EnsureCapsInitialized(mDisplay->getDevice(), &mCaps);
+
if (mExtensions.shaderPixelLocalStorageANGLE)
{
mPLSOptions.type = ShPixelLocalStorageType::FramebufferFetch;
diff --git a/src/libANGLE/renderer/wgpu/wgpu_utils.cpp b/src/libANGLE/renderer/wgpu/wgpu_utils.cpp
index af46c1266e..083d9b5c92 100644
--- a/src/libANGLE/renderer/wgpu/wgpu_utils.cpp
+++ b/src/libANGLE/renderer/wgpu/wgpu_utils.cpp
@@ -6,6 +6,7 @@
#include "libANGLE/renderer/wgpu/wgpu_utils.h"
+#include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/wgpu/ContextWgpu.h"
#include "libANGLE/renderer/wgpu/DisplayWgpu.h"
@@ -47,6 +48,30 @@ bool IsError(WGPUBufferMapAsyncStatus mapBufferStatus)
return mapBufferStatus != WGPUBufferMapAsyncStatus_Success;
}
+void EnsureCapsInitialized(const wgpu::Device &device, gl::Caps *nativeCaps)
+{
+ wgpu::SupportedLimits limitsWgpu = {};
+ device.GetLimits(&limitsWgpu);
+
+ nativeCaps->maxElementIndex = std::numeric_limits<GLuint>::max() - 1;
+ nativeCaps->max3DTextureSize = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension3D);
+ nativeCaps->max2DTextureSize = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension2D);
+ nativeCaps->maxArrayTextureLayers = rx::LimitToInt(limitsWgpu.limits.maxTextureArrayLayers);
+ nativeCaps->maxCubeMapTextureSize = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension2D);
+ nativeCaps->maxRenderbufferSize = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension2D);
+
+ nativeCaps->maxDrawBuffers = rx::LimitToInt(limitsWgpu.limits.maxColorAttachments);
+ nativeCaps->maxFramebufferWidth = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension2D);
+ nativeCaps->maxFramebufferHeight = rx::LimitToInt(limitsWgpu.limits.maxTextureDimension2D);
+ nativeCaps->maxColorAttachments = rx::LimitToInt(limitsWgpu.limits.maxColorAttachments);
+
+ nativeCaps->maxVertexAttribStride =
+ rx::LimitToInt(limitsWgpu.limits.maxVertexBufferArrayStride);
+
+ nativeCaps->maxVertexAttributes = rx::LimitToInt(limitsWgpu.limits.maxVertexAttributes);
+
+ nativeCaps->maxTextureBufferSize = rx::LimitToInt(limitsWgpu.limits.maxBufferSize);
+}
} // namespace webgpu
namespace wgpu_gl
diff --git a/src/libANGLE/renderer/wgpu/wgpu_utils.h b/src/libANGLE/renderer/wgpu/wgpu_utils.h
index 1514d8fb5b..911a5c021e 100644
--- a/src/libANGLE/renderer/wgpu/wgpu_utils.h
+++ b/src/libANGLE/renderer/wgpu/wgpu_utils.h
@@ -10,6 +10,7 @@
#include <dawn/webgpu_cpp.h>
#include <stdint.h>
+#include "libANGLE/Caps.h"
#include "libANGLE/Error.h"
#include "libANGLE/angletypes.h"
@@ -43,6 +44,7 @@ enum class RenderPassClosureReason
InvalidEnum,
EnumCount = InvalidEnum,
};
+void EnsureCapsInitialized(const wgpu::Device &device, gl::Caps *nativeCaps);
ContextWgpu *GetImpl(const gl::Context *context);
DisplayWgpu *GetDisplay(const gl::Context *context);