Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetCompatibleFormats() not implemented correctly. #1

Open
thorfdbg opened this issue Mar 24, 2023 · 5 comments
Open

GetCompatibleFormats() not implemented correctly. #1

thorfdbg opened this issue Mar 24, 2023 · 5 comments

Comments

@thorfdbg
Copy link

Just browsing the code... the "GetCOmpatibleFormat()" function is not implemented in a correct way and may cause disruptions or color artefacts if the chip driver or card driver supports aperture switches.

First of all, the mask supplied here is (ULONG)~PLANAR, which is just binary %1111...1110, thus the remaining terms that are or'd are just superfluous. What that term means, however, is that if the chip or card supports both big and little endian access, then both can be accessed at the same time without an aperature switch for all modes (16 and 32 bit modes) in the same memory window. This is typically not true, and thus may result in false colors in some modes, in particular if a non-native endianness is used.

Some background information:

The video RAM typically sits behind a "bit-flip" driver that can, upon request, perform a big to little-endian switch. How that switch operates or is controlled depends on the chip and card design, of course, but there are two typical designs:

Design a) is that the switch is dynamically controlled through an I/O port. In that case, big and little endian modes cannot be on the card in the same time as their interpretation changes dynamically with how the switch is operated. In such case, the GetCompatibleFormats() call should only the bitmask of the modes that share the same aperture switch control as the mode passed in.

This design applies, for example, for the Cybervion3D in Zorro-II mode.

Design b) makes all modes (or a subset of the modes) available through multiple windows in the 68K address space, and depending into which window you write, an endian swap happens or not. In such a case, all modes are compatible, but thue card interface then also needs to supply a GetMemory() function that, upon the RGB format passed in, adjusts the memory pointer to point to the correct aperture window into which a write has to go.

This design applies for the CyberPPC and Cybervision3D in Zorro-III mode.

Which of the two designs applies to the graphics cards behind a Prometheus switch I can only guess, that is up to the card author (i.e. "you") to know. (-:

In either case, the interface is incomplete by missing a function or not providing a consistent mask of compatible modes. Please check (carefully!) the P96 API specification at icomp.

As always, I am happy to help through mail if you have further questions.

Greetings,
Thomas

@DvdBoon
Copy link
Contributor

DvdBoon commented Jan 20, 2024

@thorfdbg Sorry for the late reply and thanks for looking at this. This part of the code I have no clue about. I took the source over from Tobias with the intention to add the PPC cards as their BARs behave differently to normal PCI cards.

Now, he had a HD crash so the sources were (much) older than the binary of library version 3.1 as his got lost, so I tried to reverse engineer it back into the source and called it 4.0. I haven't look at the .card side of things as I haven't seen color issues present itself (yet)

So that being said, I love to fix it. But I don't own P96 myself and so I don't have the API (it is part of the download, right?).

@mheyer32
Copy link

mheyer32 commented Feb 9, 2024

Even though this function is present in the Prometheus' card driver code, it is as far as I can see not actually being used. It seems, the card driver relies on the chip driver to implement it and link their own function into the boardinfo structure. At least that's how I did it for the Trio64 driver.
WRT aperture switch: I'm surprised you mention an aperture switch on the Cybervision64 which register would do such switch? (disregarding planar mode) . The Trio32/64 has AFAIK no such switch and exposes its memory (in chunky mode) as linear piece of LE memory.

The Trio64V+ and later models, however, have two apertures and expose the same memory through both windows at the same time. In this case CalculateMemory() can report either window to access the framebuffer depending on the requested format, while GetCompatibleFormats would claim that all formats can live on the board at the same time.

@thorfdbg
Copy link
Author

thorfdbg commented Feb 9, 2024 via email

@DvdBoon
Copy link
Contributor

DvdBoon commented Feb 9, 2024

The Voodoo works this way, I think. I noticed it on the Mediator, the memory list gets corrupted during an endian switch (to e.g. a PC mode) as the Mediator adds part of the VGA memory to the system as usable memory, but also places the memory header of this memory in the memory of the VGA card.

@thorfdbg
Copy link
Author

thorfdbg commented Feb 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants