softjit: Simplify constant writes.
This commit is contained in:
parent
c2985bca31
commit
357e2e9d68
4 changed files with 66 additions and 67 deletions
|
@ -327,32 +327,16 @@ void PixelJitCache::Discard(Gen::CCFlags cc) {
|
|||
|
||||
void PixelJitCache::WriteConstantPool(const PixelFuncID &id) {
|
||||
// This is used to add a fixed point 0.5 (as s.11.4) for blend factors to multiply accurately.
|
||||
if (constBlendHalf_11_4s_ == nullptr) {
|
||||
constBlendHalf_11_4s_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(1 << 3);
|
||||
}
|
||||
WriteSimpleConst8x16(constBlendHalf_11_4s_, 1 << 3);
|
||||
|
||||
// This is used for shifted blend factors, to inverse them.
|
||||
if (constBlendInvert_11_4s_ == nullptr) {
|
||||
constBlendInvert_11_4s_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(0xFF << 4);
|
||||
}
|
||||
WriteSimpleConst8x16(constBlendInvert_11_4s_, 0xFF << 4);
|
||||
|
||||
// A set of 255s, used to inverse fog.
|
||||
if (const255_16s_ == nullptr) {
|
||||
const255_16s_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(0xFF);
|
||||
}
|
||||
WriteSimpleConst8x16(const255_16s_, 0xFF);
|
||||
|
||||
// This is used for a multiply that divides by 255 with shifting.
|
||||
if (constBy255i_ == nullptr) {
|
||||
constBy255i_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(0x8081);
|
||||
}
|
||||
WriteSimpleConst8x16(constBy255i_, 0x8081);
|
||||
}
|
||||
|
||||
bool PixelJitCache::Jit_ApplyDepthRange(const PixelFuncID &id) {
|
||||
|
|
|
@ -424,4 +424,49 @@ void CodeBlock::Clear() {
|
|||
descriptions_.clear();
|
||||
}
|
||||
|
||||
void CodeBlock::WriteSimpleConst16x8(const u8 *&ptr, uint8_t value) {
|
||||
if (ptr == nullptr)
|
||||
WriteDynamicConst16x8(ptr, value);
|
||||
}
|
||||
|
||||
void CodeBlock::WriteSimpleConst8x16(const u8 *&ptr, uint16_t value) {
|
||||
if (ptr == nullptr)
|
||||
WriteDynamicConst8x16(ptr, value);
|
||||
}
|
||||
|
||||
void CodeBlock::WriteSimpleConst4x32(const u8 *&ptr, uint32_t value) {
|
||||
if (ptr == nullptr)
|
||||
WriteDynamicConst4x32(ptr, value);
|
||||
}
|
||||
|
||||
void CodeBlock::WriteDynamicConst16x8(const u8 *&ptr, uint8_t value) {
|
||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
ptr = AlignCode16();
|
||||
for (int i = 0; i < 16; ++i)
|
||||
Write8(value);
|
||||
#else
|
||||
_assert_msg_(false, "Not yet implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
void CodeBlock::WriteDynamicConst8x16(const u8 *&ptr, uint16_t value) {
|
||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
ptr = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(value);
|
||||
#else
|
||||
_assert_msg_(false, "Not yet implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
void CodeBlock::WriteDynamicConst4x32(const u8 *&ptr, uint32_t value) {
|
||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
ptr = AlignCode16();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
Write32(value);
|
||||
#else
|
||||
_assert_msg_(false, "Not yet implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -227,6 +227,13 @@ protected:
|
|||
|
||||
void Describe(const std::string &message);
|
||||
|
||||
void WriteSimpleConst16x8(const u8 *&ptr, uint8_t value);
|
||||
void WriteSimpleConst8x16(const u8 *&ptr, uint16_t value);
|
||||
void WriteSimpleConst4x32(const u8 *&ptr, uint32_t value);
|
||||
void WriteDynamicConst16x8(const u8 *&ptr, uint8_t value);
|
||||
void WriteDynamicConst8x16(const u8 *&ptr, uint16_t value);
|
||||
void WriteDynamicConst4x32(const u8 *&ptr, uint32_t value);
|
||||
|
||||
#if PPSSPP_ARCH(ARM64)
|
||||
Arm64Gen::ARM64FloatEmitter fp;
|
||||
#endif
|
||||
|
|
|
@ -856,11 +856,8 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) {
|
|||
|
||||
void SamplerJitCache::WriteConstantPool(const SamplerID &id) {
|
||||
// We reuse constants in any pool, because our code space is small.
|
||||
if (const10All16_ == nullptr) {
|
||||
const10All16_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(0x10);
|
||||
}
|
||||
WriteSimpleConst8x16(const10All16_, 0x10);
|
||||
WriteSimpleConst16x8(const10All8_, 0x10);
|
||||
|
||||
if (const10Low_ == nullptr) {
|
||||
const10Low_ = AlignCode16();
|
||||
|
@ -870,23 +867,8 @@ void SamplerJitCache::WriteConstantPool(const SamplerID &id) {
|
|||
Write16(0);
|
||||
}
|
||||
|
||||
if (const10All8_ == nullptr) {
|
||||
const10All8_ = AlignCode16();
|
||||
for (int i = 0; i < 16; ++i)
|
||||
Write8(0x10);
|
||||
}
|
||||
|
||||
if (constOnes32_ == nullptr) {
|
||||
constOnes32_ = AlignCode16();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
Write32(1);
|
||||
}
|
||||
|
||||
if (constOnes16_ == nullptr) {
|
||||
constOnes16_ = AlignCode16();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
Write16(1);
|
||||
}
|
||||
WriteSimpleConst4x32(constOnes32_, 1);
|
||||
WriteSimpleConst8x16(constOnes16_, 1);
|
||||
|
||||
if (constUNext_ == nullptr) {
|
||||
constUNext_ = AlignCode16();
|
||||
|
@ -898,37 +880,18 @@ void SamplerJitCache::WriteConstantPool(const SamplerID &id) {
|
|||
Write32(0); Write32(0); Write32(1); Write32(1);
|
||||
}
|
||||
|
||||
if (const5551Swizzle_ == nullptr) {
|
||||
const5551Swizzle_ = AlignCode16();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
Write32(0x00070707);
|
||||
}
|
||||
|
||||
if (const5650Swizzle_ == nullptr) {
|
||||
const5650Swizzle_ = AlignCode16();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
Write32(0x00070307);
|
||||
}
|
||||
WriteSimpleConst4x32(const5551Swizzle_, 0x00070707);
|
||||
WriteSimpleConst4x32(const5650Swizzle_, 0x00070307);
|
||||
|
||||
// These are unique to the sampler ID.
|
||||
if (!id.hasAnyMips) {
|
||||
constWidth256f_ = AlignCode16();
|
||||
float w256f = (1 << id.width0Shift) * 256;
|
||||
Write32(*(uint32_t *)&w256f); Write32(*(uint32_t *)&w256f);
|
||||
Write32(*(uint32_t *)&w256f); Write32(*(uint32_t *)&w256f);
|
||||
|
||||
constHeight256f_ = AlignCode16();
|
||||
WriteDynamicConst4x32(constWidth256f_, *(uint32_t *)&w256f);
|
||||
float h256f = (1 << id.height0Shift) * 256;
|
||||
Write32(*(uint32_t *)&h256f); Write32(*(uint32_t *)&h256f);
|
||||
Write32(*(uint32_t *)&h256f); Write32(*(uint32_t *)&h256f);
|
||||
WriteDynamicConst4x32(constHeight256f_, *(uint32_t *)&h256f);
|
||||
|
||||
constWidthMinus1i_ = AlignCode16();
|
||||
Write32((1 << id.width0Shift) - 1); Write32((1 << id.width0Shift) - 1);
|
||||
Write32((1 << id.width0Shift) - 1); Write32((1 << id.width0Shift) - 1);
|
||||
|
||||
constHeightMinus1i_ = AlignCode16();
|
||||
Write32((1 << id.height0Shift) - 1); Write32((1 << id.height0Shift) - 1);
|
||||
Write32((1 << id.height0Shift) - 1); Write32((1 << id.height0Shift) - 1);
|
||||
WriteDynamicConst4x32(constWidthMinus1i_, (1 << id.width0Shift) - 1);
|
||||
WriteDynamicConst4x32(constHeightMinus1i_, (1 << id.height0Shift) - 1);
|
||||
} else {
|
||||
constWidth256f_ = nullptr;
|
||||
constHeight256f_ = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue