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

Feat/vulkan #1

Closed
wants to merge 123 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
7a13769
nv2a: Add Vulkan renderer
mborgerson Jul 27, 2024
70e8b4d
archive-source.sh: Fix path to nv2a_vsh_cpu
mborgerson Jul 27, 2024
8c369f5
debian/control: Drop vendored deps
mborgerson Jul 27, 2024
0fec523
meson: Add -DVK_NO_PROTOTYPES compile args on volk
mborgerson Jul 27, 2024
21c6092
scripts/gen-license.py: Fix version detect
mborgerson Jul 27, 2024
b83fb81
meson: Vendor glslang
mborgerson Jul 27, 2024
3dad634
nv2a/vk: Remove extraneous VK_NO_PROTOTYPES defn
mborgerson Jul 27, 2024
92606f7
meson: Move VMA options into meson config
mborgerson Jul 27, 2024
3c74533
nv2a: Wrap pfifo direct renderer calls
mborgerson Jul 27, 2024
400779c
nv2a: Wrap nv2a_vm_state_change direct renderer calls
mborgerson Jul 27, 2024
3ac68c4
n2va/vk: Drop debug message
mborgerson Jul 27, 2024
ee966a9
nv2a/vk: Fix GArray free
mborgerson Jul 27, 2024
5db2956
nv2a/vk: Fix shader cache node init flag
mborgerson Jul 27, 2024
cf05ade
nv2a/vk: Clear bindings before tearing down cache
mborgerson Jul 27, 2024
e2df105
nv2a/vk: Fix snode->geometry init
mborgerson Jul 27, 2024
67da972
nv2a/gl: Improve renderer teardown
mborgerson Jul 27, 2024
b8fa97b
nv2a/gl: Ensure shader_binding exists before dirty check
mborgerson Jul 27, 2024
386957b
nv2a/gl: Make sure vulkan is not set on ShaderState
mborgerson Jul 27, 2024
7ff4565
nv2a/vk: Ensure texture bindings exist before dirty check
mborgerson Jul 27, 2024
cede219
nv2a/vk: Sync RAM buffer during renderer init
mborgerson Jul 27, 2024
b5f9649
nv2a/vk: Always provide early_context_init
mborgerson Jul 27, 2024
dcb902b
nv2a/vk: Release renderer state at finalize
mborgerson Jul 27, 2024
22ac56b
nv2a/vk: Release report queue nodes at finalize
mborgerson Jul 27, 2024
c1634b1
nv2a: Support switching renderers at runtime
mborgerson Jul 27, 2024
253a800
nv2a: Add note about downloading dirty surfaces during flush
mborgerson Jul 27, 2024
2020d2b
nv2a: Merge renderer init, init_thread methods
mborgerson Jul 27, 2024
e6321ce
nv2a/gl: Rename some functions for clarity
mborgerson Jul 27, 2024
c9f5858
nv2a: Handle renderer init errors more gracefully
mborgerson Jul 27, 2024
4a66e5e
nv2a: Block renderer finalization on display present
mborgerson Jul 27, 2024
1f2a751
meson: Fix VMA options
mborgerson Jul 27, 2024
bcf7a48
nv2a/vk: Fallback to UBO if maxPushConstantsSize is insufficient
mborgerson Jul 27, 2024
0293499
nv2a/vk: Ensure error message is always set on instance failure
mborgerson Jul 27, 2024
0e23055
nv2a/vk: Fix finish queue submission semaphore wait stage
mborgerson Jul 27, 2024
27df151
nv2a/vk: Insert barrier after staging buffer copies
mborgerson Jul 27, 2024
4dc361a
nv2a/vk: Flush vertex ram buffer, insert barrier
mborgerson Jul 27, 2024
f71150d
nv2a/vk: Add barrier after compute to staging buffer copy
mborgerson Jul 27, 2024
326f7be
nv2a/vk: Fix display dimensions
mborgerson Jul 27, 2024
4e6de83
nv2a/vk: Fix renderer debug messenger registration
mborgerson Jul 27, 2024
ed94895
nv2a/vk: Finalize clear shaders
mborgerson Jul 27, 2024
affc2f1
nv2a/vk: Drop fragment shader when only depth attachment is cleared
mborgerson Jul 27, 2024
451b3bd
nv2a/vk: Use textureLod in psh_append_shadowmap
mborgerson Jul 27, 2024
ca636cd
nv2a/vk: Ensure border color type matches format type
mborgerson Jul 27, 2024
156fbad
nv2a/vk: Don't call vkCmdBindVertexBuffers if 0 bindings
mborgerson Jul 27, 2024
f350efc
nv2a/vk: Use correct min,mag texture filters
mborgerson Jul 27, 2024
dbbba4c
nv2a/vk: Finalize, simplify render passes
mborgerson Jul 27, 2024
756e235
nv2a/vk: Finalize more display state
mborgerson Jul 27, 2024
c8f39f7
n2va/vk: Assert instead of exit() on validation error
mborgerson Jul 27, 2024
d19d5eb
nv2a/vk: Add debug helper function for inserting markers
mborgerson Jul 27, 2024
6a27aa3
nv2a/vk: Use additional descriptor sets in compute ops
mborgerson Jul 27, 2024
7184aa8
nv2a/vk: Move overlapping surface download logic to function
mborgerson Jul 27, 2024
7cd76d5
nv2a/vk: Download any dirty surfaces covering vertex buffers
mborgerson Jul 27, 2024
65902bb
nv2a/vk: Fix shadowmap readback in frag shader
mborgerson Jul 27, 2024
15a0fd4
nv2a/vk: Fix integer format border color
mborgerson Jul 27, 2024
35f503c
nv2a/vk: Target glslang to SPV 1.6
mborgerson Jul 27, 2024
99664af
nv2a/vk: Add debug_shaders option
mborgerson Jul 27, 2024
6061310
nv2a/vk: Add assert_on_validation_msg option
mborgerson Jul 27, 2024
9aaae92
nv2a/vk: Finish when queue is empty
mborgerson Jul 27, 2024
2501255
nv2a/vk: Enable synchronization validation
mborgerson Jul 27, 2024
4aa5a06
nv2a/vk: Change display renderpass loadOp to don't care
mborgerson Jul 27, 2024
1f117b0
nv2a/vk: Clear render_passes on finalization
mborgerson Jul 27, 2024
4b851da
nv2a/vk: Tighten a few layout transitions
mborgerson Jul 27, 2024
24ffbdb
nv2a/vk: Tighten renderpass dependencies
mborgerson Jul 27, 2024
c2a2728
nv2a/vk: Omit pipeline fragment shader when no color binding
mborgerson Jul 27, 2024
f633975
nv2a/glsl: Initialize vars
mborgerson Jul 27, 2024
8c16d2b
nv2a/vk: Fix compute descriptor pool size
mborgerson Jul 27, 2024
28c8aac
nv2a/vk: Fix swapped texture filters
mborgerson Jul 27, 2024
b0e18c6
nv2a/vk: Add vertex memory offset fixme
mborgerson Jul 27, 2024
988e8b6
nv2a/vk: Fix missing scale in d32_sfloat_s8_uint pack
mborgerson Jul 27, 2024
af2487d
nv2a/vk: Add compute pipeline cache, scale workgroups
mborgerson Jul 27, 2024
cce19db
nv2a/glsl: Ensure sampler type matches texture dimensionality
mborgerson Jul 27, 2024
4e6b042
nv2a/glsl: Fix project2d usampler lookup
mborgerson Jul 27, 2024
c2f8b41
nv2a/vk: Only include uniform attr definition when necessary
mborgerson Jul 27, 2024
dc020d4
nv2a/vk: Ensure pg->clearing set before pgraph_vk_surface_update
mborgerson Jul 27, 2024
2db115b
nv2a/vk: Ensure pack buffer offsets meet minStorageBufferOffsetAlignment
mborgerson Jul 27, 2024
2663c7a
nv2a/vk: Ensure clear rect never extends beyond surface
mborgerson Jul 27, 2024
79bdb58
nv2a/vk: Relax invalid surface compat check
mborgerson Jul 27, 2024
75f4a19
nv2a/vk: Create surface if one not currently bound
mborgerson Jul 27, 2024
7853c52
nv2a/vk: Specify set in compute shader layout
mborgerson Jul 29, 2024
ae20a5d
nv2a/vk: Specify local_size_{y,z} = 1 in compute shader
mborgerson Jul 29, 2024
5dcd351
nv2a/vk: Always use staging image for surface upload
mborgerson Jul 29, 2024
64940c9
nv2a: Fix nv2a_dbg_renderdoc_init on Windows
mborgerson Jul 29, 2024
574d89a
nv2a/vk: Fixup depth transition stages
mborgerson Jul 29, 2024
335b395
nv2a/vk: Don't release textures until after draw completes
mborgerson Jul 29, 2024
b65183b
nv2a/vk: Simplify zeta to texture, add barrier
mborgerson Jul 29, 2024
00654cb
nv2a/vk: Add texture finalize checks
mborgerson Jul 29, 2024
8218cc8
nv2a/vk: Include result code in device/instance creation error messages
mborgerson Jul 29, 2024
892b5f7
nv2a/vk: Make main buffers dedicated
mborgerson Jul 29, 2024
b638576
meson: Define some VMA debug options for convenience
mborgerson Jul 29, 2024
1e669e8
nv2a/vk: Disable memory trimmer for now
mborgerson Jul 29, 2024
d7ee8eb
nv2a/vk: Only clear stencil on images with stencil aspect
mborgerson Jul 30, 2024
a0f70f4
nv2a/vk: Fix compute pipeline finalize
mborgerson Jul 30, 2024
e2b49dd
nv2a/vk: Minor cleanup
mborgerson Jul 30, 2024
352b035
nv2a/vk: Flush/barrier on texture upload
mborgerson Jul 30, 2024
2f1b656
nv2a/vk: Fix mipmap filtering for _LOD0 min filters
mborgerson Jul 30, 2024
0b7bd17
nv2a/vk: Fix scissor overflow
mborgerson Jul 30, 2024
69bc83c
nv2a/vk: Fix clear scissor ymin
mborgerson Jul 30, 2024
bde4fad
nv2a/glsl: Add swizzled attr check
mborgerson Jul 30, 2024
1e570f0
nv2a: Normalize unnormalized texture coordinates in shader
mborgerson Jul 30, 2024
dccaee1
nv2a/psh: Normalize coords at sample time
mborgerson Jul 30, 2024
a56751c
nv2a/psh: Drop rect_tex assertion
mborgerson Jul 30, 2024
7dbefee
nv2a/psh: Handle rect tex on project3d
mborgerson Jul 31, 2024
036429d
nv2a/vk: Only bind clear fragment shader on partial color clear
mborgerson Jul 31, 2024
cc6bab1
nv2a/vk: Always bind fragment shader in draw pipeline
mborgerson Jul 31, 2024
527da7e
nv2a/vk: Fixup unaligned attribute data in inline buffer
mborgerson Aug 1, 2024
a9af26a
nv2a/vk: Fix reports
mborgerson Aug 1, 2024
fcbec00
nv2a/vk: Ensure queries do not include clears
mborgerson Aug 1, 2024
2d84295
nv2a/vk: Clear in separate renderpass for now
mborgerson Aug 1, 2024
7f2b032
nv2a/vk: Make pgraph_vk_insert_debug_marker format strings
mborgerson Aug 1, 2024
31b4049
nv2a/vk: Fix create_pipeline debug marker inbalance
mborgerson Aug 1, 2024
458162b
n2va/vk: Key textures on sampler state for now
mborgerson Aug 1, 2024
e1da211
nv2a/vk: Add pvideo support
mborgerson Aug 2, 2024
b7a9566
nv2a/vk: Add missing math.h include
mborgerson Aug 2, 2024
2e1abd8
ui: Add menubar backend selection
mborgerson Aug 2, 2024
8a1c138
nv2a/vk: Process pending surface upload just in time for display
mborgerson Nov 10, 2024
9d8dbec
nv2a/vk: Run full dirty texture check
mborgerson Nov 11, 2024
c706aa5
nv2a/gl: Fix bind_shaders dgroup
mborgerson Nov 11, 2024
21abcb4
nv2a/vk: Add command buffer region debug markers
mborgerson Nov 11, 2024
24bccd8
nv2a/vk: Drop display update early-out
mborgerson Nov 14, 2024
a19ee41
nv2a/vk: Drop pipeline merge stat
mborgerson Nov 14, 2024
c4de96d
nv2a/vk: Move reg dirty clear into create_pipeline
mborgerson Nov 14, 2024
52956c7
nv2a/vk: Add regs control_{0,3}, setupraster to shader dirty test
mborgerson Nov 14, 2024
307eabc
nv2a/vk: Move display GL compat after line_offset adjust
mborgerson Nov 14, 2024
98a03e9
nv2a/vk: Report dirty if no pipeline is bound
mborgerson Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ IndentWidth: 4
AccessModifierOffset: -4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: '.*_BEGIN$' # only PREC_BEGIN ?
MacroBlockEnd: '.*_END$'
#MacroBlockBegin: '.*_BEGIN$' # only PREC_BEGIN ?
#MacroBlockEnd: '.*_END$'
MaxEmptyLinesToKeep: 2
#PenaltyBreakBeforeFirstCallParameter: 19
#PenaltyBreakComment: 300
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
build_param:
artifact_name: xemu-win-release
env:
DOCKER_IMAGE_NAME: ghcr.io/xemu-project/xemu-win64-toolchain:sha-8152913
DOCKER_IMAGE_NAME: ghcr.io/xemu-project/xemu-win64-toolchain:sha-c6bad86

steps:
- name: Download source package
Expand Down
13 changes: 11 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,18 @@
[submodule "tomlplusplus"]
path = tomlplusplus
url = https://github.com/marzer/tomlplusplus
[submodule "hw/xbox/nv2a/thirdparty/nv2a_vsh_cpu"]
path = hw/xbox/nv2a/thirdparty/nv2a_vsh_cpu
[submodule "hw/xbox/nv2a/pgraph/thirdparty/nv2a_vsh_cpu"]
path = hw/xbox/nv2a/pgraph/thirdparty/nv2a_vsh_cpu
url = https://github.com/abaire/nv2a_vsh_cpu.git
[submodule "ui/thirdparty/httplib"]
path = ui/thirdparty/httplib
url = https://github.com/yhirose/cpp-httplib
[submodule "hw/xbox/nv2a/pgraph/vk/thirdparty/VulkanMemoryAllocator"]
path = thirdparty/VulkanMemoryAllocator
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
[submodule "thirdparty/volk"]
path = thirdparty/volk
url = https://github.com/zeux/volk
[submodule "thirdparty/SPIRV-Reflect"]
path = thirdparty/SPIRV-Reflect
url = https://github.com/KhronosGroup/SPIRV-Reflect
8 changes: 8 additions & 0 deletions config_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ input:
default: 18 # w

display:
renderer:
type: enum
values: ["NULL", OPENGL, VULKAN]
default: OPENGL
vulkan:
validation_layers: bool
debug_shaders: bool
assert_on_validation_msg: bool
quality:
surface_scale:
type: integer
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ else
git_submodules_action="ignore"
fi

git_submodules="ui/keycodemapdb ui/thirdparty/imgui ui/thirdparty/implot ui/thirdparty/httplib util/xxHash tomlplusplus genconfig hw/xbox/nv2a/thirdparty/nv2a_vsh_cpu"
git_submodules="ui/keycodemapdb ui/thirdparty/imgui ui/thirdparty/implot ui/thirdparty/httplib util/xxHash tomlplusplus genconfig hw/xbox/nv2a/pgraph/thirdparty/nv2a_vsh_cpu thirdparty/volk thirdparty/VulkanMemoryAllocator thirdparty/SPIRV-Reflect"
git="git"

# Don't accept a target_list environment variable.
Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Build-Depends: debhelper (>= 11),
libssl-dev,
libpcap-dev,
libslirp-dev,
libvulkan-dev,
Standards-Version: 3.9.8
Homepage: https://xemu.app
XS-Debian-Vcs-Browser: https://github.com/mborgerson/xemu
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ override_dh_auto_configure:

