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

Context3D.totalGPUMemory returns inaccurate values on some non-NVIDIA graphics cards #1816

Open
ACrazyTown opened this issue Jul 11, 2024 · 5 comments

Comments

@ACrazyTown
Copy link
Contributor

Context3D.totalGPUMemory uses the OpenGL NVX_gpu_memory_info extension to get the used/total amount of video memory. However that extension seems to be mainly be for NVIDIA cards only which leads to inaccurate values on other graphics cards. I think some other graphics cards also support the extension, but it seems to be varied. I have an AMD Radeon RX 6650 XT and the extension isn't supported, causing totalGPUMemory to always return 0.

There's an ATI_meminfo GL extension for AMD graphics cards but it only returns the number of free video memory.

@MAJigsaw77
Copy link
Contributor

Maybe this should help?

package lime.graphics.opengl.ext;

@:keep
@:noCompletion class AMD_pinned_memory
{
    public var GPU_MEMORY_INFO_DEDICATED_VIDMEM_AMD = 0x9047;
    public var GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_AMD = 0x9048;
    public var GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_AMD = 0x9049;
    public var GPU_MEMORY_INFO_EVICTION_COUNT_AMD = 0x904A;
    public var GPU_MEMORY_INFO_EVICTED_MEMORY_AMD = 0x904B;

    @:noCompletion private function new() {}
}

@ACrazyTown
Copy link
Contributor Author

ACrazyTown commented Aug 6, 2024

Maybe this should help?

package lime.graphics.opengl.ext;

@:keep
@:noCompletion class AMD_pinned_memory
{
    public var GPU_MEMORY_INFO_DEDICATED_VIDMEM_AMD = 0x9047;
    public var GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_AMD = 0x9048;
    public var GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_AMD = 0x9049;
    public var GPU_MEMORY_INFO_EVICTION_COUNT_AMD = 0x904A;
    public var GPU_MEMORY_INFO_EVICTED_MEMORY_AMD = 0x904B;

    @:noCompletion private function new() {}
}

Where did you find this? I'm looking at the documentation for AMD_pinned_memory and I don't see any of these fields, the values seem to be the same as the NVX_gpu_memory_info extension and googling the variable names I can't seem to find any results about them

@MAJigsaw77
Copy link
Contributor

MAJigsaw77 commented Aug 6, 2024

Maybe this should help?

package lime.graphics.opengl.ext;

@:keep
@:noCompletion class AMD_pinned_memory
{
    public var GPU_MEMORY_INFO_DEDICATED_VIDMEM_AMD = 0x9047;
    public var GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_AMD = 0x9048;
    public var GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_AMD = 0x9049;
    public var GPU_MEMORY_INFO_EVICTION_COUNT_AMD = 0x904A;
    public var GPU_MEMORY_INFO_EVICTED_MEMORY_AMD = 0x904B;

    @:noCompletion private function new() {}
}

Where did you find this? I'm looking at the documentation for AMD_pinned_memory and I don't see any of these fields, the values seem to be the same as the NVX_gpu_memory_info extension and googling the variable names I can't seem to find any results about them

I've searched on Github and randomly found it.

@MAJigsaw77
Copy link
Contributor

Maybe this one?

package lime.graphics.opengl.ext;

@:keep
@:noCompletion class ATI_meminfo
{
	public static inline var VBO_FREE_MEMORY_ATI:Int = 0x87FB;
	public static inline var TEXTURE_FREE_MEMORY_ATI:Int = 0x87FC;
	public static inline var RENDERBUFFER_FREE_MEMORY_ATI:Int = 0x87FD;

	@:noCompletion private function new() {}
}

https://github.com/darklegion/tremulous/blob/c862a5340c8de44dcc7abaff170c20c04f9340e8/src/renderercommon/qgl.h#L739-L744

@ACrazyTown
Copy link
Contributor Author

Maybe this one?

package lime.graphics.opengl.ext;

@:keep
@:noCompletion class ATI_meminfo
{
	public static inline var VBO_FREE_MEMORY_ATI:Int = 0x87FB;
	public static inline var TEXTURE_FREE_MEMORY_ATI:Int = 0x87FC;
	public static inline var RENDERBUFFER_FREE_MEMORY_ATI:Int = 0x87FD;

	@:noCompletion private function new() {}
}

https://github.com/darklegion/tremulous/blob/c862a5340c8de44dcc7abaff170c20c04f9340e8/src/renderercommon/qgl.h#L739-L744

I tried playing around with that one when I originally made this issue. A problem with this one is that it doesn't expose a way to get total GPU memory and from my tests the free memory values seem to be kinda inaccurate? It was reporting more than 8GB memory free on my 8GB VRAM GPU

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