Previous Thread
Next Thread
Print Thread
Page 1 of 4 1 2 3 4
#122494 07/17/23 01:53 PM
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
I was making a program so that I could re-create the UI system I wrote at my day job that I worked for the past 6 years (currently between jobs, starting a new one in August) in order to more easily make animations for the videos that I create, and wasn't sure what to choose as a renderer.

I did some cursory searching on Google, and found a minimal D3D11 example that manages to create a 3D scene and render it in just 340 lines of code - including comments.

I had kept hearing how weird D3D10 and D3D11 were, and I'll admit that they are compared to D3D9, but that's just it: They're weird compared to D3D9 and OpenGL, which were dominant in the industry at the time.

What does this have to do with MAME? Well, how many of you are tired of installing the June 2010 DirectX 9 redistributable, or are tired of having to tell users on Windows 8 and up to do so?

In any case, my code currently crashes - I'm not bringing things up in the correct order, as I don't seem to be creating a swap chain early enough - but, have some initial output!

Code
Direct3D11: Using D3D11
Physical width 2705, height 2080
Direct3D11: Initialize
Direct3D11: Configuring adapter #0 = NVIDIA GeForce RTX 3080
Direct3D11: Error 887A0001 during GetGammaControlCapabilities call
Creating texture manager
Direct3D11: Max texture size = 16384x16384

ETA: I know that BGFX is a thing now, but truth be told, I've been growing tired of dealing with it. It has random idiosyncrasies on some systems, it's not quite as good of an abstraction layer as it's held out to be, and it's tiresome having a nonexistent level of support. As I see it, the path forward leans primarily on a D3D11 renderer for Windows, a Vulkan renderer for Linux, and whatever it is that's allowed on macOS, then an OSD-side abstraction layer in front of all three.

Having modern standalone renderers for each OS opens the door to gradually shifting resources from a "core-owned, thrown over the fence to OSD" model which was growing increasingly archaic even when 0.106 rolled around, into a "core requests a handle for a hardware-backed buffer from OSD" model.

Much of MAME's rendering architecture still performs multiple copy operations between the time its core render system creates a texture, to the time the OSD is drawing it on-screen. Reworking this to directly fill screen-texture buffers, for example, eliminates these redundant copies.

Last edited by Just Desserts; 07/17/23 02:04 PM.
5 members like this: Waremonger, belegdol, B2K24, u-man, R. Belmont
Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
Great idea! If -video hlsl could just become D3D11 that would solve the persistent annoyance of the redistributable until we get to the new renderer, assuming none of our other DirectX backends (dsound, dinput) require it.

R. Belmont #122496 07/17/23 02:07 PM
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Originally Posted by R. Belmont
Great idea! If -video hlsl could just become D3D11 that would solve the persistent annoyance of the redistributable until we get to the new renderer, assuming none of our other DirectX backends (dsound, dinput) require it.

That's what I'm thinking, yeah. And ideally, the "new renderer" would just be a MAME-owned abstraction layer on top of a D3D11 renderer for Windows, Vulkan for Linux (and mobiles, too, though the Yuzu and Ryujinx people have some things to say on that), and whatever it is that macOS uses.

From there, it makes it easier to more gradually transition the rendering system, rather than doing it in one enormous task.

Joined: Jun 2001
Posts: 510
Likes: 24
O
Senior Member
Offline
Senior Member
O
Joined: Jun 2001
Posts: 510
Likes: 24
Yeah. The more complicated/interesting part of the "new renderer" will be to unify video effects so that they're common on all backends that can handle it (and vulkan/d3d11/metal/gl4 are essentially the same level of capability). With a touch of glslang/spirv-cross so that they're actually only written once.

Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
Metal on macOS was designed to facilitate D3D11 ports to an extent, but it's set up similarly to D3D12 and Vulkan.

And yeah, making the new renderer opt-in instead of global would be ideal. Start with the fallback where MAME renders in software and we're just blitting to the screen, add support for the common case of processing tilemaps and sprites on the GPU so we get half a million FPS in pacman on a 3080, and go forward from there.

Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
I just did some light reading on the differences between D3D11 and D3D12 - yeah, seems like a pretty major change, so most of this work towards a D3D11 renderer is a bit worthless. I like the sound of D3D12, though, it being more low-level sounds more my speed.