override_dh_auto_build:
./build.sh ${XEMU_BUILD_OPTIONS} ${common_configure_opts} || \
{ echo ===== BUILD FAILED ===; tail -n 50 config.log; exit 1; }
{ echo ===== BUILD FAILED ===; cat build/meson-logs/meson-log.txt; exit 1; }
cp debian/copyright debian/qemu.deb.copyright
cp dist/LICENSE.txt debian/copyright

Expand Down
98 changes: 45 additions & 53 deletions hw/xbox/nv2a/debug.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* QEMU Geforce NV2A debug helpers
* QEMU Geforce NV2A profiling and debug helpers
*
* Copyright (c) 2015 Jannik Vogel
* Copyright (c) 2012 espes
* Copyright (c) 2015 Jannik Vogel
* Copyright (c) 2018-2023 Matt Borgerson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -18,8 +19,8 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef HW_NV2A_DEBUG_H
#define HW_NV2A_DEBUG_H
#ifndef HW_XBOX_NV2A_DEBUG_H
#define HW_XBOX_NV2A_DEBUG_H

#include <stdint.h>

Expand All @@ -36,54 +37,6 @@
# define NV2A_DPRINTF(format, ...) do { } while (0)
#endif

// #define DEBUG_NV2A_GL
#ifdef DEBUG_NV2A_GL

