2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-02-13 00:52:07 +00:00
|
|
|
|
|
|
|
#include "VideoCommon/VertexLoaderARM64.h"
|
2021-02-08 23:22:10 +00:00
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "VideoCommon/DataReader.h"
|
2015-05-29 12:42:45 +00:00
|
|
|
#include "VideoCommon/VertexLoaderManager.h"
|
2015-02-13 00:52:07 +00:00
|
|
|
|
|
|
|
using namespace Arm64Gen;
|
|
|
|
|
2021-02-06 18:50:33 +00:00
|
|
|
constexpr ARM64Reg src_reg = ARM64Reg::X0;
|
|
|
|
constexpr ARM64Reg dst_reg = ARM64Reg::X1;
|
|
|
|
constexpr ARM64Reg count_reg = ARM64Reg::W2;
|
|
|
|
constexpr ARM64Reg skipped_reg = ARM64Reg::W17;
|
|
|
|
constexpr ARM64Reg scratch1_reg = ARM64Reg::W16;
|
|
|
|
constexpr ARM64Reg scratch2_reg = ARM64Reg::W15;
|
|
|
|
constexpr ARM64Reg scratch3_reg = ARM64Reg::W14;
|
|
|
|
constexpr ARM64Reg saved_count = ARM64Reg::W12;
|
|
|
|
|
|
|
|
constexpr ARM64Reg stride_reg = ARM64Reg::X11;
|
|
|
|
constexpr ARM64Reg arraybase_reg = ARM64Reg::X10;
|
|
|
|
constexpr ARM64Reg scale_reg = ARM64Reg::X9;
|
2015-02-13 00:52:07 +00:00
|
|
|
|
2021-03-11 23:57:54 +00:00
|
|
|
static constexpr int GetLoadSize(int load_bytes)
|
|
|
|
{
|
|
|
|
if (load_bytes == 1)
|
|
|
|
return 1;
|
|
|
|
else if (load_bytes <= 2)
|
|
|
|
return 2;
|
|
|
|
else if (load_bytes <= 4)
|
|
|
|
return 4;
|
|
|
|
else if (load_bytes <= 8)
|
|
|
|
return 8;
|
|
|
|
else
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
2015-09-05 15:44:21 +00:00
|
|
|
alignas(16) static const float scale_factors[] = {
|
2015-02-13 00:52:07 +00:00
|
|
|
1.0 / (1ULL << 0), 1.0 / (1ULL << 1), 1.0 / (1ULL << 2), 1.0 / (1ULL << 3),
|
|
|
|
1.0 / (1ULL << 4), 1.0 / (1ULL << 5), 1.0 / (1ULL << 6), 1.0 / (1ULL << 7),
|
|
|
|
1.0 / (1ULL << 8), 1.0 / (1ULL << 9), 1.0 / (1ULL << 10), 1.0 / (1ULL << 11),
|
|
|
|
1.0 / (1ULL << 12), 1.0 / (1ULL << 13), 1.0 / (1ULL << 14), 1.0 / (1ULL << 15),
|
|
|
|
1.0 / (1ULL << 16), 1.0 / (1ULL << 17), 1.0 / (1ULL << 18), 1.0 / (1ULL << 19),
|
|
|
|
1.0 / (1ULL << 20), 1.0 / (1ULL << 21), 1.0 / (1ULL << 22), 1.0 / (1ULL << 23),
|
|
|
|
1.0 / (1ULL << 24), 1.0 / (1ULL << 25), 1.0 / (1ULL << 26), 1.0 / (1ULL << 27),
|
|
|
|
1.0 / (1ULL << 28), 1.0 / (1ULL << 29), 1.0 / (1ULL << 30), 1.0 / (1ULL << 31),
|
|
|
|
};
|
|
|
|
|
|
|
|
VertexLoaderARM64::VertexLoaderARM64(const TVtxDesc& vtx_desc, const VAT& vtx_att)
|
|
|
|
: VertexLoaderBase(vtx_desc, vtx_att), m_float_emit(this)
|
|
|
|
{
|
|
|
|
AllocCodeSpace(4096);
|
2021-05-15 14:10:10 +00:00
|
|
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
2015-02-13 00:52:07 +00:00
|
|
|
ClearCodeSpace();
|
|
|
|
GenerateVertexLoader();
|
|
|
|
WriteProtect();
|
|
|
|
}
|
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
void VertexLoaderARM64::GetVertexAddr(int array, VertexComponentFormat attribute, ARM64Reg reg)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
if (IsIndexed(attribute))
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
if (attribute == VertexComponentFormat::Index8)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2015-09-05 00:57:08 +00:00
|
|
|
if (m_src_ofs < 4096)
|
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRB(IndexType::Unsigned, scratch1_reg, src_reg, m_src_ofs);
|
2015-09-05 00:57:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ADD(reg, src_reg, m_src_ofs);
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRB(IndexType::Unsigned, scratch1_reg, reg, 0);
|
2015-09-05 00:57:08 +00:00
|
|
|
}
|
2015-02-13 00:52:07 +00:00
|
|
|
m_src_ofs += 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-05 00:57:08 +00:00
|
|
|
if (m_src_ofs < 256)
|
|
|
|
{
|
|
|
|
LDURH(scratch1_reg, src_reg, m_src_ofs);
|
|
|
|
}
|
|
|
|
else if (m_src_ofs <= 8190 && !(m_src_ofs & 1))
|
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch1_reg, src_reg, m_src_ofs);
|
2015-09-05 00:57:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ADD(reg, src_reg, m_src_ofs);
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch1_reg, reg, 0);
|
2015-09-05 00:57:08 +00:00
|
|
|
}
|
2015-02-13 00:52:07 +00:00
|
|
|
m_src_ofs += 2;
|
|
|
|
REV16(scratch1_reg, scratch1_reg);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
if (array == ARRAY_POSITION)
|
|
|
|
{
|
2021-07-12 10:05:34 +00:00
|
|
|
EOR(scratch2_reg, scratch1_reg,
|
|
|
|
attribute == VertexComponentFormat::Index8 ? LogicalImm(0xFF, 32) :
|
|
|
|
LogicalImm(0xFFFF, 32));
|
2015-02-13 00:52:07 +00:00
|
|
|
m_skip_vertex = CBZ(scratch2_reg);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
LDR(IndexType::Unsigned, scratch2_reg, stride_reg, array * 4);
|
2015-02-13 00:52:07 +00:00
|
|
|
MUL(scratch1_reg, scratch1_reg, scratch2_reg);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
LDR(IndexType::Unsigned, EncodeRegTo64(scratch2_reg), arraybase_reg, array * 8);
|
2015-02-13 00:52:07 +00:00
|
|
|
ADD(EncodeRegTo64(reg), EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg));
|
|
|
|
}
|
2015-09-05 00:57:08 +00:00
|
|
|
else
|
|
|
|
ADD(reg, src_reg, m_src_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
s32 VertexLoaderARM64::GetAddressImm(int array, VertexComponentFormat attribute,
|
|
|
|
Arm64Gen::ARM64Reg reg, u32 align)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
if (IsIndexed(attribute) || (m_src_ofs > 255 && (m_src_ofs & (align - 1))))
|
2015-02-13 00:52:07 +00:00
|
|
|
GetVertexAddr(array, attribute, reg);
|
|
|
|
else
|
|
|
|
return m_src_ofs;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentFormat format,
|
|
|
|
int count_in, int count_out, bool dequantize, u8 scaling_exponent,
|
2015-02-17 04:01:07 +00:00
|
|
|
AttributeFormat* native_format, s32 offset)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
ARM64Reg coords = count_in == 3 ? ARM64Reg::Q31 : ARM64Reg::D31;
|
|
|
|
ARM64Reg scale = count_in == 3 ? ARM64Reg::Q30 : ARM64Reg::D30;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
int elem_size = GetElementSize(format);
|
2015-02-13 00:52:07 +00:00
|
|
|
int load_bytes = elem_size * count_in;
|
2021-03-11 23:57:54 +00:00
|
|
|
int load_size = GetLoadSize(load_bytes);
|
2015-02-17 04:01:07 +00:00
|
|
|
load_size <<= 3;
|
2015-02-13 00:52:07 +00:00
|
|
|
elem_size <<= 3;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
if (offset == -1)
|
|
|
|
{
|
|
|
|
if (count_in == 1)
|
2021-01-16 07:27:11 +00:00
|
|
|
m_float_emit.LDR(elem_size, IndexType::Unsigned, coords, EncodeRegTo64(scratch1_reg), 0);
|
2015-02-17 04:01:07 +00:00
|
|
|
else
|
|
|
|
m_float_emit.LD1(elem_size, 1, coords, EncodeRegTo64(scratch1_reg));
|
|
|
|
}
|
|
|
|
else if (offset & (load_size - 1)) // Not aligned - unscaled
|
|
|
|
{
|
|
|
|
m_float_emit.LDUR(load_size, coords, src_reg, offset);
|
|
|
|
}
|
2015-02-13 00:52:07 +00:00
|
|
|
else
|
2015-02-17 04:01:07 +00:00
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
m_float_emit.LDR(load_size, IndexType::Unsigned, coords, src_reg, offset);
|
2015-02-17 04:01:07 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (format != ComponentFormat::Float)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
// Extend and convert to float
|
|
|
|
switch (format)
|
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
case ComponentFormat::UByte:
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.UXTL(8, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
m_float_emit.UXTL(16, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
break;
|
2021-02-08 23:22:10 +00:00
|
|
|
case ComponentFormat::Byte:
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.SXTL(8, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
m_float_emit.SXTL(16, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
break;
|
2021-02-08 23:22:10 +00:00
|
|
|
case ComponentFormat::UShort:
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.REV16(8, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
m_float_emit.UXTL(16, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
break;
|
2021-02-08 23:22:10 +00:00
|
|
|
case ComponentFormat::Short:
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.REV16(8, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
m_float_emit.SXTL(16, EncodeRegToDouble(coords), EncodeRegToDouble(coords));
|
|
|
|
break;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.SCVTF(32, coords, coords);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
if (dequantize && scaling_exponent)
|
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
m_float_emit.LDR(32, IndexType::Unsigned, scale, scale_reg, scaling_exponent * 4);
|
2015-02-13 00:52:07 +00:00
|
|
|
m_float_emit.FMUL(32, coords, coords, scale, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_float_emit.REV32(8, coords, coords);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
const u32 write_size = count_out == 3 ? 128 : count_out * 32;
|
|
|
|
const u32 mask = count_out == 3 ? 0xF : count_out == 2 ? 0x7 : 0x3;
|
2015-02-17 04:01:07 +00:00
|
|
|
if (m_dst_ofs < 256)
|
|
|
|
{
|
|
|
|
m_float_emit.STUR(write_size, coords, dst_reg, m_dst_ofs);
|
|
|
|
}
|
|
|
|
else if (!(m_dst_ofs & mask))
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
m_float_emit.STR(write_size, IndexType::Unsigned, coords, dst_reg, m_dst_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ADD(EncodeRegTo64(scratch2_reg), dst_reg, m_dst_ofs);
|
|
|
|
m_float_emit.ST1(32, 1, coords, EncodeRegTo64(scratch2_reg));
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-06-07 04:50:50 +00:00
|
|
|
// Z-Freeze
|
|
|
|
if (native_format == &m_native_vtx_decl.position)
|
|
|
|
{
|
|
|
|
CMP(count_reg, 3);
|
|
|
|
FixupBranch dont_store = B(CC_GT);
|
2016-05-07 07:35:40 +00:00
|
|
|
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache);
|
2015-09-05 00:57:08 +00:00
|
|
|
ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg), EncodeRegTo64(count_reg),
|
2021-01-16 09:26:23 +00:00
|
|
|
ArithOption(EncodeRegTo64(count_reg), ShiftType::LSL, 4));
|
2015-06-07 04:50:50 +00:00
|
|
|
m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg), -16);
|
|
|
|
SetJumpTarget(dont_store);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
native_format->components = count_out;
|
|
|
|
native_format->enable = true;
|
|
|
|
native_format->offset = m_dst_ofs;
|
|
|
|
native_format->type = VAR_FLOAT;
|
|
|
|
native_format->integer = false;
|
|
|
|
m_dst_ofs += sizeof(float) * count_out;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (attribute == VertexComponentFormat::Direct)
|
2015-02-13 00:52:07 +00:00
|
|
|
m_src_ofs += load_bytes;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
return load_bytes;
|
|
|
|
}
|
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
void VertexLoaderARM64::ReadColor(VertexComponentFormat attribute, ColorFormat format, s32 offset)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
int load_bytes = 0;
|
|
|
|
switch (format)
|
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
case ColorFormat::RGB888:
|
|
|
|
case ColorFormat::RGB888x:
|
|
|
|
case ColorFormat::RGBA8888:
|
2015-02-13 00:52:07 +00:00
|
|
|
if (offset == -1)
|
2021-01-16 07:27:11 +00:00
|
|
|
LDR(IndexType::Unsigned, scratch2_reg, EncodeRegTo64(scratch1_reg), 0);
|
2015-02-17 04:01:07 +00:00
|
|
|
else if (offset & 3) // Not aligned - unscaled
|
|
|
|
LDUR(scratch2_reg, src_reg, offset);
|
2015-02-13 00:52:07 +00:00
|
|
|
else
|
2021-01-16 07:27:11 +00:00
|
|
|
LDR(IndexType::Unsigned, scratch2_reg, src_reg, offset);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (format != ColorFormat::RGBA8888)
|
2021-07-06 14:53:04 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, LogicalImm(0xFF000000, 32));
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch2_reg, dst_reg, m_dst_ofs);
|
2021-02-08 23:22:10 +00:00
|
|
|
load_bytes = format == ColorFormat::RGB888 ? 3 : 4;
|
2015-02-13 00:52:07 +00:00
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
case ColorFormat::RGB565:
|
2015-02-13 00:52:07 +00:00
|
|
|
// RRRRRGGG GGGBBBBB
|
|
|
|
// AAAAAAAA BBBBBBBB GGGGGGGG RRRRRRRR
|
|
|
|
if (offset == -1)
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch3_reg, EncodeRegTo64(scratch1_reg), 0);
|
2015-02-17 04:01:07 +00:00
|
|
|
else if (offset & 1) // Not aligned - unscaled
|
2015-06-21 02:12:31 +00:00
|
|
|
LDURH(scratch3_reg, src_reg, offset);
|
2015-02-13 00:52:07 +00:00
|
|
|
else
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch3_reg, src_reg, offset);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
REV16(scratch3_reg, scratch3_reg);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// B
|
2021-07-12 10:05:34 +00:00
|
|
|
AND(scratch2_reg, scratch3_reg, LogicalImm(0x1F, 32));
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch2_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 3));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 5));
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch1_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 16));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// G
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 5, 10);
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch2_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 2));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 6));
|
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 8));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// R
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 11, 15);
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 3));
|
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 2));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// A
|
2021-07-06 14:53:04 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, LogicalImm(0xFF000000, 32));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch1_reg, dst_reg, m_dst_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
load_bytes = 2;
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
case ColorFormat::RGBA4444:
|
2015-02-13 00:52:07 +00:00
|
|
|
// BBBBAAAA RRRRGGGG
|
|
|
|
// REV16 - RRRRGGGG BBBBAAAA
|
|
|
|
// AAAAAAAA BBBBBBBB GGGGGGGG RRRRRRRR
|
|
|
|
if (offset == -1)
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch3_reg, EncodeRegTo64(scratch1_reg), 0);
|
2015-02-17 04:01:07 +00:00
|
|
|
else if (offset & 1) // Not aligned - unscaled
|
2015-06-21 02:12:31 +00:00
|
|
|
LDURH(scratch3_reg, src_reg, offset);
|
2015-02-13 00:52:07 +00:00
|
|
|
else
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRH(IndexType::Unsigned, scratch3_reg, src_reg, offset);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// R
|
|
|
|
UBFM(scratch1_reg, scratch3_reg, 4, 7);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// G
|
2021-07-12 10:05:34 +00:00
|
|
|
AND(scratch2_reg, scratch3_reg, LogicalImm(0xF, 32));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 8));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// B
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 12, 15);
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 16));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// A
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 8, 11);
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 24));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// Final duplication
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch1_reg, ArithOption(scratch1_reg, ShiftType::LSL, 4));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch1_reg, dst_reg, m_dst_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
load_bytes = 2;
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
case ColorFormat::RGBA6666:
|
2015-02-13 00:52:07 +00:00
|
|
|
// RRRRRRGG GGGGBBBB BBAAAAAA
|
|
|
|
// AAAAAAAA BBBBBBBB GGGGGGGG RRRRRRRR
|
|
|
|
if (offset == -1)
|
2015-06-21 02:12:31 +00:00
|
|
|
{
|
|
|
|
LDUR(scratch3_reg, EncodeRegTo64(scratch1_reg), -1);
|
|
|
|
}
|
2015-02-13 00:52:07 +00:00
|
|
|
else
|
2015-06-21 02:12:31 +00:00
|
|
|
{
|
|
|
|
offset -= 1;
|
|
|
|
if (offset & 3) // Not aligned - unscaled
|
|
|
|
LDUR(scratch3_reg, src_reg, offset);
|
|
|
|
else
|
2021-01-16 07:27:11 +00:00
|
|
|
LDR(IndexType::Unsigned, scratch3_reg, src_reg, offset);
|
2015-06-21 02:12:31 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
REV32(scratch3_reg, scratch3_reg);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// A
|
2015-06-21 02:12:31 +00:00
|
|
|
UBFM(scratch2_reg, scratch3_reg, 0, 5);
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch2_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 2));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 6));
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch1_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 24));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// B
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 6, 11);
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch2_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 2));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 6));
|
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 16));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// G
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 12, 17);
|
2021-02-06 18:50:33 +00:00
|
|
|
ORR(scratch2_reg, ARM64Reg::WSP, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 2));
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch2_reg, scratch2_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 6));
|
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 8));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// R
|
|
|
|
UBFM(scratch2_reg, scratch3_reg, 18, 23);
|
2021-01-16 09:26:23 +00:00
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSL, 2));
|
|
|
|
ORR(scratch1_reg, scratch1_reg, scratch2_reg, ArithOption(scratch2_reg, ShiftType::LSR, 4));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch1_reg, dst_reg, m_dst_ofs);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
load_bytes = 3;
|
|
|
|
break;
|
|
|
|
}
|
2021-02-08 23:22:10 +00:00
|
|
|
if (attribute == VertexComponentFormat::Direct)
|
2015-02-13 00:52:07 +00:00
|
|
|
m_src_ofs += load_bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexLoaderARM64::GenerateVertexLoader()
|
|
|
|
{
|
|
|
|
// R0 - Source pointer
|
|
|
|
// R1 - Destination pointer
|
|
|
|
// R2 - Count
|
|
|
|
// R30 - LR
|
|
|
|
//
|
|
|
|
// R0 return how many
|
|
|
|
//
|
|
|
|
// Registers we don't have to worry about saving
|
|
|
|
// R9-R17 are caller saved temporaries
|
|
|
|
// R18 is a temporary or platform specific register(iOS)
|
|
|
|
//
|
|
|
|
// VFP registers
|
|
|
|
// We can touch all except v8-v15
|
|
|
|
// If we need to use those, we need to retain the lower 64bits(!) of the register
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-09-05 00:57:08 +00:00
|
|
|
bool has_tc = false;
|
|
|
|
bool has_tc_scale = false;
|
2021-02-08 23:22:10 +00:00
|
|
|
for (size_t i = 0; i < m_VtxDesc.high.TexCoord.Size(); i++)
|
2015-09-05 00:57:08 +00:00
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
has_tc |= m_VtxDesc.high.TexCoord[i] != VertexComponentFormat::NotPresent;
|
2021-03-11 06:15:43 +00:00
|
|
|
has_tc_scale |= (m_VtxAttr.GetTexFrac(i) != 0);
|
2015-09-05 00:57:08 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-03-11 06:15:43 +00:00
|
|
|
bool need_scale = (m_VtxAttr.g0.ByteDequant && m_VtxAttr.g0.PosFrac) ||
|
|
|
|
(has_tc && has_tc_scale) ||
|
2021-02-08 23:22:10 +00:00
|
|
|
(m_VtxDesc.low.Normal != VertexComponentFormat::NotPresent);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-09-05 00:57:08 +00:00
|
|
|
AlignCode16();
|
2021-02-08 23:22:10 +00:00
|
|
|
if (IsIndexed(m_VtxDesc.low.Position))
|
2021-02-06 18:50:33 +00:00
|
|
|
MOV(skipped_reg, ARM64Reg::WZR);
|
2015-02-13 00:52:07 +00:00
|
|
|
MOV(saved_count, count_reg);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-05-07 07:35:40 +00:00
|
|
|
MOVP2R(stride_reg, g_main_cp_state.array_strides);
|
|
|
|
MOVP2R(arraybase_reg, VertexLoaderManager::cached_arraybases);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-09-05 00:57:08 +00:00
|
|
|
if (need_scale)
|
2016-05-07 07:35:40 +00:00
|
|
|
MOVP2R(scale_reg, scale_factors);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
const u8* loop_start = GetCodePtr();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.low.PosMatIdx)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRB(IndexType::Unsigned, scratch1_reg, src_reg, m_src_ofs);
|
2021-07-12 10:05:34 +00:00
|
|
|
AND(scratch1_reg, scratch1_reg, LogicalImm(0x3F, 32));
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch1_reg, dst_reg, m_dst_ofs);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-06-07 04:50:50 +00:00
|
|
|
// Z-Freeze
|
|
|
|
CMP(count_reg, 3);
|
|
|
|
FixupBranch dont_store = B(CC_GT);
|
2016-05-07 07:35:40 +00:00
|
|
|
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index);
|
2021-01-16 07:27:11 +00:00
|
|
|
STR(IndexType::Unsigned, scratch1_reg, EncodeRegTo64(scratch2_reg), 0);
|
2015-06-07 04:50:50 +00:00
|
|
|
SetJumpTarget(dont_store);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
m_native_vtx_decl.posmtx.components = 4;
|
|
|
|
m_native_vtx_decl.posmtx.enable = true;
|
|
|
|
m_native_vtx_decl.posmtx.offset = m_dst_ofs;
|
|
|
|
m_native_vtx_decl.posmtx.type = VAR_UNSIGNED_BYTE;
|
|
|
|
m_native_vtx_decl.posmtx.integer = true;
|
|
|
|
m_src_ofs += sizeof(u8);
|
|
|
|
m_dst_ofs += sizeof(u32);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
std::array<u32, 8> texmatidx_ofs;
|
|
|
|
for (size_t i = 0; i < m_VtxDesc.low.TexMatIdx.Size(); i++)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.low.TexMatIdx[i])
|
2015-02-13 00:52:07 +00:00
|
|
|
texmatidx_ofs[i] = m_src_ofs++;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
// Position
|
|
|
|
{
|
2021-03-11 06:15:43 +00:00
|
|
|
int elem_size = GetElementSize(m_VtxAttr.g0.PosFormat);
|
|
|
|
int pos_elements = m_VtxAttr.g0.PosElements == CoordComponentCount::XY ? 2 : 3;
|
2021-02-08 23:22:10 +00:00
|
|
|
int load_bytes = elem_size * pos_elements;
|
2021-03-11 23:57:54 +00:00
|
|
|
int load_size = GetLoadSize(load_bytes);
|
2015-02-17 04:01:07 +00:00
|
|
|
load_size <<= 3;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
s32 offset = GetAddressImm(ARRAY_POSITION, m_VtxDesc.low.Position, EncodeRegTo64(scratch1_reg),
|
|
|
|
load_size);
|
2021-03-11 06:15:43 +00:00
|
|
|
ReadVertex(m_VtxDesc.low.Position, m_VtxAttr.g0.PosFormat, pos_elements, pos_elements,
|
|
|
|
m_VtxAttr.g0.ByteDequant, m_VtxAttr.g0.PosFrac, &m_native_vtx_decl.position, offset);
|
2015-02-17 04:01:07 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.low.Normal != VertexComponentFormat::NotPresent)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
static const u8 map[8] = {7, 6, 15, 14};
|
2021-03-11 06:15:43 +00:00
|
|
|
const u8 scaling_exponent = map[u32(m_VtxAttr.g0.NormalFormat.Value())];
|
|
|
|
const int limit = m_VtxAttr.g0.NormalElements == NormalComponentCount::NBT ? 3 : 1;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
s32 offset = -1;
|
2021-09-30 18:27:53 +00:00
|
|
|
for (int i = 0; i < limit; i++)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-03-11 06:15:43 +00:00
|
|
|
if (!i || m_VtxAttr.g0.NormalIndex3)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-03-11 06:15:43 +00:00
|
|
|
int elem_size = GetElementSize(m_VtxAttr.g0.NormalFormat);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
int load_bytes = elem_size * 3;
|
2021-03-11 23:57:54 +00:00
|
|
|
int load_size = GetLoadSize(load_bytes);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
offset = GetAddressImm(ARRAY_NORMAL, m_VtxDesc.low.Normal, EncodeRegTo64(scratch1_reg),
|
2015-02-17 04:01:07 +00:00
|
|
|
load_size << 3);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
if (offset == -1)
|
|
|
|
ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch1_reg), i * elem_size * 3);
|
|
|
|
else
|
|
|
|
offset += i * elem_size * 3;
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
2021-03-11 06:15:43 +00:00
|
|
|
int bytes_read = ReadVertex(m_VtxDesc.low.Normal, m_VtxAttr.g0.NormalFormat, 3, 3, true,
|
2015-02-17 04:01:07 +00:00
|
|
|
scaling_exponent, &m_native_vtx_decl.normals[i], offset);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
if (offset == -1)
|
|
|
|
ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch1_reg), bytes_read);
|
|
|
|
else
|
|
|
|
offset += bytes_read;
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
for (size_t i = 0; i < m_VtxDesc.low.Color.Size(); i++)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
m_native_vtx_decl.colors[i].components = 4;
|
|
|
|
m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE;
|
|
|
|
m_native_vtx_decl.colors[i].integer = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
u32 align = 4;
|
2021-03-11 06:15:43 +00:00
|
|
|
if (m_VtxAttr.GetColorFormat(i) == ColorFormat::RGB565 ||
|
|
|
|
m_VtxAttr.GetColorFormat(i) == ColorFormat::RGBA4444)
|
2015-02-13 00:52:07 +00:00
|
|
|
align = 2;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-03-26 22:46:37 +00:00
|
|
|
s32 offset = GetAddressImm(ARRAY_COLOR0 + int(i), m_VtxDesc.low.Color[i],
|
2021-02-08 23:22:10 +00:00
|
|
|
EncodeRegTo64(scratch1_reg), align);
|
2021-03-11 06:15:43 +00:00
|
|
|
ReadColor(m_VtxDesc.low.Color[i], m_VtxAttr.GetColorFormat(i), offset);
|
2015-02-13 00:52:07 +00:00
|
|
|
m_native_vtx_decl.colors[i].components = 4;
|
|
|
|
m_native_vtx_decl.colors[i].enable = true;
|
|
|
|
m_native_vtx_decl.colors[i].offset = m_dst_ofs;
|
|
|
|
m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE;
|
|
|
|
m_native_vtx_decl.colors[i].integer = false;
|
|
|
|
m_dst_ofs += 4;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
for (size_t i = 0; i < m_VtxDesc.high.TexCoord.Size(); i++)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
m_native_vtx_decl.texcoords[i].offset = m_dst_ofs;
|
|
|
|
m_native_vtx_decl.texcoords[i].type = VAR_FLOAT;
|
|
|
|
m_native_vtx_decl.texcoords[i].integer = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-03-11 06:15:43 +00:00
|
|
|
int elements = m_VtxAttr.GetTexElements(i) == TexComponentCount::S ? 1 : 2;
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.high.TexCoord[i] != VertexComponentFormat::NotPresent)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-03-11 06:15:43 +00:00
|
|
|
int elem_size = GetElementSize(m_VtxAttr.GetTexFormat(i));
|
2015-02-17 04:01:07 +00:00
|
|
|
int load_bytes = elem_size * (elements + 2);
|
2021-03-11 23:57:54 +00:00
|
|
|
int load_size = GetLoadSize(load_bytes);
|
2015-02-17 04:01:07 +00:00
|
|
|
load_size <<= 3;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
s32 offset = GetAddressImm(ARRAY_TEXCOORD0 + int(i), m_VtxDesc.high.TexCoord[i],
|
|
|
|
EncodeRegTo64(scratch1_reg), load_size);
|
2021-03-11 06:15:43 +00:00
|
|
|
u8 scaling_exponent = m_VtxAttr.GetTexFrac(i);
|
|
|
|
ReadVertex(m_VtxDesc.high.TexCoord[i], m_VtxAttr.GetTexFormat(i), elements,
|
|
|
|
m_VtxDesc.low.TexMatIdx[i] ? 2 : elements, m_VtxAttr.g0.ByteDequant,
|
|
|
|
scaling_exponent, &m_native_vtx_decl.texcoords[i], offset);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.low.TexMatIdx[i])
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
m_native_vtx_decl.texcoords[i].components = 3;
|
|
|
|
m_native_vtx_decl.texcoords[i].enable = true;
|
|
|
|
m_native_vtx_decl.texcoords[i].type = VAR_FLOAT;
|
|
|
|
m_native_vtx_decl.texcoords[i].integer = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-01-16 07:27:11 +00:00
|
|
|
LDRB(IndexType::Unsigned, scratch2_reg, src_reg, texmatidx_ofs[i]);
|
2021-02-06 18:50:33 +00:00
|
|
|
m_float_emit.UCVTF(ARM64Reg::S31, scratch2_reg);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (m_VtxDesc.high.TexCoord[i] != VertexComponentFormat::NotPresent)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
m_float_emit.STR(32, IndexType::Unsigned, ARM64Reg::D31, dst_reg, m_dst_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
m_dst_ofs += sizeof(float);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_native_vtx_decl.texcoords[i].offset = m_dst_ofs;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-17 04:01:07 +00:00
|
|
|
if (m_dst_ofs < 256)
|
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
STUR(ARM64Reg::SP, dst_reg, m_dst_ofs);
|
2015-02-17 04:01:07 +00:00
|
|
|
}
|
|
|
|
else if (!(m_dst_ofs & 7))
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
// If m_dst_ofs isn't 8byte aligned we can't store an 8byte zero register
|
|
|
|
// So store two 4byte zero registers
|
|
|
|
// The destination is always 4byte aligned
|
2021-02-06 18:50:33 +00:00
|
|
|
STR(IndexType::Unsigned, ARM64Reg::WSP, dst_reg, m_dst_ofs);
|
|
|
|
STR(IndexType::Unsigned, ARM64Reg::WSP, dst_reg, m_dst_ofs + 4);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
STR(IndexType::Unsigned, ARM64Reg::SP, dst_reg, m_dst_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
2021-02-06 18:50:33 +00:00
|
|
|
m_float_emit.STR(32, IndexType::Unsigned, ARM64Reg::D31, dst_reg, m_dst_ofs + 8);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
m_dst_ofs += sizeof(float) * 3;
|
|
|
|
}
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
// Prepare for the next vertex.
|
|
|
|
ADD(dst_reg, dst_reg, m_dst_ofs);
|
|
|
|
const u8* cont = GetCodePtr();
|
|
|
|
ADD(src_reg, src_reg, m_src_ofs);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
SUB(count_reg, count_reg, 1);
|
|
|
|
CBNZ(count_reg, loop_start);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-08 23:22:10 +00:00
|
|
|
if (IsIndexed(m_VtxDesc.low.Position))
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
SUB(ARM64Reg::W0, saved_count, skipped_reg);
|
|
|
|
RET(ARM64Reg::X30);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
SetJumpTarget(m_skip_vertex);
|
|
|
|
ADD(skipped_reg, skipped_reg, 1);
|
|
|
|
B(cont);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-06 18:50:33 +00:00
|
|
|
MOV(ARM64Reg::W0, saved_count);
|
|
|
|
RET(ARM64Reg::X30);
|
2015-02-13 00:52:07 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-02-13 00:52:07 +00:00
|
|
|
FlushIcache();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-03-11 20:55:25 +00:00
|
|
|
ASSERT(m_vertex_size == m_src_ofs);
|
2015-02-13 00:52:07 +00:00
|
|
|
m_native_vtx_decl.stride = m_dst_ofs;
|
|
|
|
}
|
|
|
|
|
2015-04-06 09:44:13 +00:00
|
|
|
int VertexLoaderARM64::RunVertices(DataReader src, DataReader dst, int count)
|
2015-02-13 00:52:07 +00:00
|
|
|
{
|
|
|
|
m_numLoadedVertices += count;
|
|
|
|
return ((int (*)(u8 * src, u8 * dst, int count)) region)(src.GetPointer(), dst.GetPointer(),
|
|
|
|
count);
|
|
|
|
}
|