Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sync/qemu-7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed Jun 18, 2023
2 parents 7cbe9d3 + 0ee7502 commit 976319b
Show file tree
Hide file tree
Showing 46 changed files with 1,714 additions and 251 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ jobs:
dist/xemu-macos-universal-debug/xemu-macos-universal-debug.zip
dist/xemu-ubuntu-release/xemu/xemu-v${{ env.XEMU_VERSION }}-x86_64.AppImage
dist/xemu-ubuntu-debug/xemu/xemu-v${{ env.XEMU_VERSION }}-dbg-x86_64.AppImage
- name: Trigger website update
uses: benc-uk/[email protected]
with:
workflow: build.yml
repo: xemu-project/xemu-website
token: ${{ secrets.XEMU_ROBOT_TOKEN }}
ref: master

# Sync archive version of source (including submodule code) to the
# ppa-snapshot branch to work around limitations of the Launchpad platform,
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/trigger-website-update.yml

This file was deleted.

6 changes: 6 additions & 0 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -2782,6 +2782,12 @@ static void bdrv_default_perms_for_storage(BlockDriverState *bs, BdrvChild *c,
shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
}

#ifdef XBOX
if (bs->open_flags & BDRV_O_RO_WRITE_SHARE) {
shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
}
#endif

*nperm = perm;
*nshared = shared;
}
Expand Down
16 changes: 16 additions & 0 deletions block/file-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "qapi/qmp/qstring.h"
#include <windows.h>
#include <winioctl.h>
#include <assert.h>

#define FTYPE_FILE 0
#define FTYPE_CD 1
Expand Down Expand Up @@ -345,6 +346,9 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
bool use_aio;
OnOffAuto locking;
int ret;
#ifdef XBOX
int sharing_flags;
#endif

s->type = FTYPE_FILE;

Expand Down Expand Up @@ -400,9 +404,21 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
if (!filename) {
goto fail;
}

