VirtualBox DirectX 9 crash

Just starting out? Need help? Post your questions and find answers here.
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

VirtualBox DirectX 9 crash

Post by Roger Hågensen »

The example code from the manual crashes in VirtualBox v5 (VirtualBox WDDM drivers installed in the Guest OS Windows 10 Preview).

I also confirmed the crash with one of my own programs, the error seems to be a invalid memory (trying to read from memory address $0000000C)
DirectX 11 not supported (Init failed), OpenGL works fine.

So either a bug in the DX9 stuff or the DX9 init lacks a check.

I used Geeks3D GPU Caps Viewer to check OpenGL caps.
By the looks of it the WDDM Guest driver seems to support OpenGL 2.1 however some things are a tad peculiar, like GLSL 4.40 seems to be available.
And the extension "GL_ARB_texture_rectangle (OpenGL 3.1)" seems to be available.
I have no idea how to quickly test DirectX 9 caps, but if PureBasic's DX9 init looks at shader model then that could be a cause of cofnusion I guess.

Code: Select all

If InitSprite() = 0
    MessageRequester("Error", "Can't open screen & sprite environment!", 0)
    End
  EndIf
  
  If OpenWindow(0, 0, 0, 220, 160, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ButtonGadget(0, 170, 135, 45, 20, "Quit")

    If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160)
      CreateSprite(0, 20, 20)
      If StartDrawing(SpriteOutput(0))
        Box(0, 0, 20, 20, RGB(255, 0, 155))
        Box(5, 5, 10, 10, RGB(155, 0, 255))
        StopDrawing()
      EndIf
    Else
      MessageRequester("Error", "Can't open windowed screen!", 0)
      End
    EndIf
  EndIf
  
  direction = 2
  Repeat
    ; It's very important to process all the events remaining in the queue at each frame
    ;
    Repeat
      Event = WindowEvent()
      
      Select Event 
        Case #PB_Event_Gadget
          If EventGadget() = 0
            End
          EndIf
        
        Case #PB_Event_CloseWindow
          End 
      EndSelect
    Until Event = 0
  
    FlipBuffers() 
    ClearScreen(RGB(0, 0, 0))
    DisplaySprite(0, x, x)
    x + direction
    If x > 140 : direction = -2 : EndIf
    If x < 0   : direction =  2 : EndIf
    Delay(1)
  ForEver
Here's hopefully relevant info from DxDiag:
Card name: VirtualBox Graphics Adapter for Windows Vista and 7
Manufacturer: Oracle Corporation
Chip type: VirtualBox VESA BIOS
DAC type: Oracle Corporation
Device Type: Full Device
Device Key: Enum\PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00
Display Memory: 383 MB
Dedicated Memory: 383 MB
Shared Memory: 0 MB
Current Mode: 1024 x 768 (32 bit) (60Hz)
Monitor Name: Generic Non-PnP Monitor
Monitor Model: unknown
Monitor Id:
Native Mode: unknown
Output Type: HD15
Driver Name: VBoxDispD3D.dll
Driver File Version: 5.00.0000.1573 (English)
Driver Version: 5.0.0.0
DDI Version: 9Ex
Feature Levels: 9.1
Driver Model: WDDM 1.0
Graphics Preemption: DMA
Compute Preemption: DMA
Miracast: Not Supported
Hybrid Graphics GPU: Not Applicable
Power P-states: Not Applicable
Driver Attributes: Final Retail
Driver Date/Size: 7/9/2015 11:56:26, 1352696 bytes
WHQL Logo'd: n/a
WHQL Date Stamp: n/a
Device Identifier: {D7B78E0E-FDAF-11CF-9565-0020AFC2C835}
Vendor ID: 0x80EE
Device ID: 0xBEEF
SubSys ID: 0x00000000
Revision ID: 0x0000
Driver Strong Name: oem5.inf:5503dd4286a0eee1:VBoxVideo:5.0.0.0:pci\ven_80ee&dev_beef
Rank Of Driver: 00F80003
Video Accel:
DXVA2 Modes:
D3D9 Overlay: Not Supported
DXVA-HD: Not Supported
DDraw Status: Enabled
D3D Status: Enabled
AGP Status: Not Available
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

Re: VirtualBox DirectX 9 crash

Post by Roger Hågensen »

I forgot to mention that it's not the InitSprite() function itself that crashes, but the OpenWindowedScreen() function.
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
Fred
Administrator
Administrator
Posts: 16690
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: VirtualBox DirectX 9 crash

