google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Home Page:https://google.github.io/filament/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OStream mutex addition breaks managed code (C++/CLI) compilations.

BStringhamVRSK opened this issue · comments

Discussed in #5329

Originally posted by BStringhamVRSK March 17, 2022
@pixelflinger @prideout @bejado
We are using Filament in a C# managed code environment. std::mutex is not supported when C++ code is compiled with the /clr flag. Because the std::mutex declaration appears in the include header file, it breaks our builds.

There are two ways forward that I can see:

  1. Move the mutex into ostream.cpp as a global. That means all ostream instances will share the same mutex. PROS: This is probably the simplest change. CONS: This could have some impact on performance, but I don't know if it's a meaningful difference.
  2. Create an interface for ostream. That would require also creating a "factory" function to create ostream instances, rather than using the new operator. PROS: ostream would continue to work as before. CONS: Breaks any code currently using "new ostream()"

Any other thoughts or suggestions on this?
I can do the programming changes, but I'd like to hear the code owners' opinions before diving in.

I think maybe another solution would be to use a pImpl pattern. This would be fine for ostream as it's not performance critical. All the private gunk could go into the cpp.

let us know how it goes.