dege-diosg / dgVoodoo2

Glide/DirectX implementation on D3D11/12
865 stars 36 forks source link

Simcity4 has glitch in texture and flickering with dedicated card rendering #3

Closed rainman7cn closed 3 years ago

rainman7cn commented 3 years ago

Dear Dege, Glad to see you put dgvoodoo into Github, I have used dgvoodoo to drive Simcity for one year, dgvoodoo is the only wrapper which could play Simcity 4 with my dedicated graphic, whereas still have some issues, i just concluded these results in the game's community here My laptop's SPEC: Windows 10 and Optimus laptop (No Mux output) Intel(R) HD Graphics 630 (Integrated Graphic Card) and NVIDIA GeForce GTX 1050ti Driver: 456.55 ID:10DE 1C8D 8217103C (Dedicated Graphic Card) 1, Without any wrapper, SC4 runs with Integrated card (Intel 630), Screen flickering or frames droping when draging and zoom in/out. and becomes to more worse when population up to about 1000000. 2, With dgvoodoo's full screen mode, SC4 runs with dedicated card (GTX 1050ti), But some textures abnormal or flickering, Such as water: (the flicker just happens somewhere when clicking) 20201003132418 jpg 3d983b5cda7fa801f63229f6b8187c25 3, With dgvoodoo's window mode, SC4 runs with dedicated card (GTX 1050ti), issues get better, but still a bit delay when dragging screen, 20201003132554 jpg 53a47db913dac932d9d8c854d34f78fe

I have no issue with DDrawCompat but it runs with integrated card, here below is the normal one: New-City-Jan jpg eb243f70dc77b88a53c401fce0660800

rainman7cn commented 3 years ago

Besides, this game has to modify its rule files so that dgvoodoo could be recognized, Graphics-Rules_sgr jpg 61e21bc96abfd95d95d89e4e41178f35 Video-Cards_sgr jpg 62701698e8cd580190617edeb53b2cb4 and here below is game's log:

Log generated on 10/3/2020, 13:16 Flags

hardwareDriver = true DXT = true fullscreen = false MMX = true FPU = true backingStore = true forcedFSAA = false

Strings

userName = Raymond appName = SimCity 4 version = 1.1.641.0 osVersion = Windows NT 6.2 computerName = HP-RAYMOND CPU = GenuineIntel sglDriverName = DirectX sglDriverVersion = 2.0 driverName = dgVoodoo driverVersion = 17479.2.7.0, GUID: D7B71E3E-5105-11CF-E877-FE140EC2CD35 cardName = dgVoodoo DirectX Wrapper cardVersion = Vendor: 0000, Device: 0000, Board: 0000, Chipset: 0000 cardIdentity = dgvoodoo, DirectX Wrapper soundDriverName = soundCardName = Audio SOund buildType = Release

Numbers

cpuSpeed = 2496 memory = 4096 freeMemory = 4096 screenWidth = 1920 screenHeight = 1080 screenBPP = 32 videoMemory = 2048 textureMemory = 2048 textureStages = 8 bogoFPS = 0 bogoMPPS = 0

Rules

applying Sound applying high sound detail applying City Detail and Day/Night Settings applying low computer power> applying high computer power option 9 = 3 option 13 = 1 option 15 = 3 applying Texture Quality and Building Variety Settings applying low memory> applying high memory option 3 = 3 option 14 = 3 applying Variable Speed Automata applying default option 10 = 1 applying Standard hardware option 0 = 1 option 1 = 1 option 2 = 1 option 4 = 0 option 5 = 1 option 8 = 1 option 7 = 1 option 6 = 1 option 11 = 0 option 12 = 0 applying Standard hardware> option 1 = 2 applying Standard hardware>> option 0 = 2 applying Standard hardware>>> option 2 = 2 applying Standard hardware>>>> option 4 = 1 applying Standard hardware>>>>> option 11 = 1 applying Two stages applying Lotsa vidmem applying Not Slow GeForce applying Fast card applying Fast card> option 12 = 1 applying Fast card>> option 1 = 3 applying Fast card>>> option 0 = 3 applying Fast card>>>> option 2 = 3 applying Fast card>>>>> option 4 = 1

Options