Post by Fred »

You should post this as a bug for VirtualBox or I miss something ?
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

Re: VirtualBox DirectX 9 crash

Post by Roger Hågensen »

I have no clue if this is a bug in the PureBasic DX9 subsystem or not.

If PureBasic's DX9 subsystem is using Direct3D API features that it assumes is there (no feature testing) then that would be a PureBasic bug.


But I have no clue as to how to find out where the crash happens, or what causes it.


DX9 not working is not a major issue as I can test my program using OpenGL subsystem instead (DX11 does not work, Init returns false for that), my test was not the rendering anyway, but the crashing prevented me from testing other Windows API stuff.


Also, what would I report to the VirtualBox devs? That PureBasic compiled programs does not work? For all I know they'll just say that the issue lies with PureBasic.

I tested on a Windows XP VM in VirtualBox and there sprite init returns false so I can at least handle the error (show a error box and quit instead of crashing).
I then installed the Direct3D Hardware support addon for VirtualBox in XP. PureBasic DX9 works ok then.

But the XP 3D support modifies system files (requires booting into safe mode) while VirtualBox supports WDDM for Vista/7/8.x/10 (no need to boot into safe mode, though 8.x/10 needs the installing to be under Win7 compatibility mode).
The WDDM also makes OpenGL 2.1 available (if not you'll just get OpenGL 1.1)


As I said above, I don't have a problem with sprite init returning false for DX9, it's the unexpected crash when calling OpenWindowedScreen that is more worrysome.

For now I've resorted to using onerror and setting a variable to 1 just before trying to open the windowed screen and setting i to 0 after, that way in the onerror callback I'll know where the crash happen and can handle it. (I basically edit the saved setting for the program so the next time it will start up using the OpenGL compiled exe instead).
I'll also need to specify in the manual for my program that PureBasic DirectX9 exe does not work and will crash if run in a virtual machine.
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: VirtualBox DirectX 9 crash

Post by Danilo »

Did you install DirectX9 within your non-final Windows 10 virtual machine?

DX9 is so old, it even needs to be explicitely installed in Win8.1... (and if I remember correctly, even in Win7).
Additionally, Windows 10 isn't final yet. Add that to your manual, too. ;)

Try DirectX End-User Runtime Web Installer
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

Re: VirtualBox DirectX 9 crash

Post by Roger Hågensen »

I already did that as that was one of my suspicions as well.


Another thing that is odd is the following does not crash, it just quits at OpenScreen. No error no crash it just seems to quit.

Code: Select all

If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Sprite system can't be initialized", 0)
  End
EndIf

;
; Now, open a 800*600 - 32 bits screen
;
If OpenScreen(800, 600, 32, "Sprite")

  ; Load our 16 bit sprite (which is a 24 bit picture in fact, as BMP doesn't support 16 bit format)
  ; 
  LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
  CopySprite(0, 1, 0)
  
  Repeat
    
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    
    FlipBuffers()
    
    ClearScreen(RGB(0,0,0))
    
    ; Draw our sprite

    ClipSprite(0, 0, 0, x, x/8)
     
    DisplaySprite(0, x, 100)
    DisplaySprite(1, x, x)
    DisplaySprite(0, 600-x, x)
    
    x+1
    
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
  
Else
  MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

Re: VirtualBox DirectX 9 crash

Post by Roger Hågensen »

Danilo wrote:Windows 10 isn't final yet. Add that to your manual, too. ;)
Well in 3 weeks Windows 10 is released so it's final then.

Also the WDDM driver is the same for Vista/7/8/8.1/10. If I have some time to spare I may test it on the other VMs but right now I'm busy tweaking my program in preparation for Win10 (and to make the program look/behave similar across pretty much the entire series of Windows OSes so far.
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
User avatar
Roger Hågensen
User
User
Posts: 47
Joined: Wed Mar 25, 2015 1:06 pm
Location: Norway

Re: VirtualBox DirectX 9 crash

Post by Roger Hågensen »

I just did a quick test of the OpenWindowedScreen demo and it does not crash on a Vista VM in VirtualBox using WDDM drivers, in fact it seems to run without any issues at all. I also tested my own program and tat works fine there too.
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: VirtualBox DirectX 9 crash

Post by Everything »

Confirm WinXP x32 with DX9 installed PB 5.70 VBox 5.2

Crash right after d3d9.dll loading and Direct3DCreate9 call...
Post Reply