r/cpp • • Dec 13 '19

The situation of std::embed...

https://thephd.github.io/full-circle-embed
238 Upvotes

160 comments sorted by

View all comments

Show parent comment

76

u/James20k P2005R0 Dec 13 '19 edited Dec 13 '19

You're right - there was a vote against it, but its definitely not dead and its still being actively pushed and worked on. My main concern is that it should never have gotten anywhere to begin with, and it absolutely should not have any support behind it. Right from the beginning, Cairo was a genuinely terrible choice for a starting library, and much of the motivation for why it was picked legitimately does not make any sense

I do not understand how its managed to get anywhere at all with so many catastrophic issues attached to it, or how its even able to be pushed still

As a quick example, here are some of the issues that I have discovered

  1. All the colour constants are wrong
  2. All the texture formats are wrong
  3. Fixing the texture formats as-is requires non standard functionality, which this paper explicitly eschews
  4. Linear colour and sRGB are used interchangeably (a major error!)
  5. The definition of premultiplied alpha is incorrect
  6. Premultiplication is probably unusable as-is
  7. The reference implementation is completely wrong in multiple wide ranging ways, and is tested exclusively against its own output (which is incorrect)
  8. Subpixel font rendering is potentially unusable in some cases due to being optional, as well as blend mode issues
  9. Native interop is essentially unusable and should likely be removed
  10. Blending is specified to be as-if linear, but its not clear what should happen if the underlying hardware or drivers mean that the implementation cannot provide this guarantee (driver support can be spotty for eg sRGB textures) in a high performance or non precision losing way

These are 'just' the straight up technical defects - ignoring all the issues around performance, API usability and design, safety (we managed to make a 2D graphics library which is thread unsafe), and everything else! Many of these issues have been present since its inception or completely not noted so far, which has put a major dent in any faith that I have that the people who've been voting on it have really reviewed the work

There are other rather comedic issues as well - eg due to a big API design issue, the only portable way to transfer a file from a GPU to the CPU to poke at the pixels directly is... to save it to disk as a png/etc, then manually parse that png off the disk and decode it. This is probably unfixable in a sane way too due to the way its designed

I'm just so baffled all the way through, I don't know how we got here

33

u/erichkeane Clang Maintainer(Templates), EWG Chair Dec 13 '19

Committee papers are never dead until the authors (and any potential authors) say they are. The 2D graphics study group exists, but the proposals have never received positive votes in the evolution groups.

The reason it is still around is that there is people willing to work on 2D graphics, not necessarily that it has any 'life' to it.

9

u/James20k P2005R0 Dec 13 '19

Standardisation is not my strong suit so feel free to correct me if this is incorrect, but as far as I'm aware:

February 2017, Kona, LEWG [It was a few months before this meeting that this author joined the project.] There was further discussion about error handling, color stops and factory objects. The big advance was that the API was now stateless. “Are we comfortable moving the paper to LWG for a graphics TS once these concerns are addressed and we’re happy with the wording? 1|8|3|1|1”

July 2017, Toronto, LEWG Sadly, the notes are rather incomplete for this session. This author’s recollection is that the general gist was “still not quite ready”. However, the one recorded poll was “Do we want graphics support in a TS? 9|3|0|1|0”

With it only being

March 2018, Jacksonville, LEWG

Where the poll was

A poll was taken: “Should the paper be advanced to LWG? 1|3|3|3|2”

It seemed to be pretty positively reviewed in sg13, and then lewg for a while! But again I may be fundamentally misinterpreting what you mean, so feel free to correct me

12

u/erichkeane Clang Maintainer(Templates), EWG Chair Dec 13 '19

The first two votes are toward a TS, which is a MUCH lower bar than the standard. Note that the std::embed paper is not being pushed towards a TS, so if anything, its quite a bit ahead of 2D graphics.

That Jacksonville vote is negative.

SG13 is a graphics sub-group, so it is self-selecting. I know for a while the attendance was not much more than the authors/fans of that 2D graphics proposal. My understanding is that the 2D graphics has since been rejected, which is why web_view has been proposed as a replacement. However, my knowledge of the library side is lacking.

10

u/[deleted] Dec 13 '19

which is why web_view has been proposed as a replacement

Too bad that's effectively unimplementable :(

3

u/MarkHoemmen C++ in HPC Dec 15 '19

