Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
Deeplearning Script
by wolfi. 02/26/24 12:46
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/22/24 16:22
AssetAdd() vs. modern asset list?
by jcl. 02/21/24 15:01
How many still using A8
by Aku_Aku. 02/20/24 12:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 521 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 5 of 10 1 2 3 4 5 6 7 9 10
Re: video memory and d3d_texfree [Re: Superku] #465441
04/27/17 16:36
04/27/17 16:36
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, that's fine since bmap_createblack, as long as nothing else happens, just creates an empty bmap and has no impact on sys_memory or d3d_texbmaps.

Re: video memory and d3d_texfree [Re: jcl] #465444
04/27/17 17:06
04/27/17 17:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: jcl
Yes, that's fine since bmap_createblack, as long as nothing else happens, just creates an empty bmap and has no impact on sys_memory or d3d_texbmaps.

But d3d_texbmaps does increase as I'm using draw_quad...

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

#define MAX_BMAPS 196 // start with the default nexus/ "run current script"
BMAP* test_bmps[MAX_BMAPS];
int num_bmaps = 0;

void main()
{
	int i;
	fps_max = 60;
	video_mode = 6;
	while(1)
	{
		draw_text(str_printf(NULL,"sys_memory: %.1f",(double)sys_memory),20,20,COLOR_RED);
		draw_text(str_printf(NULL,"d3d_texbmaps: %.1f",(double)d3d_texbmaps),20,40,COLOR_RED);
		draw_text(str_printf(NULL,"nexus: %.1f/ %d",(double)nexus,(int)max_nexus),20,60,COLOR_RED);
		draw_text(str_printf(NULL,"d3d_texfree: %.1f",(double)d3d_texfree),20,80,COLOR_RED);
		if(num_bmaps < MAX_BMAPS)
		{
			test_bmps[num_bmaps] = bmap_createblack(2048,1024,32); //bmap_create("test8MB.tga"); //
			draw_quad(test_bmps[num_bmaps],vector(10,10,10),NULL,NULL,NULL,NULL,50,0);
			num_bmaps++;
		}
		draw_text(str_printf(NULL,"num_bmaps: %d",(int)num_bmaps),20,120,COLOR_RED);
		
		wait(1);
	}
}



That code creates 196 bitmaps, 8MB per image, and consumes about 1.6GB of memory. EDIT: d3d_texbmaps at 1552MB, no error.

If I replace
bmap_createblack(2048,1024,32)
with
bmap_create("test8MB.tga"); // 2048x1024x32
the application errors E2005 after ~100 bitmaps, ~1.6GB of memory (task manager), with sys_memory at 849MB and d3d_texbmaps at 776MB. After closing that message it prints "Out of Memory" (E1005).

This cannot be correct, right?

Last edited by Superku; 04/27/17 17:07.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: video memory and d3d_texfree [Re: Superku] #465445
04/27/17 17:17
04/27/17 17:17
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
There can be many reasons, for instance that your graphics driver needs less memory for monochrome textures, using some compressed format. You could test this by comparing the memory consumption of different images, some monochrome, some with content.

Re: video memory and d3d_texfree [Re: jcl] #465448
04/27/17 18:27
04/27/17 18:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
So it is intended that version A)

test_bmps[num_bmaps] = bmap_create("test8MB.tga");
draw_quad(test_bmps[num_bmaps],...);

uses twice the memory (read: 16MB per 8MB (source) image) compared to version B)

BMAP* source_bmp = "test8MB.tga"; // global bitmap
...
test_bmps[num_bmaps] = bmap_createblack(2048,1024,32);
bmap_blit(test_bmps[num_bmaps],source_bmp, NULL, NULL);
draw_quad(test_bmps[num_bmaps],...);

(which both display the same content to the screen)?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: video memory and d3d_texfree [Re: Superku] #465455
04/28/17 12:22
04/28/17 12:22
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
No, it's the other way around. If your video driver compresses monochrome bitmaps, then "test8MB.tga" uses 8 MB video memory, and bmap_createblack(2048,1024,32) uses an unknown, but smaller amount. And when you blit some content into it, they should use the same memory amount. Unless your 8 MB test image is bigger than 8 MB.

Re: video memory and d3d_texfree [Re: jcl] #465471
04/29/17 14:43
04/29/17 14:43
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Please download this code plus bitmap then and give it a try: http://superku.de/crash_test5.zip

The problem:
Originally Posted By: Superku
the application errors E2005 after ~100 bitmaps, ~1.6GB of memory (task manager), with sys_memory at 849MB and d3d_texbmaps at 776MB. After closing that message it prints "Out of Memory" (E1005).

Changing
Code:
if(0) // < ---------- here


to true results in sys_memory not rising and me being able to create twice as many bitmaps.


EDIT: If I'm not mistaken I only then have ~800MB of memory to work with to make PC games with A8.

Last edited by Superku; 04/29/17 14:44.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: video memory and d3d_texfree [Re: Superku] #465472
04/29/17 17:29
04/29/17 17:29
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
I can confirm what Superku said. On my Asus UX360UAK-BB285T I got the following results with bmap_createblack and bmap_blit:

sys_memory 65.6
d3d_texbmaps 1560.0
nexus 0.4/40
d3d_texfree 2557.0

num_bmaps 194

Error 2005 until MAX_BMAPS. After that d3d_texfree is 2549.0 and the engine continues to run.

With bmap_create I got:

sys_memory 841.6
d3d_texbmaps 776.0
nexus 0.4/40
d3d_texfree 3325.0

num_bmaps 98

Error 1005 and the engine crashes.

