Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Windows build #11

Open
Superbelko opened this issue Feb 29, 2020 · 8 comments
Open

Basic Windows build #11

Superbelko opened this issue Feb 29, 2020 · 8 comments

Comments

@Superbelko
Copy link

Sorry for not going normal fork-PR procedure. But if you insist I can do it that way.

So, anyway. In order to build on Windows you need to handle dependencies with dub and handle platform init.

dub.json - split 'posix' deps (these are your current deps) and 'windows' deps (also note you have bxRelease two times, which is probably a type or copy paste error)

	"libs-posix": [
		"SDL2", "SDL2_image",
		"bgfxRelease", "bxRelease", "bimgRelease",
		"stdc++", "GL", "x11", "bxRelease",
	],
	"libs-windows": [
		"SDL2", "SDL2_image",
		"bgfxRelease", "bxRelease", "bimgRelease",
	],

However this is not enough, LDC will happily tell you that unreachable code is detected in file
source\serpent\graphics\pipeline\bgfx\pipeline.d somewhere inside integrateWindowBgfx() function.

Let's fix this, and while we are here let's also change platform handling to proper static assert which will clearly state the problem and give a hint to potential devs what they should do before they can build and use it.

source\serpent\graphics\pipeline\bgfx\pipeline.d

    final void integrateWindowBgfx() @system
    {
        // ...
        version (Posix)
        {
            // ... 
        }
        else version (Windows)
        {
            pd.nwh = wm.info.win.window;
        }
        else
        {
            static assert(0, "Unsupported platform");
        }
        // ...
    }

Assuming you've already build SDL2, SDL2_Image and bgfx libraries and placed them inside that same folder(a hacky solution for now) you will be able to build demo scene project like the one on a repo page.

@ikeycode
Copy link
Collaborator

ikeycode commented Mar 6, 2020

bxRelease was actually repeated due to linkage issues :) I'll implement the bits I can, but I can't validate as I haven't got Windows >_> - Thanks bud

@ikeycode
Copy link
Collaborator

ikeycode commented Mar 6, 2020

FWIW I know some stuff is going to fail on paths so I'll preempt some of that

ikeycode added a commit that referenced this issue Mar 6, 2020
In older toolchain versions (Ubuntu) we had to present bxRelease.a twice
to satisfy linking. It appears to be solved now. Thanks for heads up in
issue #11.

Signed-off-by: Ikey Doherty <[email protected]>
ikeycode added a commit that referenced this issue Mar 6, 2020
Contribution is from @Superbelko per issue #11, as we begin to add some
initial Windows support. We'll need to improve our library configuration
and ensure we're not directly accessing POSIX specific paths anywhere,
which we probably are because stuff is still hacky.

Signed-off-by: Ikey Doherty <[email protected]>
ikeycode added a commit that referenced this issue Mar 6, 2020
For POSIX APIs we currently expect X11 linkage, which isn't present on
a Windows build. Eventually we'll make this a Linux-X11 specific target
as we're planning for macOS, and Wayland on Linux.

This is a contribution from @Superbelko per issue #11 to start being a
bit more portable for Windows.

Signed-off-by: Ikey Doherty <[email protected]>
ikeycode added a commit that referenced this issue Mar 6, 2020
Just use enforce, we're looking at fatal errors here, so there is no
sense in our custom weird exception handling right now. This is due to
cleanups per issue #11.

Signed-off-by: Ikey Doherty <[email protected]>
@ikeycode
Copy link
Collaborator

ikeycode commented Mar 6, 2020

Some initial changes now in

@ikeycode
Copy link
Collaborator

ikeycode commented Mar 6, 2020

We're gonna need to figure out compilation of shaders on Windows too which will be fun..

@Superbelko
Copy link
Author

Ok, tried it again, and there is some issues with coordination of things. Paths and other stuff isn't uniform right now, there is discrepancies in behavior between prepare-shaders.d and .sh variants and some other little nasty things.

I see there is plans to use google shaderc instead bgfx one, but anyway, for some reason script uses plain shaderc name while bgfx built version adds suffixes like 'Release' and 'Debug'.

So I got the exception about world context manager assets/World doesn't exists, adding empty folder solved this.

After all manipulations it worked as before.
But for now I assume it is better just to wait until things settle up a bit and demo game is extracted to the separate repo.

@ikeycode
Copy link
Collaborator

ikeycode commented Mar 7, 2020

Aye, I'm in the process of deprecating the current scripts in favour of prepare-shaders.d.
Note that our builds use the serpent-support repo which expects certain filenames, as there just isn't really a convention for bgfx builds.

I need to fix some bugs in the repo so that the demo-rpg repo can build against this repo and benefit from the internal shaders, which means we won't need to load any files in the core, helping with portability and startup speed a lot.

Primarily our focus is Linux, so we need to be able to correctly link against the system libraries and runtime stuff like bgfx. Eventually we expect Serpent games to bundle minimal requirements such as bgfx and the LDC runtime, to run correctly everywhere. Unfortunately bgfx has no release process, no versioning and no SONAME, so we're having to jimmy the whole lot together.

prepare-shaders.d will precook the shaders into a built/ path ready for import. We're also planning #12 to do shader caching too, so there is a lot of work going on in the 'make shaders not suck' department. Eventually all that will exist in assets/ is the shader source.

ikeycode added a commit that referenced this issue Mar 7, 2020
We're moving to `prepare-shaders.d` which does the work of precompiling
shaders for us. Thus, kill the hacky confusing script now.

Signed-off-by: Ikey Doherty <[email protected]>
ikeycode added a commit that referenced this issue Mar 7, 2020
Signed-off-by: Ikey Doherty <[email protected]>
ikeycode added a commit that referenced this issue Mar 7, 2020
@Superbelko
Copy link
Author

Hi, sorry for bothering again.

But this has to be capitalized. Only 'linux' one is all lower case for some historical reasons, all the rest version identifiers names are capitalized (ok, iOS is funky too).[1]
https://github.com/lispysnake/serpent/blob/master/scripts/prepare-shaders.d#L59

[1] https://dlang.org/spec/version.html#predefined-versions

@ikeycode
Copy link
Collaborator

Derp, my bad sorry. don't mind the the bothering it helps me :D

ikeycode added a commit that referenced this issue Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants