Skip to content

Commit

Permalink
GPU: Move backend work off CPU thread
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 19, 2024
1 parent 831c982 commit 2d659fc
Show file tree
Hide file tree
Showing 59 changed files with 6,753 additions and 4,902 deletions.
41 changes: 39 additions & 2 deletions src/common/intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#define CPU_ARCH_SIMD 1
#define CPU_ARCH_SSE 1
#include <emmintrin.h>
#include <tmmintrin.h>
#include <smmintrin.h>
#include <immintrin.h>
#include <smmintrin.h>
#include <tmmintrin.h>

#if defined(__AVX2__)
#define CPU_ARCH_AVX 1
Expand Down Expand Up @@ -96,3 +96,40 @@ ALWAYS_INLINE_RELEASE static void MemsetPtrs(T* ptr, T value, u32 count)
for (u32 i = 0; i < remaining_count; i++)
*(dest++) = value;
}

ALWAYS_INLINE static void MultiPause()
{
#if defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64)
_mm_pause();
_mm_pause();
_mm_pause();
_mm_pause();
_mm_pause();
_mm_pause();
_mm_pause();
_mm_pause();
#elif defined(CPU_ARCH_ARM64) && defined(_MSC_VER)
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
__isb(_ARM64_BARRIER_SY);
#elif defined(CPU_ARCH_ARM64) || defined(CPU_ARCH_ARM32)
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
__asm__ __volatile__("isb");
#elif defined(CPU_ARCH_RISCV64)
// Probably wrong... pause is optional :/
asm volatile("fence" ::: "memory");
#else
#pragma warning("Missing implementation")
#endif
}
1 change: 1 addition & 0 deletions src/common/log_channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
X(GPU) \
X(GPUDevice) \
X(GPUDump) \
X(GPUThread) \
X(GPU_SW) \
X(GPU_HW) \
X(GameDatabase) \
Expand Down
7 changes: 3 additions & 4 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ add_library(core
gpu_shadergen.h
gpu_sw.cpp
gpu_sw.h
gpu_sw_backend.cpp
gpu_sw_backend.h
gpu_sw_rasterizer.cpp
gpu_sw_rasterizer.h
gpu_thread.cpp
gpu_thread.h
gpu_thread_commands.h
gpu_types.h
guncon.cpp
guncon.h
Expand All @@ -73,8 +74,6 @@ add_library(core
gte_types.h
host.cpp
host.h
host_interface_progress_callback.cpp
host_interface_progress_callback.h
hotkeys.cpp
input_types.h
imgui_overlays.cpp
Expand Down
Loading

0 comments on commit 2d659fc

Please sign in to comment.