How to increase video memory?

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

How to increase video memory?

Postby Yesterplay80 » 2017-6-29 @ 06:05

Out of curiosity: I tried to increase the size of the video memory available by changing these lines in vga_s3.cpp from
Code: Select all
   if (vga.vmemsize == 0)
      vga.vmemsize = 2*1024*1024; // the most common S3 configuration


to

Code: Select all
   if (vga.vmemsize == 0)
      vga.vmemsize = 2*2048*1024; // the most common S3 configuration


and came up with a DOSBox executable with 4MB video memory (according to the UniVBE utility). But I couldn't get out more than 4 MB, no matter which values I tried for vga.vmemsize. So there must be a limiter somewhere else in the code. Could someone please show me, how to increase the video memory capacity? I know it isn't an official configuration of the emulated video card and might lead to some kind of trouble, I just want to play around a bit.
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby ripsaw8080 » 2017-6-29 @ 14:03

There is code immediately following the line you refer to that sets the S3 CRTC register 36 for the VRAM size, and you need to change that to support more than 4MB. This is the code from MB6 that goes as high as 8MB:
Code: Select all
   // Set CRTC 36 to specify amount of VRAM and PCI
   if (vga.vmemsize < 1024*1024) {
      vga.vmemsize = 512*1024;
      vga.s3.reg_36 = 0xfa;      // less than 1mb fast page mode
   } else if (vga.vmemsize < 2048*1024)   {
      vga.vmemsize = 1024*1024;
      vga.s3.reg_36 = 0xda;      // 1mb fast page mode
   } else if (vga.vmemsize < 3072*1024)   {
      vga.vmemsize = 2048*1024;
      vga.s3.reg_36 = 0x9a;      // 2mb fast page mode
   } else if (vga.vmemsize < 4096*1024)   {
      vga.vmemsize = 3072*1024;
      vga.s3.reg_36 = 0x5a;      // 3mb fast page mode
   } else if (vga.vmemsize < 8192*1024) {   // Trio64 supported only up to 4M
      vga.vmemsize = 4096*1024;
      vga.s3.reg_36 = 0x1a;      // 4mb fast page mode
   } else {   // 8M
      vga.vmemsize = 8192*1024;
      vga.s3.reg_36 = 0x7a;      // 8mb fast page mode
   }
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4274
Joined: 2006-4-25 @ 23:24

Re: How to increase video memory?

Postby Yesterplay80 » 2017-6-30 @ 06:33

If I set this, should i comment out the two lines from my first post? And how do those hex values correspond to the amount of video memory? Are more than 8M possible? Is there some sort of table I could look that up? Sorry about all those questions!

UPDATE: I just tried this, dumping the 3MB definition to allow for a 16 MB one:
Code: Select all
   if (vga.vmemsize == 0)
      vga.vmemsize = 16384*1024; // hopefully fixes Build engine games

   // Set CRTC 36 to specify amount of VRAM and PCI
   if (vga.vmemsize < 1024*1024) {
      vga.vmemsize = 512*1024;
      vga.s3.reg_36 = 0xfa;      // less than 1mb fast page mode
   } else if (vga.vmemsize < 2048*1024)   {
      vga.vmemsize = 1024*1024;
      vga.s3.reg_36 = 0xda;      // 1mb fast page mode
   } else if (vga.vmemsize < 3072*1024)   {
      vga.vmemsize = 2048*1024;
      vga.s3.reg_36 = 0x9a;      // 2mb fast page mode
   } else if (vga.vmemsize < 4096*1024)   {
      vga.vmemsize = 4096*1024;
      vga.s3.reg_36 = 0x5a;      // 4mb fast page mode
   } else if (vga.vmemsize < 8192*1024)   {   // Trio64 supported only up to 4M
      vga.vmemsize = 8192*1024;
      vga.s3.reg_36 = 0x1a;      // 8mb fast page mode
   } else if (vga.vmemsize < 16384*1024)   {
      vga.vmemsize = 16384*1024;
      vga.s3.reg_36 = 0x7a;         // 16mb fast page mode
   }

But UVCONFIG.EXE (from UNIVBE) still shows only 4MB?
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby ripsaw8080 » 2017-6-30 @ 08:47

Change the condition block to what I posted, then change the line above to: vga.vmemsize = 8*1024*1024;

The register values (in hex) correspond to the amount of memory. In your reworking of the conditions you've mismatched the register and vmemsize values. Also, the last of the conditions should be an "else", not an "else if", in order to catch any value above.

I don't know if more than 8MB is possible, or what the register values would be. I guess search for S3 specs if you really want to know.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4274
Joined: 2006-4-25 @ 23:24

Re: How to increase video memory?

Postby Yesterplay80 » 2017-6-30 @ 09:29

