Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 1,592 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
video memory usage #341766
09/20/10 06:50
09/20/10 06:50
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

is there a way to get the overall video memory usage?

I know there are some d3d_ commands, but:

1) d3d_texfree

I'm not sure if it's a bug, but even when starting just an empty main.c "d3d_textfree" always returns a negative value (e.g. -19532830) though in the manual is said that the value should be higher than 0. (I've tested it with the latest A7 Pro and A8 Pro)

2) d3d_texbmaps, d3d_texskins, d3d_texsmaps, d3d_texsurfs

The manual says:

"Due to swapping and compression, the total value can be remarkably higher than the amount of video memory available on the 3D card."

Hmm ... so how can I interpret those values?

Is there any chance to get NVIDIA PerfHud running using lite-c? (http://developer.nvidia.com/object/nvperfhud_home.html) I haven't found the time to get a closer look at PerfHud, but I'm not sure if the binding code can be used in lite-c.

Regards,
Pegamode.

Re: video memory usage [Re: pegamode] #341769
09/20/10 07:05
09/20/10 07:05
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
A variable gets a negative value when the var range is exceeded. So as long as d3d_texfree is below 0, you have at least 1 GB video memory left.

We'll probably replace it with a long variable in a future version, as well as other memory variables.

Re: video memory usage [Re: jcl] #341770
09/20/10 07:11
09/20/10 07:11
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Is there any way to get the "real" value (e.g. read something from directX into a string)?

Currently it would be hard to do something like this:

Code:
if (d3d_texfree < 10000) {
 // do something
}



I could do it like this:

Code:
if (d3d_texfree < 10000 && d3d_texfree >= 0) {
 // do something
}



But it's not a nice code.

But it would be more interesting to get the value how much video memory is in use instead of the value how much video memory is left, because this value would be independent from the gfx-card.

Is there any way to get good values? Maybe from DirectX?


Last edited by pegamode; 09/20/10 07:19.
Re: video memory usage [Re: pegamode] #341771
09/20/10 07:50
09/20/10 07:50
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Sure:

long mem = ((LPDIRECT3DDEVICE9)pd3ddev)->GetAvailableTextureMem();
printf("Memory at start: %i",mem);
...
long mem_used = mem - ((LPDIRECT3DDEVICE9)pd3ddev)->GetAvailableTextureMem();
printf("Memory used: %i",mem_used);

GetAvailableTextureMem() is the same as d3d_texfree.

Re: video memory usage [Re: jcl] #341773
09/20/10 09:36
09/20/10 09:36
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Thanks ... that will help a lot.

Re: video memory usage [Re: pegamode] #341778
09/20/10 11:37
09/20/10 11:37
Joined: Jun 2009
Posts: 43
MCKiller Offline
Newbie
MCKiller  Offline
Newbie

Joined: Jun 2009
Posts: 43
I tried that with the following code:

Code:
#include <acknex.h>
#include <d3d9.h>


FONT* standard_font 	= "Arial#20b";
STRING* memo 		= "not available";

TEXT* dx =
{
  layer = 1;
  pos_x = 400;
  pos_y = 100;
  font  = standard_font;
  string = memo;
  flags = CENTER_X | TRANSLUCENT | SHOW;
	
}

void main() {

	video_mode 	=  8;	
	video_depth 	= 32;		
	fps_max		= 60;
	d3d_texdepth 	=  4;	
	
	
	STRING* tmp	="0";
	
	level_load(NULL);
		
	while(1){
		
		LPDIRECT3DDEVICE9 pd3dDev;
     	        pd3dDev = (LPDIRECT3DDEVICE9)draw_begin();
   
     	        if (!pd3dDev) return;
	
		long mem = (LPDIRECT3DDEVICE9)pd3dDev)->GetAvailableTextureMem();
		
		//printf("freeTextureMem: %i",mem);
	
		str_for_int(tmp,mem);
		str_cpy(memo,tmp);
	
		wait(1);	
	}
	
}



The result is: -1360003072

MSDN says that GetAvailableTextureMem() returns the values in Megabytes?!?

So maybe there is something strange....

Re: video memory usage [Re: MCKiller] #341811
09/20/10 19:32
09/20/10 19:32
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I overworked MCKiller's code a bit, but I also get this negative value (btw. the same as if I use d3d_texfree).

The code I use:

Code:
#include <acknex.h>
#include <d3d9.h>

void main() {
	video_mode 	 =  8;	
	video_depth  = 32;		
	fps_max		 = 60;
	d3d_texdepth =  4;			
	
	level_load(NULL);
	wait(1);
		
	LPDIRECT3DDEVICE9 pd3dDev = (LPDIRECT3DDEVICE9)draw_begin();   
    if (!pd3dDev) sys_exit("-1");
				
	while(1){					
		long mem = pd3dDev->GetAvailableTextureMem();				
		draw_text(str_printf(NULL, "freemem: %d",mem),10,10,COLOR_RED);				
		wait(1);	
	}	
}



Any hint???

Regards,
Pegamode.

Re: video memory usage [Re: pegamode] #341813
09/20/10 19:43
09/20/10 19:43
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I changed the draw_text line from

Code:
draw_text(str_printf(NULL, "freemem: %d",mem),10,10,COLOR_RED);



to

Code:
draw_text(str_printf(NULL, "freemem: %u",mem),10,10,COLOR_RED);



The value I see now could be the right one ... I will check it out a little further.

Re: video memory usage [Re: pegamode] #341819
09/20/10 20:01
09/20/10 20:01
Joined: Jun 2009
Posts: 43
MCKiller Offline
Newbie
MCKiller  Offline
Newbie

Joined: Jun 2009
Posts: 43
For me, too.
That make sense. In the MSDN for directx they use an UINT.


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1