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")
set(CPU_ARCH "x86")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(CPU_ARCH "aarch64")
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # Might have an A64 kernel, e.g. Raspbian.
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
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(CPU_ARCH "aarch32")

View file

@ -87,6 +87,30 @@ asm(
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
asm(

View file

@ -14,6 +14,8 @@ struct fastjmp_buf
static constexpr std::size_t BUF_SIZE = 240;
#elif defined(_M_ARM64) || defined(__aarch64__)
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__)
static constexpr std::size_t BUF_SIZE = 64;
#elif defined(_M_IX86) || defined(__i386__)

View file

@ -102,8 +102,10 @@ enum : u32
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.
static constexpr size_t FASTMEM_ARENA_SIZE = UINT64_C(0x100000000);
#endif
bool AllocateMemory();
void ReleaseMemory();

View file

@ -82,6 +82,8 @@ bool OpenGLDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width,
}
else
{
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_read_fbo);
if (T->GetLayers() > 1)
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, T->GetGLId(), level, layer);
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);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
return true;
@ -137,17 +140,24 @@ void OpenGLDevice::CopyTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u32
else
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, D->GetGLTarget(), did, dst_level);
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
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);
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);
glEnable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
if (m_current_framebuffer)
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
}
@ -185,8 +195,15 @@ void OpenGLDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u
GL_COLOR_BUFFER_BIT, GL_LINEAR);
glEnable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
if (m_current_framebuffer)
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_current_framebuffer ? m_current_framebuffer->GetGLId() : 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
void OpenGLDevice::ClearRenderTarget(GPUTexture* t, u32 c)
@ -638,9 +655,6 @@ bool OpenGLDevice::CreateBuffers(bool buggy_pbo)
m_read_fbo = fbos[0];
m_write_fbo = fbos[1];
// Read FBO gets left bound.
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_read_fbo);
return true;
}
@ -665,7 +679,7 @@ bool OpenGLDevice::BeginPresent(bool skip_present)
return false;
}
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
const Common::Rectangle<s32> window_rc =
Common::Rectangle<s32>::FromExtents(0, 0, m_window_info.surface_width, m_window_info.surface_height);

View file

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

View file

@ -11,7 +11,7 @@
#include <cstdarg>
#include <string_view>
#ifdef _DEBUG
#if defined(_DEBUG) && !defined(CPU_ARCH_ARM32) && !defined(CPU_ARCH_X86)
#define ENABLE_VULKAN_DEBUG_OBJECTS 1
#endif
@ -413,4 +413,4 @@ static inline void SetObjectName(VkDevice device, T object_handle, const std::st
SetFormattedObjectName(device, object_handle, "%.*s", static_cast<int>(sv.length()), sv.data());
#endif
}
} // namespace Vulkan
} // namespace Vulkan