Strangely, this is detected as only 2 MB:
Code: Select all
   if (vga.vmemsize == 0)
      vga.vmemsize = 8*1024*1024; // hopefully fixes Build engine games

   // Set CRTC 36 to specify amount of VRAM and PCI
   if (vga.vmemsize < 1024*1024) {
      vga.vmemsize = 512*1024;
      vga.s3.reg_36 = 0xfa;      // less than 1mb fast page mode
   } else if (vga.vmemsize < 2048*1024)   {
      vga.vmemsize = 1024*1024;
      vga.s3.reg_36 = 0xda;      // 1mb fast page mode
   } else if (vga.vmemsize < 3072*1024)   {
      vga.vmemsize = 2048*1024;
      vga.s3.reg_36 = 0x9a;      // 2mb fast page mode
   } else if (vga.vmemsize < 4096*1024)   {
      vga.vmemsize = 3072*1024;
      vga.s3.reg_36 = 0x5a;      // 3mb fast page mode
   } else if (vga.vmemsize < 8192*1024)   {   // Trio64 supported only up to 4M
      vga.vmemsize = 4096*1024;
      vga.s3.reg_36 = 0x1a;      // 4mb fast page mode
   } else   {
      vga.vmemsize = 8192*1024;
      vga.s3.reg_36 = 0x7a;         // 8mb fast page mode
   }
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby ripsaw8080 » 2017-6-30 @ 09:46

UniVBE 5.3a says 3MB, and it does the same for MB6 and Daum with a vmemsize=8 setting, so perhaps unreliable detection (or an unrealistic amount of memory ;))
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4274
Joined: 2006-4-25 @ 23:24

Re: How to increase video memory?

Postby gandhig » 2017-7-01 @ 18:03

VBETEST does show it as having 16384 Kb memory in the Version output, when you set vga.vmemsize to 16384*1024 (initially as well as after the last 'else'). However, not sure whether it effects the desired change actually.

As per S3Trio64 datasheet, max display memory size is 4 MB which corresponds to reg_36's value of 1a(EDO) or 1e(fast page). That aside, comments in the vga_s3 source file mention 'EDO' mode as 'fast page' mode for all the vram combinations.

s3_trio32_64.pdf
(53.96 KiB) Downloaded 26 times
User avatar
gandhig
Member
 
Posts: 377
Joined: 2014-2-12 @ 08:35
Location: Unknown...yet. Triangulating inside...Level 1

Re: How to increase video memory?

Postby Yesterplay80 » 2018-11-30 @ 10:21

I'm currently trying to get the video memory configurable via the conf file, but lacking C++ skills, this is all I could come up with until now:

Code: Select all
diff -ruN dosbox/src/dosbox.cpp dosbox_vmem/src/dosbox.cpp
--- dosbox/src/dosbox.cpp   2018-11-30 10:03:33 +0000
+++ dosbox_vmem/src/dosbox.cpp   2018-11-30 10:06:45 +0000
@@ -438,6 +438,11 @@
       "This value is best left at its default to avoid problems with some games,\n"
       "though few games might require a higher value.\n"
       "There is generally no speed advantage when raising this value.");
+   Pint = secprop->Add_int("vmemsize", Property::Changeable::WhenIdle, 2);
+   Pint->SetMinMax(1,8);
+   Pint->Set_help("Amount of video memory for the emulated S3 video card. The default \n"
+               "value is 2 MB, officially a maximum of 4MB is supported. Can be set \n"
+               "up to 8MB, e.g. to reduce flickering in Build engine games.");      
    secprop->AddInitFunction(&CALLBACK_Init);
    secprop->AddInitFunction(&PIC_Init);//done
    secprop->AddInitFunction(&PROGRAMS_Init);
diff -ruN dosbox/src/hardware/vga_s3.cpp dosbox_vmem/src/hardware/vga_s3.cpp
--- dosbox/src/hardware/vga_s3.cpp   2018-11-30 10:03:02 +0000
+++ dosbox_vmem/src/hardware/vga_s3.cpp   2018-11-30 10:09:32 +0000
@@ -532,7 +532,7 @@
    svga.accepts_mode = &SVGA_S3_AcceptsMode;
 
    if (vga.vmemsize == 0)