1 member likes this: u-man
Joined: Jun 2001
Posts: 510
Likes: 24
O
Senior Member
Offline
Senior Member
O
Joined: Jun 2001
Posts: 510
Likes: 24
Oh, I really expect the render-on-gpu to be fully optional. But we really need a better backend however we do the rendering, the per-osd video effects are beyond annoying, and bgfx not at all handling live shader compilation makes it a dead end.

3 members like this: u-man, Just Desserts, R. Belmont
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
After thinking about it, I'm not sure what GPU acceleration being optional gets you. If the intention is to preserve the existing F12 screenshot functionality that gets you the exact output of the driver with no post-processing, in order to be able to diff PNGs to find regressions, that can still be done. I can't think of a single platform at this point where taking a screenshot of a GPU-accelerated program is impossible, and it would be a win to be able to abandon the shitfest of code that is rendersw.hxx.

In other news, have a screenshot with things actually on-screen:
[Linked Image from i.imgur.com]

MAME currently crashes when quitting (not all resources are destroyed correctly), the initial info screen doesn't render for some reason, and as you can see, dynamic textures don't currently work. Still, it's progress. Last week was a non-MAME week for me since I had company over.

5 members like this: Dullaron, mixmaster, anoid, belegdol, R. Belmont
Joined: Jan 2021
Posts: 153
Likes: 5
=
Senior Member
Offline
Senior Member
=
Joined: Jan 2021
Posts: 153
Likes: 5
Beware! Keep GPU acceleration strictly optional. Not every office PC supports hardware 3D rendering or has Linux drivers those enable it on exotic (RasPi-like) hardware. My laptop e.g. has no modern 3D GPU at all.

And if MAME wants to be a "reference" implementation for rendering the most authentic graphics output, relying on the 3D SFX of the installed graphics card driver is a truly bad idea. E.g. you may get automatically interpolated sprite zoom pixels (blurred Atari Lynx games can look better, but are they authentic?) and all kind of image dishancer artefacts, those in future may go up to AI hallucinations those by default e.g. replace what looks like a pixelish tree with photos of an actual tree, similar like some soundcard drivers add reverb, loudness and equalizer to the sound. For a commercial game app player with emulation that is optimized for speed and "modern" image quality (upscaling etc.) the 3D graphics driver of the operating system may be an appropriate choice (with the same attitude like hacking the game code itself to run smoother or look more modern), but for MAME this needs to stay optional.

Last edited by =CO=Windler; 07/25/23 01:29 AM.

MAY THE SOFTWARE BE WITH YOU!

{weltenschule.de}
Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
You're 17 years behind MAMEdev's thinking on all of those topics. Please try to keep up.

- Pis that we support have GPU drivers. In 2023 if your device doesn't have GPU drivers, it sucks.
- We're going to run renderer programs on the GPU. No "normal" drawing will take place so the drivers can't touch it.

R. Belmont #122526 07/25/23 11:41 AM
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Originally Posted by R. Belmont
You're 17 years behind MAMEdev's thinking on all of those topics. Please try to keep up.

- Pis that we support have GPU drivers. In 2023 if your device doesn't have GPU drivers, it sucks.
- We're going to run renderer programs on the GPU. No "normal" drawing will take place so the drivers can't touch it.

Beyond that, Windler's bloviating is particularly fucking stupid and belies an abject sort of ignorance that can only come from not keeping up with his schizo meds. All of the potential "issues" cited aren't actually issues, because the person programming the renderer is in complete control of everything.

Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Got the info screens rendering again; it helps to update the constant buffer at the start of the frame, rather than when first encountering a screen texture.

[Linked Image from i.imgur.com]

Still left to do:
- Get the shader pipeline working again
- Get prescaling working again
- Figure out why some D3D11 resources are being leaked on exit

