aboutsummaryrefslogtreecommitdiff
path: root/sokol_app.h
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2024-05-13 14:52:46 +0200
committerAndre Weissflog <floooh@gmail.com>2024-05-13 14:52:46 +0200
commit13554f665ebf32522b9e0323b35f08fb836b98b2 (patch)
tree9e173a76f2a2ffc8b0c48782b83c72e548283f94 /sokol_app.h
parent2703dde33182c636687b409071acbf07690cfa2b (diff)
sokol_app.h wgpu: add a bounds check to the wgpu feature detection code
Diffstat (limited to 'sokol_app.h')
-rw-r--r--sokol_app.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 6e4d56ae..df3c1f25 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -5765,22 +5765,28 @@ _SOKOL_PRIVATE void _sapp_emsc_wgpu_request_adapter_cb(WGPURequestAdapterStatus
SOKOL_ASSERT(adapter);
_sapp.wgpu.adapter = adapter;
size_t cur_feature_index = 1;
- WGPUFeatureName requiredFeatures[8] = {
+ #define _SAPP_WGPU_MAX_REQUESTED_FEATURES (8)
+ WGPUFeatureName requiredFeatures[_SAPP_WGPU_MAX_REQUESTED_FEATURES] = {
WGPUFeatureName_Depth32FloatStencil8,
};
// check for optional features we're interested in
if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_TextureCompressionBC)) {
+ SOKOL_ASSERT(cur_feature_index < _SAPP_WGPU_MAX_REQUESTED_FEATURES);
requiredFeatures[cur_feature_index++] = WGPUFeatureName_TextureCompressionBC;
}
if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_TextureCompressionETC2)) {
+ SOKOL_ASSERT(cur_feature_index < _SAPP_WGPU_MAX_REQUESTED_FEATURES);
requiredFeatures[cur_feature_index++] = WGPUFeatureName_TextureCompressionETC2;
}
if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_TextureCompressionASTC)) {
+ SOKOL_ASSERT(cur_feature_index < _SAPP_WGPU_MAX_REQUESTED_FEATURES);
requiredFeatures[cur_feature_index++] = WGPUFeatureName_TextureCompressionASTC;
}
if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_Float32Filterable)) {
+ SOKOL_ASSERT(cur_feature_index < _SAPP_WGPU_MAX_REQUESTED_FEATURES);
requiredFeatures[cur_feature_index++] = WGPUFeatureName_Float32Filterable;
}
+ #undef _SAPP_WGPU_MAX_REQUESTED_FEATURES
WGPUDeviceDescriptor dev_desc;
_sapp_clear(&dev_desc, sizeof(dev_desc));