]> git.tdb.fi Git - libs/gl.git/commitdiff
Make FrameAttachment capable of distinguishing RGB and BGR formats
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 15:00:49 +0000 (17:00 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 14 Nov 2021 09:47:47 +0000 (11:47 +0200)
source/core/frameformat.cpp
source/core/frameformat.h

index 649693a43715a94b02974501148b21e4bc576592..d80fca3d4bbacc419d7680b36fced8b83e7092cf 100644 (file)
@@ -85,7 +85,7 @@ FrameAttachment make_typed_attachment(FrameAttachment fa, PixelFormat pf)
        }
 
        DataType type = get_component_type(pf);
-       return static_cast<FrameAttachment>((fa&0xFC00) | (is_float(type)*0x100) | get_type_size(type)<<4 | get_component_count(comp));
+       return static_cast<FrameAttachment>((fa&0xFC00) | (is_float(type)*0x100) | get_type_size(type)<<4 | ((comp&0x20)>>2) | get_component_count(comp));
 }
 
 FrameAttachment make_indexed_attachment(FrameAttachment fa, unsigned i)
@@ -108,7 +108,7 @@ PixelFormat get_attachment_pixelformat(FrameAttachment fa)
        else if(get_attach_point(fa)==get_attach_point(STENCIL_ATTACHMENT))
                comp = STENCIL_INDEX;
        else
-               comp = static_cast<PixelComponents>(fa&7);
+               comp = static_cast<PixelComponents>((fa&7) | (fa&8)<<2);
 
        DataType type;
        if(fa&0x100)
index 4662ae8f9d2d02ec8aebe576532f13e932d67ed8..c55a0f303b269a2d495d29be5cd3354bf4a3e06b 100644 (file)
@@ -13,8 +13,9 @@ of the attachment point and the format of the attached texture.
 
 The values are bitfields laid as follows:
 
-nnnn nn_f _sss _ccc
-      │ │    │    └╴Number of components
+nnnn nn_f _sss rccc
+      │ │    │ │  └╴Number of components
+      │ │    │ └───╴Reverse order flag
       │ │    └─────╴Size of one component
       │ └──────────╴Floating-point flag
       └────────────╴Attachment index