mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 02:29:51 +01:00
Merge branch 'darkstalkers-work' into TemporaryHackishBranch
This commit is contained in:
commit
2e31a93a26
3 files changed
+95
-28
No files matched your search
@@ -208,7 +208,7 @@ void ProcessRect(const VertexData& v0, const VertexData& v1)
|
||||
bool state_check = !gstate.isModeClear();
|
||||
bool alpha_check = true;
|
||||
if ((coord_check || !gstate.isTextureMapEnabled()) && state_check && alpha_check) {
|
||||
Rasterizer::DrawPSXSprite(v0, v1);
|
||||
Rasterizer::DrawSprite(v0, v1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+93
-26
@@ -1287,19 +1287,60 @@ void DrawTriangleSlice(
|
||||
}
|
||||
}
|
||||
|
||||
// Slow but can handle all input.
|
||||
void SafeScanline(int s, int ds, int t, int x1, int x2, int y, int z, const u8 *texptr, int texbufw, Sampler::Funcs &sampler, Vec4<int> v0_color) {
|
||||
for (int x = x1; x < x2; x++) {
|
||||
Vec4<int> prim_color = v0_color;
|
||||
Vec4<int> tex_color = Vec4<int>::FromRGBA(sampler.nearest(s, t, texptr, texbufw, 0));
|
||||
prim_color = GetTextureFunctionOutput(prim_color, tex_color);
|
||||
DrawingCoords pos(x, y, z);
|
||||
DrawSinglePixel<false>(pos, (u16)z, 1.0f, prim_color);
|
||||
s += ds;
|
||||
}
|
||||
|
||||
// Through mode, with the specific Darkstalker settings.
|
||||
inline void DrawSinglePixel5551(const DrawingCoords &p, const Vec4<int> &color_in) {
|
||||
Vec4<int> prim_color = color_in;
|
||||
if (prim_color.a() == 0)
|
||||
return;
|
||||
|
||||
const u32 old_color = GetPixelColor(p.x, p.y);
|
||||
u32 new_color;
|
||||
|
||||
u8 stencil = GetPixelStencil(p.x, p.y);
|
||||
|
||||
const Vec4<int> dst = Vec4<int>::FromRGBA(old_color);
|
||||
Vec3<int> blended = AlphaBlendingResult(prim_color, dst);
|
||||
|
||||
// ToRGB() always automatically clamps.
|
||||
new_color = blended.ToRGB();
|
||||
new_color |= stencil << 24;
|
||||
new_color = (new_color & ~gstate.getColorMask()) | (old_color & gstate.getColorMask());
|
||||
SetPixelColor(p.x, p.y, new_color);
|
||||
}
|
||||
|
||||
void DrawPSXSprite(const VertexData& v0, const VertexData& v1) {
|
||||
static inline Vec4<int> ModulateRGBA(const Vec4<int>& prim_color, const Vec4<int>& texcolor) {
|
||||
Vec3<int> out_rgb;
|
||||
int out_a;
|
||||
|
||||
#if defined(_M_SSE)
|
||||
// We can be accurate up to 24 bit integers, should be enough.
|
||||
const __m128 p = _mm_cvtepi32_ps(prim_color.ivec);
|
||||
const __m128 t = _mm_cvtepi32_ps(texcolor.ivec);
|
||||
const __m128 b = _mm_mul_ps(p, t);
|
||||
if (gstate.isColorDoublingEnabled()) {
|
||||
// We double right here, only for modulate. Other tex funcs do not color double.
|
||||
const __m128 doubleColor = _mm_setr_ps(2.0f / 255.0f, 2.0f / 255.0f, 2.0f / 255.0f, 1.0f / 255.0f);
|
||||
out_rgb.ivec = _mm_cvtps_epi32(_mm_mul_ps(b, doubleColor));
|
||||
} else {
|
||||
out_rgb.ivec = _mm_cvtps_epi32(_mm_mul_ps(b, _mm_set_ps1(1.0f / 255.0f)));
|
||||
}
|
||||
return Vec4<int>(out_rgb.ivec);
|
||||
#else
|
||||
if (gstate.isColorDoublingEnabled()) {
|
||||
out_rgb = (prim_color.rgb() * texcolor.rgb() * 2) / 255;
|
||||
} else {
|
||||
out_rgb = prim_color.rgb() * texcolor.rgb() / 255;
|
||||
}
|
||||
out_a = (rgba) ? (prim_color.a() * texcolor.a() / 255) : prim_color.a();
|
||||
#endif
|
||||
|
||||
return Vec4<int>(out_rgb.r(), out_rgb.g(), out_rgb.b(), out_a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DrawSprite(const VertexData& v0, const VertexData& v1) {
|
||||
const u8 *texptr = nullptr;
|
||||
|
||||
GETextureFormat texfmt = gstate.getTextureFormat();
|
||||
@@ -1309,7 +1350,7 @@ void DrawPSXSprite(const VertexData& v0, const VertexData& v1) {
|
||||
texptr = Memory::GetPointerUnchecked(texaddr);
|
||||
|
||||
ScreenCoords pprime(v0.screenpos.x, v0.screenpos.y, 0);
|
||||
Sampler::Funcs sampler = Sampler::GetFuncs();
|
||||
Sampler::NearestFunc nearestFunc = Sampler::GetNearestFunc(); // Looks at gstate.
|
||||
|
||||
DrawingCoords pos0 = TransformUnit::ScreenToDrawing(v0.screenpos);
|
||||
DrawingCoords pos1 = TransformUnit::ScreenToDrawing(v1.screenpos);
|
||||
@@ -1347,21 +1388,47 @@ void DrawPSXSprite(const VertexData& v0, const VertexData& v1) {
|
||||
pos0.y = scissorTL.y;
|
||||
}
|
||||
|
||||
int t = t_start;
|
||||
for (int y = pos0.y; y < pos1.y; y++) {
|
||||
int s = s_start;
|
||||
SafeScanline(s, ds, t, pos0.x, pos1.x, y, z, texptr, texbufw, sampler, v0.color0);
|
||||
/*
|
||||
for (int x = pos0.x; x < pos1.x; x++) {
|
||||
Vec4<int> prim_color = v0.color0;
|
||||
Vec4<int> tex_color = Vec4<int>::FromRGBA(sampler.nearest(s, t, texptr, texbufw, 0));
|
||||
prim_color = GetTextureFunctionOutput(prim_color, tex_color);
|
||||
DrawingCoords pos(x, y, z);
|
||||
DrawSinglePixel<false>(pos, (u16)z, fog, prim_color);
|
||||
s += ds;
|
||||
if (!gstate.isStencilTestEnabled() &&
|
||||
!gstate.isDepthTestEnabled() &&
|
||||
!gstate.isLogicOpEnabled() &&
|
||||
!gstate.isColorTestEnabled() &&
|
||||
!gstate.isDitherEnabled() &&
|
||||
gstate.isAlphaTestEnabled() &&
|
||||
gstate.getAlphaTestRef() == 0 &&
|
||||
gstate.getAlphaTestMask() == 0xFF &&
|
||||
gstate.isAlphaBlendEnabled() &&
|
||||
gstate.isTextureAlphaUsed() &&
|
||||
gstate.getTextureFunction() == GE_TEXFUNC_MODULATE &&
|
||||
gstate.FrameBufFormat() == GE_FORMAT_5551) {
|
||||
int t = t_start;
|
||||
for (int y = pos0.y; y < pos1.y; y++) {
|
||||
int s = s_start;
|
||||
// Not really that fast but faster than triangle.
|
||||
for (int x = pos0.x; x < pos1.x; x++) {
|
||||
Vec4<int> prim_color = v0.color0;
|
||||
Vec4<int> tex_color = Vec4<int>::FromRGBA(nearestFunc(s, t, texptr, texbufw, 0));
|
||||
prim_color = ModulateRGBA(prim_color, tex_color);
|
||||
DrawingCoords pos(x, y, z);
|
||||
DrawSinglePixel5551(pos, prim_color);
|
||||
s += ds;
|
||||
}
|
||||
t += dt;
|
||||
}
|
||||
} else {
|
||||
int t = t_start;
|
||||
for (int y = pos0.y; y < pos1.y; y++) {
|
||||
int s = s_start;
|
||||
// Not really that fast but faster than triangle.
|
||||
for (int x = pos0.x; x < pos1.x; x++) {
|
||||
Vec4<int> prim_color = v0.color0;
|
||||
Vec4<int> tex_color = Vec4<int>::FromRGBA(nearestFunc(s, t, texptr, texbufw, 0));
|
||||
prim_color = GetTextureFunctionOutput(prim_color, tex_color);
|
||||
DrawingCoords pos(x, y, z);
|
||||
DrawSinglePixel<false>(pos, (u16)z, 1.0f, prim_color);
|
||||
s += ds;
|
||||
}
|
||||
t += dt;
|
||||
}
|
||||
*/
|
||||
t += dt;
|
||||
}
|
||||
} else {
|
||||
if (pos1.x > scissorBR.x) pos1.x = scissorBR.x;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Rasterizer {
|
||||
void DrawTriangle(const VertexData& v0, const VertexData& v1, const VertexData& v2);
|
||||
void DrawPoint(const VertexData &v0);
|
||||
void DrawLine(const VertexData &v0, const VertexData &v1);
|
||||
void DrawPSXSprite(const VertexData &v0, const VertexData &v1);
|
||||
void DrawSprite(const VertexData &v0, const VertexData &v1);
|
||||
void ClearRectangle(const VertexData &v0, const VertexData &v1);
|
||||
|
||||
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer);
|
||||
|
||||
Reference in new issue
Block a user