Skip to content

Commit

Permalink
sokol_gfx.h mtl: allow binding multisampled textured
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 16, 2024
1 parent 2c6fc74 commit b4bcec6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -3948,6 +3948,7 @@ typedef struct sg_frame_stats {
_SG_LOGITEM_XMACRO(VALIDATE_ABND_EXPECTED_IMAGE_BINDING, "sg_apply_bindings: image binding is missing or the image handle is invalid") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_IMG_EXISTS, "sg_apply_bindings: bound image no longer alive") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_IMAGE_TYPE_MISMATCH, "sg_apply_bindings: type of bound image doesn't match shader desc") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_EXPECTED_MULTISAMPLED_IMAGE, "sg_apply_bindings: expected image with sample_count > 1") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_IMAGE_MSAA, "sg_apply_bindings: cannot bind image with sample_count>1") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_EXPECTED_FILTERABLE_IMAGE, "sg_apply_bindings: filterable image expected") \
_SG_LOGITEM_XMACRO(VALIDATE_ABND_EXPECTED_DEPTH_IMAGE, "sg_apply_bindings: depth image expected") \
Expand Down Expand Up @@ -12607,7 +12608,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_
// initialize MTLTextureDescriptor with MSAA attributes
_SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt_msaa(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) {
SOKOL_ASSERT(img->cmn.sample_count > 1);
mtl_desc.usage = MTLTextureUsageRenderTarget;
mtl_desc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
mtl_desc.resourceOptions = MTLResourceStorageModePrivate;
mtl_desc.textureType = MTLTextureType2DMultisample;
mtl_desc.sampleCount = (NSUInteger)img->cmn.sample_count;
Expand Down Expand Up @@ -17238,7 +17239,10 @@ _SOKOL_PRIVATE bool _sg_validate_apply_bindings(const sg_bindings* bindings) {
_SG_VALIDATE(img != 0, VALIDATE_ABND_IMG_EXISTS);
if (img && img->slot.state == SG_RESOURCESTATE_VALID) {
_SG_VALIDATE(img->cmn.type == shd->cmn.images[i].image_type, VALIDATE_ABND_IMAGE_TYPE_MISMATCH);
_SG_VALIDATE(img->cmn.sample_count == 1, VALIDATE_ABND_IMAGE_MSAA);
// _SG_VALIDATE(img->cmn.sample_count == 1, VALIDATE_ABND_IMAGE_MSAA);
if (shd->cmn.images[0].multisampled) {
_SG_VALIDATE(img->cmn.sample_count > 1, VALIDATE_ABND_EXPECTED_MULTISAMPLED_IMAGE);
}
const _sg_pixelformat_info_t* info = &_sg.formats[img->cmn.pixel_format];
switch (shd->cmn.images[i].sample_type) {
case SG_IMAGESAMPLETYPE_FLOAT:
Expand Down

0 comments on commit b4bcec6

Please sign in to comment.