Availvidmem & Totalvidmem Bug

Archives Forums/Blitz3D Bug Reports/Availvidmem & Totalvidmem Bug

Imphenzia(Posted 2007) [#1]
I am getting
totalvidmem = -1648644096
availvidmem = -1672968604

(but UsedvidMem seems to be reporting a correct figure)

I am running:
Blitz3D 1.99

Computer:
MB: Gigabyte P35-DQ6
CPU: QuadCore Q6600
Memory: 4 GB
GFX card: GeForce 8800GTX (768 mb) and official drivers 7.15.0011.6369 (according to DX Diag which is also reporting 2523MB of video memory)
OS: Windows Vista Ultimate 64bit with DX10

Anyone else with this problem or can I provide any more details to help out to isolate where things go wrong?


Floyd(Posted 2007) [#2]
I assume this is a driver problem.

Note that Blitz3D TotalVidMem reports the same wrong value as DX Diag, but interprets it as a signed 32-bit integer.
( Blitz3D TotalVidMem ) = ( DX Diag value ) - 2^32



Imphenzia(Posted 2007) [#3]
Well spotted. You think the best solution is to just detect when vidmem-commands are showing negative results and assume it's > 512MB cards?

I am currently using these commands to detect wether videosettings should be reduced and it now thinks it's ran out of memory.


John Blackledge(Posted 2007) [#4]
This is a bit over my head.

Can you come up with a (Vidmem conversion) formula that will work with all graphics cards?


jfk EO-11110(Posted 2010) [#5]
It seems to be a signed/unsigned problem. Normally I'd convert it this way:

vm=TotalVidMem()
if vm<0 then vm=vm shl 1

But since the result from -1648644096 would be about 1 billion, but it should be 768 megs, I have no idea what's going on here.

I even haven't got a clue why the minus bit is ever set where there are only 768 megs. The minus bit would only be set if there were more than 2 gigs of vram.

It may have something to do with the maximum adress space, that is 4 gigs on a 32 Bit machine and/or in 32 Bit compatibility mode. Adresses must be mapped in this space, as far as I know, and when there are more than 4 gigs (or even 2 if unsingeds are involved, as with B3D) of vram PLUS normal ram together, problems may arise.

BTW this problem is still persistent.

Last edited 2010


yaragad(Posted 2013) [#6]
What about this problem? Was it solved?

If I execute several times the Graphic mode:
Graphics3D 1900, 1080, 0, 2

The available mem keep increasing each time i execute it


Floyd(Posted 2013) [#7]
Blitz3D is just repeating what it is being told. But with signed integers it can only display numbers under 2^31. Above that they are interpreted as negative.

You have to reinterpret the negative values yourself. Here's a function to do that. The example uses values from my PC.

DXDiag says 4050MB while TotalVidMem says -47894528 bytes, which is about -46MB.

Print "DXDiag reports about     4050MB."
Print "TotalVidMem() reports   -47894528 bytes."
Print "VideoMB( -47894528 ) is  " + VideoMB( -47894528 )

WaitKey

Function VideoMB( VidMem )  ; approximate number of megabytes.

	VidMem = VidMem / 2^20
	If VidMem < 0 Then VidMem = VidMem + 2^12  ; 2^12 = 2^32 / 2^20
	Return VidMem

End Function



virtlands(Posted 2013) [#8]
Blitz3D is just repeating what it is being told.

That's quite interesting.
Someone should make some function that displays values past max_pos_32bit for Blitz3D.

As for your displayed example:

the famous maximum number =
0111 1111 1111 1111 1111 1111 1111 1111 (32 bit binary) = 2,147,483,647

your TotalVidMem =
1111 1101 0010 0101 0011 0000 0000 0000 (32 bit binary) = -47,894,528 OR 4,247,072,768

Would you say that -47,894,528 = 4,247,072,768 (bytes) is correct


Floyd(Posted 2013) [#9]
Would you say that -47,894,528 = 4,247,072,768 (bytes) is correct

Yes.

Someone should make some function that displays values past max_pos_32bit for Blitz3D.

I'll take a shot at it.

Print unsigned( -47894528 )

WaitKey

Function unsigned$( n )
	If n >= 0 Then Return n
	Local digit, prefix
	digit =  ( 10 + (6 + n) Mod 10 ) Mod 10
	prefix = 429496729 + n / 10 - ( digit > 6 )
	Return Str( prefix ) + Str( digit )
End Function



virtlands(Posted 2013) [#10]
I just tried Floyd's unsigned$(). I don't understand the math that
went into that unsigned$() function, yet it works perfectly, thanks to Floyd.
---------

Here is my own version of see_unsigned:

In this case, I let Pelles C do the work via a DLL,
"see_u32.dll" -- ( see unsigned 32-bit value )



You can download the code from here :: (includes Pelles C code + BB code + DLLs + .DECLS )
http://tinyurl.com/nakyef5 OR http://tinyurl.com/qef74uo

The running program requires 2 DLLs, see_u32.dll & pocrt.dll .

The purpose of pocrt.dll is to enable "sprintf( , , )"
The purpose of see_u32.dll is to enable "see_u32(v)".

My philosophy is " Let another language do the hard work for you, then just paste it into Blitz... ".