Misc: Fix arm32 build

This commit is contained in:
Stenzek 2023-10-02 21:34:34 +10:00
parent fb659d817e
commit da1c28bd16
7 changed files with 70 additions and 16 deletions

View File

@ -150,7 +150,13 @@ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR "${CMAKE_SYSTEM_PROCESSOR}"
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
set(CPU_ARCH "x86") set(CPU_ARCH "x86")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # Might have an A64 kernel, e.g. Raspbian.
set(CPU_ARCH "aarch64") set(CPU_ARCH "aarch64")
else()
set(CPU_ARCH "aarch32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -march=armv7-a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a")
endif()
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a" OR elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l") "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(CPU_ARCH "aarch32") set(CPU_ARCH "aarch32")

View File

@ -87,6 +87,30 @@ asm(
br x30 br x30
)"); )");
#elif defined(__arm__)
asm(
"\t.global " PREFIX "fastjmp_set\n"
"\t.global " PREFIX "fastjmp_jmp\n"
"\t.text\n"
"\t" PREFIX "fastjmp_set:" R"(
vstmia r0!, {d8-d15}
stmia r0!, {r4-r14}
fmrx r1, fpscr
str r1, [r0]
mov r0, #0
bx lr
)"
"\t" PREFIX "fastjmp_jmp:" R"(
vldmia r0!, {d8-d15}
ldmia r0!, {r4-r14}
ldr r0, [r0]
fmxr fpscr, r0
mov r0, r1
bx lr
)");
#elif defined(__riscv) && __riscv_xlen == 64 #elif defined(__riscv) && __riscv_xlen == 64
asm( asm(

View File

@ -14,6 +14,8 @@ struct fastjmp_buf
static constexpr std::size_t BUF_SIZE = 240; static constexpr std::size_t BUF_SIZE = 240;
#elif defined(_M_ARM64) || defined(__aarch64__) #elif defined(_M_ARM64) || defined(__aarch64__)
static constexpr std::size_t BUF_SIZE = 168; static constexpr std::size_t BUF_SIZE = 168;
#elif defined(_M_ARM) || defined(__arm__)
static constexpr std::size_t BUF_SIZE = 112;
#elif defined(__x86_64__) #elif defined(__x86_64__)
static constexpr std::size_t BUF_SIZE = 64; static constexpr std::size_t BUF_SIZE = 64;
#elif defined(_M_IX86) || defined(__i386__) #elif defined(_M_IX86) || defined(__i386__)

View File

@ -102,8 +102,10 @@ enum : u32
FASTMEM_LUT_NUM_SLOTS = FASTMEM_LUT_NUM_PAGES * 2, FASTMEM_LUT_NUM_SLOTS = FASTMEM_LUT_NUM_PAGES * 2,
}; };
#ifdef ENABLE_MMAP_FASTMEM
// Fastmem region size is 4GB to cover the entire 32-bit address space. // Fastmem region size is 4GB to cover the entire 32-bit address space.
static constexpr size_t FASTMEM_ARENA_SIZE = UINT64_C(0x100000000); static constexpr size_t FASTMEM_ARENA_SIZE = UINT64_C(0x100000000);
#endif
bool AllocateMemory(); bool AllocateMemory();
void ReleaseMemory(); void ReleaseMemory();

View File

@ -82,6 +82,8 @@ bool OpenGLDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width,
} }
else else
{ {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_read_fbo);
if (T->GetLayers() > 1) if (T->GetLayers() > 1)
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, T->GetGLId(), level, layer); glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, T->GetGLId(), level, layer);
else else
@ -91,6 +93,7 @@ bool OpenGLDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width,
glReadPixels(x, y, width, height, gl_format, gl_type, out_data); glReadPixels(x, y, width, height, gl_format, gl_type, out_data);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
} }
return true; return true;
@ -137,18 +140,25 @@ void OpenGLDevice::CopyTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u32
else else
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, D->GetGLTarget(), did, dst_level); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, D->GetGLTarget(), did, dst_level);
if (S->IsTextureArray()) if (S->IsTextureArray())
glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, sid, src_level, src_layer); glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, sid, src_level, src_layer);
else else
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, S->GetGLTarget(), sid, src_level); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, S->GetGLTarget(), sid, src_level);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glBlitFramebuffer(src_x, src_y, src_x + width, src_y + width, dst_x, dst_y, dst_x + width, dst_y + height, glBlitFramebuffer(src_x, src_y, src_x + width, src_y + height, dst_x, dst_y, dst_x + width, dst_y + height,
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
if (m_current_framebuffer)
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
} }
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
} }
void OpenGLDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u32 dst_layer, u32 dst_level, void OpenGLDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u32 dst_layer, u32 dst_level,
@ -185,8 +195,15 @@ void OpenGLDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u
GL_COLOR_BUFFER_BIT, GL_LINEAR); GL_COLOR_BUFFER_BIT, GL_LINEAR);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
if (m_current_framebuffer)
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
} }
void OpenGLDevice::ClearRenderTarget(GPUTexture* t, u32 c) void OpenGLDevice::ClearRenderTarget(GPUTexture* t, u32 c)
@ -638,9 +655,6 @@ bool OpenGLDevice::CreateBuffers(bool buggy_pbo)
m_read_fbo = fbos[0]; m_read_fbo = fbos[0];
m_write_fbo = fbos[1]; m_write_fbo = fbos[1];
// Read FBO gets left bound.
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_read_fbo);
return true; return true;
} }
@ -665,7 +679,7 @@ bool OpenGLDevice::BeginPresent(bool skip_present)
return false; return false;
} }
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
const Common::Rectangle<s32> window_rc = const Common::Rectangle<s32> window_rc =
Common::Rectangle<s32>::FromExtents(0, 0, m_window_info.surface_width, m_window_info.surface_height); Common::Rectangle<s32>::FromExtents(0, 0, m_window_info.surface_width, m_window_info.surface_height);

View File

@ -484,6 +484,9 @@ void OpenGLDevice::CommitClear(OpenGLTexture* tex)
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
if (tex->IsDepthStencil()) if (tex->IsDepthStencil())
{ {
if (glClearDepthf)
glClearDepthf(tex->GetClearDepth());
else
glClearDepth(tex->GetClearDepth()); glClearDepth(tex->GetClearDepth());
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
} }
@ -556,6 +559,9 @@ void OpenGLDevice::CommitClear(OpenGLFramebuffer* fb)
case GPUTexture::State::Cleared: case GPUTexture::State::Cleared:
{ {
if (glClearDepthf)
glClearDepthf(DS->GetClearDepth());
else
glClearDepth(DS->GetClearDepth()); glClearDepth(DS->GetClearDepth());
clear_flags |= GL_DEPTH_BUFFER_BIT; clear_flags |= GL_DEPTH_BUFFER_BIT;
DS->SetState(GPUTexture::State::Dirty); DS->SetState(GPUTexture::State::Dirty);

View File

@ -11,7 +11,7 @@
#include <cstdarg> #include <cstdarg>
#include <string_view> #include <string_view>
#ifdef _DEBUG #if defined(_DEBUG) && !defined(CPU_ARCH_ARM32) && !defined(CPU_ARCH_X86)
#define ENABLE_VULKAN_DEBUG_OBJECTS 1 #define ENABLE_VULKAN_DEBUG_OBJECTS 1
#endif #endif