7 members like this: Dullaron, Darkstar, mixmaster, B2K24, pmackinlay, R. Belmont
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Currently working on getting the actual shader system (d3dhlsl.cpp) ported over to D3D11.

I finally have something showing up on-screen, but it doesn't seem quite right. wink

[Linked Image from i.imgur.com]

4 members like this: Dullaron, R. Belmont, robcfg, B2K24
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Shader system is ported over and running, but the actual post-processing is still pretty broken. That said, at least UI geometry and textures are routing through the shader system without issue:

[Linked Image from i.imgur.com]

7 members like this: Dullaron, B2K24, Luengo, anoid, mixmaster, R. Belmont
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Things are starting to look better. As far as I can ascertain, only the phosphor effect and bloom are broken right now. I thought scanlines were broken, but it was because I was doing all of my testing with the SGI Indy driver, which by default, outputs at 1288x1024 - a resolution that scanlines will naturally cause the equivalent of moiré if applied to:

[Linked Image from i.imgur.com]

3 members like this: Dullaron, Foxhack, R. Belmont
Joined: Jul 2007
Posts: 42
Likes: 2
Member
Offline
Member
Joined: Jul 2007
Posts: 42
Likes: 2
Great progress. We are doing something similar at work, moving an ancient GDI rendering to the GPU.

Will moving the rendering to the GPU help with the current issues with interlaced video, such as the laserdisc games?

Obviously there is a cost to software render to textures for the GPU. I would expect the post processing of scan lines to be faster on the GPU, but does the rendering to textures negate the performance gain? Would you expect any performance improvements, if not using scan lines or other effects? Maybe the GPU could scale to 4K instead of changing resolutions?

Too many questions. Thanks for your hard work.

A-noid.

Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
This work is just to port -video d3d9 to use D3D11, so that you don't have to install the Microsoft DirectX runtime on a new Windows 7/8/10/11 machine in order to run MAME.

There will be a more extensive new renderer down the line where doing things like a deinterlace shader could be a thing.

2 members like this: Dullaron, robcfg
R. Belmont #122559 08/02/23 04:02 PM
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Originally Posted by R. Belmont
This work is just to port -video d3d9 to use D3D11, so that you don't have to install the Microsoft DirectX runtime on a new Windows 7/8/10/11 machine in order to run MAME.

There will be a more extensive new renderer down the line where doing things like a deinterlace shader could be a thing.

You're correct, that's all this is, but these two things are a bit intertwined.

I'm using this as a learning opportunity to write a brand new video backend from scratch, or at least while being able to use the existing D3D9 renderer as a guide - which hasn't been as helpful as one might think, given how much rendering APIs have changed in the intervening decade and a half.

The next step from here is to write a D3D12 renderer, and once that's working, start looking at writing a Vulkan renderer, and the equivalent macOS backend via MoltenVK. I'm going to need you to be available for that when I get around to it, RB.

2 members like this: Waremonger, R. Belmont
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
More specifically, once all backends (Windows, Linux, macOS) are operating harmoniously, that's when the renderer rewrite becomes a viable thing.

Something I want to experiment with in a branch, prior to all of this, is adding the ability for drivers to request OSD resources more frequently than they currently do. Work units are currently something that the core benefits from which relies on handing out OS-side handles via the OSD layer, but beyond that, examples are pretty thin on the ground.

There are things as simple as bitmap allocation that currently exist 100% in software, but which would avoid a considerable amount of overhead if they could simply rely on being given a handle by the OSD layer. In the annoying and rare event that it's a purely software-rendering setup, or an anemic piece of hardware, then those handles can be managed in-situ by the relevant OSD module. If not, the OSD can hand off a handle to the relevant buffer in order to avoid a costly copy operation.

3 members like this: mixmaster, R. Belmont, Dullaron
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Quite a bit was broken compared to my original assumptions back on the 31st.

That said, all effects in raster mode are now working. This screenshot intentionally looks terrible, as it has all of the effects turned on and turned up in order to be distinctly visible:

[Linked Image from i.imgur.com]

