1
0
Fork 0
Commit graph

5041 commits

Author SHA1 Message Date
krcroft
34d46ecd7f Fix alignment when incrementing values in the cache 2020-04-15 14:26:28 +02:00
krcroft
86249ec821 Fix alignment when fetching values in the decoder 2020-04-15 14:26:28 +02:00
krcroft
94c404577d Fix alignment when incrementing the invalidation map
We also eliminate the endian-branch because endian differences are
already taken care of in the host_add* functions.
2020-04-15 14:26:28 +02:00
krcroft
0d004f4c60 Fix alignment when writing to the cache 2020-04-15 14:26:28 +02:00
krcroft
32692cc50e Fix alignment when reading values from the write-map 2020-04-15 14:26:28 +02:00
krcroft
902c678081 Make host-mem functions endian-safe and alignment-safe
The host_read*, and host_write* functions currently rely on
casting unaligned memory to translate from byte arrays into
higher-level types (like 16and 32bit ints), however this
approach is implementation specific, can cause undefined
behavior, and forces the compiler to use less efficient
aliasing rules.

Unaligned memory casts have historically been corrected by
expanding multi-byte types into their constituents bytes,
shifting them, and re-packing. They've also been solved using
union objects to access the same underlying memory for each
member (legal under C, but not C++). However, we use memcpy
which is compact, readable, universally compatible, and
compiles down efficient inline single-instructions; therefore
imparting no penalty.

This commit adds host_add* functions (for 16 and 32bit values)
that add a host-formatted value to the implied value at a
memory address.

