KeenSoftwareHouse / SpaceEngineers

2.94k stars 894 forks source link

Fix your performance, c# vulkan api #556

Open ericwomer opened 8 years ago

ericwomer commented 8 years ago

Here is a suggestion, I don't know where else to put it, but here it is. https://github.com/mono/VulkanSharp

PsychoNineSix commented 8 years ago

Vulkan is really good, but it would also take a lot of work. Just depends on if the increase is worth the time put in. Unless us dev-gamers collab and put a lot of effort in (which i don't see happening to be honest)

Even though I don't expect it, it'd be good to at least be considered by the devs!

AlonzoTG commented 8 years ago

killie01 wrote:

Vulkan is really good, but it would also take a lot of work. Just depends on if the increase is worth the time put in. Unless us dev-gamers collab and put a lot of effort in (which i don't see happening to be honest)

Even though I don't expect it, it'd be good to at least be considered by the devs!

Vulkan is the future. It opens all operating systems and all devices to Space Engineers and provides a portable interface to GPU compute too.

I've been following the development of a C# binding library for Vulkan.

My only issue right now is that the interface to your renderer is a bit opaque because it is split among like ten different classes. Is there a way to collect all the sub-interfaces and generate a requirements document for what the renderer needs to do? if so, I'd be chomping at the bit to try to write it myself. Not that I know anything whatsoever. =P

IQ is a measure of how stupid you feel.

Powers are not rights.

aaronfranke commented 8 years ago

+1 Vulkan. It's worth the effort for sure.

malware-dev commented 8 years ago

You probably don't realize it, but you're practically saying "ditch the game and start all over".

This is not a feasible action.

Not to mention the fact that rendering isn't the problem of SE.

g4borg commented 8 years ago

I would not say, replacing a rendering system is ditching the game. If it is that hard to do, it might even need that kind of rewrite. I do agree, if they would make a opengl port, they should probably go straight for vulkan. Considering however, there is no other game engine really offering it right now (just on roadmap in unity), and some parts of vulkan being still under construction, and the state of other parts of SE code, much more important stuff, being incomplete, I do agree it is a bit much to ask right now, especially since I also agree, that rendering is not really the main issue atm. Of course vulkan would mean, increasing chances of a port to non-windows, so I don't think rendering performance is the issue behind the request.

To be honest, scanning the code for the rendering code and summarizing all needed functionality and it's equivalent functions from dx to vk is something someone could already do for Keen, rather than directly starting a port; Collecting such information is much more work, than the actual implementation, usually.

malware-dev commented 8 years ago

Seeing how much time it took to convert from DX9 to DX11, how much time would you think it would take to replace the entire renderer, every shader, every piece of code that uses DX?

Plus the time needed to learn a completely new API.

This won't happen. Far too expensive compared to gains. Simply not worth it.

aaronfranke commented 8 years ago

You're right that it would be a lot of work, but it's work that needs to be done, because it reflects a more underlying issue. At the moment, SE is very poorly internally designed - pieces of code are tied to many others, and a failure in one area will cause other failures too. This is the primary reason that there are so many bugs and why every update seems to be one step forward two steps back. This is the reason why it took so long to change to DX11 and is why every mod had to be re-written, which is really stupid, mods should be renderer-independent. This is why I've had SE crash on me when I plug headphones into my computer - the audio code failing in no way should crash the rest of the game, at worse I'd expect no sound.

malware-dev commented 8 years ago

The renderer itself is separate. That's not the issue. I have quite a lot of experience working with the source code (I'm the guy who wrote the new ingame script compiler, for instance).

The reason why mods had to be redone is because of shaders. This can't be abstracted away without writing a completely new shader language that gets translated to whatever the target platform is. That takes way too much time and effort for something that will rarely change.

Mods break because the game is being developed. Bugs occur because the game is being developed. This is just par for the course, won't change and can't change. This is the price for playing and/or modding an early access game. From how you write, I believe you already know this.

Problem is, reality rarely reflects the ideal, unfortunately. You're describing an utopia that simply isn't possible to live up to. Yes, I agree, the SE framework is poorly designed. Absolutely. But it's way too late to do something about that now. It will simply be too expensive, and it will introduce all new bugs. It really would be easier to scrap SE and start over - something they simply aren't going to do.

g4borg commented 8 years ago

Seeing how much time it took to convert from DX9 to DX11, how much time would you think it would take to replace the entire renderer, every shader, every piece of code that uses DX?

This can't be abstracted away without writing a completely new shader language that gets translated to whatever the target platform is.

On a sidenote (sry), I do agree that the investment might be too heavy in time and work, even if I don't see it drastic (maybe because I am not involved, but sometimes being too involved also clouds the horizon). Also it should be seen as a separate VRage development, not just SE development, anyway. But the shaders made me a bit curious, as to be honest, all shaders in unity are written in HLSL and compiled by either dx or opengl, so such an "unified shading solution" already seems possible to create, seems to just need a lot of know-how.

aaronfranke commented 8 years ago

That's a good point, if Keen is serious about licensing out Vrage, Vulkan support would make it much more attractive.

minecrawler commented 7 years ago

On a side-note for an old thread (since I prefer Linux gaming, so Vulkan would be very welcome): Vulkan uses the SPIR-V binary shader format. You can literally use any language to write the shaders (even C#) and then just compile and ship them. There is no need to rewrite any shader code at all. The much greater issue is the compiler, which at the moment seems to be quite young and maybe not too mature, concerning HLSL at least.

Apart from the shader, I think it is quite important to first evaluate the gains. Is the game CPU-bound? Does it use many threads, but not efficiently enough because of the renderer? Are there core features which might have considerable performance and efficiency hits without Vulkan?

D3D12 and Vulkan are improvements over older technology, but that does not mean that the latest tech is needed to have a smooth and fulfilling game experience! I also enjoy playing quite old games (like Spellforce 1, The Settlers 5, Gothic 2, etc.), because they are fun. They certainly do not need Vulkan to be good.

I have not taken a look at those metrics, but that's the stuff I would investigate, first. One does not even need to be a developer to collect a few stats about the game's run-time behavior

Project579 commented 7 years ago

Well using Vulkan would not bring the game to Linux anyway because C# only officially runs on windows. There are projects that are trying to create a .NET Framework for Linux anyway.

minecrawler commented 7 years ago

Microsoft opensourced the .NET core long ago to foster its spread to other platforms and project Mono is very stable. If the developers of this game decide that they will officially support Mono on Linux (or Wine, as many big studios sometimes do), then the game will officially be supported on Linux. No need for Microsoft on Linux ( please NO! Don't let them touch Linux D: )

aaronfranke commented 7 years ago

Vulkan is an improvement for everyone. Even if Keen never brings SE to Linux, you still have better Windows performance and better Wine compatibility.

Project579 commented 7 years ago

Vulkan isn't a direct improvement at all because, first of all the shaders would need to be recreated witch will cause a very serious change in the game it might run better or not run at all. The real advantages of vulkan are at low level which means they will need to redo their entire renderer to actually get the performance improvent that Vulkan can offer and that requires a lot of a work and testing. In the end is far better to start over but that obviosly cannot be done with Space Engineers due to the fact that the game is practically already realease.

Spartan322 commented 7 years ago

An OpenGL port would be difficult enough, (with slim gain) a Vulkan port is out of the question. (with also slim gain) Shaders would need to be reworked entirely, all rendering code and anything relating to that code would have to be dumped. And Vulkan is low level, so a majority of the stuff you can ignore in OpenGL and DirectX has to be redone in Vulkan. If Keen really wanted to do Vulkan/OpenGL in the future on anything, the only possible way to manage it is to plan it for the engine in the future, (likely near the bottom of the priority list) and probably never bother with porting the games before.

And lets not forget, if you screw up messing with any of the lower level stuff, you may never gain anything in terms of performance anyway.

arch-user-france1 commented 3 years ago

Well using Vulkan would not bring the game to Linux anyway because C# only officially runs on windows. There are projects that are trying to create a .NET Framework for Linux anyway.

You can use proton and protontricks of course for .net

arch-user-france1 commented 3 years ago

Microsoft opensourced the .NET core long ago to foster its spread to other platforms and project Mono is very stable. If the developers of this game decide that they will officially support Mono on Linux (or Wine, as many big studios sometimes do), then the game will officially be supported on Linux. No need for Microsoft on Linux ( please NO! Don't let them touch Linux D: )

Linux has more performance. I've got 100MB/s download on steam. On Windows just 40-50MB/s Also cpu is better utilized on Fedora (but Ubuntu21.04 is just too laggy to play the game I left Ubuntu I don't want it)

Spartan322 commented 3 years ago

You can use proton and protontricks of course for .net

Sure, not really any reason to bring it up in the issues though since its offtopic.

Linux has more performance. I've got 100MB/s download on steam. On Windows just 40-50MB/s Also cpu is better utilized on Fedora (but Ubuntu21.04 is just too laggy to play the game I left Ubuntu I don't want it)

While in my general experience, and as a devoted Linux-only user nowadays this is mostly true, (kernel version, drivers, GPU, installed daemons, and more playing each a role) this is not all that relevant either, you didn't need to necro this. Also this has no bearing on the issue of a Vulkan port.