Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Get the player's machine specifications in C#(CPU, RAM, DX, GPU, ARCHITECTURE, OS)

Discussion in 'Scripting' started by MikeyJY, May 28, 2023.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I want to make a system for my game that based on how performant player's machine creates and automatic graphics/quality options set that balances rendering speed and beautifulness of the scene.

    For example:
    Code (CSharp):
    1. public string ramGB = System.something.how_many_ram_are_there;
    2. public string CPU = System.something.what_cpu_am_i_running_on;
    3. public string GPU = ...
    4. etc.
    The problem is even if I manage to get this data about the machine of the user I don't know how to make a program that takes as input a hardware configuration and returns a options file.
    For example I thought something like this:
    Code (CSharp):
    1. public class ComputerHardWare{
    2.     public string cpu;
    3.     public int cpuCores;
    4.     public string gpu;
    5.     public int ram;
    6.     public os;
    7.     public gl; //dx version or opengl
    8.     public architecture;
    9. }
    10. public class Options{
    11.     //ctor
    12.     public Resolution resolution;
    13.     public int Quality;
    14.     public bool vSync;
    15.     public bool VBO;
    16.     public farClippingPlaneDistance;
    17.     public int fogQuality;
    18.     public int shadowsQuality;
    19.     public bool bloom;
    20.     public bool antialiasing;
    21.     public bool ambientocclusion;
    22.     public int waterQuality;
    23.     public int folliageQuality;
    24.     public int grassDensity;
    25. }
    26.  
    27. public Options optimalSettings(ComputerHardWare hw){
    28.       ????
    29.       return new Options(...);
    30. }
    The first solution is: I can place some terrible if and switch statements, but it would be the messiest thing I ever did.
    The second solution comes from the fact that this seems to be the perfect job for and AI to input some pc specifications and to output a options set for the game, but it is impossible for me to code such an AI
    The third solution is simple and not messy, but the result won't be the best, the option set that will return won't be very accurate, but at least is simple to implement:
    This is the idea:
    Each hardware information has a score and each option has a cost, for example:
    having 8GB ram adds to the hardware score 5 points, having 16GB ram adds 10 points, having a very high end graphics card adds you 30 points, having a good cpu, adds you another value of points, etc.(each field of the hardware class contribiutes some amount to the score factor, depending on how much impact it has on the framerate). Now each setting value has its own cost for example having soft shadows costs you 5 points, having lower quality shadows costs you 2 points. Having the best looking water with waves costs you 20 points, having post processing costs you some value. Now, the score spent on graphics can't be more that the score acumulated by the hardware components.
    It is a nice approach, however it has its own difficulties for example(deciding the cost and the score of each setting/hardware aspect, the score of ram value can be easily decided as being proportional to the number of gb, however the processor manufacturer(intel/amd) and version(i5, i7, i9) and the frequency and the numbers of cores and the type(kabylake/skylake) and the cache values are difficult to be proportional to the score because many of these proprieties come as strings, so I would need to create a hashmap that maps the keywords(intel/amd, kabylake/skylake/etc) to score values) and the last problem with this approach is that it takes a lot of score tweaking to find a configuration that actually is concludent for a hardware, and such a score configuration might not exist.
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    A couple of things.

    First is that you'd likely need separate scores for CPU, GPU and memory, because they each have different strengths and weaknesses. Having a stronger CPU does not help if your GPU is too slow. Having an amazing CPU and GPU won't help if you've only got a tiny amount of RAM, and so on. So you'd need to evaluate them separately, and different settings would scale based on a different score. But it's still not going to be super accurate.

    The other issue is that even identical hardware can perform differently based on its software configuration - OS version, driver versions, how things are set up, whether there's a second monitor running YouTube videos and Discord and 43 other browser tabs, and so on.

    Some things I'd suggest looking at as reference points:
    1. The "Windows Experience" performance scores. They're similar to your proposed system in principle.
    2. The settings screens in a semi-recent Ubisoft game, such as Watch Dogs: Legion or maybe Far Cry 6. I think they do try to scale the defaults based on the system, but more importantly they estimate VRAM usage of different features, show a preview of each, and I think give descriptions of what hardware they're dependent on.
    3. I've seen various games include a "Benchmark" button on the Settings screen, and at least one game able to recommend settings based on that. I suspect that this is a much better approach than trying to guess, for a couple of reasons:
    - First, you only care what hardware they've got to infer how fast it might be. But we all know that measuring is better than guessing, any day, in some cases and you can measure the impact of the settings themselves.
    - Second, user preferences vary. I'll turn some options down to get a solid 60fps, but others prefer their shinies and are happy with 30fps, and others want to use their high refresh rate gear, and so on.