#ifdef XBOX
sharing_flags = FILE_SHARE_READ;
if (flags & BDRV_O_RO_WRITE_SHARE) {
assert(access_flags == GENERIC_READ);
sharing_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;
}
s->hfile = CreateFileW(wfilename, access_flags,
sharing_flags, NULL,
OPEN_EXISTING, overlapped, NULL);
#else
s->hfile = CreateFileW(wfilename, access_flags,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, overlapped, NULL);
#endif
g_free(wfilename);
if (s->hfile == INVALID_HANDLE_VALUE) {
int err = GetLastError();
Expand Down
69 changes: 36 additions & 33 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ package_macos() {

cp Info.plist dist/xemu.app/Contents/

plutil -replace CFBundleShortVersionString -string $(cat ${project_source_dir}/XEMU_VERSION | cut -f1 -d-) dist/xemu.app/Contents/Info.plist
plutil -replace CFBundleVersion -string $(cat ${project_source_dir}/XEMU_VERSION | cut -f1 -d-) dist/xemu.app/Contents/Info.plist

codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - "${exe_path}"
python3 ./scripts/gen-license.py --version-file=macos-libs/$target_arch/INSTALLED > dist/LICENSE.txt
}
Expand Down Expand Up @@ -170,6 +173,32 @@ else
opts="--enable-lto"
fi

most_recent_macosx_sdk_ver () {
local min_ver="${1}"
local macos_sdk_base=/Library/Developer/CommandLineTools/SDKs
local sdks=("${macos_sdk_base}"/MacOSX[0-9]*.[0-9]*.sdk)
for i in "${!sdks[@]}"; do
local newval="${sdks[i]##${macos_sdk_base}/MacOSX}"
sdks[$i]="${newval%%.sdk}"
done

IFS=$'\n' sdks=($(sort -nr <<<"${sdks[*]}"))
unset IFS

local newest_sdk_ver="${sdks[0]}"

local sdk_path="${macos_sdk_base}/MacOSX${newest_sdk_ver}.sdk"
if ! test -d "${sdk_path}"; then
echo ""
return
fi

if ! LC_ALL=C awk 'BEGIN {exit ('${newest_sdk_ver}' < '${min_ver}')}'; then
echo ""
return
fi
echo "${sdk_path}"
}

case "$platform" in # Adjust compilation options based on platform
Linux)
Expand All @@ -180,47 +209,21 @@ case "$platform" in # Adjust compilation options based on platform
;;
Darwin)
echo "Compiling for MacOS for $target_arch..."
sdk_base=/Library/Developer/CommandLineTools/SDKs/
sdk_macos_10_14="${sdk_base}/MacOSX10.14.sdk"
sdk_macos_10_15="${sdk_base}/MacOSX10.15.sdk"
sdk_macos_11_1="${sdk_base}/MacOSX11.1.sdk"
sdk_macos_11_3="${sdk_base}/MacOSX11.3.sdk"
sdk_macos_12_0="${sdk_base}/MacOSX12.0.sdk"
sdk_macos_12_1="${sdk_base}/MacOSX12.1.sdk"
if [ "$target_arch" == "arm64" ]; then
macos_min_ver=11.3
if test -d "$sdk_macos_12_1"; then
sdk="$sdk_macos_12_1"
elif test -d "$sdk_macos_12_0"; then
sdk="$sdk_macos_12_0"
elif test -d "$sdk_macos_11_3"; then
sdk="$sdk_macos_11_3"
else
echo "SDK not found. Install Xcode Command Line Tools"
exit 1
fi
elif [ "$target_arch" == "x86_64" ]; then
macos_min_ver=10.13
if test -d "$sdk_macos_12_1"; then
sdk="$sdk_macos_12_1"
elif test -d "$sdk_macos_12_0"; then
sdk="$sdk_macos_12_0"
elif test -d "$sdk_macos_11_3"; then
sdk="$sdk_macos_11_3"
elif test -d "$sdk_macos_11_1"; then
sdk="$sdk_macos_11_1"
elif test -d "$sdk_macos_10_15"; then
sdk="$sdk_macos_10_15"
elif test -d "$sdk_macos_10_14"; then
sdk="$sdk_macos_10_14"
else
echo "SDK not found. Install Xcode Command Line Tools"
exit 1
fi
else
echo "Unsupported arch $target_arch"
exit 1
fi

sdk="$(most_recent_macosx_sdk_ver ${macos_min_ver})"
if [[ -z "${sdk}" ]]; then
echo "SDK >= ${macos_min_ver} not found. Install Xcode Command Line Tools"
exit 1
fi

python3 ./scripts/download-macos-libs.py ${target_arch}
lib_prefix=${PWD}/macos-libs/${target_arch}/opt/local
export CFLAGS="-arch ${target_arch} \
Expand Down
14 changes: 13 additions & 1 deletion config_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ general:
# throttle_io: bool
last_viewed_menu_index: integer
user_token: string
snapshots:
shortcuts:
f5: string
f6: string
f7: string
f8: string
filter_current_game: bool

input:
bindings:
Expand Down Expand Up @@ -108,6 +115,7 @@ display:
default: 1
window:
fullscreen_on_startup: bool
fullscreen_exclusive: bool
startup_size:
type: enum
values: [last_used, 640x480, 1280x720, 1280x800, 1280x960, 1920x1080, 2560x1440, 2560x1600, 2560x1920, 3840x2160]
Expand All @@ -130,8 +138,12 @@ display:
default: true
fit:
type: enum
values: [center, scale, scale_16_9, scale_4_3, stretch]
values: [center, scale, stretch]
default: scale
aspect_ratio:
type: enum
values: [native, auto, 4x3, 16x9]
default: auto
scale:
type: integer
default: 1
Expand Down
9 changes: 9 additions & 0 deletions hw/xbox/acpi_xbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "hw/xbox/xbox_pci.h"
#include "hw/xbox/acpi_xbox.h"
#include "migration/vmstate.h"
#include "ui/xemu-widescreen.h"