Re: video memory and d3d_texfree [Re: Ezzett] #465473
04/29/17 18:06
04/29/17 18:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Thanks for testing!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: video memory and d3d_texfree [Re: Superku] #465475
04/29/17 23:09
04/29/17 23:09
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
I tested it also with the engine sdk in Visual Studio Community 2015. Maybe this is helpfull, because it's possible to look inside the structs.

Code:
#define WIN32_LEAN_AND_MEAN		
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "var.h"
#include "adll.h"

ENGINE_VARS *ev;
COLOR COLOR_RED = { _VAR(255), _VAR(0), _VAR(0) };
COLOR COLOR_WHITE = { _VAR(255), _VAR(255), _VAR(255) };

#define MAX_BMAPS 196 // start with the default nexus/ "run current script"
BMAP* test_bmps[MAX_BMAPS];
int num_bmaps = 0;

int APIENTRY WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR     lpCmdLine,
	int       nCmdShow)
{
	ev = engine_open(NULL);

	int i;
	v(fps_max) = 60;
	v(video_mode) = 6;
	engine_frame();
	static BMAP* source_bmp = bmap_create("test8MB3.tga");
	
	while (engine_frame()) {

		if (num_bmaps < MAX_BMAPS)
		{
			if (1) // < ---------- here
			{
				test_bmps[num_bmaps] = bmap_createblack(_VAR(2048), _VAR(1024), _VAR(32));
				bmap_blit(test_bmps[num_bmaps], source_bmp, NULL, NULL);
			}
			else test_bmps[num_bmaps] = bmap_create((char *)"test8MB3.tga");
			draw_quad(test_bmps[num_bmaps], vector(_VAR(10), _VAR(10), _VAR(10)), NULL, NULL, NULL, NULL, _VAR(100), _VAR(0));
			//cprintf4("n%d) w %d, h %d, b %d",(int)(num_bmaps+1),(int)test_bmps[num_bmaps]->finalwidth,(int)test_bmps[num_bmaps]->finalheight,(int)test_bmps[num_bmaps]->finalbytespp);
			num_bmaps++;
		}
		draw_text(_CHR(str_printf(NULL, "sys_memory: %.1f", (double)v(sys_memory))), _VAR(20), _VAR(20), &COLOR_RED);
		draw_text(_CHR(str_printf(NULL, "d3d_texbmaps: %.1f", (double)v(d3d_texbmaps))), _VAR(20), _VAR(40), &COLOR_RED);
		draw_text(_CHR(str_printf(NULL, "nexus: %.1f/ %d", (double)v(nexus), (int)v(max_nexus))), _VAR(20), _VAR(60), &COLOR_WHITE);
		draw_text(_CHR(str_printf(NULL, "d3d_texfree: %.1f", (double)v(d3d_texfree))), _VAR(20), _VAR(80), &COLOR_WHITE);
		draw_text(_CHR(str_printf(NULL, "num_bmaps: %d", (int)num_bmaps)), _VAR(20), _VAR(120), &COLOR_WHITE);
	}
	engine_close();
	return 0;
}



For me it has the exact same result like running the script with SED.

I don't know if this is relevant (I really doubt it has something to do with the memory problems), but when I use if(1), the u1,v1- and u2,v2-coordinates of the bitmaps are not zero but slightly off:

Code:
u1	0.000244140625	float
v1	0.000488281250	float
u2	0.999755859	float
v2	0.999511719	float



This is even true for the source_bmp which is declared before the if branch. I have no idea what is going on here.

Here is something more interesting. When I'm using if(0) and I look inside the bmap members I can see that the pixel member is filled:

Code:
pixels	0x0bd3d020 "T^nÿWaqÿYctÿZduÿZeuÿ\gwÿ]hxÿ]hxÿ\fvÿYduÿXbsÿYctÿYctÿXbsÿWbrÿWbrÿXbrÿWaqÿV`pÿU_nÿT^mÿT^mÿS]kÿR\jÿS^kÿT^lÿS]kÿQ[iÿPYgÿOXfÿOXfÿPYgÿOYfÿNWeÿOXeÿOXeÿOXfÿQZhÿQ[iÿQ[iÿQZhÿOXeÿNWdÿNWdÿNWdÿNWdÿOXfÿOXfÿPYgÿPYgÿ...	84 'T' unsigned char *



But when I'm changing the branch to if(1) the pixel member of the bitmap created by bmap_createblack can't be read:
Code:
pixels	0x00000000 <NULL> <Unable to read memory>	unsigned char *


This is also true, after bmap_blit is used.

Could it be, that the pixel member of a bitmap takes up 8 MB of memory? If bmap_create is used, the pixel member is filled. But when bmap_createblack or bmap_blit is used, the pixel member is NULL. Maybe this is the cause the first function can only create half as many bitmaps until the memory is full. (1.6 GB equals 200 * 8 MB or 100 * 16 MB)

Re: video memory and d3d_texfree [Re: Ezzett] #465482
04/30/17 11:19
04/30/17 11:19
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
I made some other tests in SED and VSC 2015.

If I remove draw_quad I can create as many bitmaps with bmap_create as I can create with bmap_createblack and bmap_blit.

If I also remove bmap_blit I can create thousands of bmap_createblack bitmaps. It seems that bmap_createblack writes into the same memory area every time.

It also seems that the sys_memory and d3d_texbmaps need to be added together. If d3d_texbmaps stays at 0 then sys_memory can rise up to 1.6 GB before the out of memory message appears.

If sys_memory + d3d_texbmaps are just before 1.6GB and sys_memory rises while d3d_texbmaps stays the same Error 1005 appears.

When sys_memory stays the same and d3d_texbmaps rises you'll get Error 2005.

The sum of both values need to stay under 1.6 GB.

Page 5 of 10 1 2 3 4 5 6 7 9 10

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