0 registered members (),
677
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
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...
///////////////////////////////
#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: jcl]
#465448
04/27/17 18:27
04/27/17 18:27
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
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: jcl]
#465471
04/29/17 14:43
04/29/17 14:43
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
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.zipThe problem: 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
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]
#465475
04/29/17 23:09
04/29/17 23:09
|
Joined: Aug 2003
Posts: 118 Deutschland
Ezzett
Member
|
Member
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.
#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:
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:
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:
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)
|
|
|
|