Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Martin

Pages: [1]
1
General / Re: Understanding memory usage of my application
« on: November 14, 2015, 01:56:20 pm »
Hi! Thanks for all the suggestions. It will take me a while to give them a go. I will do and I'll get back with my findings.

2
General / Re: Understanding memory usage of my application
« on: November 13, 2015, 05:02:44 pm »
Okay, I managed to make my game run on the high-performance card, and now main memory usage is down to 175MB - much more what I expected! Sorry for the multiple posts. So now my question is just: How can I profile the graphics memory usage?

3
General / Re: Understanding memory usage of my application
« on: November 13, 2015, 04:54:49 pm »
Ah, part of my confusion stems from the fact that my development machine has two graphics cards: An integrated Intel one, and a more powerful NVidia one. The NVidia graphics card has 2GB of dedicated memory - that's more like what I remembered!

So I need to confirm whether or not SFML is using the more powerful graphics card. If it is the question remains: Why is all this main memory being used? If it is not, then I need to figure out how to make sure I use the more powerful card.

Either way, I'd still really appreciate any advice on profiling graphics memory usage.

Thanks for the help so far!

4
General / Re: Understanding memory usage of my application
« on: November 13, 2015, 04:45:30 pm »
I am disposing of Textures, SoundBuffers, and RenderTextures as I finish with them.

I use a thread to load Textures in without causing the main menu to hang. Once I am into the main game loop everything is single-threaded.

Looking into it I see I have misunderstood how much memory my graphics card has - it only has 128MB of dedicated memory, so the rest will be being stored in main memory.

So I would guess that the majority of my memory usage is textures. Is there any way of getting a breakdown of graphics memory usage? It would be really helpful for identifying exactly which game elements are taking up the majority of memory.

5
General / Understanding memory usage of my application
« on: November 13, 2015, 02:28:14 pm »
Hi,

I'm developing a game using SFML.NET. My application is compiled against .NET 4.5.1 using version 2.2 of the SFML.NET NuGet package.

The game uses a lot of high-resolution graphics, as well as some audio. This game is 2D, but it is high-fidelity. Recently memory usage has shot up from around 200MB to 750MB.

I'd like some advice on how to profile the memory usage of the application. I had expected that as I added more textures that these would be held in VRAM, and wouldn't significantly impact main memory usage, at least until I ran out of VRAM and OpenGL had to started swapping textures in and out more.

When I try profiling using Visual Studio 2015's built-in profiler, it only reports about 100MB of managed and heap memory usage. How can I get a more accurate breakdown of what is using up the memory?

Thanks for you time and your help.

6
Hello. I realize that this is an old topic. But given that I found this topic when looking for an answer, I thought others might also.

Here is the solution I came up with:

using SFML.Graphics;
using System;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

public static class ImageExtensions
{
    public static System.Drawing.Bitmap ConvertToBitmap(this Image image)
    {
        var bitmap = new System.Drawing.Bitmap((int)image.Size.X, (int)image.Size.Y, PixelFormat.Format32bppArgb);
        var bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            ImageLockMode.WriteOnly, bitmap.PixelFormat);
        byte[] data = getPixelData(image);
        Marshal.Copy(data, 0, bitmapData.Scan0, data.Length);
        bitmap.UnlockBits(bitmapData);
        return bitmap;
    }

    private static byte[] getPixelData(Image image)
    {
        byte[] data = image.Pixels;

        // SFML is always RGBA, regardless of the endian-ness of the CPU. On a little-endian
        // CPU, System.Drawing.Bitmap expects BGRA.
        if (BitConverter.IsLittleEndian)
        {
            byte[] source = image.Pixels;
            data = new byte[source.Length];
            for (int i = 0; i < data.Length; i += 4)
            {
                data[i] = source[i + 2];
                data[i + 1] = source[i + 1];
                data[i + 2] = source[i];
                data[i + 3] = source[i + 3];
            }
        }
        return data;
    }
}

(The above code is free for anyone to use and adapt, without restriction, for any purpose)

7
DotNet / LoadingFailedException using PostFx object
« on: July 06, 2010, 05:46:46 pm »
At a guess, it looks like it might be something to do with line endings. The files seem fine until they get saved by Visual Studio.

8
DotNet / LoadingFailedException using PostFx object
« on: July 06, 2010, 05:34:01 pm »
I have now tried the samples from the SDK, including the one the tutorial is based off - and they work fine! Thank you.

Sorry, I should have thought of that.

It turns out it's one of these mysterious bugs - if I copy and paste from the SDK sample into my sfx file so that they're character for character the same, it doesn't work. It's apparently just a cursed file.

But every other file seems to be working fine, so I'll leave it at that. Sorry for using you as tech support!

9
DotNet / LoadingFailedException using PostFx object
« on: July 06, 2010, 02:29:08 pm »
Thank you for the reply, Laurent. Let me know if this doesn't provide you with sufficient information:

The fx folder's contents is copied to the working directory at compile time, using Visual Studio's "Copy to Ouptput Directory" option. But in any case, as I mentioned, I can load the files using a FileStream, so that must be a valid path.

I run from the IDE normally, but I have reproduced the bug running from the explorer.

I can load images using the Image object, I haven't tried loading any other resources. If you tell me which resource to try, I'd be happy to.
Edit: I have also successfully loaded a font file.

10
DotNet / LoadingFailedException using PostFx object
« on: July 06, 2010, 12:56:07 pm »
(Apologies if this issue has been brought up in a separate thread. If it has, I've been unable to find it.)

I am using the .NET bindings for SFML 1.6. I have been happily drawing sprites and so forth to the screen using the RenderWindow. I then took a look at the PostFx tutorial.

I copied the GSGL code from the tutorial, and have it in a file whose path is "fx/grey.sfx":

 
Code: [Select]
texture framebuffer
vec3 color

effect
{
    // Get the value of the current screen pixel
    vec4 pixel = framebuffer(_in);

    // Compute its gray level
    float gray = pixel.r * 0.39 + pixel.g * 0.50 + pixel.b * 0.11;

    // Finally write the output pixel using 50% of the source pixel and 50% of its colored version
    _out = vec4(gray * color, 1.0) * 0.5 + pixel * 0.5;
}


I am able to load this file in as a string using a StreamReader object, so the program definitely has access to it.

However, when I try and construct a PostFx object, passing in that path as the parameter, it throws a LoadingFailedException. This happens with other sfx files I have tried as well. The message in the exception is "Failed to load post-fx from file fx/grey.sfx". Looking at the source code for PostFx, as far as I can tell the .NET bindings always throw away any information the C code might return on why the thing has failed to load and just throw this exception.

The tutorial says that errors during compilation of the fragment shader code will appear on the standard error out. As far as I can work out, this is not the case under C#.NET. If there is a way of getting at that kind of output, please let me know.

Otherwise, any other ideas what I'm doing wrong?

Code: [Select]
using SFML.Graphics;

namespace SFMLTest
{
    class TestMain
    {
        static void Main()
        {
            PostFx fx = null;

            if (PostFx.CanUsePostFX)
            {
                string filename = "fx/grey.sfx";
                fx = new PostFx(filename);
            }
        }
    }
}

Pages: [1]
anything