#include <stdbool.h>
#include "gl/gloffscreen.h"
#include "config-host.h"

void gl_debug_initialize(void);
void gl_debug_message(bool cc, const char *fmt, ...);
void gl_debug_group_begin(const char *fmt, ...);
void gl_debug_group_end(void);
void gl_debug_label(GLenum target, GLuint name, const char *fmt, ...);
void gl_debug_frame_terminator(void);

# define NV2A_GL_DPRINTF(cc, format, ...) \
gl_debug_message(cc, "nv2a: " format, ## __VA_ARGS__)
# define NV2A_GL_DGROUP_BEGIN(format, ...) \
gl_debug_group_begin("nv2a: " format, ## __VA_ARGS__)
# define NV2A_GL_DGROUP_END() \
gl_debug_group_end()
# define NV2A_GL_DLABEL(target, name, format, ...) \
gl_debug_label(target, name, "nv2a: { " format " }", ## __VA_ARGS__)
#define NV2A_GL_DFRAME_TERMINATOR() \
gl_debug_frame_terminator()

#ifdef __cplusplus
extern "C" {
#endif

#ifdef CONFIG_RENDERDOC
bool nv2a_dbg_renderdoc_available(void);
void nv2a_dbg_renderdoc_capture_frames(uint32_t num_frames);
#endif

#ifdef __cplusplus
}
#endif

#else
# define NV2A_GL_DPRINTF(cc, format, ...) do { \
if (cc) NV2A_DPRINTF(format "\n", ##__VA_ARGS__ ); \
} while (0)
# define NV2A_GL_DGROUP_BEGIN(format, ...) do { } while (0)
# define NV2A_GL_DGROUP_END() do { } while (0)
# define NV2A_GL_DLABEL(target, name, format, ...) do { } while (0)
# define NV2A_GL_DFRAME_TERMINATOR() do { } while (0)
#endif

/* Debug prints to identify when unimplemented or unconfirmed features
* are being exercised. These cases likely result in graphical problems of
* varying degree, but should otherwise not crash the system. Enable this
Expand Down Expand Up @@ -111,6 +64,22 @@ void nv2a_dbg_renderdoc_capture_frames(uint32_t num_frames);
#endif

#define NV2A_PROF_COUNTERS_XMAC \
_X(NV2A_PROF_FINISH_VERTEX_BUFFER_DIRTY) \
_X(NV2A_PROF_FINISH_SURFACE_CREATE) \
_X(NV2A_PROF_FINISH_SURFACE_DOWN) \
_X(NV2A_PROF_FINISH_NEED_BUFFER_SPACE) \
_X(NV2A_PROF_FINISH_FRAMEBUFFER_DIRTY) \
_X(NV2A_PROF_FINISH_PRESENTING) \
_X(NV2A_PROF_FINISH_FLIP_STALL) \
_X(NV2A_PROF_FINISH_FLUSH) \
_X(NV2A_PROF_FINISH_STALLED) \
_X(NV2A_PROF_CLEAR) \
_X(NV2A_PROF_QUEUE_SUBMIT) \
_X(NV2A_PROF_QUEUE_SUBMIT_AUX) \
_X(NV2A_PROF_PIPELINE_NOTDIRTY) \
_X(NV2A_PROF_PIPELINE_GEN) \
_X(NV2A_PROF_PIPELINE_BIND) \
_X(NV2A_PROF_PIPELINE_RENDERPASSES) \
_X(NV2A_PROF_BEGIN_ENDS) \
_X(NV2A_PROF_DRAW_ARRAYS) \
_X(NV2A_PROF_INLINE_BUFFERS) \
Expand All @@ -120,18 +89,26 @@ void nv2a_dbg_renderdoc_capture_frames(uint32_t num_frames);
_X(NV2A_PROF_SHADER_GEN) \
_X(NV2A_PROF_SHADER_BIND) \
_X(NV2A_PROF_SHADER_BIND_NOTDIRTY) \
_X(NV2A_PROF_SHADER_UBO_DIRTY) \
_X(NV2A_PROF_SHADER_UBO_NOTDIRTY) \
_X(NV2A_PROF_ATTR_BIND) \
_X(NV2A_PROF_TEX_UPLOAD) \
_X(NV2A_PROF_TEX_BIND) \
_X(NV2A_PROF_GEOM_BUFFER_UPDATE_1) \
_X(NV2A_PROF_GEOM_BUFFER_UPDATE_2) \
_X(NV2A_PROF_GEOM_BUFFER_UPDATE_3) \
_X(NV2A_PROF_GEOM_BUFFER_UPDATE_4) \
_X(NV2A_PROF_GEOM_BUFFER_UPDATE_4_NOTDIRTY) \
_X(NV2A_PROF_SURF_SWIZZLE) \
_X(NV2A_PROF_SURF_CREATE) \
_X(NV2A_PROF_SURF_DOWNLOAD) \
_X(NV2A_PROF_SURF_UPLOAD) \
_X(NV2A_PROF_SURF_TO_TEX) \
_X(NV2A_PROF_SURF_TO_TEX_FALLBACK) \
_X(NV2A_PROF_QUEUE_SUBMIT_1) \
_X(NV2A_PROF_QUEUE_SUBMIT_2) \
_X(NV2A_PROF_QUEUE_SUBMIT_3) \
_X(NV2A_PROF_QUEUE_SUBMIT_4) \
_X(NV2A_PROF_QUEUE_SUBMIT_5) \

enum NV2A_PROF_COUNTERS_ENUM {
#define _X(x) x,
Expand Down Expand Up @@ -161,6 +138,21 @@ extern NV2AStats g_nv2a_stats;

const char *nv2a_profile_get_counter_name(unsigned int cnt);
int nv2a_profile_get_counter_value(unsigned int cnt);
void nv2a_profile_increment(void);
void nv2a_profile_flip_stall(void);

static inline void nv2a_profile_inc_counter(enum NV2A_PROF_COUNTERS_ENUM cnt)
{
g_nv2a_stats.frame_working.counters[cnt] += 1;
}

#ifdef CONFIG_RENDERDOC
void nv2a_dbg_renderdoc_init(void);
void *nv2a_dbg_renderdoc_get_api(void);
bool nv2a_dbg_renderdoc_available(void);
void nv2a_dbg_renderdoc_capture_frames(int num_frames);
extern int renderdoc_capture_frames;
#endif

#ifdef __cplusplus
}
Expand Down
6 changes: 0 additions & 6 deletions hw/xbox/nv2a/gl/meson.build

This file was deleted.

12 changes: 1 addition & 11 deletions hw/xbox/nv2a/meson.build
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
specific_ss.add(files(
'nv2a.c',
'debug.c',
'pbus.c',
'pcrtc.c',
'pfb.c',
'pfifo.c',
'pgraph.c',
'pmc.c',
'pramdac.c',
'prmcio.c',
'prmdio.c',
'prmvio.c',
'psh.c',
'ptimer.c',
'pvideo.c',
'shaders.c',
'stubs.c',
'user.c',
'vsh.c',
'swizzle.c',
's3tc.c',
))
subdir('gl')

subdir('thirdparty')
specific_ss.add(nv2a_vsh_cpu)
subdir('pgraph')
28 changes: 18 additions & 10 deletions hw/xbox/nv2a/nv2a.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ static void nv2a_get_offsets(VGACommonState *s,
*pline_compare = line_compare;
}

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;
}

static void nv2a_vga_gfx_update(void *opaque)
{
VGACommonState *vga = opaque;
Expand Down Expand Up @@ -277,7 +287,7 @@ static void nv2a_reset(NV2AState *d)
}

memset(d->pfifo.regs, 0, sizeof(d->pfifo.regs));
memset(d->pgraph.regs, 0, sizeof(d->pgraph.regs));
memset(d->pgraph.regs_, 0, sizeof(d->pgraph.regs_));
memset(d->pvideo.regs, 0, sizeof(d->pvideo.regs));

d->pcrtc.start = 0;
Expand Down Expand Up @@ -365,11 +375,10 @@ static void nv2a_vm_state_change(void *opaque, bool running, RunState state)
if (state == RUN_STATE_SAVE_VM) {
nv2a_lock_fifo(d);
qatomic_set(&d->pfifo.halt, true);
qatomic_set(&d->pgraph.download_dirty_surfaces_pending, true);
qemu_event_reset(&d->pgraph.dirty_surfaces_download_complete);
pgraph_pre_savevm_trigger(d);
nv2a_unlock_fifo(d);
qemu_mutex_unlock_iothread();
qemu_event_wait(&d->pgraph.dirty_surfaces_download_complete);
pgraph_pre_savevm_wait(d);
qemu_mutex_lock_iothread();
nv2a_lock_fifo(d);
} else if (state == RUN_STATE_RESTORE_VM) {
Expand All @@ -382,11 +391,10 @@ static void nv2a_vm_state_change(void *opaque, bool running, RunState state)
nv2a_unlock_fifo(d);
} else if (state == RUN_STATE_SHUTDOWN) {
nv2a_lock_fifo(d);
qatomic_set(&d->pgraph.shader_cache_writeback_pending, true);
qemu_event_reset(&d->pgraph.shader_cache_writeback_complete);
pgraph_pre_shutdown_trigger(d);
nv2a_unlock_fifo(d);
qemu_mutex_unlock_iothread();
qemu_event_wait(&d->pgraph.shader_cache_writeback_complete);
pgraph_pre_shutdown_wait(d);
qemu_mutex_lock_iothread();
}
}
Expand Down Expand Up @@ -515,9 +523,9 @@ static const VMStateDescription vmstate_nv2a = {
VMSTATE_UINT32(pgraph.inline_buffer_length, NV2AState), // fixme
VMSTATE_UINT32(pgraph.draw_arrays_length, NV2AState),
VMSTATE_UINT32(pgraph.draw_arrays_max_count, NV2AState),
VMSTATE_INT32_ARRAY(pgraph.gl_draw_arrays_start, NV2AState, 1250),
VMSTATE_INT32_ARRAY(pgraph.gl_draw_arrays_count, NV2AState, 1250),
VMSTATE_UINT32_ARRAY(pgraph.regs, NV2AState, 0x2000),
VMSTATE_INT32_ARRAY(pgraph.draw_arrays_start, NV2AState, 1250),
VMSTATE_INT32_ARRAY(pgraph.draw_arrays_count, NV2AState, 1250),
VMSTATE_UINT32_ARRAY(pgraph.regs_, NV2AState, 0x2000),
VMSTATE_UINT32(pmc.pending_interrupts, NV2AState),
VMSTATE_UINT32(pmc.enabled_interrupts, NV2AState),
VMSTATE_UINT32(pfifo.pending_interrupts, NV2AState),
Expand Down
3 changes: 2 additions & 1 deletion hw/xbox/nv2a/nv2a.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#define HW_NV2A_H

void nv2a_init(PCIBus *bus, int devfn, MemoryRegion *ram);
void nv2a_gl_context_init(void);
void nv2a_context_init(void);
int nv2a_get_framebuffer_surface(void);
void nv2a_release_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);
Expand Down
Loading