// #define DEBUG
#ifdef DEBUG
Expand All @@ -44,6 +45,8 @@
#define XBOX_PM_GPIO_BASE 0xC0
#define XBOX_PM_GPIO_LEN 26

#define XBOX_PM_GPIO_ASPECT_RATIO 0x16

static int field_pin;

static uint64_t xbox_pm_gpio_read(void *opaque, hwaddr addr, unsigned width)
Expand All @@ -66,6 +69,12 @@ static void xbox_pm_gpio_write(void *opaque, hwaddr addr, uint64_t val,
unsigned width)
{
XBOX_DPRINTF("pm gpio write [0x%llx] = 0x%llx\n", addr, val);

if (addr == XBOX_PM_GPIO_ASPECT_RATIO) {
xemu_set_widescreen(val == 5);
}

// FIXME: Add GPIO to VM state
}

static const MemoryRegionOps xbox_pm_gpio_ops = {
Expand Down
1 change: 1 addition & 0 deletions hw/xbox/nv2a/nv2a.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ int nv2a_get_framebuffer_surface(void);
void nv2a_set_surface_scale_factor(unsigned int scale);
unsigned int nv2a_get_surface_scale_factor(void);
const uint8_t *nv2a_get_dac_palette(void);
int nv2a_get_screen_off(void);

#endif
4 changes: 4 additions & 0 deletions hw/xbox/nv2a/nv2a_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@
# define NV_PGRAPH_CHEOPS_OFFSET_PROG_LD_PTR 0x000000FF
# define NV_PGRAPH_CHEOPS_OFFSET_CONST_LD_PTR 0x0000FF00
#define NV_PGRAPH_DMA_STATE 0x00001034
#define NV_PGRAPH_ANTIALIASING 0x00001800
# define NV_PGRAPH_ANTIALIASING_ENABLE (1 << 0)
#define NV_PGRAPH_BLEND 0x00001804
# define NV_PGRAPH_BLEND_EQN 0x00000007
# define NV_PGRAPH_BLEND_EN (1 << 3)
Expand Down Expand Up @@ -1220,6 +1222,8 @@
# define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN 0x000000F0
# define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN_CULL 0
# define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN_CLAMP 1
# define NV097_SET_ANTI_ALIASING_CONTROL 0x00001D7C
# define NV097_SET_ANTI_ALIASING_CONTROL_ENABLE (1 << 0)
# define NV097_SET_ZSTENCIL_CLEAR_VALUE 0x00001D8C
# define NV097_SET_COLOR_CLEAR_VALUE 0x00001D90
# define NV097_CLEAR_SURFACE 0x00001D94
Expand Down
4 changes: 0 additions & 4 deletions hw/xbox/nv2a/pfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ uint64_t pfb_read(void *opaque, hwaddr addr, unsigned int size)

uint64_t r = 0;
switch (addr) {
case NV_PFB_CFG0:
/* 3-4 memory partitions. The debug bios checks this. */
r = 3;
break;
case NV_PFB_CSTATUS:
r = memory_region_size(d->vram);
break;
Expand Down
44 changes: 32 additions & 12 deletions hw/xbox/nv2a/pgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,12 +2841,25 @@ DEF_METHOD(NV097, SET_BEGIN_END)
bool depth_test = control_0 & NV_PGRAPH_CONTROL_0_ZENABLE;
bool stencil_test =
pg->regs[NV_PGRAPH_CONTROL_1] & NV_PGRAPH_CONTROL_1_STENCIL_TEST_ENABLE;
bool is_nop_draw = !(color_write || depth_test || stencil_test);

if (parameter == NV097_SET_BEGIN_END_OP_END) {
if (pg->primitive_mode == PRIM_TYPE_INVALID) {
NV2A_DPRINTF("End without Begin!\n");
}
nv2a_profile_inc_counter(NV2A_PROF_BEGIN_ENDS);

if (is_nop_draw) {
// FIXME: Check PGRAPH register 0x880.
// HW uses bit 11 in 0x880 to enable or disable a color/zeta limit
// check that will raise an exception in the case that a draw should
// modify the color and/or zeta buffer but the target(s) are masked
// off. This check only seems to trigger during the fragment
// processing, it is legal to attempt a draw that is entirely
// clipped regardless of 0x880. See xemu#635 for context.
return;
}

pgraph_flush_draw(d);

/* End of visibility testing */
Expand Down Expand Up @@ -2878,14 +2891,7 @@ DEF_METHOD(NV097, SET_BEGIN_END)
pgraph_update_surface(d, true, true, depth_test || stencil_test);
pgraph_reset_inline_buffers(pg);

if (!(color_write || depth_test || stencil_test)) {
// FIXME: Check PGRAPH register 0x880.
// HW uses bit 11 in 0x880 to enable or disable a color/zeta limit
// check that will raise an exception in the case that a draw should
// modify the color and/or zeta buffer but the target(s) are masked
// off. This check only seems to trigger during the fragment
// processing, it is legal to attempt a draw that is entirely
// clipped regardless of 0x880. See xemu#635 for context.
if (is_nop_draw) {
return;
}

Expand Down Expand Up @@ -3042,15 +3048,17 @@ DEF_METHOD(NV097, SET_BEGIN_END)

glEnable(GL_PROGRAM_POINT_SIZE);

bool anti_aliasing = GET_MASK(pg->regs[NV_PGRAPH_ANTIALIASING], NV_PGRAPH_ANTIALIASING_ENABLE);

/* Edge Antialiasing */
if (pg->regs[NV_PGRAPH_SETUPRASTER] &
NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) {
if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] &
NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) {
glEnable(GL_LINE_SMOOTH);
} else {
glDisable(GL_LINE_SMOOTH);
}
if (pg->regs[NV_PGRAPH_SETUPRASTER] &
NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) {
if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] &
NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) {
glEnable(GL_POLYGON_SMOOTH);
} else {
glDisable(GL_POLYGON_SMOOTH);
Expand Down Expand Up @@ -3451,6 +3459,13 @@ DEF_METHOD(NV097, SET_ZMIN_MAX_CONTROL)
}
}

DEF_METHOD(NV097, SET_ANTI_ALIASING_CONTROL)
{
SET_MASK(pg->regs[NV_PGRAPH_ANTIALIASING], NV_PGRAPH_ANTIALIASING_ENABLE,
GET_MASK(parameter, NV097_SET_ANTI_ALIASING_CONTROL_ENABLE));
// FIXME: Handle the remaining bits (observed values 0xFFFF0000, 0xFFFF0001)
}

DEF_METHOD(NV097, SET_ZSTENCIL_CLEAR_VALUE)
{
pg->regs[NV_PGRAPH_ZSTENCILCLEARVALUE] = parameter;
Expand Down Expand Up @@ -5335,6 +5350,11 @@ const uint8_t *nv2a_get_dac_palette(void)
return g_nv2a->puserdac.palette;
}

int nv2a_get_screen_off(void)
{
return g_nv2a->vga.sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_SCREEN_OFF;
}

int nv2a_get_framebuffer_surface(void)
{
NV2AState *d = g_nv2a;
Expand Down
1 change: 1 addition & 0 deletions hw/xbox/nv2a/pgraph_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ DEF_METHOD_RANGE(NV097, SET_VERTEX_DATA4S_M, 32)
DEF_METHOD(NV097, SET_SEMAPHORE_OFFSET)
DEF_METHOD(NV097, BACK_END_WRITE_SEMAPHORE_RELEASE)
DEF_METHOD(NV097, SET_ZMIN_MAX_CONTROL)
DEF_METHOD(NV097, SET_ANTI_ALIASING_CONTROL)
DEF_METHOD(NV097, SET_ZSTENCIL_CLEAR_VALUE)
DEF_METHOD(NV097, SET_COLOR_CLEAR_VALUE)
DEF_METHOD(NV097, CLEAR_SURFACE)
Expand Down
Loading

0 comments on commit 976319b

Please sign in to comment.