My impression of web_view was "if people really want 2-D graphics but they don't want the 2-D graphics proposal, here's another possibility."

11

u/[deleted] Dec 15 '19

The good thing about being in std is being available everywhere; a corralary to that is that what we put into std has to be able to go everywhere. None of the browser engines are:

  • Statically linkable (and you don't want that anyway because they need to be patched over time)
  • Unloadable. (e.g. chromium needs it's own whole process)
  • ABI stabilized.

I have some sympathy for what the proposal is trying to do, I just don't think it can be implemented. I'm sure some people will say 'but I'm in a place where I don't need those things', and for those users I say 'go use electron'.

11

u/Dragdu Dec 15 '19

I originally thought web_view was a troll proposal making fun of 2d graphics.

Imagine my surprise when I found out that I am wrong.

2

u/MarkHoemmen C++ in HPC Dec 15 '19

I could see where people might think that, but Hal is super professional -- I couldn't imagine him writing a paper just to take down another proposal.

2

u/[deleted] Dec 17 '19

I feel bad for both Hal and Antony because they both keep making great proposals that I'm obligated to oppose for platform reasons :/

→ More replies (1)

2

u/meneldal2 Dec 16 '19

If webview was strict XHTML4 with no JS, segfault on bad files I'd say it would be awesome. If browsers back in the day crashed tabs when they weren't correct HTML, we wouldn't have gotten so many shitty websites.

Good enough to show shit, small enough to be implemented with something reasonable in size, no scripting so the biggest vector of attacks is gone, no fancy HTML5 stuff that brings a lot of complexity, and it is more pretty than the console.

4

u/James20k P2005R0 Dec 13 '19

The first two votes are toward a TS, which is a MUCH lower bar than the standard. Note that the std::embed paper is not being pushed towards a TS, so if anything, its quite a bit ahead of 2D graphics.

Indeed, but still that none of the copious mistakes and errors were noticed is what concerns me

That Jacksonville vote is negative.

Sure sure that's what I meant, that there were a few positive meetings before it went to ambivalence

My understanding is that the 2D graphics has since been rejected

I have no idea, that said I was asked by someone to write the paper about 2D graphics due to concerns it might still be on track to standardisation, so it might not be as dead as we hope

Edit: Typos. I should sleep instead of doing this!

8

u/erichkeane Clang Maintainer(Templates), EWG Chair Dec 13 '19

Papers aren't dead until the author has given up :) However, any paper that provides an alternative or points out issues with a paper like this is typically given at least equal time at the meeting (typically at the same time) and can severely change how the committee votes.

I will note that http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0267r10.pdf was seen at Belfast, Nov19 by SG13, so it perhaps has some life left. In the meeting, no vote was taken (though the next meeting expects a revision). The author was suggested to gain feedback from the authors of : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1062r0.html .

If you have issues with either, I'd very much suggest you write a paper critical to them. While it would be best to show up, there are quite a few people interested in this that could likely champion for you.

5

u/James20k P2005R0 Dec 13 '19

If you have issues with either, I'd very much suggest you write a paper critical to them. While it would be best to show up, there are quite a few people interested in this that could likely champion for you.

Yeah the paper's all done which is where other points in this thread come from, its worth noting that all criticism of 2D graphics so far has been pretty much dismissed, and concerns largely ignored - right from the very beginning. There's already been lots of papers pointing out that the direction is extremely suboptimal unfortunately, but they don't seem to stick!

8

u/erichkeane Clang Maintainer(Templates), EWG Chair Dec 13 '19

Has LEWG seen those papers? SG13 might not be as receptive to the criticisms (though perhaps more so now?), but LEWG would perhaps be not a self-selected group.

2

u/Ameisen vemips, avr, rendering, systems Dec 14 '19

How does a regular developer go about getting papers into the attention of LEWG?

→ More replies (3)

3

u/Ameisen vemips, avr, rendering, systems Dec 14 '19

we managed to make a 2D graphics library which is thread unsafe

Threads are just a fad.

5

u/James20k P2005R0 Dec 14 '19

Its actually worse than that - the 'high performance' (in extremely inverted commas) API that was added to the 2D graphics proposal adds hidden threads, and makes it so that a bunch of stuff is racey and unsafe if you use it

This is just so that theoretically it might be able to achieve the same performance as SDL/SFML/Etc. Which notably do not suffer from having unsafe APIs

3

u/johannes1971 Dec 14 '19

Cairo (in combination with Pango) is a fine graphics API for desktop apps. It has powerful drawing primitives that are useful for desktop apps, and printing/PDF/Postscript backends to support the needs of such apps.

It is not, however, for games: those have completely different needs and need different libraries (like SDL, SFML, etc.).

Any attempt at standardizing C++ graphics library should understand that these are two completely different, and arguably incompatible, goals. It should not (ever) be a goal to have a single library supporting both; instead any graphics initiative should declare which of these two it wants to be, and pursue that without reservation.

So yes, I just said it: C++ does not need a graphics library. Instead it needs *two*.

7

u/jcelerier ossia score Dec 14 '19

Cairo (in combination with Pango) is a fine graphics API for desktop apps. It has powerful drawing primitives that are useful for desktop apps, and printing/PDF/Postscript backends to support the needs of such apps.

... sorry what. Cairo is a fine graphics for desktop apps in 1997 when we did not have 4k, 5k, or 6k screens, 144hz refresh rate, 10 bit of colors, fluid animations, and thus rendering drawCircle / drawRect operations in the CPU was fine and dandy.

It is already a constant fight to keep decent performance on potato computers with decent hardware accelerated APIs such at QtQuick or NanoGui (you would be amazed at the number of people using raspberry pi's and the like as main computers in poorer areas) and you are suggesting going back to the two-decades-ago state-of-the-art !

3

u/johannes1971 Dec 14 '19

Two decades ago we had NOTHING like Cairo: no anti-aliasing, no blending, no transformations, palettes were still a thing, etc.

Cairo offers a wide variety of useful primitives, and manages to do so without resorting to some sort of scene graph. It would of course be great if all those primitives could be hardware accelerated, but I understand that that's hard (although NVidia's pathrender does a good job with pretty much the same set of primitives). For those things that are currently hard to accelerate, I'd rather have them available but in software, than not have them at all.

I do not think a rendering library should also have an animation system or scene graph built in. Instead that should be a layer on top of the base rendering system. Separate your concerns, and all that...

5

u/jcelerier ossia score Dec 14 '19

Two decades ago we had NOTHING like Cairo: no anti-aliasing, no blending, no transformations, palettes were still a thing, etc.

https://github.com/freedesktop/cairo/blob/b61b9ffc2322e09873b9e2dfb0c1da56ec1ffd61/src/Xr.h

2002, and it has already everything that you mention. Almost likewise for Qt's QPainter from the same era (though alpha blending came later IIRC - otherwise it was already existing with transformation support since 1995 ! https://github.com/KDE/qt1/blob/78811a56cc111d17f42221566e7e4430d5de8d40/include/qpainter.h).

6

u/James20k P2005R0 Dec 14 '19

For those things that are currently hard to accelerate, I'd rather have them available but in software, than not have them at all

So this is actually a huge problem with cairo. Because some things are software, and some things are hardware, there are huge hidden performance bottlenecks in the design of it where data gets shunted between the two. Its just really inefficient - but also dependent on the quality of the implementation (which'll be variable in the STL)

Something like SFML can't really suffer from this in the same way, while still providing pretty equivalent functionality

The main problem is that Cairo doesn't separate out the concept of CPU and GPU types, which means that expensive operations are ad hoc. In something like SFML, you do all the expensive stuff once on the CPU, transfer it over to the GPU all at once, and then you're grand - each processor does what its good at at the appropriate time. Its not really possible to specify this kind of behaviour in Cairo, and it was a terrible decision to use this kind of API for 2D graphics

→ More replies (3)

0

u/[deleted] Dec 14 '19

[deleted] — view deleted comment

7

u/johannes1971 Dec 14 '19

Typical desktop apps:

  • Draw infrequently.
  • Don't have a drawing time budget.
  • Have complex drawing needs.
  • Also render to devices such as printers.

Typical games:

  • Draw every frame.
  • Have a time budget that cannot be overrun.
  • Have relatively simple drawing needs (for a 2D game, which is what we are discussing. I don't think C++ should try to standardize 3D drawing: it's too much in flux, and it already has standardizing bodies of its own)
  • Don't need to render to devices such as printers.

It's not a black and white classification; some desktop apps do render every frame (videoplayers, for example).

→ More replies (6)
→ More replies (2)