-      vga.vmemsize = 2*1024*1024; // the most common S3 configuration
+      vga.vmemsize = vmemsize*1024*1024; // variable S3 configuration
 
    // Set CRTC 36 to specify amount of VRAM and PCI
    if (vga.vmemsize < 1024*1024) {
@@ -547,9 +547,12 @@
    } else if (vga.vmemsize < 4096*1024)   {
       vga.vmemsize = 3072*1024;
       vga.s3.reg_36 = 0x5a;      // 3mb fast page mode
-   } else {   // Trio64 supported only up to 4M
+   } else if (vga.vmemsize < 8192*1024)   {   // Trio64 supported only up to 4M
       vga.vmemsize = 4096*1024;
       vga.s3.reg_36 = 0x1a;      // 4mb fast page mode
+   } else {
+      vga.vmemsize = vmemsize*1024;
+      vga.s3.reg_36 = 0x7a;      // amount in MB set in conf file      
    }
 
    // S3 ROM signature

Of course, this doesn't compile. Can anyone help me out here? How can I "connect" the value in the cpp files to the variable used in the conf file of the compiled binary?
vmem_error.jpg
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby spiroyster » 2018-11-30 @ 10:26

Change...
Code: Select all
vga.vmemsize = vmemsize*1024;

to...
Code: Select all
vga.vmemsize = vga.vmemsize*1024;


For both lines.
User avatar
spiroyster
Member
 
Posts: 407
Joined: 2015-10-12 @ 12:26

Re: How to increase video memory?

Postby Yesterplay80 » 2018-11-30 @ 11:06

Thanks, it compiles now, but no matter what I set for vmemsize in the conf file, VBETEST always reports back only 512kbyte of video memory, which seems to be a fallback minimum defined in vga_s3.cpp:
Code: Select all
// Set CRTC 36 to specify amount of VRAM and PCI
   if (vga.vmemsize < 1024*1024) {
      vga.vmemsize = 512*1024;
      vga.s3.reg_36 = 0xfa;      // less than 1mb fast page mode

With all other DOSBox binaries I tried the memory is reported correctly. Something is missing obviously.
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby spiroyster » 2018-11-30 @ 11:26

Actually scratch that change to get it to compile. The line doesn't make sense.. since the previous condition checks if vga.vmemsize is 0, the expression is always going to evaluate to 0.

Need to see the rest of the source to see where the vmemsize (not vga.vmemsize) value is defined. Is that code you posted just the diff from sourceforge?

[EDIT:] I don't think having a variable vmemsize for S3 hardware is going to work. Like ripsaw said, you need to set the registry value that corresponds to the size of the buffer, unless you know that you will be out of luck.
User avatar
spiroyster
Member
 
Posts: 407
Joined: 2015-10-12 @ 12:26

Re: How to increase video memory?

Postby ripsaw8080 » 2018-11-30 @ 11:50

Well, you could simply borrow the relevant code from the Daum build, as it has a conf-configurable vmemsize. Still, I don't know what the fuss is for if it's all about the Build Engine; just use machine=vesa_nolfb to be rid of flicker.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4274
Joined: 2006-4-25 @ 23:24

Re: How to increase video memory?

Postby Yesterplay80 » 2018-11-30 @ 13:16

ripsaw8080 wrote:Well, you could simply borrow the relevant code from the Daum build, as it has a conf-configurable vmemsize.

DOSBox-X has it, too. But I can't figure out what I'm missing, due to a lack of knowledge.
ripsaw8080 wrote:Still, I don't know what the fuss is for if it's all about the Build Engine; just use machine=vesa_nolfb to be rid of flicker.

I personally am fine with just 800x600, but obviously many like the possibility to use much higher resolution, which, afair, were not even available with the standard 2 MB. That's why I raised the memory to 8MB in ECE.
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby ripsaw8080 » 2018-11-30 @ 13:38

The Build Engine only uses 8-bits per color modes, and 2 MB is enough of a frame buffer for even 1600x1200, although the highest resolution built into vanilla DOSBox is 1280x1024. If you want higher resolution AND higher color depth for some reason then more video memory becomes necessary, but again, Build ignores any mode that isn't 8-bit color.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4274
Joined: 2006-4-25 @ 23:24

Re: How to increase video memory?

Postby Yesterplay80 » 2018-12-01 @ 10:08

I just played a bit of Blood and Redneck Rampage with vesa_nolfb and indeed, it ran just fine and I didn't encounter any flickering. So if more memory actually serves no other purpose, I think I'll stick with a maximum of 4 MB as a compromise, which also prevents the graphics error with the mouse pointer in Windows 3.1.
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: How to increase video memory?

Postby Jo22 » 2018-12-06 @ 02:36

Yesterplay80 wrote:[..] which also prevents the graphics error with the mouse pointer in Windows 3.1.

Now that's interesting. I had no clue this was related to video memory size. I also encountered in VPC2007 (16MiB S3).
Back in tme I solved this glitchy pointer issue issue by switching between S3 Trio and S3 864 1.41B5 drivers..
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3036
Joined: 2009-12-13 @ 07:06
Location: Europe


Return to DOSBox Development

Who is online

Users browsing this forum: rcblanke and 2 guests