raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
88 stars 23 forks source link

Raysect for Windows? #269

Open Gjacquenot opened 5 years ago

Gjacquenot commented 5 years ago

I have tried to compile raysect for Windows with appveyor, by just adding a appveyor.yml file at root of the project

After tiny changes in the code, I have succeeded in launching compilation.

Compilation runs fine till the call to this function:

https://github.com/raysect/source/blob/986ff4320bd0a00f2a0756455cb36c539d8e915f/raysect/optical/observer/pipeline/rgb.pyx#L495

Error can be seen here , with this weird message: can't cast a typeA to typeA.

raysect\optical\observer\pipeline\rgb.c(11871): error C2440: 'type cast': cannot convert from '__pyx_ctuple_double__and_double__and_double' to '__pyx_ctuple_double__and_double__and_double'

Disabling the call to this function allows to build successfully the code. (So there is one tiny little change to do to have a Windows version).

Can someone have a look at this call? Could the following function be refactored by using 3 scalar parameters instead of a tuple of three double?

rgb_pixel = ciexyz_to_srgb(
    xyz_image_mv[ix, iy, 0],
    xyz_image_mv[ix, iy, 1],
    xyz_image_mv[ix, iy, 2]
)
Gjacquenot commented 5 years ago

Adding the following functions in source/raysect/optical/colour.pxd with their corresponding implementations in colour.pyx, one can compile source/raysect/optical/observer/pipeline/rgb.pyx with MSVC.

cpdef double ciexyz_to_srgb_r(double x, double y, double z)
cpdef double ciexyz_to_srgb_g(double x, double y, double z)
cpdef double ciexyz_to_srgb_b(double x, double y, double z)

@CnlPepper , @mattngc : would you be interested in such a patch to compile with windows?

CnlPepper commented 5 years ago

Hi @Gjacquenot, thanks for your interest. So far we haven't supported windows due to Raysect's heavy use of multiple processes to render using all the available processor cores.

Multiprocessing on windows has a few issues, the largest being that each process in windows requires a full copy of the memory of the main process - this would heavily limit the ability to perform large, complex renders. Under linux forking a process doesn't use any additional memory which makes the system more scalable. It could be made to run but it might not be as useful or efficient as it is under linux.

If you just want to use a single core, Raysect should already function under windows if it has compiled. You'd need to switch the observers to use the SerialEngine as the render engine: https://github.com/raysect/source/blob/986ff4320bd0a00f2a0756455cb36c539d8e915f/raysect/core/workflow.py#L95 It would be slow, but should work.

If you do make the changes necessary to run raysect on windows (the hardest will be in the workflow.py linked above) and it runs stably, we'd be happy to look into merging those changes.

Gjacquenot commented 5 years ago

Thanks for your answer, @CnlPepper .

I understand your point of view. For time being, I succeed in compiling the code.

I have experienced the multiprocessing problems, while running a demo.

I will try to switch the observers and keep you informed.

mattngc commented 5 years ago

@Gjacquenot, there is some example code for the RenderEngines in the documentation here:

https://raysect.github.io/documentation/api_reference/core/render_engines.html#raysect.core.workflow.SerialEngine

You should be able to get everything working with the SerialEngine, it just won't be as performant without the multi-processing.