To-do:
- Test vector screens and ensure those work
- Implement shader-based palette conversions and ditch the "copyline" functions (mainly porting over from the BGFX frontend)
- Massive amount of code cleanup
- Eliminate as many redundant state-set calls as possible

4 members like this: u-man, anoid, robcfg, Darkstar
Joined: Jul 2015
Posts: 114
Senior Member
Offline
Senior Member
Joined: Jul 2015
Posts: 114
Hi Just Desserts,

I dont know if it helps you, but for correct vector rendering, you should refer to version 0.179 . It is the last version, that rendered vector points in vector objects. I created a report on MT some years ago.

You can test vector point rendering pretty well with HLSL .ini settings:

red_ratio (Red Output from RGB)
grn_ratio (Green Output from RGB)
blu_ratio (Blue Output from RGB)

if you use higher settings then 1.0, the points will become more and more visible. These settings are named differently in the official MAME UI. I think it is RGB power there, but not 100% sure, can’t check it right now.

MAME versions higher then 0.179 , don’t support this HLSL settings no more.


I live... I die... I live again.
Joined: Jul 2015
Posts: 114
Senior Member
Offline
Senior Member
Joined: Jul 2015
Posts: 114


I live... I die... I live again.
Joined: May 2009
Posts: 2,157
Likes: 206
J
Very Senior Member
OP Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,157
Likes: 206
Managed to fix the bloom alignment, turns out the viewport should be rounded down to the nearest integer rather than passing in fractional viewport coordinates.

[Linked Image from i.imgur.com]

I'm ignoring the previous two posts on this page, as they're extremely premature and I'm obviously focusing on the initial bring-up, not fixing pre-existing bugs.

4 members like this: Mr. Do, Dullaron, ICEknight, Pernod
Joined: May 1999
Posts: 597
Likes: 1
Senior Member
Offline
Senior Member
Joined: May 1999
Posts: 597
Likes: 1
Those are some nice looking vectors, JD. Space Duel was a favourite game of my youth.

Joined: Mar 2010
Posts: 154
Likes: 1
S
Senior Member
Offline
Senior Member
S
Joined: Mar 2010
Posts: 154
Likes: 1
Wow does that look nice, JD. Pardon as I've been out of the loop on this one and may have missed something, but will this work on Linux or is that a challenge for another day?

Joined: Dec 2011
Posts: 192
Likes: 2
Senior Member
Offline
Senior Member
Joined: Dec 2011
Posts: 192
Likes: 2
It's Direct3D 11, so no, it obviously won't work on Linux lol.

Joined: Jul 2015
Posts: 114
Senior Member
Offline
Senior Member
Joined: Jul 2015
Posts: 114
Why is my comment removed???


I live... I die... I live again.
Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
You were bullying Just Desserts. His scope of work is his decision, not yours.

Joined: Jul 2015
Posts: 114
Senior Member
Offline
Senior Member
Joined: Jul 2015
Posts: 114
I dont get it, where i was bullying him? Its nonsense and in fact he is flaming me and my comments, calling them extremely premature and what not.


I live... I die... I live again.
Joined: Mar 2001
Posts: 17,070
Likes: 143
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 17,070
Likes: 143
Your comments were premature. The code isn't in a condition to fix your bugs, so it's premature to bring them up.

R. Belmont #122697 08/29/23 12:19 PM
Joined: Jul 2015
Posts: 114
Senior Member
Offline
Senior Member
Joined: Jul 2015
Posts: 114
Originally Posted by R. Belmont
Your comments were premature. The code isn't in a condition to fix your bugs, so it's premature to bring them up.

Ok, i understand it now. But still, i dont want to bully him, it is not like i give him orders what to do. For me it is only important, that this thing is not forgotten. When or if this solved at any point, is of course up to him. My thoughts where "tell this better earlier, then later where people could say, why you did not mentioned it earlier.", nothing else and please just believe this.


I live... I die... I live again.
Page 1 of 4 1 2 3 4

Link Copied to Clipboard
Who's Online Now
2 members (Augusto, nerd4gw), 33 guests, and 2 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,221
Posts120,756
Members5,053
Most Online1,283
Dec 21st, 2022
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com