Visual Effects current: 2 recommended: 3 Cars/Sims current: 1 recommended: 3 Shadows current: 1 recommended: 3 Atmospheric effects current: 1 recommended: 1 Water effects current: 0 recommended: 1 Software/Hardware current: 1 recommended: 1 Cursor current: 0 recommended: 1 VariableSpeedAutomata current: 1 recommended: 1 Translucent UI current: 1 recommended: 1 Graphic Detail current: 3 recommended: 3 Building Load Speed current: 3 recommended: 3 Texture Quality current: 3 recommended: 3

Properties

forcesoftwaredriver = false renderdynamicview = true renderstaticview = true renderwatereffects = true rendercloudsandfog = true forcepointsampling = false forcebilinear = false forcenoalphablend = false forcenoalphatest = false rendershadows = true renderdecals = true usesecondstage = true forcedebugtexture = false renderparticleeffects = true renderflorashadows = true renderterrain = true showupdateregions = false usecursoreffects = true drawlottextures = true drawlotfoundations = true drawlotwalls = true forcetexturerepeat = false usescreenshake = true renderui = true useupdaterectclipping = true usevertexbuffers = true showboundingboxes = false useoverlayculling = true rendersnapshot = false noaddsigned = false nopartialbackingstorecopies = false usescreenflash = true renderautomata = true preferopaque = false displayalertborders = true drawlotopaquetextures = true useviewcleanup = false doautozoomandrotationchanges = true

viewoffsety = 0 viewoffsetx = 0 texturebits = 32 lodoffset = 0 shadowdebug = 0 maxparticlestarget = 10000 particlelodoffset = 0 effectprioritylevel = 5 backingstoremaxzoomall = 5 backingstoremaxzoombuildingsprops = 5 backingstoremaxzoomterrain = 5 backingstoremaxzoomflora = 5 shadowquality = 2 minvehiclezoom = 3 minpedzoom = 4 cursortype = 1 depthoffset = 2 debugtexture = 0 dirtyrectmergeframes = 2 sounddetail = 2 buildingvariety = 2 buildingloaderspeed = 1 modellodoffset = 0 stringtexturecachesize = 1024

particleeffectslod = 5 splattexturescale = 50 texbindmaxfree = 8 particledensity = 1 particledamping = 0 particlescale = 1 lightingupdatedelta = 0.0001 shadowmodelthreshold = 12 demolishmodelthreshold = 12 rendermodelthreshold = 6 rendermodelthresholdscroll = 40 particlesizethreshold = 300 maxvehiclepct = 1 maxpedpct = 1 opaqueuialphavalue = 0.55

rainman7cn commented 3 years ago

;========================================================================== ; === Text based config file for dgVoodoo2 ; === Use this file if you are a game modder/hacker or an experted user and ; want to modify some advanced properties not available via the CPL. ;==========================================================================

Version = 0x262

;--------------------------------------------------------------------------

[General]

; OutputAPI: "d3d11warp", "d3d11_fl10_0", "d3d11_fl10_1", "d3d11_fl11_0", "bestavailable" ; Adapters: "all", or the ordinal of the adapter (1, ...) ;FullScreenOutput: "default", or the ordinal of the output on the adapter (1, ...) ; ScalingMode: "unspecified", "centered", "stretched", "centered_ar", "stretched_ar", ; "stretched_4_3", "stretched_4_3_crt", "stretched_4_3_c64"

OutputAPI = bestavailable Adapters = 1 FullScreenOutput = default FullScreenMode = true ScalingMode = unspecified ProgressiveScanlineOrder = false EnumerateRefreshRates = false

Brightness = 100 Color = 100 Contrast = 100 InheritColorProfileInFullScreenMode = false

KeepWindowAspectRatio = false CaptureMouse = false CenterAppWindow = false

;--------------------------------------------------------------------------

[GeneralExt]

