mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-26 04:12:34 +01:00
- [Psy-X] split draw batch for offscreen
This commit is contained in:
parent
33bf94c404
commit
31479d87a6
@ -78,7 +78,7 @@ void DrawDebugOverlays()
|
|||||||
gDebug_numLines = 0;
|
gDebug_numLines = 0;
|
||||||
|
|
||||||
DR_TPAGE* tp = (DR_TPAGE*)current->primptr;
|
DR_TPAGE* tp = (DR_TPAGE*)current->primptr;
|
||||||
setDrawTPage(tp, 0, 0, 0);
|
setDrawTPage(tp, 1, 1, 0);
|
||||||
addPrim(current->ot + 2, tp);
|
addPrim(current->ot + 2, tp);
|
||||||
current->primptr += sizeof(DR_TPAGE);
|
current->primptr += sizeof(DR_TPAGE);
|
||||||
|
|
||||||
|
@ -1444,13 +1444,19 @@ void Emulator_Perspective3D(const float fov, const float width, const float heig
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator_SetupClipMode(const RECT16& rect)
|
void Emulator_SetupClipMode(const RECT16& rect, int enable)
|
||||||
{
|
{
|
||||||
// [A] isinterlaced dirty hack for widescreen
|
// [A] isinterlaced dirty hack for widescreen
|
||||||
bool enabled = activeDispEnv.isinter || (rect.x - activeDispEnv.disp.x > 0 ||
|
bool scissorOn = enable && (activeDispEnv.isinter ||
|
||||||
|
(rect.x - activeDispEnv.disp.x > 0 ||
|
||||||
rect.y - activeDispEnv.disp.y > 0 ||
|
rect.y - activeDispEnv.disp.y > 0 ||
|
||||||
rect.w < activeDispEnv.disp.w - 1 ||
|
rect.w < activeDispEnv.disp.w - 1 ||
|
||||||
rect.h < activeDispEnv.disp.h - 1);
|
rect.h < activeDispEnv.disp.h - 1));
|
||||||
|
|
||||||
|
Emulator_SetScissorState(scissorOn);
|
||||||
|
|
||||||
|
if (!scissorOn)
|
||||||
|
return;
|
||||||
|
|
||||||
float psxScreenW = activeDispEnv.disp.w;
|
float psxScreenW = activeDispEnv.disp.w;
|
||||||
float psxScreenH = activeDispEnv.disp.h;
|
float psxScreenH = activeDispEnv.disp.h;
|
||||||
@ -1462,7 +1468,6 @@ void Emulator_SetupClipMode(const RECT16& rect)
|
|||||||
float clipRectH = (float)(rect.h) / psxScreenH;
|
float clipRectH = (float)(rect.h) / psxScreenH;
|
||||||
|
|
||||||
// then map to screen
|
// then map to screen
|
||||||
|
|
||||||
{
|
{
|
||||||
clipRectX -= 0.5f;
|
clipRectX -= 0.5f;
|
||||||
#ifdef USE_PGXP
|
#ifdef USE_PGXP
|
||||||
@ -1477,11 +1482,6 @@ void Emulator_SetupClipMode(const RECT16& rect)
|
|||||||
clipRectX += 0.5f;
|
clipRectX += 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator_SetScissorState(enabled);
|
|
||||||
|
|
||||||
if(!enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(RENDERER_OGL) || defined(OGLES)
|
#if defined(RENDERER_OGL) || defined(OGLES)
|
||||||
float flipOffset = g_windowHeight - clipRectH * (float)g_windowHeight;
|
float flipOffset = g_windowHeight - clipRectH * (float)g_windowHeight;
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ extern void Emulator_DestroyTexture(TextureID texture);
|
|||||||
extern void Emulator_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
|
extern void Emulator_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
|
||||||
extern void Emulator_SetViewPort(int x, int y, int width, int height);
|
extern void Emulator_SetViewPort(int x, int y, int width, int height);
|
||||||
extern void Emulator_SetTexture(TextureID texture, TexFormat texFormat);
|
extern void Emulator_SetTexture(TextureID texture, TexFormat texFormat);
|
||||||
extern void Emulator_SetupClipMode(const RECT16& rect);
|
extern void Emulator_SetupClipMode(const RECT16& rect, int enable);
|
||||||
extern void Emulator_SetWireframe(bool enable);
|
extern void Emulator_SetWireframe(bool enable);
|
||||||
extern void Emulator_UpdateVertexBuffer(const Vertex* vertices, int count);
|
extern void Emulator_UpdateVertexBuffer(const Vertex* vertices, int count);
|
||||||
extern void Emulator_DrawTriangles(int start_vertex, int triangles);
|
extern void Emulator_DrawTriangles(int start_vertex, int triangles);
|
||||||
|
@ -23,12 +23,14 @@ int g_GPUDisabledState = 0;
|
|||||||
|
|
||||||
struct VertexBufferSplit
|
struct VertexBufferSplit
|
||||||
{
|
{
|
||||||
TextureID textureId;
|
RECT16 clipRect;
|
||||||
unsigned short vIndex;
|
|
||||||
unsigned short vCount;
|
|
||||||
BlendMode blendMode;
|
BlendMode blendMode;
|
||||||
TexFormat texFormat;
|
TexFormat texFormat;
|
||||||
RECT16 clipRect;
|
TextureID textureId;
|
||||||
|
int flags;
|
||||||
|
u_short startVertex;
|
||||||
|
u_short numVerts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//#define DEBUG_POLY_COUNT
|
//#define DEBUG_POLY_COUNT
|
||||||
@ -351,14 +353,10 @@ DRAWENV* SetDefDrawEnv(DRAWENV* env, int x, int y, int w, int h)//(F)
|
|||||||
env->b0 = 0;
|
env->b0 = 0;
|
||||||
env->dtd = 1;
|
env->dtd = 1;
|
||||||
|
|
||||||
if (GetVideoMode() == 0)
|
if (GetVideoMode() == MODE_NTSC)
|
||||||
{
|
env->dfe = h < 289 ? 1 : 0;
|
||||||
env->dfe = h < 0x121 ? 1 : 0;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
env->dfe = h < 257 ? 1 : 0;
|
||||||
env->dfe = h < 0x101 ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
env->ofs[0] = x;
|
env->ofs[0] = x;
|
||||||
env->ofs[1] = y;
|
env->ofs[1] = y;
|
||||||
@ -436,20 +434,24 @@ void AddSplit(bool semiTrans, int page, TextureID textureId)
|
|||||||
BlendMode blendMode = semiTrans ? GET_TPAGE_BLEND(page) : BM_NONE;
|
BlendMode blendMode = semiTrans ? GET_TPAGE_BLEND(page) : BM_NONE;
|
||||||
TexFormat texFormat = GET_TPAGE_FORMAT(page);
|
TexFormat texFormat = GET_TPAGE_FORMAT(page);
|
||||||
|
|
||||||
|
int flags = (activeDrawEnv.dfe << 0);
|
||||||
|
|
||||||
RECT16& clipRect = activeDrawEnv.clip;
|
RECT16& clipRect = activeDrawEnv.clip;
|
||||||
|
|
||||||
|
// FIXME: compare drawing environment too?
|
||||||
if (curSplit.blendMode == blendMode &&
|
if (curSplit.blendMode == blendMode &&
|
||||||
curSplit.texFormat == texFormat &&
|
curSplit.texFormat == texFormat &&
|
||||||
curSplit.textureId == textureId &&
|
curSplit.textureId == textureId &&
|
||||||
curSplit.clipRect.x == clipRect.x &&
|
curSplit.clipRect.x == clipRect.x &&
|
||||||
curSplit.clipRect.y == clipRect.y &&
|
curSplit.clipRect.y == clipRect.y &&
|
||||||
curSplit.clipRect.w == clipRect.w &&
|
curSplit.clipRect.w == clipRect.w &&
|
||||||
curSplit.clipRect.h == clipRect.h)
|
curSplit.clipRect.h == clipRect.h &&
|
||||||
|
curSplit.flags != flags)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
curSplit.vCount = g_vertexIndex - curSplit.vIndex;
|
curSplit.numVerts = g_vertexIndex - curSplit.startVertex;
|
||||||
|
|
||||||
VertexBufferSplit& split = g_splits[++g_splitIndex];
|
VertexBufferSplit& split = g_splits[++g_splitIndex];
|
||||||
|
|
||||||
@ -460,9 +462,10 @@ void AddSplit(bool semiTrans, int page, TextureID textureId)
|
|||||||
split.clipRect.y = clipRect.y;
|
split.clipRect.y = clipRect.y;
|
||||||
split.clipRect.w = clipRect.w;
|
split.clipRect.w = clipRect.w;
|
||||||
split.clipRect.h = clipRect.h;
|
split.clipRect.h = clipRect.h;
|
||||||
|
split.flags = flags;
|
||||||
|
|
||||||
split.vIndex = g_vertexIndex;
|
split.startVertex = g_vertexIndex;
|
||||||
split.vCount = 0;
|
split.numVerts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangulateQuad()
|
void TriangulateQuad()
|
||||||
@ -488,10 +491,10 @@ void TriangulateQuad()
|
|||||||
|
|
||||||
void DrawSplit(const VertexBufferSplit& split)
|
void DrawSplit(const VertexBufferSplit& split)
|
||||||
{
|
{
|
||||||
Emulator_SetupClipMode(split.clipRect);
|
Emulator_SetupClipMode(split.clipRect, (split.flags & 0x1));
|
||||||
Emulator_SetTexture(split.textureId, split.texFormat);
|
Emulator_SetTexture(split.textureId, split.texFormat);
|
||||||
Emulator_SetBlendMode(split.blendMode);
|
Emulator_SetBlendMode(split.blendMode);
|
||||||
Emulator_DrawTriangles(split.vIndex, split.vCount / 3);
|
Emulator_DrawTriangles(split.startVertex, split.numVerts / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -555,7 +558,7 @@ void AggregatePTAGsToSplits(u_long* p, bool singlePrimitive)
|
|||||||
|
|
||||||
// single primitive
|
// single primitive
|
||||||
ParsePrimitive((uintptr_t)p);
|
ParsePrimitive((uintptr_t)p);
|
||||||
g_splits[g_splitIndex].vCount = g_vertexIndex - g_splits[g_splitIndex].vIndex;
|
g_splits[g_splitIndex].numVerts = g_vertexIndex - g_splits[g_splitIndex].startVertex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1232,6 +1235,8 @@ int ParsePrimitive(uintptr_t primPtr)
|
|||||||
activeDrawEnv.tpage = (code & 0x1FF);
|
activeDrawEnv.tpage = (code & 0x1FF);
|
||||||
activeDrawEnv.dtd = (code >> 9) & 1;
|
activeDrawEnv.dtd = (code >> 9) & 1;
|
||||||
activeDrawEnv.dfe = (code >> 10) & 1;
|
activeDrawEnv.dfe = (code >> 10) & 1;
|
||||||
|
if(!activeDrawEnv.dfe)
|
||||||
|
printf("drEnv.dfe is off\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xE2:
|
case 0xE2:
|
||||||
@ -1250,36 +1255,17 @@ int ParsePrimitive(uintptr_t primPtr)
|
|||||||
}
|
}
|
||||||
case 0xE4:
|
case 0xE4:
|
||||||
{
|
{
|
||||||
RECT16 emuScreen;
|
|
||||||
activeDrawEnv.clip.w = code & 1023;
|
activeDrawEnv.clip.w = code & 1023;
|
||||||
activeDrawEnv.clip.h = (code >> 10) & 1023;
|
activeDrawEnv.clip.h = (code >> 10) & 1023;
|
||||||
|
|
||||||
activeDrawEnv.clip.w -= activeDrawEnv.clip.x;
|
activeDrawEnv.clip.w -= activeDrawEnv.clip.x;
|
||||||
activeDrawEnv.clip.h -= activeDrawEnv.clip.y;
|
activeDrawEnv.clip.h -= activeDrawEnv.clip.y;
|
||||||
|
|
||||||
#if 0
|
|
||||||
Emulator_GetPSXWidescreenMappedViewport(&emuScreen);
|
|
||||||
|
|
||||||
// if new clip rectangle is outside the screen frame - we gonna render to FBO now
|
|
||||||
// [A] isinterlaced dirty hack for widescreen
|
|
||||||
int insideScreen = (activeDrawEnv.clip.x - activeDispEnv.disp.y >= emuScreen.x && activeDrawEnv.clip.x + activeDrawEnv.clip.w <= emuScreen.w,
|
|
||||||
activeDrawEnv.clip.y - activeDispEnv.disp.y >= emuScreen.y && activeDrawEnv.clip.y + activeDrawEnv.clip.h <= emuScreen.h);
|
|
||||||
|
|
||||||
if(insideScreen)
|
|
||||||
{
|
|
||||||
// switch back to main backbuffer
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eprintf("outside screen\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xE5:
|
case 0xE5:
|
||||||
{
|
{
|
||||||
activeDrawEnv.ofs[0] = code & 2047;//sign_x_to_s32(11, (*cb & 2047));
|
activeDrawEnv.ofs[0] = code & 2047;
|
||||||
activeDrawEnv.ofs[1] = (code >> 11) & 2047; //sign_x_to_s32(11, ((*cb >> 11) & 2047));
|
activeDrawEnv.ofs[1] = (code >> 11) & 2047;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1302,11 +1288,7 @@ int ParsePrimitive(uintptr_t primPtr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXTENDED_PRIM_POINTERS
|
return (pTag->len + P_LEN) * sizeof(long);
|
||||||
return (pTag->len + 2) * sizeof(long);
|
|
||||||
#else
|
|
||||||
return (pTag->len + 1) * sizeof(long);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ParseLinkedPrimitiveList(uintptr_t packetStart, uintptr_t packetEnd)
|
int ParseLinkedPrimitiveList(uintptr_t packetStart, uintptr_t packetEnd)
|
||||||
@ -1325,7 +1307,7 @@ int ParseLinkedPrimitiveList(uintptr_t packetStart, uintptr_t packetEnd)
|
|||||||
currentAddress += lastSize;
|
currentAddress += lastSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_splits[g_splitIndex].vCount = g_vertexIndex - g_splits[g_splitIndex].vIndex;
|
g_splits[g_splitIndex].numVerts = g_vertexIndex - g_splits[g_splitIndex].startVertex;
|
||||||
|
|
||||||
return lastSize;
|
return lastSize;
|
||||||
}
|
}
|
||||||
|
@ -645,6 +645,7 @@ typedef struct {
|
|||||||
u_short tpage; /* texture page */
|
u_short tpage; /* texture page */
|
||||||
u_char dtd; /* dither flag (0:off, 1:on) */
|
u_char dtd; /* dither flag (0:off, 1:on) */
|
||||||
u_char dfe; /* flag to draw on display area (0:off 1:on) */
|
u_char dfe; /* flag to draw on display area (0:off 1:on) */
|
||||||
|
u_char drt;
|
||||||
u_char isbg; /* enable to auto-clear */
|
u_char isbg; /* enable to auto-clear */
|
||||||
u_char r0, g0, b0; /* initital background color */
|
u_char r0, g0, b0; /* initital background color */
|
||||||
DR_ENV dr_env; /* reserved */
|
DR_ENV dr_env; /* reserved */
|
||||||
|
@ -688,7 +688,7 @@ int FMV_main(RENDER_ARGS* args)
|
|||||||
PutDrawEnv(&draw);
|
PutDrawEnv(&draw);
|
||||||
PutDispEnv(&disp);
|
PutDispEnv(&disp);
|
||||||
|
|
||||||
Emulator_SetupClipMode(draw.clip);
|
Emulator_SetupClipMode(draw.clip, draw.dfe);
|
||||||
|
|
||||||
for (int i = 0; i < args->nRenders; i++)
|
for (int i = 0; i < args->nRenders; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user