Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GH Action committed May 13, 2024
1 parent beff18b commit 0b2587f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
18 changes: 15 additions & 3 deletions src/sokol/c/sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -5765,16 +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
// FIXME: ASTC texture compression
if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_TextureCompressionBC)) {
SOKOL_ASSERT(cur_feature_index < _SAPP_WGPU_MAX_REQUESTED_FEATURES);
requiredFeatures[cur_feature_index++] = WGPUFeatureName_TextureCompressionBC;
} else if (wgpuAdapterHasFeature(adapter, WGPUFeatureName_TextureCompressionETC2)) {
}
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));
Expand Down
19 changes: 15 additions & 4 deletions src/sokol/c/sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6483,6 +6483,12 @@ _SOKOL_PRIVATE void _sg_pixelformat_sr(_sg_pixelformat_info_t* pfi) {
pfi->render = true;
}

_SOKOL_PRIVATE void _sg_pixelformat_sfr(_sg_pixelformat_info_t* pfi) {
pfi->sample = true;
pfi->filter = true;
pfi->render = true;
}

_SOKOL_PRIVATE void _sg_pixelformat_srmd(_sg_pixelformat_info_t* pfi) {
pfi->sample = true;
pfi->render = true;
Expand Down Expand Up @@ -13756,10 +13762,15 @@ _SOKOL_PRIVATE void _sg_wgpu_init_caps(void) {
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]);
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]);

// FIXME: can be made filterable with extension
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32F]);
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32F]);
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32F]);
if (wgpuDeviceHasFeature(_sg.wgpu.dev, WGPUFeatureName_Float32Filterable)) {
_sg_pixelformat_sfr(&_sg.formats[SG_PIXELFORMAT_R32F]);
_sg_pixelformat_sfr(&_sg.formats[SG_PIXELFORMAT_RG32F]);
_sg_pixelformat_sfr(&_sg.formats[SG_PIXELFORMAT_RGBA32F]);
} else {
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32F]);
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RG32F]);
_sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_RGBA32F]);
}

_sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH]);
_sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL]);
Expand Down

0 comments on commit 0b2587f

Please sign in to comment.