; DesktopResolution: Desktop (native) resolution can be forced for dgVoodoo's internal calculations. ; Useful for rare applications that pre-set the desktop to other than the native ; resolution before dgVoodoo gets in action. Only the compact format can be used here, ; and applies to all outputs of the desktop. ; DesktopBitDepth: You can define what screen bit depth should be reported through dgVoodoo ; (8, 16, 32) ; DeframerSize: When resolution is forced to other than the app default then ; a black frame is drawn around the output image coming from a wrapped API ; to remove scaling artifacts - ; frame thickness can be defined in pixels (max 16, 0 = disable) ; ImageScaleFactor: Integer factor for scaling the output image coming from a wrapped API ; Always done by nearest point filtering, independent on scaling mode ; (0 = max available) ; Separate factors can be defined for horizontal and vertical scaling ; by subproperties, e.g. ; ImageScaleFactor = x:3, y:2 ; DisplayROI: Display region of interest ; If scaling is done by the dgVoodoo then you can define a subrect of the ; output image, coming from a wrapped API, to be displayed. The defined subrect ; is mapped to the display output according to the current scaling mode ; It can be useful for applications rendering a widescreen subimage into a 4:3 ; resolution; in this case you can scale up that subimage to (nearly) fill the ; whole screen on a widescreen monitor. ; DisplayROI empty value means the whole image. ; DisplayROI value can be a proportion in form of %d_%d or a pixel size (%d|%d) ; Pos subproperty is not mandatory and can be 'centered' or a pixel position (%d|%d) ; Examples: DisplayROI = 16_9, pos:centered ; DisplayROI = (320|200), pos:(10|10) ;ForceNearestPointFilter: When scaling is done by the dgVoodoo for the given scaling mode, ; you can force nearest point filtering instead of bilinear one ; FreeMouse: If true then physical mouse is free to move inside the game window ; when using emulated scaling and/or application and forced resolution ; differs; can be useful when a game relies on the physical window size ; WindowedAttributes: You can define attributes for forced windowed appearance (separated by commas): ; 'borderless' - forces the app window not have any border ; 'alwaysontop' - forces the app window into the top-most band ; 'fullscreensize' - forces the app window to be full screen size with image scaling inside ; Environment: Software environment in which dgVoodoo is running: can be left unspecified (native) ; or can be set to 'DosBox' or 'QEmu'. ; EnableGDIHooking: If enabled then dgVoodoo hooks GDI to be able to render graphical contents ; (like movie playback through the ancient Windows Multimedia AVI player library) ; rendered through GDI - experimental feature, for the time being it's implemented ; only for DX emulation

DesktopResolution = DesktopBitDepth = DeframerSize = 1 ImageScaleFactor = 1 DisplayROI = ForceNearestPointFilter = false FreeMouse = false WindowedAttributes = Environment = EnableGDIHooking = false

;--------------------------------------------------------------------------

[Glide]

; VideoCard: "voodoo_graphics", "voodoo_rush", "voodoo_2", "voodoo_banshee", "other_greater" ; OnboardRAM: in MBs ; MemorySizeOfTMU: in kBs ; ; Resolution: either "unforced", "max", "max_isf", "max_fhd", "max_fhd_isf", "max_qhd", "max_qhd_isf", "%d x" ; or subproperties: h: horizontal, v: vertical ; + optional subproperty refrate: refresh rate in Hz ; e.g. Resolution = max, refrate:60 ; Resolution = 2x, refrate:59 ; Resolution = h:1280, v:1024, refrate:75 ; or just use the compact form like "1024x768@60" or "512x384" ; ;Antialiasing: "off", "appdriven", "2x", "4x", "8x", "16x" (your GPU must support the chosen one)

VideoCard = voodoo_2 OnboardRAM = 8 MemorySizeOfTMU = 4096 NumberOfTMUs = 2 ForceBilinearFilter = false DisableMipmapping = false Resolution = unforced Antialiasing = appdriven

EnableGlideGammaRamp = true ForceVerticalSync = true ForceEmulatingTruePCIAccess = false 16BitDepthBuffer = false 3DfxWatermark = true 3DfxSplashScreen = false PointcastPalette = false EnableInactiveAppState = false

;--------------------------------------------------------------------------

[GlideExt]

; DitheringEffect: "pure32bit", "dither2x2", "dither4x4" ; Dithering: "disabled", "appdriven", "forcealways" ; DitherOrderedMatrixSizeScale: integer scale value for dither matrix size ; 1 = normal, 2 = double size, etc. ; 0 = automatic (the aim is to have some retro feel&look)

DitheringEffect = pure32bit Dithering = forcealways DitherOrderedMatrixSizeScale = 0

;--------------------------------------------------------------------------

[DirectX]

; VideoCard: "svga", "internal3D", "geforce_ti_4800", "ati_radeon_8500", ; "matrox_parhelia-512", "geforce_fx_5700_ultra" ; VRAM: in MBs (default) or in GBs (e.g. VRAM = 2GB) ; Filtering: "appdriven", "pointsampled", "bilinear", "linearmip", "trilinear" ; or the integer value of an anisotropic filtering level (1-16)