This commit adds handling for quad-words as well: host_readq,
host_writeq, which we use in the cache, which otherwise suffers
from the same alignment issues.
2020-04-15 14:26:28 +02:00
Patryk Obara
c05bbafb5d Create byteorder header for host_to_le functions 2020-04-15 00:01:25 +02:00
Patryk Obara
52fd4ed2d0 Hide remaining OpenGL parts behind C_OPENGL ifdef 2020-04-15 00:01:02 +02:00
Patryk Obara
851b65c5f9 Inform user about allowed windowresolution bounds 2020-04-14 06:28:08 +02:00
Patryk Obara
4a2369d4a6 Create aliases for boolean SetWindowMode parameters
This way it's more obvious to the reader, what given parameter does
(instead of non-descriptive 'false/true'.

Create alias 'FIXED_SIZE' for 'false' meaning "non-resizable" window. It's a
constexpr bool global variable, so compiler will remind us when it'll
be time to remove it.
2020-04-14 06:28:08 +02:00
Patryk Obara
6ee68c5182 Rework interface of GetAvailableArea function
New interface allows for shorter function and clearly states what
happens when sdl.draw.pixel_aspect == 1.0.
2020-04-14 06:28:08 +02:00
Patryk Obara
3680049510 Replace Bitu with size_t when drawing surface 2020-04-14 06:28:08 +02:00
Patryk Obara
7198ea306c Add SPDX identifier in sdlmain.cpp
At this point, this file was heavily modified compared to upstream
version, so include our own copyright line in here.
2020-04-14 06:28:08 +02:00
Patryk Obara
c24816a586 Check if window exists before making it resizable 2020-04-14 06:28:08 +02:00
Patryk Obara
65b4e7c5d7 Remove HandleVideoResize call from SetWindowMode
This call was useful during development and testing with
output=opengl, but now it's no longer necessary.  This call causes
output=texture to go into initialization loop, which falls back to
surface, which we definitely do not want.
2020-04-14 06:28:08 +02:00
Patryk Obara
75e0a1af86 Add windowresolution options: 'resizable' and 'default'
'resizable' option turns on resizable window if all the prerequisites
are met (OpenGL and compatible shader). Right now only shader 'sharp' was
tested as compatible, but other built-in shaders might be whitelisted in
the future as well (e.g. 'advmame*' shaders seem like good candidates).

Using incompatible shader does not cause any particular problems for the
users, but it looks really ugly - shader implementations clearly were
implemented only for a fixed window size.

'default' option acts as 'resizable' on Linux and 'original' everywhere
else. It also gives as an option to tweak available windowresolution
settings without causing too much disruption to end users.
2020-04-14 06:28:08 +02:00
Patryk Obara
2ab250d1a1 Update minimum window size
It's necessary for usecase when game changes resolution while in game.
We don't want to resize the window in such case, just change minimum
size (SDL might decide to update the window size in the result, if new
resolution is higher than current window size).
2020-04-14 06:28:08 +02:00
Patryk Obara
7a98ff787f Update clip when window is being resized
This works very well when user is resizing the window and going
in/leaving fullscreen.  It does not affect usecase where window size is
being updated by the emulator (e.g. game changing resolution).
2020-04-14 06:28:08 +02:00
Patryk Obara
a5e8118afd Cleanup and initialize all fields in sdl.draw 2020-04-14 06:28:08 +02:00
Patryk Obara
5ee474fdb8 Restore redraw instead of reset during expose
This prevents perceived lag window is being dragged (at least on Linux).
2020-04-14 06:28:08 +02:00
Patryk Obara
edf8e7e850 Make window resizable with a minimum size 2020-04-14 06:28:08 +02:00
Patryk Obara
860003a89f Calculate clip stretching inside the window 2020-04-14 06:28:08 +02:00
Patryk Obara
5b5cbd7f4b Watch window resize events 2020-04-14 06:28:08 +02:00
Patryk Obara
fff4dcf8b3 Add want_resizable_window flag 2020-04-14 06:28:08 +02:00
Patryk Obara
ffb9fe14bb Add 'resizable' parameter to SetWindowMode 2020-04-14 06:28:08 +02:00
Patryk Obara
c890c7b05b Implement iround helper function 2020-04-14 06:28:08 +02:00
krcroft
96943eb68b Add ARM platforms to the build script 2020-04-14 05:55:18 +02:00
Patryk Obara
1503fb4ebc Merge branch 'svn/trunk' r4336 2020-04-13 15:40:54 +02:00
Patryk Obara
cee4f1adba Update allowed warnings limits
Clang in MSYS2 got updated to Clang 10, and now detects some warnings,
that were earlier marked only by GCC.
2020-04-13 14:32:49 +02:00
krcroft
9d576b5cb7 Statically link libasan during ASAN builds
Some deployments of GCC won't link ASAN build without explicitly
specifying the library, and report:

  "ASan runtime does not come first in initial library list;
   you should either link runtime to your application or
   manually preload it with LD_PRELOAD"

This commit includes the asan library by default for respective
builds.
2020-04-13 14:15:07 +02:00
krcroft
85517f82a9 Add memory-count instrumentation to Clang MSAN builds 2020-04-13 14:15:07 +02:00
krcroft
e1d2fe3135 Make sanitizers platform-agnostic 2020-04-13 14:15:07 +02:00
ripsaw8080
d09f74cae8 Correct an oversight of r4186 when floppy disks are mounted.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4336
2020-04-12 20:21:12 +00:00
Patryk Obara
f5b0b0736c Update allowed warnings limits 2020-04-10 11:20:17 +02:00
Patryk Obara
e4b19ccd37 Fix window size and position when leaving fullscreen
Overrides previous, Windows-only hack used for the same purpose.

After initial window position, OS or window manager will take care of
emplacing window - this change takes care only of situation, when there
is NO initial window position.

Additionally, avoid re-setting the window size on every SetSDLWindowMode
call. This prevents a number of issues with the window being set to
incorrect size while switching between fullscreen and window.

Overally this change takes care of number of small issues happening on
macOS, Windows (without need for an ifdef), and Linux with KDE and MATE.
Also makes the behaviour more consistent for Gnome when starting dosbox
via XWayland.
2020-04-10 09:57:29 +02:00
Patryk Obara
803d65dd23 Log SDL window events
SDL2 introduced a bunch of new events, that old SDL1.2 implementation
did not have. We probably should start using some of them…

It's also extremely helpful for comparing order/number of window events
arriving on different OSes and WMs.
2020-04-10 09:57:29 +02:00
Patryk Obara
b6959e2e4c Add DEBUG_LOG_MSG macro
For printing logs only when DEBUG macro is turned on (without sprinkling
idefs all around the code).
2020-04-10 09:57:29 +02:00
Patryk Obara
86d6647b4e Improved windowresolution handling
Move the code to a separate function to make it easier to understand and
modify. Remove traces of windowresolution=X% support - this option
causes more harm than benefit.

Add bound checks to prevent user from setting up window size bigger then
configured display allows.
2020-04-10 09:57:29 +02:00
Patryk Obara
d0bf1ee09b Allow selecting windowresolution only on start
Changing this option dynamically via "config" built-in never worked, it
was always broken.  Set it to change'able only on start, otherwise all
broken edge-cases would need to be fixed.
2020-04-10 09:57:29 +02:00
Patryk Obara
294b1a5297 Change default render.scaler to "none"
And do small cleanup in surrounding area.

Using normal2x has several undesired side-effects:

- slightly slower performance (I did some perf flamegraphs and turns out
  scaler code is a significant bottleneck, even when using normal1x aka
  none) - we should limit it as much as possible before addressing the
  problem directly.
- it makes default glshader=sharp less precise
- it will negatively affect window resizing code
2020-04-10 09:57:29 +02:00
Patryk Obara
b1c69bebff Wrap description of sdl.mapperfile in .conf file 2020-04-10 09:57:29 +02:00
Patryk Obara
bf514eebfe Make HandleVideoResize a static function 2020-04-10 09:57:29 +02:00
krcroft
6d308e1129 Append to lists to avoid clobbering 2020-04-09 11:59:04 +02:00
krcroft
de3958fd74 Add an 'optinfo' build target
The 'optinfo' build target asks GCC to print optimizations that
could not be performed to local 'missing.txt' files; these will
appear in each repsective subdirectory having source files.

Both GCC and Clang will now print Verbose vectorization information
during the build process, often describing why vectorization
cannot be performed.

This commit also enables basic instruction and math vectorization
for both the 'release' and 'optinfo' targets. This includes making
use of altivec instructions (available on all powerpc processors),
and at a minimum sse4.2 on all x86_64 processors (circa-2008+ AMD
and Intel CPUs).

Vectorization is also re-enabled for GCC FDO builds, which would
otherwise be disabled when we switch to -O2 optimizations.
2020-04-09 11:58:51 +02:00
Patryk Obara
c7287e116e Fix Coverity warnings about BlockRead/Write
These are false-positive findings, but they touch flimsy part of code,
that could very easily break.

In all 4 cases the code looked like this:

    uint8_t buf[MEM_PAGE_SIZE];  // old lines 600, 601
    …
    if (region.bytes > MEM_PAGE_SIZE)
            toread = MEM_PAGE_SIZE; // old line 635
    else
            toread = region.bytes;

    // assert toread <= MEM_PAGE_SIZE
    if (toread < remain) {
            MEM_BlockWrite(…, buf, toread);
    } else {
            MEM_BlockWrite(…, buf, remain);
            MEM_BlockWrite(…, &buf[remain], toread - remain);
            //                ~~~~~~~~~~~~
            //                ^
            //                Coverity flags buffer overrun here
            //                when: toread == remain == MEM_PAGE_SIZE
            //                because buf has size MEM_PAGE_SIZE
            //
            // Sometimes it's MEM_BlockRead, but the problem is the same
    }

In such cases, second MEM_BlockWrite is a no-op because
(toread - remain == 0), but Coverity did not reach this point in
analysis (Coverity is right to check the corner case, but didn't know,
that we can assert toread <= MEM_PAGE_SIZE, so the corner case is the
only value triggering this buffer overrun).

Change `if (toread < remain)` to `if (toread <= remain)`, so corner case
will never trigger second (no-op) MEM_BlockRead/Write inside `else`.
2020-04-06 20:39:05 +02:00
Patryk Obara
a6792a44ad Fix effc++ warnings in ems.cpp 2020-04-06 20:39:05 +02:00
krcroft
278d699128
Update allowed warnings limits 2020-04-05 21:40:22 -07:00
David Reid
50df2eb641
Bump dr_flac to v0.12.9 2020-04-05 21:30:00 -07:00
David Reid
7236ea552d
Bump dr_mp3 to v0.6.1 2020-04-05 21:19:23 -07:00
Patryk Obara
fcf78f0e6c
Use more reference links in the readme file
This improves the readability of the file when viewed as plain text.
2020-04-05 08:48:02 +02:00