DisableAndPassThru = false

VideoCard = internal3D VRAM = 2048 Filtering = appdriven DisableMipmapping = false Resolution = unforced Antialiasing = appdriven

AppControlledScreenMode = false DisableAltEnterToToggleScreenMode = false

BilinearBlitStretch = false PhongShadingWhenPossible = false ForceVerticalSync = false dgVoodooWatermark = false FastVideoMemoryAccess = false

;--------------------------------------------------------------------------

[DirectXExt]

; AdapterIDType: "nvidia", "amd", "intel" or leave it undefined ; You can define what type of driver version and vendor id's the wrapper should report to ; the application; Some games rely on that information so it can be useful for them ; Can be defined only for SVGA and Internal3D card types; the others have their own wired ; information

; VendorID, DeviceID, SubsystemID, RevisionID: ; Can be defined only for SVGA and Internal3D card types ; You can overwrite these properties even if a non-default AdapterIDType is defined; ; say, you defined an nvidia id type but would like to refine the vendor id

; DefaultEnumeratedResolutions: you can define what resolutions should be enumerated to the application by default ; "all", "classics", "none"

; ExtraEnumeratedResolutions: you can add extra resolutions (separated by commas, max 16) that will get ; enumerated to the application as display adapter supported ones - ; can be useful if an app supports rendering at arbitrary resolutions ; and you have a particular favorite resolution that are not ; enumerated to the application by default ; you can either use the compact resolution format here, or ; "max", "max@refrate" meaning your desktop resolution with a potential refresh rate, or ; "max_4_3", "max_4_3@refrate", "max_16_9", "max_16_9@refrate" ; meaning the maximum resolution with the given aspect ratio calculated from ; the desktop resolution with the given refresh rate, e.g. "max_4_3@60", "max_16_9"

; EnumeratedResolutionBitdepths: you can filter what bitdepths are included in the resolution enumeration ; any subset of {"8", "16", "32"}, or "all"

; DitheringEffect: "pure32bit", "ordered2x2", "ordered4x4" ; Dithering: "disabled", "appdriven", "forceon16bit", "forcealways" ; DitherOrderedMatrixSizeScale: integer scale value for dither matrix size ; 1 = normal, 2 = double size, etc. ; 0 = automatic ; DepthBuffersBitDepth: internal bit depth of depth/stencil buffers for 3D rendering (32 bit is not recommended) ; "appdriven", "forcemin24bit", "force32bit"

; MaxVSConstRegisters: Max number of vertex shader constant registers (DX8/9 only) ; Can be defined only for SVGA and Internal3D card types ; Valid values are 256 (default), 512 or 1024

; MSD3DDeviceNames: if true then original Microsoft D3D device names are exposed ; (some applications check for them and they fail)

; RTTexturesForceScaleAndMSAA: if true then forced resolution scaling and MSAA is ; applied also to rendertarget textures ; Set it to false for games requiring pixel-precise rendering ; but be careful it can EASILY break certain things, not recommended

; SmoothedDepthSampling: if true then extra smoothing is added to depth textures ; when they are sampled

; DeferredScreenModeSwitch: If true the switching to full screen is deferred after the application initialized ; the DirectX device; can be useful for games that don't expect rendering window changes ; during initialization and crash

; PrimarySurfaceBatchedUpdate: If true then direct changes of the primary surface are batched together for presenting them ; If false then each change is instantly presented (debug-like mode)

AdapterIDType = VendorID = DeviceID = SubsystemID = RevisionID =

DefaultEnumeratedResolutions = all ExtraEnumeratedResolutions = EnumeratedResolutionBitdepths = all

DitheringEffect = pure32bit Dithering = forcealways DitherOrderedMatrixSizeScale = 0 DepthBuffersBitDepth = appdriven

MaxVSConstRegisters = 256

MSD3DDeviceNames = false RTTexturesForceScaleAndMSAA = true SmoothedDepthSampling = true DeferredScreenModeSwitch = false PrimarySurfaceBatchedUpdate = false

;--------------------------------------------------------------------------

[Debug]

; This section affects only debug/spec release builds ; ; Info, Warning, Error ; "Disable" - disables all messages and debugger break ; "Enable" - enables messages and disables debugger break ; "EnableBreak" - enables both messages and breaking into debugger ; ; MaxTraceLevel: Maximum level of tracing API calls ; 0 - Disable ; 1 - API Functions and methods ; 2 - Additional trace info for internals ; ; LogToFile: if false or debugger is detected then output goes to the debug output ; if true and no debugger detected then output goes to 'dgVoodoo.log' ; (not implemented yet, always the default debug output is used)

Info = enable Warning = enable Error = enable MaxTraceLevel = 0

LogToFile = false

rainman7cn commented 3 years ago

I have tried many combinations of setting, but still have no luck there, Really appreciate any advice on this, I can do any further tests whenever you suggest, Thank you very much for the efforts you put into this so that we could continue with our beloved game. Sincerely, -- Raymond

dege-diosg commented 3 years ago

Thanks for the feedback!

I don't really have an idea and I don't yet have this game but I'll look into it later.

rainman7cn commented 3 years ago

@dege-diosg , Thank you very much, Dege, Do you have an email? i have an issue about donation which i hope to consult you a bit there.

dege-diosg commented 3 years ago

@rainman7cn I had a look at this game, and indeed, color banding appears with dgVoodoo. I think the game uploads its textures in 16 bit color quality for some reason (even if 32 bit quality is selected) but I didn't yet figure out the reason. I guess it's somehow related to video card vendorID/deviceID (but it's just a guess) which is NULL for the internal video card by default. I couldn't find any valid values though, so it all requires more debugging and deeper understanding of what happens in the game.

Yes, I have an email address. Can we send private message to each other on GitHub?

rainman7cn commented 3 years ago

@dege-diosg Ah, Sorry for my rudeness, I do hope so, Sir, whereas i couldn't find it out in Github, Maybe we couldn't as below: https://github.community/t/how-send-a-private-message-to-github-users/2539 Anyway, This is my email address, it doesn't matter to me. raymond7cn@gmail.com Thank you ! Sincerely, -- Raymond

rainman7cn commented 3 years ago

In terms of 32 bit color, I forgot to mention it, we need to add parameters into its shortcut's property : https://wiki.sc4devotion.com/index.php?title=File:Shortcut_Properties.jpg I used these parameters to run the game with dgvoodoo: …Simcity 4.exe" -f -CustomResolution:enabled -r1920x1080x32 -intro:off -d:directx -CPUCount:1

https://wiki.sc4devotion.com/index.php?title=Shortcut_Parameters I hope it helps. Sincerely, -- Raymond

dege-diosg commented 3 years ago

No problem, it wasn't rudeness. I'm not that familiar with GitHub yet, that's why I asked it.

Thanks for the addendum, I'll give it a go. I noticed that the game sets a 16bit display mode even if 32bit quality is selected in the options.

rainman7cn commented 3 years ago

Ah, i got your point, Dege, You mean even i have set game to 32 bit colors and there is texturebits = 32 in game's log, But Actually, The game runs in 16 bit mode, I'm not profession on this, However it explains my result, From the shot i captured above, i can see the side water is abnormal, Meanwhile, i know some game's textures reference to some special pics, For instance, the side water, there is a 1x128 pixels picture which decides how the water changes gradually. Here below is a post we discuss about this: https://community.simtropolis.com/forums/topic/758160-coris-side-water-alternate-paint-scheme-tutorial/ Thank you for advancing! Sincerely, -- Raymond

dege-diosg commented 3 years ago

I found the root of the color banding problem:

No matter what bit depth parameter you start the game with, it always sets the given resolution at 16bit mode as fullscreen mode. I found it hardwired in the game code. This is a problem because the game adjusts the color bit depth of its textures (or certain textures) to the screen mode. That's why you get low quality textures with dgVoodoo.

The game runs perfectly fine for me natively (with MS DX) with good quality textures. The trick is, Windows has a built-in app-compatibility entry in its system compat database:

image

The entry I marked with the red rectangle makes MS DDraw to override its default behavior and always create a 32bit flipping chain for this game, so the textures become 32bit as well. That's what I cannot do with dgVoodoo, as it doesn't have any game specific code and tweak.

The best I can do is give you a patched SimCity4.exe with hardwired 32bit screen mode which seems to work nicely with dgVoodoo too.

dege-diosg commented 3 years ago

Try this version of the executable, patched to 32bit display mode:

SimCity 4_32bit.zip

dege-diosg commented 3 years ago

I suppose the modified executable works as expected, so I close this issue. Let's reopen it if any further question arises.