Clean up more space/tab mismatches in AudioCommon, Common, and VideoCommon.

Not planning to touch Core since it's the most actively changed part of the project.
This commit is contained in:
lioncash 2013-03-19 21:51:12 -04:00
commit edd9d0e0ef
91 changed files with 2151 additions and 2169 deletions

File diff suppressed because it is too large Load diff

View file

@ -25,18 +25,18 @@ enum
{
ARRAY_POSITION = 0,
ARRAY_NORMAL = 1,
ARRAY_COLOR = 2,
ARRAY_COLOR2 = 3,
ARRAY_TEXCOORD0 = 4,
ARRAY_COLOR = 2,
ARRAY_COLOR2 = 3,
ARRAY_TEXCOORD0 = 4,
};
// Vertex components
enum
{
NOT_PRESENT = 0,
DIRECT = 1,
INDEX8 = 2,
INDEX16 = 3,
DIRECT = 1,
INDEX8 = 2,
INDEX16 = 3,
};
enum
@ -74,14 +74,14 @@ union TVtxDesc
// 0: not present
// 1: present
u32 PosMatIdx : 1;
u32 Tex0MatIdx : 1;
u32 Tex1MatIdx : 1;
u32 Tex2MatIdx : 1;
u32 Tex3MatIdx : 1;
u32 Tex4MatIdx : 1;
u32 Tex5MatIdx : 1;
u32 Tex6MatIdx : 1;
u32 Tex7MatIdx : 1;
u32 Tex0MatIdx : 1;
u32 Tex1MatIdx : 1;
u32 Tex2MatIdx : 1;
u32 Tex3MatIdx : 1;
u32 Tex4MatIdx : 1;
u32 Tex5MatIdx : 1;
u32 Tex6MatIdx : 1;
u32 Tex7MatIdx : 1;
// 00: not present
// 01: direct
@ -89,156 +89,156 @@ union TVtxDesc
// 11: 16 bit index
u32 Position : 2;
u32 Normal : 2;
u32 Color0 : 2;
u32 Color1 : 2;
u32 Tex0Coord : 2;
u32 Tex1Coord : 2;
u32 Tex2Coord : 2;
u32 Tex3Coord : 2;
u32 Tex4Coord : 2;
u32 Tex5Coord : 2;
u32 Tex6Coord : 2;
u32 Tex7Coord : 2;
u32 Color0 : 2;
u32 Color1 : 2;
u32 Tex0Coord : 2;
u32 Tex1Coord : 2;
u32 Tex2Coord : 2;
u32 Tex3Coord : 2;
u32 Tex4Coord : 2;
u32 Tex5Coord : 2;
u32 Tex6Coord : 2;
u32 Tex7Coord : 2;
u32 :31;
};
struct {
u32 Hex0, Hex1;
};
struct {
u32 Hex0, Hex1;
};
};
union UVAT_group0
{
u32 Hex;
struct
{
// 0:8
u32 PosElements : 1;
u32 PosFormat : 3;
u32 PosFrac : 5;
// 9:12
u32 NormalElements : 1;
u32 NormalFormat : 3;
// 13:16
u32 Color0Elements : 1;
u32 Color0Comp : 3;
// 17:20
u32 Color1Elements : 1;
u32 Color1Comp : 3;
// 21:29
u32 Tex0CoordElements : 1;
u32 Tex0CoordFormat : 3;
u32 Tex0Frac : 5;
// 30:31
u32 ByteDequant : 1;
u32 NormalIndex3 : 1;
};
u32 Hex;
struct
{
// 0:8
u32 PosElements : 1;
u32 PosFormat : 3;
u32 PosFrac : 5;
// 9:12
u32 NormalElements : 1;
u32 NormalFormat : 3;
// 13:16
u32 Color0Elements : 1;
u32 Color0Comp : 3;
// 17:20
u32 Color1Elements : 1;
u32 Color1Comp : 3;
// 21:29
u32 Tex0CoordElements : 1;
u32 Tex0CoordFormat : 3;
u32 Tex0Frac : 5;
// 30:31
u32 ByteDequant : 1;
u32 NormalIndex3 : 1;
};
};
union UVAT_group1
{
u32 Hex;
struct
{
// 0:8
u32 Tex1CoordElements : 1;
u32 Tex1CoordFormat : 3;
u32 Tex1Frac : 5;
// 9:17
u32 Tex2CoordElements : 1;
u32 Tex2CoordFormat : 3;
u32 Tex2Frac : 5;
// 18:26
u32 Tex3CoordElements : 1;
u32 Tex3CoordFormat : 3;
u32 Tex3Frac : 5;
// 27:30
u32 Tex4CoordElements : 1;
u32 Tex4CoordFormat : 3;
//
u32 : 1;
};
u32 Hex;
struct
{
// 0:8
u32 Tex1CoordElements : 1;
u32 Tex1CoordFormat : 3;
u32 Tex1Frac : 5;
// 9:17
u32 Tex2CoordElements : 1;
u32 Tex2CoordFormat : 3;
u32 Tex2Frac : 5;
// 18:26
u32 Tex3CoordElements : 1;
u32 Tex3CoordFormat : 3;
u32 Tex3Frac : 5;
// 27:30
u32 Tex4CoordElements : 1;
u32 Tex4CoordFormat : 3;
//
u32 : 1;
};
};
union UVAT_group2
{
u32 Hex;
struct
{
// 0:4
u32 Tex4Frac : 5;
// 5:13
u32 Tex5CoordElements : 1;
u32 Tex5CoordFormat : 3;
u32 Tex5Frac : 5;
// 14:22
u32 Tex6CoordElements : 1;
u32 Tex6CoordFormat : 3;
u32 Tex6Frac : 5;
// 23:31
u32 Tex7CoordElements : 1;
u32 Tex7CoordFormat : 3;
u32 Tex7Frac : 5;
};
u32 Hex;
struct
{
// 0:4
u32 Tex4Frac : 5;
// 5:13
u32 Tex5CoordElements : 1;
u32 Tex5CoordFormat : 3;
u32 Tex5Frac : 5;
// 14:22
u32 Tex6CoordElements : 1;
u32 Tex6CoordFormat : 3;
u32 Tex6Frac : 5;
// 23:31
u32 Tex7CoordElements : 1;
u32 Tex7CoordFormat : 3;
u32 Tex7Frac : 5;
};
};
struct ColorAttr
{
u8 Elements;
u8 Comp;
u8 Elements;
u8 Comp;
};
struct TexAttr
{
u8 Elements;
u8 Format;
u8 Frac;
u8 Elements;
u8 Format;
u8 Frac;
};
struct TVtxAttr
{
u8 PosElements;
u8 PosFormat;
u8 PosFrac;
u8 NormalElements;
u8 NormalFormat;
ColorAttr color[2];
TexAttr texCoord[8];
u8 ByteDequant;
u8 NormalIndex3;
{
u8 PosElements;
u8 PosFormat;
u8 PosFrac;
u8 NormalElements;
u8 NormalFormat;
ColorAttr color[2];
TexAttr texCoord[8];
u8 ByteDequant;
u8 NormalIndex3;
};
// Matrix indices
union TMatrixIndexA
{
struct
{
u32 PosNormalMtxIdx : 6;
u32 Tex0MtxIdx : 6;
u32 Tex1MtxIdx : 6;
u32 Tex2MtxIdx : 6;
u32 Tex3MtxIdx : 6;
};
struct
{
u32 Hex : 30;
u32 unused : 2;
};
struct
{
u32 PosNormalMtxIdx : 6;
u32 Tex0MtxIdx : 6;
u32 Tex1MtxIdx : 6;
u32 Tex2MtxIdx : 6;
u32 Tex3MtxIdx : 6;
};
struct
{
u32 Hex : 30;
u32 unused : 2;
};
};
union TMatrixIndexB
{
struct
{
u32 Tex4MtxIdx : 6;
u32 Tex5MtxIdx : 6;
u32 Tex6MtxIdx : 6;
u32 Tex7MtxIdx : 6;
};
struct
{
u32 Hex : 24;
u32 unused : 8;
};
struct
{
u32 Tex4MtxIdx : 6;
u32 Tex5MtxIdx : 6;
u32 Tex6MtxIdx : 6;
u32 Tex7MtxIdx : 6;
};
struct
{
u32 Hex : 24;
u32 unused : 8;
};
};
#pragma pack()

View file

@ -325,7 +325,7 @@ void Write16(const u16 _Value, const u32 _Address)
case CLEAR_REGISTER:
{
UCPClearReg tmpCtrl(_Value);
m_CPClearReg.Hex = tmpCtrl.Hex;
m_CPClearReg.Hex = tmpCtrl.Hex;
DEBUG_LOG(COMMANDPROCESSOR,"\t write to CLEAR_REGISTER : %04x", _Value);
SetCpClearRegister();
}
@ -414,7 +414,7 @@ void Write16(const u16 _Value, const u32 _Address)
}
else
{
ResetVideoBuffer();
ResetVideoBuffer();
}
IncrementCheckContextId();
DEBUG_LOG(COMMANDPROCESSOR,"try to write to FIFO_RW_DISTANCE_HI : %04x", _Value);
@ -462,7 +462,6 @@ void STACKALIGN GatherPipeBursted()
ProcessFifoAllDistance();
waitingForPEInterruptDisable = false;
}
}
return;
}
@ -492,11 +491,11 @@ void STACKALIGN GatherPipeBursted()
void UpdateInterrupts(u64 userdata)
{
if (userdata)
if (userdata)
{
interruptSet = true;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
}
else
{
@ -504,7 +503,7 @@ void UpdateInterrupts(u64 userdata)
INFO_LOG(COMMANDPROCESSOR,"Interrupt cleared");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false);
}
interruptWaiting = false;
interruptWaiting = false;
}
void UpdateInterruptsFromVideoBackend(u64 userdata)
@ -520,11 +519,11 @@ void AbortFrame()
void SetCpStatus(bool isCPUThread)
{
// overflow & underflow check
// overflow & underflow check
fifo.bFF_HiWatermark = (fifo.CPReadWriteDistance > fifo.CPHiWatermark);
fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark);
fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark);
// breakpoint
// breakpoint
if (!isCPUThread)
{
if (fifo.bFF_BPEnable)
@ -562,12 +561,12 @@ void SetCpStatus(bool isCPUThread)
isHiWatermarkActive = ovfInt && m_CPCtrlReg.GPReadEnable;
isLoWatermarkActive = undfInt && m_CPCtrlReg.GPReadEnable;
if (interrupt != interruptSet && !interruptWaiting)
{
u64 userdata = interrupt?1:0;
if (IsOnThread())
{
if (!interrupt || bpInt || undfInt || ovfInt)
if (interrupt != interruptSet && !interruptWaiting)
{
u64 userdata = interrupt?1:0;
if (IsOnThread())
{
if (!interrupt || bpInt || undfInt || ovfInt)
{
if (!isCPUThread)
{
@ -579,14 +578,14 @@ void SetCpStatus(bool isCPUThread)
{
// CPU thread:
interruptSet = interrupt;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);
}
}
}
else
CommandProcessor::UpdateInterrupts(userdata);
}
}
else
CommandProcessor::UpdateInterrupts(userdata);
}
}
void ProcessFifoToLoWatermark()

View file

@ -80,7 +80,7 @@ void FreeLookInput( UINT iMsg, WPARAM wParam )
static bool mouseLookEnabled = false;
static bool mouseMoveEnabled = false;
static float lastMouse[2];
POINT point;
POINT point;
switch(iMsg)
{
case WM_USER_KEYDOWN:
@ -133,7 +133,7 @@ void FreeLookInput( UINT iMsg, WPARAM wParam )
lastMouse[1] = (float)point.y;
mouseLookEnabled= true;
break;
case WM_MBUTTONDOWN:
case WM_MBUTTONDOWN:
GetCursorPos(&point);
lastMouse[0] = (float)point.x;
lastMouse[1] = (float)point.y;

View file

@ -43,10 +43,10 @@ static int size = 0;
void Fifo_DoState(PointerWrap &p)
{
p.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size);
p.DoPointer(g_pVideoData, videoBuffer);
p.Do(g_bSkipCurrentFrame);
p.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size);
p.DoPointer(g_pVideoData, videoBuffer);
p.Do(g_bSkipCurrentFrame);
}
void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)
@ -69,8 +69,8 @@ void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)
void Fifo_Init()
{
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
{
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
size = 0;
GpuRunningState = false;
Common::AtomicStore(CommandProcessor::VITicks, CommandProcessor::m_cpClockOrigin);
@ -79,12 +79,12 @@ void Fifo_Init()
void Fifo_Shutdown()
{
if (GpuRunningState) PanicAlert("Fifo shutting down while active");
FreeMemoryPages(videoBuffer, FIFO_SIZE);
FreeMemoryPages(videoBuffer, FIFO_SIZE);
}
u8* GetVideoBufferStartPtr()
{
return videoBuffer;
return videoBuffer;
}
u8* GetVideoBufferEndPtr()
@ -119,20 +119,20 @@ void EmulatorState(bool running)
// Description: RunGpuLoop() sends data through this function.
void ReadDataFromFifo(u8* _uData, u32 len)
{
if (size + len >= FIFO_SIZE)
{
if (size + len >= FIFO_SIZE)
{
int pos = (int)(g_pVideoData - videoBuffer);
size -= pos;
if (size + len > FIFO_SIZE)
{
PanicAlert("FIFO out of bounds (sz = %i, len = %i at %08x)", size, len, pos);
}
memmove(&videoBuffer[0], &videoBuffer[pos], size);
if (size + len > FIFO_SIZE)
{
PanicAlert("FIFO out of bounds (sz = %i, len = %i at %08x)", size, len, pos);
}
memmove(&videoBuffer[0], &videoBuffer[pos], size);
g_pVideoData = videoBuffer;
}
}
// Copy new video instructions to videoBuffer for future use in rendering the new picture
memcpy(videoBuffer + size, _uData, len);
size += len;
memcpy(videoBuffer + size, _uData, len);
size += len;
}
void ResetVideoBuffer()
@ -153,7 +153,7 @@ void RunGpuLoop()
while (GpuRunningState)
{
g_video_backend->PeekMessages();
g_video_backend->PeekMessages();
VideoFifo_CheckAsyncRequest();
@ -240,7 +240,7 @@ void RunGpu()
while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance && !AtBreakpoint() )
{
u8 *uData = Memory::GetPointer(fifo.CPReadPointer);
FPURoundMode::SaveSIMDState();
FPURoundMode::LoadDefaultSIMDState();
ReadDataFromFifo(uData, 32);

View file

@ -60,12 +60,12 @@ const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr
m_realXFBSource->texHeight = fbHeight;
// TODO: stuff only used by OGL... :/
// OpenGL texture coordinates originate at the lower left, which is why
// sourceRc.top = fbHeight and sourceRc.bottom = 0.
m_realXFBSource->sourceRc.left = 0;
m_realXFBSource->sourceRc.top = fbHeight;
m_realXFBSource->sourceRc.right = fbWidth;
m_realXFBSource->sourceRc.bottom = 0;
// OpenGL texture coordinates originate at the lower left, which is why
// sourceRc.top = fbHeight and sourceRc.bottom = 0.
m_realXFBSource->sourceRc.left = 0;
m_realXFBSource->sourceRc.top = fbHeight;
m_realXFBSource->sourceRc.right = fbWidth;
m_realXFBSource->sourceRc.bottom = 0;
// Decode YUYV data from GameCube RAM
m_realXFBSource->DecodeToTexture(xfbAddr, fbWidth, fbHeight);

View file

@ -23,7 +23,7 @@
namespace DLCache
{
void Init()
{
}
@ -33,7 +33,7 @@ void Shutdown()
}
void Clear()
{
{
}
void ProgressiveCleanup()

View file

@ -480,7 +480,7 @@ inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
dst[0] = ((src[0] & 0xFF) << 24) | ((src[0] & 0xFF00)>>8) | (src2[0] << 8);
@ -519,7 +519,7 @@ void decodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
{
int blue3 = ((blue2 - blue1) >> 1) - ((blue2 - blue1) >> 3);
int green3 = ((green2 - green1) >> 1) - ((green2 - green1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
colors[2] = makecol(red1 + red3, green1 + green3, blue1 + blue3, 255);
colors[3] = makecol(red2 - red3, green2 - green3, blue2 - blue3, 255);
}
@ -562,7 +562,7 @@ void decodeDXTBlockRGBA(u32 *dst, const DXTBlock *src, int pitch)
{
int blue3 = ((blue2 - blue1) >> 1) - ((blue2 - blue1) >> 3);
int green3 = ((green2 - green1) >> 1) - ((green2 - green1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
colors[2] = makeRGBA(red1 + red3, green1 + green3, blue1 + blue3, 255);
colors[3] = makeRGBA(red2 - red3, green2 - green3, blue2 - blue3, 255);
}
@ -664,22 +664,22 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = yStep * 8; iy < 8; iy++, xStep++)
decodebytesC4_5A3_To_BGRA32((u32*)dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
decodebytesC4_5A3_To_BGRA32((u32*)dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
else
{
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = yStep * 8; iy < 8; iy++, xStep++)
decodebytesC4_To_Raw16((u16*)dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
decodebytesC4_To_Raw16((u16*)dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
return GetPCFormatFromTLUTFormat(tlutfmt);
case GX_TF_I4:
{
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = yStep * 8 ; iy < 8; iy++,xStep++)
for (int ix = 0; ix < 4; ix++)
@ -692,19 +692,17 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return PC_TEX_FMT_I4_AS_I8;
case GX_TF_I8: // speed critical
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
{
((u64*)(dst + (y + iy) * width + x))[0] = ((u64*)(src + 8 * xStep))[0];
}
}
return PC_TEX_FMT_I8;
case GX_TF_C8:
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_5A3_To_BGRA32((u32*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
@ -713,7 +711,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
{
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_To_Raw16((u16*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
@ -722,7 +720,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return GetPCFormatFromTLUTFormat(tlutfmt);
case GX_TF_IA4:
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesIA4((u16*)dst + (y + iy) * width + x, src + 8 * xStep);
@ -730,7 +728,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return PC_TEX_FMT_IA4_AS_IA8;
case GX_TF_IA8:
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = yStep * 4; iy < 4; iy++, xStep++)
{
@ -739,21 +737,20 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
for(int j = 0; j < 4; j++)
*ptr++ = Common::swap16(*s++);
}
}
return PC_TEX_FMT_IA8;
case GX_TF_C14X2:
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2_5A3_To_BGRA32((u32*)dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
}
else
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2_To_Raw16((u16*)dst + (y + iy) * width + x,(u16*)(src + 8 * xStep), tlutaddr);
@ -761,7 +758,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return GetPCFormatFromTLUTFormat(tlutfmt);
case GX_TF_RGB565:
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
{
@ -774,7 +771,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return PC_TEX_FMT_RGB565;
case GX_TF_RGB5A3:
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
//decodebytesRGB5A3((u32*)dst+(y+iy)*width+x, (u16*)src, 4);
@ -783,15 +780,14 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
return PC_TEX_FMT_BGRA32;
case GX_TF_RGBA8: // speed critical
{
for (int y = 0; y < height; y += 4)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
{
const u8* src2 = src + 64 * yStep;
for (int iy = 0; iy < 4; iy++)
decodebytesARGB8_4((u32*)dst + (y+iy)*width + x, (u16*)src2 + 4 * iy, (u16*)src2 + 4 * iy + 16);
}
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
{
const u8* src2 = src + 64 * yStep;
for (int iy = 0; iy < 4; iy++)
decodebytesARGB8_4((u32*)dst + (y+iy)*width + x, (u16*)src2 + 4 * iy, (u16*)src2 + 4 * iy + 16);
}
}
}
return PC_TEX_FMT_BGRA32;
@ -817,7 +813,7 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh
}
return PC_TEX_FMT_DXT1;
#else
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
{
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8, yStep++)
{
@ -862,22 +858,21 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8,yStep++)
for (int iy = 0, xStep = 8 * yStep; iy < 8; iy++,xStep++)
decodebytesC4_5A3_To_rgba32(dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
else if(tlutfmt == 0)
{
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8,yStep++)
for (int iy = 0, xStep = 8 * yStep; iy < 8; iy++,xStep++)
decodebytesC4IA8_To_RGBA(dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
}
else
{
for (int y = 0; y < height; y += 8)
for (int y = 0; y < height; y += 8)
for (int x = 0, yStep = (y / 8) * Wsteps8; x < width; x += 8,yStep++)
for (int iy = 0, xStep = 8 * yStep; iy < 8; iy++,xStep++)
decodebytesC4RGB565_To_RGBA(dst + (y + iy) * width + x, src + 4 * xStep, tlutaddr);
@ -925,34 +920,33 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_5A3_To_RGBA32((u32*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
}
else if(tlutfmt == 0)
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8IA8_To_RGBA(dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8IA8_To_RGBA(dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
}
else
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8RGB565_To_RGBA(dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8RGB565_To_RGBA(dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
}
break;
case GX_TF_IA4:
{
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesIA4RGBA(dst + (y + iy) * width + x, src + 8 * xStep);
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesIA4RGBA(dst + (y + iy) * width + x, src + 8 * xStep);
}
break;
case GX_TF_IA8:
@ -975,21 +969,21 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he
if (tlutfmt == 2)
{
// Special decoding is required for TLUT format 5A3
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2_5A3_To_BGRA32(dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
}
else if (tlutfmt == 0)
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2IA8_To_RGBA(dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
}
else
{
for (int y = 0; y < height; y += 4)
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps4; x < width; x += 4, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC14X2rgb565_To_RGBA(dst + (y + iy) * width + x, (u16*)(src + 8 * xStep), tlutaddr);
@ -1130,7 +1124,7 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in
dtp[(y + yoff)*width + x + xoff] = ptr[x] ? 0xFFFF : 0x0000;
break;
}
default:
default:
case PC_TEX_FMT_BGRA32:
{
int *dtp = (int*)dst;
@ -1160,7 +1154,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u32 base = (tBlk * widthBlks + sBlk) * blockWidth * blockHeight;
u16 blkS = s & (blockWidth - 1);
u16 blkT = t & (blockHeight - 1);
u32 blkOff = blkT * blockWidth + blkS;
u32 blkOff = blkT * blockWidth + blkS;
*/
switch (texformat)
@ -1174,9 +1168,9 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 7;
u32 blkOff = (blkT << 3) + blkS;
int rs = (blkOff & 1)?0:4;
u32 offset = base + (blkOff >> 1);
u32 offset = base + (blkOff >> 1);
u8 val = (*(src + offset) >> rs) & 0xF;
u16 *tlut = (u16*)(texMem + tlutaddr);
@ -1186,7 +1180,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -1204,9 +1198,9 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 7;
u32 blkOff = (blkT << 3) + blkS;
int rs = (blkOff & 1)?0:4;
u32 offset = base + (blkOff >> 1);
u32 offset = base + (blkOff >> 1);
u8 val = (*(src + offset) >> rs) & 0xF;
val = Convert4To8(val);
@ -1225,7 +1219,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
dst[0] = val;
dst[1] = val;
@ -1242,7 +1236,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
u16 *tlut = (u16*)(texMem + tlutaddr);
@ -1251,7 +1245,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -1269,7 +1263,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
const u8 a = Convert4To8(val>>4);
const u8 l = Convert4To8(val&0xF);
@ -1288,7 +1282,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -1304,7 +1298,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -1316,7 +1310,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -1334,7 +1328,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -1392,7 +1386,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u32 offset = (base + blkOff) << 3;
const DXTBlock* dxtBlock = (const DXTBlock*)(src + offset);
u16 c1 = Common::swap16(dxtBlock->color1);
u16 c2 = Common::swap16(dxtBlock->color2);
int blue1 = Convert5To8(c1 & 0x1F);
@ -1411,7 +1405,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
colorSel |= c1 > c2?0:4;
u32 color = 0;
switch (colorSel)
{
case 0:

View file

@ -25,22 +25,22 @@
struct TGA_HEADER
{
u8 identsize; // size of ID field that follows 18 u8 header (0 usually)
u8 colourmaptype; // type of colour map 0=none, 1=has palette
u8 imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
u8 identsize; // size of ID field that follows 18 u8 header (0 usually)
u8 colourmaptype; // type of colour map 0=none, 1=has palette
u8 imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
s16 colourmapstart; // first colour map entry in palette
s16 colourmaplength; // number of colours in palette
u8 colourmapbits; // number of bits per palette entry 15,16,24,32
s16 colourmapstart; // first colour map entry in palette
s16 colourmaplength; // number of colours in palette
u8 colourmapbits; // number of bits per palette entry 15,16,24,32
s16 xstart; // image x origin
s16 ystart; // image y origin
s16 width; // image width in pixels
s16 height; // image height in pixels
u8 bits; // image bits per pixel 8,16,24,32
u8 descriptor; // image descriptor bits (vh flip bits)
// pixel data follows header
s16 xstart; // image x origin
s16 ystart; // image y origin
s16 width; // image width in pixels
s16 height; // image height in pixels
u8 bits; // image bits per pixel 8,16,24,32
u8 descriptor; // image descriptor bits (vh flip bits)
// pixel data follows header
};
#pragma pack(pop)
@ -53,7 +53,7 @@ bool SaveTGA(const char* filename, int width, int height, void* pdata)
return false;
_assert_(sizeof(TGA_HEADER) == 18 && sizeof(hdr) == 18);
memset(&hdr, 0, sizeof(hdr));
hdr.imagetype = 2;
hdr.bits = 32;

View file

@ -63,7 +63,7 @@ void IndexGenerator::AddIndices(int primitive, u32 numVerts)
//case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVerts); break;
//case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVerts); break;
//case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVerts); break;
//case GX_DRAW_LINES: IndexGenerator::AddLineList(numVerts); break;
//case GX_DRAW_LINES: IndexGenerator::AddLineList(numVerts); break;
//case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVerts); break;
//case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVerts); break;
//}

View file

@ -27,17 +27,17 @@ class IndexGenerator
public:
// Init
static void Start(u16 *Triangleptr,u16 *Lineptr,u16 *Pointptr);
static void AddIndices(int primitive, u32 numVertices);
// Interface
static u32 GetNumTriangles() {return numT;}
static u32 GetNumLines() {return numL;}
static u32 GetNumPoints() {return numP;}
// returns numprimitives
static u32 GetNumVerts() {return index;}
static u32 GetTriangleindexLen() {return (u32)(Tptr - BASETptr);}
static u32 GetLineindexLen() {return (u32)(Lptr - BASELptr);}
static u32 GetPointindexLen() {return (u32)(Pptr - BASEPptr);}
@ -56,16 +56,16 @@ private:
static void AddStrip(u32 numVerts);
static void AddFan(u32 numVerts);
static void AddQuads(u32 numVerts);
// Lines
static void AddLineList(u32 numVerts);
static void AddLineStrip(u32 numVerts);
// Points
static void AddPoints(u32 numVerts);
static void WriteTriangle(u32 index1, u32 index2, u32 index3);
static u16 *Tptr;
static u16 *BASETptr;
static u16 *Lptr;

View file

@ -123,7 +123,7 @@ void InterpretDisplayList(u32 address, u32 size)
Statistics::SwapDL();
}
// reset to the old pointer
// reset to the old pointer
g_pVideoData = old_pVideoData;
}
@ -140,14 +140,14 @@ u32 FifoCommandRunnable(u32 &command_size)
{
u32 cycleTime = 0;
u32 buffer_size = (u32)(GetVideoBufferEndPtr() - g_pVideoData);
if (buffer_size == 0)
if (buffer_size == 0)
return 0; // can't peek
u8 cmd_byte = DataPeek8(0);
switch (cmd_byte)
{
case GX_NOP: // Hm, this means that we scan over nop streams pretty slowly...
switch (cmd_byte)
{
case GX_NOP: // Hm, this means that we scan over nop streams pretty slowly...
command_size = 1;
cycleTime = 6;
break;
@ -155,30 +155,30 @@ u32 FifoCommandRunnable(u32 &command_size)
command_size = 1;
cycleTime = 6;
break;
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
command_size = 1;
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
command_size = 1;
cycleTime = 6;
break;
break;
case GX_LOAD_BP_REG:
command_size = 5;
case GX_LOAD_BP_REG:
command_size = 5;
cycleTime = 12;
break;
break;
case GX_LOAD_CP_REG:
command_size = 6;
case GX_LOAD_CP_REG:
command_size = 6;
cycleTime = 12;
break;
break;
case GX_LOAD_INDX_A:
case GX_LOAD_INDX_B:
case GX_LOAD_INDX_C:
case GX_LOAD_INDX_D:
command_size = 5;
case GX_LOAD_INDX_A:
case GX_LOAD_INDX_B:
case GX_LOAD_INDX_C:
case GX_LOAD_INDX_D:
command_size = 5;
cycleTime = 6; // TODO
break;
break;
case GX_CMD_CALL_DL:
case GX_CMD_CALL_DL:
{
// FIXME: Calculate the cycle time of the display list.
//u32 address = DataPeek32(1);
@ -208,42 +208,42 @@ u32 FifoCommandRunnable(u32 &command_size)
command_size = 9;
cycleTime = 45; // This is unverified
}
break;
break;
case GX_LOAD_XF_REG:
{
// check if we can read the header
if (buffer_size >= 5)
{
command_size = 1 + 4;
u32 Cmd2 = DataPeek32(1);
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
command_size += transfer_size * 4;
case GX_LOAD_XF_REG:
{
// check if we can read the header
if (buffer_size >= 5)
{
command_size = 1 + 4;
u32 Cmd2 = DataPeek32(1);
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
command_size += transfer_size * 4;
cycleTime = 18 + 6 * transfer_size;
}
else
}
else
{
return 0;
}
}
break;
return 0;
}
}
break;
default:
if (cmd_byte & 0x80)
{
// check if we can read the header
if (buffer_size >= 3)
default:
if (cmd_byte & 0x80)
{
// check if we can read the header
if (buffer_size >= 3)
{
command_size = 1 + 2;
u16 numVertices = DataPeek16(1);
command_size = 1 + 2;
u16 numVertices = DataPeek16(1);
command_size += numVertices * VertexLoaderManager::GetVertexSize(cmd_byte & GX_VAT_MASK);
cycleTime = 1600; // This depends on the number of pixels rendered
}
}
else
{
return 0;
}
}
{
return 0;
}
}
else
{
// TODO(Omega): Maybe dump FIFO to file on this error
@ -258,7 +258,7 @@ u32 FifoCommandRunnable(u32 &command_size)
Host_SysMessage(szTemp);
INFO_LOG(VIDEO, "%s", szTemp);
{
SCPFifoStruct &fifo = CommandProcessor::fifo;
SCPFifoStruct &fifo = CommandProcessor::fifo;
char szTmp[512];
// sprintf(szTmp, "Illegal command %02x (at %08x)",cmd_byte,g_pDataReader->GetPtr());
@ -283,18 +283,18 @@ u32 FifoCommandRunnable(u32 &command_size)
Host_SysMessage(szTmp);
INFO_LOG(VIDEO, "%s", szTmp);
}
}
break;
}
if (command_size > buffer_size)
return 0;
}
break;
}
// INFO_LOG("OP detected: cmd_byte 0x%x size %i buffer %i",cmd_byte, command_size, buffer_size);
if (command_size > buffer_size)
return 0;
// INFO_LOG("OP detected: cmd_byte 0x%x size %i buffer %i",cmd_byte, command_size, buffer_size);
if (cycleTime == 0)
cycleTime = 6;
return cycleTime;
return cycleTime;
}
u32 FifoCommandRunnable()
@ -305,92 +305,92 @@ u32 FifoCommandRunnable()
static void Decode()
{
u8 *opcodeStart = g_pVideoData;
u8 *opcodeStart = g_pVideoData;
int cmd_byte = DataReadU8();
switch (cmd_byte)
{
case GX_NOP:
break;
int cmd_byte = DataReadU8();
switch (cmd_byte)
{
case GX_NOP:
break;
case GX_LOAD_CP_REG: //0x08
{
u8 sub_cmd = DataReadU8();
u32 value = DataReadU32();
LoadCPReg(sub_cmd, value);
case GX_LOAD_CP_REG: //0x08
{
u8 sub_cmd = DataReadU8();
u32 value = DataReadU32();
LoadCPReg(sub_cmd, value);
INCSTAT(stats.thisFrame.numCPLoads);
}
break;
}
break;
case GX_LOAD_XF_REG:
{
u32 Cmd2 = DataReadU32();
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
case GX_LOAD_XF_REG:
{
u32 Cmd2 = DataReadU32();
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
u32 xf_address = Cmd2 & 0xFFFF;
GC_ALIGNED128(u32 data_buffer[16]);
DataReadU32xFuncs[transfer_size-1](data_buffer);
LoadXFReg(transfer_size, xf_address, data_buffer);
LoadXFReg(transfer_size, xf_address, data_buffer);
INCSTAT(stats.thisFrame.numXFLoads);
}
break;
}
break;
case GX_LOAD_INDX_A: //used for position matrices
LoadIndexedXF(DataReadU32(), 0xC);
break;
case GX_LOAD_INDX_B: //used for normal matrices
LoadIndexedXF(DataReadU32(), 0xD);
break;
case GX_LOAD_INDX_C: //used for postmatrices
LoadIndexedXF(DataReadU32(), 0xE);
break;
case GX_LOAD_INDX_D: //used for lights
LoadIndexedXF(DataReadU32(), 0xF);
break;
case GX_LOAD_INDX_A: //used for position matrices
LoadIndexedXF(DataReadU32(), 0xC);
break;
case GX_LOAD_INDX_B: //used for normal matrices
LoadIndexedXF(DataReadU32(), 0xD);
break;
case GX_LOAD_INDX_C: //used for postmatrices
LoadIndexedXF(DataReadU32(), 0xE);
break;
case GX_LOAD_INDX_D: //used for lights
LoadIndexedXF(DataReadU32(), 0xF);
break;
case GX_CMD_CALL_DL:
{
u32 address = DataReadU32();
u32 count = DataReadU32();
ExecuteDisplayList(address, count);
}
break;
case GX_CMD_CALL_DL:
{
u32 address = DataReadU32();
u32 count = DataReadU32();
ExecuteDisplayList(address, count);
}
break;
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
DEBUG_LOG(VIDEO, "GX 0x44: %08x", cmd_byte);
break;
break;
case GX_CMD_INVL_VC: // Invalidate Vertex Cache
DEBUG_LOG(VIDEO, "Invalidate (vertex cache?)");
break;
case GX_CMD_INVL_VC: // Invalidate Vertex Cache
DEBUG_LOG(VIDEO, "Invalidate (vertex cache?)");
break;
case GX_LOAD_BP_REG: //0x61
{
case GX_LOAD_BP_REG: //0x61
{
u32 bp_cmd = DataReadU32();
LoadBPReg(bp_cmd);
LoadBPReg(bp_cmd);
INCSTAT(stats.thisFrame.numBPLoads);
}
break;
}
break;
// draw primitives
default:
if (cmd_byte & 0x80)
{
// load vertices (use computed vertex size from FifoCommandRunnable above)
// draw primitives
default:
if (cmd_byte & 0x80)
{
// load vertices (use computed vertex size from FifoCommandRunnable above)
u16 numVertices = DataReadU16();
VertexLoaderManager::RunVertices(
cmd_byte & GX_VAT_MASK, // Vertex loader index (0 - 7)
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT,
numVertices);
}
else
{
}
else
{
ERROR_LOG(VIDEO, "OpcodeDecoding::Decode: Illegal command %02x", cmd_byte);
break;
}
break;
}
break;
}
break;
}
// Display lists get added directly into the FIFO stream
if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL)
@ -399,89 +399,89 @@ static void Decode()
static void DecodeSemiNop()
{
u8 *opcodeStart = g_pVideoData;
u8 *opcodeStart = g_pVideoData;
int cmd_byte = DataReadU8();
switch (cmd_byte)
{
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
case GX_CMD_INVL_VC: // Invalidate Vertex Cache
case GX_NOP:
int cmd_byte = DataReadU8();
switch (cmd_byte)
{
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
case GX_CMD_INVL_VC: // Invalidate Vertex Cache
case GX_NOP:
break;
case GX_LOAD_CP_REG: //0x08
// We have to let CP writes through because they determine the size of vertices.
{
u8 sub_cmd = DataReadU8();
u32 value = DataReadU32();
LoadCPReg(sub_cmd, value);
INCSTAT(stats.thisFrame.numCPLoads);
}
break;
{
u8 sub_cmd = DataReadU8();
u32 value = DataReadU32();
LoadCPReg(sub_cmd, value);
INCSTAT(stats.thisFrame.numCPLoads);
}
break;
case GX_LOAD_XF_REG:
{
u32 Cmd2 = DataReadU32();
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
u32 address = Cmd2 & 0xFFFF;
GC_ALIGNED128(u32 data_buffer[16]);
DataReadU32xFuncs[transfer_size-1](data_buffer);
LoadXFReg(transfer_size, address, data_buffer);
INCSTAT(stats.thisFrame.numXFLoads);
}
break;
case GX_LOAD_XF_REG:
{
u32 Cmd2 = DataReadU32();
int transfer_size = ((Cmd2 >> 16) & 15) + 1;
u32 address = Cmd2 & 0xFFFF;
GC_ALIGNED128(u32 data_buffer[16]);
DataReadU32xFuncs[transfer_size-1](data_buffer);
LoadXFReg(transfer_size, address, data_buffer);
INCSTAT(stats.thisFrame.numXFLoads);
}
break;
case GX_LOAD_INDX_A: //used for position matrices
LoadIndexedXF(DataReadU32(), 0xC);
break;
case GX_LOAD_INDX_B: //used for normal matrices
LoadIndexedXF(DataReadU32(), 0xD);
break;
case GX_LOAD_INDX_C: //used for postmatrices
LoadIndexedXF(DataReadU32(), 0xE);
break;
case GX_LOAD_INDX_D: //used for lights
LoadIndexedXF(DataReadU32(), 0xF);
break;
case GX_LOAD_INDX_A: //used for position matrices
LoadIndexedXF(DataReadU32(), 0xC);
break;
case GX_LOAD_INDX_B: //used for normal matrices
LoadIndexedXF(DataReadU32(), 0xD);
break;
case GX_LOAD_INDX_C: //used for postmatrices
LoadIndexedXF(DataReadU32(), 0xE);
break;
case GX_LOAD_INDX_D: //used for lights
LoadIndexedXF(DataReadU32(), 0xF);
break;
case GX_CMD_CALL_DL:
case GX_CMD_CALL_DL:
// Hm, wonder if any games put tokens in display lists - in that case,
// we'll have to parse them too.
DataSkip(8);
break;
DataSkip(8);
break;
case GX_LOAD_BP_REG: //0x61
case GX_LOAD_BP_REG: //0x61
// We have to let BP writes through because they set tokens and stuff.
// TODO: Call a much simplified LoadBPReg instead.
{
{
u32 bp_cmd = DataReadU32();
LoadBPReg(bp_cmd);
LoadBPReg(bp_cmd);
INCSTAT(stats.thisFrame.numBPLoads);
}
break;
}
break;
// draw primitives
default:
if (cmd_byte & 0x80)
{
// load vertices (use computed vertex size from FifoCommandRunnable above)
// draw primitives
default:
if (cmd_byte & 0x80)
{
// load vertices (use computed vertex size from FifoCommandRunnable above)
u16 numVertices = DataReadU16();
DataSkip(numVertices * VertexLoaderManager::GetVertexSize(cmd_byte & GX_VAT_MASK));
}
else
{
}
else
{
ERROR_LOG(VIDEO, "OpcodeDecoding::Decode: Illegal command %02x", cmd_byte);
break;
}
break;
}
break;
}
break;
}
if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL)
FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, u32(g_pVideoData - opcodeStart));
}
void OpcodeDecoder_Init()
{
{
g_pVideoData = GetVideoBufferStartPtr();
#if _M_SSE >= 0x301
@ -494,8 +494,8 @@ void OpcodeDecoder_Init()
if (g_Config.bEnableOpenCL)
{
OpenCL::Initialize();
TexDecoder_OpenCL_Initialize();
OpenCL::Initialize();
TexDecoder_OpenCL_Initialize();
}
}
@ -504,8 +504,8 @@ void OpcodeDecoder_Shutdown()
{
if (g_Config.bEnableOpenCL)
{
TexDecoder_OpenCL_Shutdown();
OpenCL::Destroy();
TexDecoder_OpenCL_Shutdown();
OpenCL::Destroy();
}
}

View file

@ -44,7 +44,7 @@
#define GX_DRAW_LINES 0x5 // 0xA8
#define GX_DRAW_LINE_STRIP 0x6 // 0xB0
#define GX_DRAW_POINTS 0x7 // 0xB8
#define GX_DRAW_NONE 0x1; //Tis is a fake value to used in the backends
#define GX_DRAW_NONE 0x1; //Tis is a fake value to used in the backends
extern bool g_bRecordFifoData;

View file

@ -148,25 +148,25 @@ cl_program CompileProgram(const char *Kernel)
// Build the program executable
err = clBuildProgram(program , 0, NULL, NULL, NULL, NULL);
if(err != CL_SUCCESS) {
HandleCLError(err, "Error: failed to build program");
HandleCLError(err, "Error: failed to build program");
char *buildlog = NULL;
size_t buildlog_size = 0;
size_t buildlog_size = 0;
clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &buildlog_size);
buildlog = new char[buildlog_size + 1];
err = clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, buildlog_size, buildlog, NULL);
buildlog[buildlog_size] = 0;
if(err != CL_SUCCESS)
{
HandleCLError(err, "Error: can't get build log");
} else
{
ERROR_LOG(COMMON, "Error log:\n%s\n", buildlog);
}
buildlog = new char[buildlog_size + 1];
err = clGetProgramBuildInfo(program, OpenCL::device_id, CL_PROGRAM_BUILD_LOG, buildlog_size, buildlog, NULL);
buildlog[buildlog_size] = 0;
if(err != CL_SUCCESS)
{
HandleCLError(err, "Error: can't get build log");
} else
{
ERROR_LOG(COMMON, "Error log:\n%s\n", buildlog);
}
delete[] buildlog;
delete[] buildlog;
return NULL;
}

View file

@ -98,7 +98,7 @@ void TexDecoder_OpenCL_Initialize()
size_t nDevices = 0;
cl_device_id *devices = NULL;
size_t *binary_sizes = NULL;
char **binaries = NULL;
char **binaries = NULL;
std::string filename;
char dolphin_rev[HEADER_SIZE];
@ -132,7 +132,7 @@ void TexDecoder_OpenCL_Initialize()
{
OpenCL::HandleCLError(err, "clCreateProgramWithBinary");
}
if (!err)
{
err = clBuildProgram(g_program, 1, &OpenCL::device_id, NULL, NULL, NULL);

View file

@ -126,8 +126,8 @@ bool bbox_active;
enum
{
INT_CAUSE_PE_TOKEN = 0x200, // GP Token
INT_CAUSE_PE_FINISH = 0x400, // GP Finished
INT_CAUSE_PE_TOKEN = 0x200, // GP Token
INT_CAUSE_PE_FINISH = 0x400, // GP Finished
};
void DoState(PointerWrap &p)

View file

@ -24,13 +24,13 @@ class PointerWrap;
// internal hardware addresses
enum
{
PE_ZCONF = 0x00, // Z Config
PE_ALPHACONF = 0x02, // Alpha Config
PE_DSTALPHACONF = 0x04, // Destination Alpha Config
PE_ALPHAMODE = 0x06, // Alpha Mode Config
PE_ALPHAREAD = 0x08, // Alpha Read
PE_ZCONF = 0x00, // Z Config
PE_ALPHACONF = 0x02, // Alpha Config
PE_DSTALPHACONF = 0x04, // Destination Alpha Config
PE_ALPHAMODE = 0x06, // Alpha Mode Config
PE_ALPHAREAD = 0x08, // Alpha Read
PE_CTRL_REGISTER = 0x0a, // Control
PE_TOKEN_REG = 0x0e, // Token
PE_TOKEN_REG = 0x0e, // Token
PE_BBOX_LEFT = 0x10, // Flip Left
PE_BBOX_RIGHT = 0x12, // Flip Right
PE_BBOX_TOP = 0x14, // Flip Top

View file

@ -374,38 +374,38 @@ static const char *tevOpTable[] = { // TEV
static const char *tevCInputTable[] = // CC
{
"(prev.rgb)", // CPREV,
"(prev.rgb)", // CPREV,
"(prev.aaa)", // APREV,
"(c0.rgb)", // C0,
"(c0.rgb)", // C0,
"(c0.aaa)", // A0,
"(c1.rgb)", // C1,
"(c1.rgb)", // C1,
"(c1.aaa)", // A1,
"(c2.rgb)", // C2,
"(c2.rgb)", // C2,
"(c2.aaa)", // A2,
"(textemp.rgb)", // TEXC,
"(textemp.rgb)", // TEXC,
"(textemp.aaa)", // TEXA,
"(rastemp.rgb)", // RASC,
"(rastemp.rgb)", // RASC,
"(rastemp.aaa)", // RASA,
"float3(1.0f, 1.0f, 1.0f)", // ONE
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(konsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(konsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.0f, 0.0f, 0.0f)", // ZERO
///aded extra values to map clamped values
"(cprev.rgb)", // CPREV,
"(cprev.aaa)", // APREV,
"(cc0.rgb)", // C0,
"(cc0.aaa)", // A0,
"(cc1.rgb)", // C1,
"(cc1.aaa)", // A1,
"(cc2.rgb)", // C2,
"(cc2.aaa)", // A2,
"(textemp.rgb)", // TEXC,
"(cprev.rgb)", // CPREV,
"(cprev.aaa)", // APREV,
"(cc0.rgb)", // C0,
"(cc0.aaa)", // A0,
"(cc1.rgb)", // C1,
"(cc1.aaa)", // A1,
"(cc2.rgb)", // C2,
"(cc2.aaa)", // A2,
"(textemp.rgb)", // TEXC,
"(textemp.aaa)", // TEXA,
"(crastemp.rgb)", // RASC,
"(crastemp.aaa)", // RASA,
"(crastemp.rgb)", // RASC,
"(crastemp.aaa)", // RASA,
"float3(1.0f, 1.0f, 1.0f)", // ONE
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(ckonsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(ckonsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.0f, 0.0f, 0.0f)", // ZERO
"PADERROR1", "PADERROR2", "PADERROR3", "PADERROR4"
};
@ -425,7 +425,7 @@ static const char *tevAInputTable[] = // CA
"cc0", // A0,
"cc1", // A1,
"cc2", // A2,
"textemp", // TEXA,
"textemp", // TEXA,
"crastemp", // RASA,
"ckonsttemp", // KONST, (hw1 had quarter)
"float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO

View file

@ -28,8 +28,8 @@
#define I_INDTEXSCALE "cindscale"
#define I_INDTEXMTX "cindmtx"
#define I_FOG "cfog"
#define I_PLIGHTS "cPLights"
#define I_PMATERIALS "cPmtrl"
#define I_PLIGHTS "cPLights"
#define I_PMATERIALS "cPmtrl"
#define C_COLORMATRIX 0 // 0
#define C_COLORS 0 // 0

View file

@ -87,61 +87,61 @@ void PixelShaderManager::SetConstants()
{
if (g_ActiveConfig.backend_info.APIType == API_OPENGL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO)
Dirty();
for (int i = 0; i < 2; ++i)
for (int i = 0; i < 2; ++i)
{
if (s_nColorsChanged[i])
if (s_nColorsChanged[i])
{
int baseind = i ? C_KCOLORS : C_COLORS;
for (int j = 0; j < 4; ++j)
int baseind = i ? C_KCOLORS : C_COLORS;
for (int j = 0; j < 4; ++j)
{
if (s_nColorsChanged[i] & (1 << j))
SetPSConstant4fv(baseind+j, &lastRGBAfull[i][j][0]);
}
s_nColorsChanged[i] = 0;
}
}
if (s_nColorsChanged[i] & (1 << j))
SetPSConstant4fv(baseind+j, &lastRGBAfull[i][j][0]);
}
s_nColorsChanged[i] = 0;
}
}
if (s_nTexDimsChanged)
if (s_nTexDimsChanged)
{
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 8; ++i)
{
if (s_nTexDimsChanged & (1<<i))
if (s_nTexDimsChanged & (1<<i))
SetPSTextureDims(i);
}
s_nTexDimsChanged = 0;
}
}
s_nTexDimsChanged = 0;
}
if (s_bAlphaChanged)
if (s_bAlphaChanged)
{
SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f);
s_bAlphaChanged = false;
}
}
if (s_bZTextureTypeChanged)
{
float ftemp[4];
switch (bpmem.ztex2.type)
float ftemp[4];
switch (bpmem.ztex2.type)
{
case 0:
// 8 bits
ftemp[0] = 0; ftemp[1] = 0; ftemp[2] = 0; ftemp[3] = 255.0f/16777215.0f;
break;
case 1:
// 16 bits
ftemp[0] = 255.0f/16777215.0f; ftemp[1] = 0; ftemp[2] = 0; ftemp[3] = 65280.0f/16777215.0f;
break;
case 2:
// 24 bits
case 0:
// 8 bits
ftemp[0] = 0; ftemp[1] = 0; ftemp[2] = 0; ftemp[3] = 255.0f/16777215.0f;
break;
case 1:
// 16 bits
ftemp[0] = 255.0f/16777215.0f; ftemp[1] = 0; ftemp[2] = 0; ftemp[3] = 65280.0f/16777215.0f;
break;
case 2:
// 24 bits
ftemp[0] = 16711680.0f/16777215.0f; ftemp[1] = 65280.0f/16777215.0f; ftemp[2] = 255.0f/16777215.0f; ftemp[3] = 0;
break;
}
break;
}
SetPSConstant4fv(C_ZBIAS, ftemp);
s_bZTextureTypeChanged = false;
}
if (s_bZBiasChanged || s_bDepthRangeChanged)
{
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
@ -152,78 +152,78 @@ void PixelShaderManager::SetConstants()
//ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias);
SetPSConstant4f(C_ZBIAS+1, xfregs.viewport.farZ / 16777216.0f, xfregs.viewport.zRange / 16777216.0f, 0, (float)(lastZBias)/16777215.0f);
s_bZBiasChanged = s_bDepthRangeChanged = false;
}
}
// indirect incoming texture scales
if (s_nIndTexScaleChanged)
// indirect incoming texture scales
if (s_nIndTexScaleChanged)
{
// set as two sets of vec4s, each containing S and T of two ind stages.
float f[8];
float f[8];
if (s_nIndTexScaleChanged & 0x03)
if (s_nIndTexScaleChanged & 0x03)
{
for (u32 i = 0; i < 2; ++i)
for (u32 i = 0; i < 2; ++i)
{
f[2 * i] = bpmem.texscale[0].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
f[2 * i] = bpmem.texscale[0].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE, f);
}
}
if (s_nIndTexScaleChanged & 0x0c) {
for (u32 i = 2; i < 4; ++i) {
f[2 * i] = bpmem.texscale[1].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
if (s_nIndTexScaleChanged & 0x0c) {
for (u32 i = 2; i < 4; ++i) {
f[2 * i] = bpmem.texscale[1].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
}
}
s_nIndTexScaleChanged = 0;
}
s_nIndTexScaleChanged = 0;
}
if (s_nIndTexMtxChanged)
if (s_nIndTexMtxChanged)
{
for (int i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
if (s_nIndTexMtxChanged & (1 << i))
if (s_nIndTexMtxChanged & (1 << i))
{
int scale = ((u32)bpmem.indmtx[i].col0.s0 << 0) |
((u32)bpmem.indmtx[i].col1.s1 << 2) |
((u32)bpmem.indmtx[i].col2.s2 << 4);
float fscale = powf(2.0f, (float)(scale - 17)) / 1024.0f;
int scale = ((u32)bpmem.indmtx[i].col0.s0 << 0) |
((u32)bpmem.indmtx[i].col1.s1 << 2) |
((u32)bpmem.indmtx[i].col2.s2 << 4);
float fscale = powf(2.0f, (float)(scale - 17)) / 1024.0f;
// xyz - static matrix
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
// rev 2972 - now using / 256.... verify that this works
// xyz - static matrix
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
// rev 2972 - now using / 256.... verify that this works
SetPSConstant4f(C_INDTEXMTX + 2 * i,
bpmem.indmtx[i].col0.ma * fscale,
bpmem.indmtx[i].col0.ma * fscale,
bpmem.indmtx[i].col1.mc * fscale,
bpmem.indmtx[i].col2.me * fscale,
fscale * 4.0f);
SetPSConstant4f(C_INDTEXMTX + 2 * i + 1,
bpmem.indmtx[i].col0.mb * fscale,
SetPSConstant4f(C_INDTEXMTX + 2 * i + 1,
bpmem.indmtx[i].col0.mb * fscale,
bpmem.indmtx[i].col1.md * fscale,
bpmem.indmtx[i].col2.mf * fscale,
fscale * 4.0f);
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n",
i, 1024.0f*fscale,
bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale,
bpmem.indmtx[i].col0.mb * fscale, bpmem.indmtx[i].col1.md * fscale, bpmem.indmtx[i].col2.mf * fscale);
}
}
s_nIndTexMtxChanged = 0;
}
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n",
i, 1024.0f*fscale,
bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale,
bpmem.indmtx[i].col0.mb * fscale, bpmem.indmtx[i].col1.md * fscale, bpmem.indmtx[i].col2.mf * fscale);
}
}
s_nIndTexMtxChanged = 0;
}
if (s_bFogColorChanged)
if (s_bFogColorChanged)
{
SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0);
s_bFogColorChanged = false;
}
}
if (s_bFogParamChanged)
if (s_bFogParamChanged)
{
if(!g_ActiveConfig.bDisableFog)
{
@ -236,8 +236,8 @@ void PixelShaderManager::SetConstants()
else
SetPSConstant4f(C_FOG + 1, 0.0, 1.0, 0.0, 1.0);
s_bFogParamChanged = false;
}
s_bFogParamChanged = false;
}
if (s_bFogRangeAdjustChanged)
{
@ -341,11 +341,11 @@ void PixelShaderManager::SetConstants()
void PixelShaderManager::SetPSTextureDims(int texid)
{
// texdims.xy are reciprocals of the real texture dimensions
// texdims.zw are the scaled dimensions
float fdims[4];
// texdims.xy are reciprocals of the real texture dimensions
// texdims.zw are the scaled dimensions
float fdims[4];
TCoordInfo& tc = bpmem.texcoords[texid];
TCoordInfo& tc = bpmem.texcoords[texid];
fdims[0] = 1.0f / (float)(lastTexDims[texid] & 0xffff);
fdims[1] = 1.0f / (float)((lastTexDims[texid] >> 16) & 0xfff);
fdims[2] = (float)(tc.s.scale_minus_1 + 1);
@ -359,7 +359,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
// and update it when the shader constant is set, only.
void PixelShaderManager::SetColorChanged(int type, int num, bool high)
{
float *pf = &lastRGBAfull[type][num][0];
float *pf = &lastRGBAfull[type][num][0];
if (!high) {
int r = bpmem.tevregs[num].low.a;
int a = bpmem.tevregs[num].low.b;
@ -371,45 +371,45 @@ void PixelShaderManager::SetColorChanged(int type, int num, bool high)
pf[1] = (float)g * (1.0f / 255.0f);
pf[2] = (float)b * (1.0f / 255.0f);
}
s_nColorsChanged[type] |= 1 << num;
PRIM_LOG("pixel %scolor%d: %f %f %f %f\n", type?"k":"", num, pf[0], pf[1], pf[2], pf[3]);
s_nColorsChanged[type] |= 1 << num;
PRIM_LOG("pixel %scolor%d: %f %f %f %f\n", type?"k":"", num, pf[0], pf[1], pf[2], pf[3]);
}
void PixelShaderManager::SetAlpha(const AlphaTest& alpha)
{
if ((alpha.hex & 0xffff) != lastAlpha)
if ((alpha.hex & 0xffff) != lastAlpha)
{
lastAlpha = (lastAlpha & ~0xffff) | (alpha.hex & 0xffff);
s_bAlphaChanged = true;
}
lastAlpha = (lastAlpha & ~0xffff) | (alpha.hex & 0xffff);
s_bAlphaChanged = true;
}
}
void PixelShaderManager::SetDestAlpha(const ConstantAlpha& alpha)
{
if (alpha.alpha != (lastAlpha >> 16))
if (alpha.alpha != (lastAlpha >> 16))
{
lastAlpha = (lastAlpha & ~0xff0000) | ((alpha.hex & 0xff) << 16);
s_bAlphaChanged = true;
}
lastAlpha = (lastAlpha & ~0xff0000) | ((alpha.hex & 0xff) << 16);
s_bAlphaChanged = true;
}
}
void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt)
{
u32 wh = width | (height << 16) | (wraps << 28) | (wrapt << 30);
if (lastTexDims[texmapid] != wh)
u32 wh = width | (height << 16) | (wraps << 28) | (wrapt << 30);
if (lastTexDims[texmapid] != wh)
{
lastTexDims[texmapid] = wh;
lastTexDims[texmapid] = wh;
s_nTexDimsChanged |= 1 << texmapid;
}
}
}
void PixelShaderManager::SetZTextureBias(u32 bias)
{
if (lastZBias != bias)
if (lastZBias != bias)
{
s_bZBiasChanged = true;
lastZBias = bias;
}
s_bZBiasChanged = true;
lastZBias = bias;
}
}
void PixelShaderManager::SetViewportChanged()
@ -420,12 +420,12 @@ void PixelShaderManager::SetViewportChanged()
void PixelShaderManager::SetIndTexScaleChanged(u8 stagemask)
{
s_nIndTexScaleChanged |= stagemask;
s_nIndTexScaleChanged |= stagemask;
}
void PixelShaderManager::SetIndMatrixChanged(int matrixidx)
{
s_nIndTexMtxChanged |= 1 << matrixidx;
s_nIndTexMtxChanged |= 1 << matrixidx;
}
void PixelShaderManager::SetZTextureTypeChanged()
@ -435,22 +435,22 @@ void PixelShaderManager::SetZTextureTypeChanged()
void PixelShaderManager::SetTexCoordChanged(u8 texmapid)
{
s_nTexDimsChanged |= 1 << texmapid;
s_nTexDimsChanged |= 1 << texmapid;
}
void PixelShaderManager::SetFogColorChanged()
{
s_bFogColorChanged = true;
s_bFogColorChanged = true;
}
void PixelShaderManager::SetFogParamChanged()
{
s_bFogParamChanged = true;
s_bFogParamChanged = true;
}
void PixelShaderManager::SetFogRangeAdjustChanged()
{
s_bFogRangeAdjustChanged = true;
s_bFogRangeAdjustChanged = true;
}
void PixelShaderManager::SetColorMatrix(const float* pmatrix)

View file

@ -54,7 +54,6 @@ public:
static void SetColorMatrix(const float* pmatrix);
static void InvalidateXFRange(int start, int end);
static void SetMaterialColorChanged(int index);
};

View file

@ -53,8 +53,8 @@ char *Statistics::ToString(char *ptr)
ptr+=sprintf(ptr,"pshaders (unique, delete cache first): %i\n",stats.numUniquePixelShaders);
ptr+=sprintf(ptr,"vshaders created: %i\n",stats.numVertexShadersCreated);
ptr+=sprintf(ptr,"vshaders alive: %i\n",stats.numVertexShadersAlive);
ptr+=sprintf(ptr,"dlists called: %i\n",stats.numDListsCalled);
ptr+=sprintf(ptr,"dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
ptr+=sprintf(ptr,"dlists called: %i\n",stats.numDListsCalled);
ptr+=sprintf(ptr,"dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
ptr+=sprintf(ptr,"dlists alive: %i\n",stats.numDListsAlive);
ptr+=sprintf(ptr,"primitive joins: %i\n",stats.thisFrame.numPrimitiveJoins);
ptr+=sprintf(ptr,"draw calls: %i\n",stats.thisFrame.numDrawCalls);

View file

@ -24,20 +24,20 @@
struct Statistics
{
int numPixelShadersCreated;
int numPixelShadersAlive;
int numVertexShadersCreated;
int numVertexShadersAlive;
int numPixelShadersCreated;
int numPixelShadersAlive;
int numVertexShadersCreated;
int numVertexShadersAlive;
int numTexturesCreated;
int numTexturesAlive;
int numTexturesCreated;
int numTexturesAlive;
int numRenderTargetsCreated;
int numRenderTargetsAlive;
int numDListsCalled;
int numDListsCreated;
int numDListsAlive;
int numRenderTargetsCreated;
int numRenderTargetsAlive;
int numDListsCalled;
int numDListsCreated;
int numDListsAlive;
int numVertexLoaders;
@ -52,30 +52,30 @@ struct Statistics
std::vector<EFBRectangle> efb_regions;
struct ThisFrame
{
int numBPLoads;
int numCPLoads;
int numXFLoads;
int numBPLoadsInDL;
int numCPLoadsInDL;
int numXFLoadsInDL;
int numDLs;
int numPrims;
int numDLPrims;
int numShaderChanges;
struct ThisFrame
{
int numBPLoads;
int numCPLoads;
int numXFLoads;
int numBPLoadsInDL;
int numCPLoadsInDL;
int numXFLoadsInDL;
int numDLs;
int numPrims;
int numDLPrims;
int numShaderChanges;
int numPrimitiveJoins;
int numDrawCalls;
int numIndexedDrawCalls;
int numBufferSplits;
int numPrimitiveJoins;
int numDrawCalls;
int numIndexedDrawCalls;
int numBufferSplits;
int numDListsCalled;
};
ThisFrame thisFrame;
void ResetFrame();
};
ThisFrame thisFrame;
void ResetFrame();
static void SwapDL();
// Yeah, this is unsafe, but we really don't wanna faff around allocating

View file

@ -56,7 +56,7 @@ TextureCache::TextureCache()
if (!temp)
temp = (u8*)AllocateAlignedMemory(temp_size, 16);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures)
if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures)
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);
}
@ -725,7 +725,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
case 1: // R8
case 8: // R8
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
cbufid = 13;
cbufid = 13;
break;
case 2: // RA4
@ -746,11 +746,11 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
case 9: // G8
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f;
cbufid = 17;
cbufid = 17;
break;
case 10: // B8
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f;
cbufid = 18;
cbufid = 18;
break;
case 11: // RG8
@ -759,7 +759,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
break;
case 12: // GB8
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1.0f;
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1.0f;
cbufid = 20;
break;

View file

@ -39,23 +39,23 @@ namespace TextureConversionShader
u16 GetEncodedSampleCount(u32 format)
{
switch (format) {
case GX_TF_I4: return 8;
switch (format) {
case GX_TF_I4: return 8;
case GX_TF_I8: return 4;
case GX_TF_IA4: return 4;
case GX_TF_IA8: return 2;
case GX_TF_IA8: return 2;
case GX_TF_RGB565: return 2;
case GX_TF_RGB5A3: return 2;
case GX_TF_RGBA8: return 1;
case GX_CTF_R4: return 8;
case GX_CTF_RA4: return 4;
case GX_CTF_RA8: return 2;
case GX_CTF_A8: return 4;
case GX_CTF_R8: return 4;
case GX_CTF_G8: return 4;
case GX_CTF_B8: return 4;
case GX_CTF_RG8: return 2;
case GX_CTF_GB8: return 2;
case GX_CTF_RA4: return 4;
case GX_CTF_RA8: return 2;
case GX_CTF_A8: return 4;
case GX_CTF_R8: return 4;
case GX_CTF_G8: return 4;
case GX_CTF_B8: return 4;
case GX_CTF_RG8: return 2;
case GX_CTF_GB8: return 2;
case GX_TF_Z8: return 4;
case GX_TF_Z16: return 2;
case GX_TF_Z24X8: return 1;
@ -63,8 +63,8 @@ u16 GetEncodedSampleCount(u32 format)
case GX_CTF_Z8M: return 4;
case GX_CTF_Z8L: return 4;
case GX_CTF_Z16L: return 2;
default: return 1;
}
default: return 1;
}
}
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
@ -100,10 +100,9 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
else
{
WRITE(p,"sampler samp0 : register(s0);\n");
WRITE(p, "Texture2D Tex0 : register(t0);\n");
WRITE(p, "Texture2D Tex0 : register(t0);\n");
}
if (ApiType == API_OPENGL)
{
WRITE(p, " out float4 ocol0;\n");
@ -123,9 +122,9 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n");
}
WRITE(p, "{\n"
" float2 sampleUv;\n"
" float2 sampleUv;\n"
" float2 uv1 = floor(uv0);\n");
WRITE(p, " uv1.x = uv1.x * %f;\n", samples);
@ -147,14 +146,14 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
if (ApiType == API_OPENGL)
WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n");
WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n");
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
}
// block dimensions : widthStride, heightStride
@ -182,7 +181,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
else
{
WRITE(p,"sampler samp0 : register(s0);\n");
WRITE(p, "Texture2D Tex0 : register(t0);\n");
WRITE(p, "Texture2D Tex0 : register(t0);\n");
}
if (ApiType == API_OPENGL)
@ -204,12 +203,12 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n");
}
WRITE(p, "{\n"
" float2 sampleUv;\n"
" float2 sampleUv;\n"
" float2 uv1 = floor(uv0);\n");
WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH);
WRITE(p, " float yb = yl * %f;\n", blkH);
WRITE(p, " float yoff = uv1.y - yb;\n");
@ -217,26 +216,26 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, " float xel = floor(xp / 2);\n");
WRITE(p, " float xb = floor(xel / %f);\n", blkH);
WRITE(p, " float xoff = xel - (xb * %f);\n", blkH);
WRITE(p, " float x2 = uv1.x * 2;\n");
WRITE(p, " float xl = floor(x2 / %f);\n", blkW);
WRITE(p, " float xib = x2 - (xl * %f);\n", blkW);
WRITE(p, " float halfxb = floor(xb / 2);\n");
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
WRITE(p, " sampleUv.y = yb + xoff;\n");
WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n");
if (ApiType == API_OPENGL)
WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n");
WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n");
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
}
void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType)
@ -465,11 +464,11 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WriteSampleColor(p, "rgba", "texSample", ApiType);
// 0.8784 = 224 / 255 which is the maximum alpha value that can be represented in 3 bits
WRITE(p, "if(texSample.a > 0.878f) {\n");
// 0.8784 = 224 / 255 which is the maximum alpha value that can be represented in 3 bits
WRITE(p, "if(texSample.a > 0.878f) {\n");
WriteToBitDepth(p, 5, "texSample.g", "color0");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0f;\n");
WriteToBitDepth(p, 5, "texSample.r", "ocol0.b");
@ -477,27 +476,27 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 5, "texSample.b", "ocol0.g");
WRITE(p, " ocol0.g = ocol0.g + gLower * 32.0f;\n");
WRITE(p, "} else {\n");
WRITE(p, "} else {\n");
WriteToBitDepth(p, 4, "texSample.r", "ocol0.b");
WriteToBitDepth(p, 4, "texSample.b", "ocol0.g");
WriteToBitDepth(p, 4, "texSample.r", "ocol0.b");
WriteToBitDepth(p, 4, "texSample.b", "ocol0.g");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.b = ocol0.b + color0 * 16.0f;\n");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.b = ocol0.b + color0 * 16.0f;\n");
WriteToBitDepth(p, 4, "texSample.g", "color0");
WRITE(p, "ocol0.g = ocol0.g + color0 * 16.0f;\n");
WRITE(p, "ocol0.g = ocol0.g + color0 * 16.0f;\n");
WRITE(p, "}\n");
WRITE(p, "}\n");
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, "if(texSample.a > 0.878f) {\n");
WRITE(p, "if(texSample.a > 0.878f) {\n");
WriteToBitDepth(p, 5, "texSample.g", "color0");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gUpper = floor(color0 / 8.0f);\n");
WRITE(p, " gLower = color0 - gUpper * 8.0f;\n");
WriteToBitDepth(p, 5, "texSample.r", "ocol0.r");
@ -505,17 +504,17 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 5, "texSample.b", "ocol0.a");
WRITE(p, " ocol0.a = ocol0.a + gLower * 32.0f;\n");
WRITE(p, "} else {\n");
WRITE(p, "} else {\n");
WriteToBitDepth(p, 4, "texSample.r", "ocol0.r");
WriteToBitDepth(p, 4, "texSample.b", "ocol0.a");
WriteToBitDepth(p, 4, "texSample.r", "ocol0.r");
WriteToBitDepth(p, 4, "texSample.b", "ocol0.a");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.r = ocol0.r + color0 * 16.0f;\n");
WriteToBitDepth(p, 3, "texSample.a", "color0");
WRITE(p, "ocol0.r = ocol0.r + color0 * 16.0f;\n");
WriteToBitDepth(p, 4, "texSample.g", "color0");
WRITE(p, "ocol0.a = ocol0.a + color0 * 16.0f;\n");
WRITE(p, "ocol0.a = ocol0.a + color0 * 16.0f;\n");
WRITE(p, "}\n");
WRITE(p, "}\n");
WRITE(p, " ocol0 = ocol0 / 255.0f;\n");
WriteEncoderEnd(p, ApiType);
@ -680,96 +679,96 @@ void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_Z8M, ApiType);
WRITE(p, " float depth;\n");
WRITE(p, " float depth;\n");
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier);
WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);
WriteEncoderEnd(p, ApiType);
}
void WriteZ16Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_Z16, ApiType);
WriteSwizzler(p, GX_TF_Z16, ApiType);
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
// byte order is reversed
// byte order is reversed
WriteSampleColor(p, "b", "depth", ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " ocol0.b = expanded.g / 255;\n");
WRITE(p, " ocol0.g = expanded.r / 255;\n");
WRITE(p, " ocol0.b = expanded.g / 255;\n");
WRITE(p, " ocol0.g = expanded.r / 255;\n");
WriteIncrementSampleX(p, ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " ocol0.r = expanded.g / 255;\n");
WRITE(p, " ocol0.a = expanded.r / 255;\n");
WRITE(p, " ocol0.r = expanded.g / 255;\n");
WRITE(p, " ocol0.a = expanded.r / 255;\n");
WriteEncoderEnd(p, ApiType);
WriteEncoderEnd(p, ApiType);
}
void WriteZ16LEncoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_Z16L, ApiType);
WriteSwizzler(p, GX_CTF_Z16L, ApiType);
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
// byte order is reversed
// byte order is reversed
WriteSampleColor(p, "b", "depth", ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth -= expanded.g * 256;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth -= expanded.g * 256;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " ocol0.b = expanded.b / 255;\n");
WRITE(p, " ocol0.g = expanded.g / 255;\n");
WRITE(p, " ocol0.b = expanded.b / 255;\n");
WRITE(p, " ocol0.g = expanded.g / 255;\n");
WriteIncrementSampleX(p, ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth -= expanded.g * 256;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
WRITE(p, " depth -= expanded.r * 256 * 256;\n");
WRITE(p, " expanded.g = floor(depth / 256);\n");
WRITE(p, " depth -= expanded.g * 256;\n");
WRITE(p, " expanded.b = depth;\n");
WRITE(p, " ocol0.r = expanded.b;\n");
WRITE(p, " ocol0.a = expanded.g;\n");
WRITE(p, " ocol0.r = expanded.b;\n");
WRITE(p, " ocol0.a = expanded.g;\n");
WriteEncoderEnd(p, ApiType);
WriteEncoderEnd(p, ApiType);
}
void WriteZ24Encoder(char* p, API_TYPE ApiType)
@ -779,16 +778,16 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
WRITE(p, " float cl = xb - (halfxb * 2);\n");
WRITE(p, " float depth0;\n");
WRITE(p, " float depth1;\n");
WRITE(p, " float3 expanded0;\n");
WRITE(p, " float3 expanded1;\n");
WRITE(p, " float depth1;\n");
WRITE(p, " float3 expanded0;\n");
WRITE(p, " float3 expanded1;\n");
WriteSampleColor(p, "b", "depth0", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth1", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth1", ApiType);
for (int i = 0; i < 2; i++)
{
for (int i = 0; i < 2; i++)
{
WRITE(p, " depth%i *= 16777215.0f;\n", i);
WRITE(p, " expanded%i.r = floor(depth%i / (256 * 256));\n", i, i);
@ -796,23 +795,23 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
WRITE(p, " expanded%i.g = floor(depth%i / 256);\n", i, i);
WRITE(p, " depth%i -= expanded%i.g * 256;\n", i, i);
WRITE(p, " expanded%i.b = depth%i;\n", i, i);
}
}
WRITE(p, " if(cl > 0.5f) {\n");
// upper 16
WRITE(p, " ocol0.b = expanded0.g / 255;\n");
WRITE(p, " ocol0.g = expanded0.b / 255;\n");
WRITE(p, " ocol0.r = expanded1.g / 255;\n");
WRITE(p, " ocol0.a = expanded1.b / 255;\n");
WRITE(p, " } else {\n");
// lower 8
WRITE(p, " ocol0.b = 1.0f;\n");
WRITE(p, " ocol0.g = expanded0.r / 255;\n");
WRITE(p, " ocol0.r = 1.0f;\n");
WRITE(p, " ocol0.a = expanded1.r / 255;\n");
WRITE(p, " }\n");
WRITE(p, " if(cl > 0.5f) {\n");
// upper 16
WRITE(p, " ocol0.b = expanded0.g / 255;\n");
WRITE(p, " ocol0.g = expanded0.b / 255;\n");
WRITE(p, " ocol0.r = expanded1.g / 255;\n");
WRITE(p, " ocol0.a = expanded1.b / 255;\n");
WRITE(p, " } else {\n");
// lower 8
WRITE(p, " ocol0.b = 1.0f;\n");
WRITE(p, " ocol0.g = expanded0.r / 255;\n");
WRITE(p, " ocol0.r = 1.0f;\n");
WRITE(p, " ocol0.a = expanded1.r / 255;\n");
WRITE(p, " }\n");
WriteEncoderEnd(p, ApiType);
WriteEncoderEnd(p, ApiType);
}
const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
@ -902,7 +901,7 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
PanicAlert("TextureConversionShader generator - buffer too small, canary has been eaten!");
setlocale(LC_NUMERIC, ""); // restore locale
return text;
return text;
}
void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride,float buffW,float buffH)

View file

@ -27,41 +27,41 @@ extern GC_ALIGNED16(u8 texMem[TMEM_SIZE]);
enum TextureFormat
{
GX_TF_I4 = 0x0,
GX_TF_I8 = 0x1,
GX_TF_IA4 = 0x2,
GX_TF_IA8 = 0x3,
GX_TF_RGB565 = 0x4,
GX_TF_RGB5A3 = 0x5,
GX_TF_RGBA8 = 0x6,
GX_TF_C4 = 0x8,
GX_TF_C8 = 0x9,
GX_TF_C14X2 = 0xA,
GX_TF_CMPR = 0xE,
GX_TF_I4 = 0x0,
GX_TF_I8 = 0x1,
GX_TF_IA4 = 0x2,
GX_TF_IA8 = 0x3,
GX_TF_RGB565 = 0x4,
GX_TF_RGB5A3 = 0x5,
GX_TF_RGBA8 = 0x6,
GX_TF_C4 = 0x8,
GX_TF_C8 = 0x9,
GX_TF_C14X2 = 0xA,
GX_TF_CMPR = 0xE,
_GX_TF_CTF = 0x20, // copy-texture-format only (simply means linear?)
_GX_TF_ZTF = 0x10, // Z-texture-format
_GX_TF_CTF = 0x20, // copy-texture-format only (simply means linear?)
_GX_TF_ZTF = 0x10, // Z-texture-format
// these formats are also valid when copying targets
GX_CTF_R4 = 0x0 | _GX_TF_CTF,
GX_CTF_RA4 = 0x2 | _GX_TF_CTF,
GX_CTF_RA8 = 0x3 | _GX_TF_CTF,
GX_CTF_YUVA8 = 0x6 | _GX_TF_CTF,
GX_CTF_A8 = 0x7 | _GX_TF_CTF,
GX_CTF_R8 = 0x8 | _GX_TF_CTF,
GX_CTF_G8 = 0x9 | _GX_TF_CTF,
GX_CTF_B8 = 0xA | _GX_TF_CTF,
GX_CTF_RG8 = 0xB | _GX_TF_CTF,
GX_CTF_GB8 = 0xC | _GX_TF_CTF,
// these formats are also valid when copying targets
GX_CTF_R4 = 0x0 | _GX_TF_CTF,
GX_CTF_RA4 = 0x2 | _GX_TF_CTF,
GX_CTF_RA8 = 0x3 | _GX_TF_CTF,
GX_CTF_YUVA8 = 0x6 | _GX_TF_CTF,
GX_CTF_A8 = 0x7 | _GX_TF_CTF,
GX_CTF_R8 = 0x8 | _GX_TF_CTF,
GX_CTF_G8 = 0x9 | _GX_TF_CTF,
GX_CTF_B8 = 0xA | _GX_TF_CTF,
GX_CTF_RG8 = 0xB | _GX_TF_CTF,
GX_CTF_GB8 = 0xC | _GX_TF_CTF,
GX_TF_Z8 = 0x1 | _GX_TF_ZTF,
GX_TF_Z16 = 0x3 | _GX_TF_ZTF,
GX_TF_Z24X8 = 0x6 | _GX_TF_ZTF,
GX_TF_Z8 = 0x1 | _GX_TF_ZTF,
GX_TF_Z16 = 0x3 | _GX_TF_ZTF,
GX_TF_Z24X8 = 0x6 | _GX_TF_ZTF,
GX_CTF_Z4 = 0x0 | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z8M = 0x9 | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z8L = 0xA | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z16L = 0xC | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z4 = 0x0 | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z8M = 0x9 | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z8L = 0xA | _GX_TF_ZTF | _GX_TF_CTF,
GX_CTF_Z16L = 0xC | _GX_TF_ZTF | _GX_TF_CTF,
};
int TexDecoder_GetTexelSizeInNibbles(int format);

View file

@ -121,10 +121,10 @@ void LOADERDECL UpdateBoundingBox()
{
if (!PixelEngine::bbox_active)
return;
// reset videodata pointer
VertexManager::s_pCurBufferPointer = s_bbox_pCurBufferPointer_orig;
// copy vertex pointers
memcpy(VertexManager::s_pCurBufferPointer, s_bbox_vertex_buffer, 12);
VertexManager::s_pCurBufferPointer += 12;
@ -335,7 +335,7 @@ void VertexLoader::CompileVertexTranslator()
nat_offset += 12;
vtx_decl.normal_offset[2] = nat_offset;
nat_offset += 12;
}
}
int numNormals = (m_VtxAttr.NormalElements == 1) ? NRM_THREE : NRM_ONE;
m_NativeFmt->m_components |= VB_HAS_NRM0;
@ -367,7 +367,7 @@ void VertexLoader::CompileVertexTranslator()
default: _assert_(0); break;
}
break;
case INDEX8:
case INDEX8:
m_VertexSize += 1;
switch (m_VtxAttr.color[i].Comp)
{
@ -558,7 +558,7 @@ int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const
m_VtxAttr.texCoord[0].Frac = g_VtxAttr[vtx_attr_group].g0.Tex0Frac;
m_VtxAttr.texCoord[1].Frac = g_VtxAttr[vtx_attr_group].g1.Tex1Frac;
m_VtxAttr.texCoord[2].Frac = g_VtxAttr[vtx_attr_group].g1.Tex2Frac;
m_VtxAttr.texCoord[3].Frac = g_VtxAttr[vtx_attr_group].g1.Tex3Frac;
m_VtxAttr.texCoord[3].Frac = g_VtxAttr[vtx_attr_group].g1.Tex3Frac;
m_VtxAttr.texCoord[4].Frac = g_VtxAttr[vtx_attr_group].g2.Tex4Frac;
m_VtxAttr.texCoord[5].Frac = g_VtxAttr[vtx_attr_group].g2.Tex5Frac;
m_VtxAttr.texCoord[6].Frac = g_VtxAttr[vtx_attr_group].g2.Tex6Frac;
@ -607,11 +607,11 @@ void VertexLoader::ConvertVertices ( int count )
void VertexLoader::RunCompiledVertices(int vtx_attr_group, int primitive, int const count, u8* Data)
{
auto const new_count = SetupRunVertices(vtx_attr_group, primitive, count);
memcpy_gc(VertexManager::s_pCurBufferPointer, Data, native_stride * new_count);
VertexManager::s_pCurBufferPointer += native_stride * new_count;
DataSkip(new_count * m_VertexSize);
VertexManager::AddVertices(primitive, new_count);
}
@ -645,7 +645,7 @@ void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)
m_VtxAttr.texCoord[2].Frac = vat.g1.Tex2Frac;
m_VtxAttr.texCoord[3].Elements = vat.g1.Tex3CoordElements;
m_VtxAttr.texCoord[3].Format = vat.g1.Tex3CoordFormat;
m_VtxAttr.texCoord[3].Frac = vat.g1.Tex3Frac;
m_VtxAttr.texCoord[3].Frac = vat.g1.Tex3Frac;
m_VtxAttr.texCoord[4].Elements = vat.g1.Tex4CoordElements;
m_VtxAttr.texCoord[4].Format = vat.g1.Tex4CoordFormat;

View file

@ -134,6 +134,6 @@ private:
void WriteGetVariable(int bits, Gen::OpArg dest, void *address);
void WriteSetVariable(int bits, void *address, Gen::OpArg dest);
#endif
};
};
#endif

View file

@ -46,7 +46,7 @@ __forceinline float FracAdjust(T val)
//auto const U8FRAC = 1.f / (1u << 7);
//auto const S16FRAC = 1.f / (1u << 14);
//auto const U16FRAC = 1.f / (1u << 15);
// TODO: is this right?
return val / float(1u << (sizeof(T) * 8 - std::numeric_limits<T>::is_signed - 1));
}
@ -64,7 +64,7 @@ __forceinline void ReadIndirect(const T* data)
{
DataWrite(FracAdjust(Common::FromBigEndian(data[i])));
}
LOG_NORM();
}
@ -77,7 +77,7 @@ struct Normal_Direct
ReadIndirect<T, N * 3>(source);
DataSkip<N * 3 * sizeof(T)>();
}
static const int size = sizeof(T) * N * 3;
};
@ -99,7 +99,7 @@ struct Normal_Index
{
Normal_Index_Offset<I, T, N, 0>();
}
static const int size = sizeof(I);
};
@ -112,7 +112,7 @@ struct Normal_Index_Indices3
Normal_Index_Offset<I, T, 1, 1>();
Normal_Index_Offset<I, T, 1, 2>();
}
static const int size = sizeof(I) * 3;
};

View file

@ -25,43 +25,43 @@ class VertexLoader_Normal
{
public:
// Init
static void Init(void);
// Init
static void Init(void);
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format,
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format,
unsigned int _elements, unsigned int _index3);
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type,
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type,
unsigned int _format, unsigned int _elements, unsigned int _index3);
private:
enum ENormalType
{
NRM_NOT_PRESENT = 0,
NRM_DIRECT = 1,
NRM_INDEX8 = 2,
NRM_INDEX16 = 3,
NUM_NRM_TYPE
};
enum ENormalType
{
NRM_NOT_PRESENT = 0,
NRM_DIRECT = 1,
NRM_INDEX8 = 2,
NRM_INDEX16 = 3,
NUM_NRM_TYPE
};
enum ENormalFormat
{
FORMAT_UBYTE = 0,
FORMAT_BYTE = 1,
FORMAT_USHORT = 2,
FORMAT_SHORT = 3,
FORMAT_FLOAT = 4,
NUM_NRM_FORMAT
};
enum ENormalFormat
{
FORMAT_UBYTE = 0,
FORMAT_BYTE = 1,
FORMAT_USHORT = 2,
FORMAT_SHORT = 3,
FORMAT_FLOAT = 4,
NUM_NRM_FORMAT
};
enum ENormalElements
{
NRM_NBT = 0,
NRM_NBT3 = 1,
NUM_NRM_ELEMENTS
};
enum ENormalElements
{
NRM_NBT = 0,
NRM_NBT3 = 1,
NUM_NRM_ELEMENTS
};
enum ENormalIndices
{

View file

@ -87,10 +87,10 @@ template <typename T, int N>
void LOADERDECL Pos_ReadDirect()
{
static_assert(N <= 3, "N > 3 is not sane!");
for (int i = 0; i < 3; ++i)
DataWrite(i<N ? PosScale(DataRead<T>()) : 0.f);
LOG_VTX();
}
@ -99,15 +99,15 @@ void LOADERDECL Pos_ReadIndex()
{
static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
static_assert(N <= 3, "N > 3 is not sane!");
auto const index = DataRead<I>();
if (index < std::numeric_limits<I>::max())
{
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * arraystrides[ARRAY_POSITION]));
for (int i = 0; i < 3; ++i)
DataWrite(i<N ? PosScale(Common::FromBigEndian(data[i])) : 0.f);
LOG_VTX();
}
}

View file

@ -21,14 +21,14 @@
class VertexLoader_Position {
public:
// Init
static void Init(void);
// Init
static void Init(void);
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements);
};
#endif

View file

@ -70,7 +70,7 @@ void LOADERDECL TexCoord_ReadDirect()
DataWrite(TCScale(DataRead<T>()));
LOG_TEX<N>();
++tcIndex;
}
@ -82,10 +82,10 @@ void LOADERDECL TexCoord_ReadIndex()
auto const index = DataRead<I>();
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex]
+ (index * arraystrides[ARRAY_TEXCOORD0 + tcIndex]));
for (int i = 0; i != N; ++i)
DataWrite(TCScale(Common::FromBigEndian(data[i])));
LOG_TEX<N>();
++tcIndex;
}
@ -97,7 +97,7 @@ template <typename I>
void LOADERDECL TexCoord_ReadIndex_Short2_SSE4()
{
static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
// Heavy in ZWW
auto const index = DataRead<I>();
const s32 *pData = (const s32*)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
@ -121,7 +121,7 @@ template <typename I>
void LOADERDECL TexCoord_ReadIndex_Float2_SSSE3()
{
static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
auto const index = DataRead<I>();
const u32 *pData = (const u32 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
GC_ALIGNED128(const __m128i a = _mm_loadl_epi64((__m128i*)pData));

View file

@ -24,18 +24,18 @@ class VertexLoader_TextCoord
{
public:
// Init
static void Init(void);
// Init
static void Init(void);
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetSize
static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetFunction
static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements);
// GetDummyFunction
// GetDummyFunction
// It is important to synchronize tcIndex.
static TPipelineFunction GetDummyFunction();
static TPipelineFunction GetDummyFunction();
};
#endif

View file

@ -103,7 +103,7 @@ void VertexManager::AddVertices(int primitive, u32 numVertices)
ADDSTAT(stats.thisFrame.numPrims, numVertices);
INCSTAT(stats.thisFrame.numPrimitiveJoins);
IndexGenerator::AddIndices(primitive, numVertices);
}
@ -111,14 +111,14 @@ void VertexManager::Flush()
{
if (g_vertex_manager->IsFlushed())
return;
// loading a state will invalidate BP, so check for it
g_video_backend->CheckInvalidState();
VideoFifo_CheckEFBAccess();
g_vertex_manager->vFlush();
g_vertex_manager->ResetBuffer();
}

View file

@ -45,10 +45,10 @@ public:
virtual void DestroyDeviceObjects(){};
protected:
u16* GetTriangleIndexBuffer() { return &TIBuffer[0]; }
u16* GetLineIndexBuffer() { return &LIBuffer[0]; }
u16* GetPointIndexBuffer() { return &PIBuffer[0]; }
u8* GetVertexBuffer() { return &s_pBaseBufferPointer[0]; }
u16* GetTriangleIndexBuffer() { return &TIBuffer[0]; }
u16* GetLineIndexBuffer() { return &LIBuffer[0]; }
u16* GetPointIndexBuffer() { return &PIBuffer[0]; }
u8* GetVertexBuffer() { return &s_pBaseBufferPointer[0]; }
virtual void vDoState(PointerWrap& p) { DoStateShared(p); }
void DoStateShared(PointerWrap& p);

View file

@ -174,7 +174,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans);
bool is_d3d = (ApiType & API_D3D9 || ApiType == API_D3D11);
u32 lightMask = 0;
if (xfregs.numChan.numColorChans > 0)
@ -184,11 +184,11 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
char *p = text;
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
// uniforms
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "layout(std140) uniform VSBlock {\n");
WRITE(p, "%sfloat4 " I_POSNORMALMATRIX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
WRITE(p, "%sfloat4 " I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
WRITE(p, "%sfloat4 " I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS));
@ -198,10 +198,9 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "%sfloat4 " I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES));
WRITE(p, "%sfloat4 " I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES));
WRITE(p, "%sfloat4 " I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS));
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "};\n");
p = GenerateVSOutputStruct(p, components, ApiType);
@ -221,7 +220,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "ATTRIN float4 color0; // ATTR%d,\n", SHADER_COLOR0_ATTRIB);
if (components & VB_HAS_COL1)
WRITE(p, "ATTRIN float4 color1; // ATTR%d,\n", SHADER_COLOR1_ATTRIB);
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
@ -258,8 +257,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
}
else
{
WRITE(p, "VS_OUTPUT main(\n");
WRITE(p, "VS_OUTPUT main(\n");
// inputs
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 : NORMAL0,\n");
@ -335,8 +334,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if (!(components & VB_HAS_NRM0))
WRITE(p, "float3 _norm0 = float3(0.0f, 0.0f, 0.0f);\n");
WRITE(p, "o.pos = float4(dot(" I_PROJECTION"[0], pos), dot(" I_PROJECTION"[1], pos), dot(" I_PROJECTION"[2], pos), dot(" I_PROJECTION"[3], pos));\n");
WRITE(p, "float4 mat, lacc;\n"
@ -506,9 +503,9 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "o.tex7 = pos.xyzz;\n");
else
WRITE(p, "o.tex7.w = pos.z;\n");
}
}
if (components & VB_HAS_COL0)
WRITE(p, "o.colors_0 = color0;\n");
WRITE(p, "o.colors_0 = color0;\n");
if (components & VB_HAS_COL1)
WRITE(p, "o.colors_1 = color1;\n");
@ -522,26 +519,26 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
}
else
{
// this results in a scale from -1..0 to -1..1 after perspective
// divide
WRITE(p, "o.pos.z = o.pos.w + o.pos.z * 2.0f;\n");
// this results in a scale from -1..0 to -1..1 after perspective
// divide
WRITE(p, "o.pos.z = o.pos.w + o.pos.z * 2.0f;\n");
// Sonic Unleashed puts its final rendering at the near or
// far plane of the viewing frustrum(actually box, they use
// orthogonal projection for that), and we end up putting it
// just beyond, and the rendering gets clipped away. (The
// primitive gets dropped)
WRITE(p, "o.pos.z = o.pos.z * 1048575.0f/1048576.0f;\n");
// Sonic Unleashed puts its final rendering at the near or
// far plane of the viewing frustrum(actually box, they use
// orthogonal projection for that), and we end up putting it
// just beyond, and the rendering gets clipped away. (The
// primitive gets dropped)
WRITE(p, "o.pos.z = o.pos.z * 1048575.0f/1048576.0f;\n");
// the next steps of the OGL pipeline are:
// (x_c,y_c,z_c,w_c) = o.pos //switch to OGL spec terminology
// clipping to -w_c <= (x_c,y_c,z_c) <= w_c
// (x_d,y_d,z_d) = (x_c,y_c,z_c)/w_c//perspective divide
// z_w = (f-n)/2*z_d + (n+f)/2
// z_w now contains the value to go to the 0..1 depth buffer
//trying to get the correct semantic while not using glDepthRange
//seems to get rather complicated
// the next steps of the OGL pipeline are:
// (x_c,y_c,z_c,w_c) = o.pos //switch to OGL spec terminology
// clipping to -w_c <= (x_c,y_c,z_c) <= w_c
// (x_d,y_d,z_d) = (x_c,y_c,z_c)/w_c//perspective divide
// z_w = (f-n)/2*z_d + (n+f)/2
// z_w now contains the value to go to the 0..1 depth buffer
//trying to get the correct semantic while not using glDepthRange
//seems to get rather complicated
}
if (ApiType & API_D3D9)
@ -579,7 +576,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " uv%d_2%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
}
}
}
WRITE(p, "colors_02 = o.colors_0;\n");
WRITE(p, "colors_12 = o.colors_1;\n");
WRITE(p, "gl_Position = o.pos;\n");

View file

@ -61,7 +61,7 @@
#define C_NORMALMATRICES (C_TRANSFORMMATRICES + 64)
#define C_POSTTRANSFORMMATRICES (C_NORMALMATRICES + 32)
#define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64)
#define C_VENVCONST_END (C_DEPTHPARAMS + 1)
#define C_VENVCONST_END (C_DEPTHPARAMS + 1)
const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 },
{I_PROJECTION , C_PROJECTION, 4 },
{I_MATERIALS, C_MATERIALS, 4 },

View file

@ -102,7 +102,7 @@ float PHackValue(std::string sValue)
c[i] = (cStr[i] == ',') ? '.' : *(cStr+i);
if (c[i] == '.')
fp = true;
}
}
cStr = c;
sTof.str(cStr);
sTof >> f;
@ -119,22 +119,22 @@ void UpdateProjectionHack(int iPhackvalue[], std::string sPhackvalue[])
float fhacksign1 = 1.0, fhacksign2 = 1.0;
bool bProjHack3 = false;
const char *sTemp[2];
if (iPhackvalue[0] == 1)
{
NOTICE_LOG(VIDEO, "\t\t--- Ortographic Projection Hack ON ---");
fhacksign1 *= (iPhackvalue[1] == 1) ? -1.0f : fhacksign1;
sTemp[0] = (iPhackvalue[1] == 1) ? " * (-1)" : "";
fhacksign2 *= (iPhackvalue[2] == 1) ? -1.0f : fhacksign2;
sTemp[1] = (iPhackvalue[2] == 1) ? " * (-1)" : "";
fhackvalue1 = PHackValue(sPhackvalue[0]);
NOTICE_LOG(VIDEO, "- zNear Correction = (%f + zNear)%s", fhackvalue1, sTemp[0]);
fhackvalue2 = PHackValue(sPhackvalue[1]);
NOTICE_LOG(VIDEO, "- zFar Correction = (%f + zFar)%s", fhackvalue2, sTemp[1]);
sTemp[0] = "DISABLED";
bProjHack3 = (iPhackvalue[3] == 1) ? true : bProjHack3;
if (bProjHack3)
@ -171,22 +171,22 @@ void VertexShaderManager::Dirty()
{
nTransformMatricesChanged[0] = 0;
nTransformMatricesChanged[1] = 256;
nNormalMatricesChanged[0] = 0;
nNormalMatricesChanged[1] = 96;
nPostTransformMatricesChanged[0] = 0;
nPostTransformMatricesChanged[1] = 256;
nLightsChanged[0] = 0;
nLightsChanged[1] = 0x80;
bPosNormalMatrixChanged = true;
bTexMatricesChanged[0] = true;
bTexMatricesChanged[1] = true;
bProjectionChanged = true;
nMaterialsChanged = 15;
}
@ -358,7 +358,7 @@ void VertexShaderManager::SetConstants()
switch(xfregs.projection.type)
{
case GX_PERSPECTIVE:
g_fProjectionMatrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW;
g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = rawProjection[1];
@ -374,7 +374,7 @@ void VertexShaderManager::SetConstants()
g_fProjectionMatrix[10] = rawProjection[4];
g_fProjectionMatrix[11] = rawProjection[5];
g_fProjectionMatrix[12] = 0.0f;
g_fProjectionMatrix[13] = 0.0f;
// donkopunchstania: GC GPU rounds differently?
@ -399,9 +399,9 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]);
break;
case GX_ORTHOGRAPHIC:
g_fProjectionMatrix[0] = rawProjection[0];
g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = 0.0f;
@ -426,10 +426,10 @@ void VertexShaderManager::SetConstants()
this hack was added...setting g_fProjectionMatrix[14] to -1 might make the hack more stable, needs more testing.
Only works for OGL and DX9...this is not helping DX11
*/
g_fProjectionMatrix[14] = 0.0f;
g_fProjectionMatrix[15] = (g_ProjHack3 && rawProjection[0] == 2.0f ? 0.0f : 1.0f); //causes either the efb copy or bloom layer not to show if proj hack enabled
SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]);
SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]);
SETSTAT_FT(stats.g2proj_2, g_fProjectionMatrix[2]);
@ -453,7 +453,7 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.proj_4, rawProjection[4]);
SETSTAT_FT(stats.proj_5, rawProjection[5]);
break;
default:
ERROR_LOG(VIDEO, "unknown projection type: %d", xfregs.projection.type);
}

View file

@ -43,7 +43,7 @@ public:
static void Dirty();
static void Shutdown();
static void DoState(PointerWrap &p);
;
// constant management
static void SetConstants();

View file

@ -52,7 +52,7 @@ void VideoConfig::Load(const char *ini_file)
std::string temp;
IniFile iniFile;
iniFile.Load(ini_file);
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
@ -78,17 +78,17 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle, 0);
iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0);
iniFile.Get("Settings", "HackedBufferUpload", &bHackedBufferUpload, 0);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native
iniFile.Get("Settings", "DstAlphaPass", &bDstAlphaPass, false);
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableFog", &bDisableFog, 0);
iniFile.Get("Settings", "EnableOpenCL", &bEnableOpenCL, false);
iniFile.Get("Settings", "OMPDecoder", &bOMPDecoder, false);
@ -98,7 +98,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 0); // NOTE - this is x in (1 << x)
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
iniFile.Get("Enhancements", "Enable3dVision", &b3DVision, false);
iniFile.Get("Hacks", "EFBAccessEnable", &bEFBAccessEnable, true);
iniFile.Get("Hacks", "DlistCachingEnable", &bDlistCachingEnable,false);
iniFile.Get("Hacks", "EFBCopyEnable", &bEFBCopyEnable, true);
@ -219,14 +219,14 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "EnableOpenCL", bEnableOpenCL);
iniFile.Set("Settings", "OMPDecoder", bOMPDecoder);
iniFile.Set("Settings", "EnableShaderDebugging", bEnableShaderDebugging);
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
iniFile.Set("Enhancements", "Enable3dVision", b3DVision);
iniFile.Set("Hacks", "EFBAccessEnable", bEFBAccessEnable);
iniFile.Set("Hacks", "DlistCachingEnable", bDlistCachingEnable);
iniFile.Set("Hacks", "EFBCopyEnable", bEFBCopyEnable);
@ -237,7 +237,7 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Hacks", "EFBEmulateFormatChanges", bEFBEmulateFormatChanges);
iniFile.Set("Hardware", "Adapter", iAdapter);
iniFile.Save(ini_file);
}

View file

@ -99,12 +99,12 @@ struct VideoConfig
bool bTexFmtOverlayCenter;
bool bShowEFBCopyRegions;
bool bLogFPSToFile;
// Render
bool bWireFrame;
bool bDstAlphaPass;
bool bDisableFog;
// Utility
bool bDumpTextures;
bool bHiresTextures;
@ -164,7 +164,7 @@ struct VideoConfig
bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL
bool bSupportsFormatReinterpretation;
bool bSupportsPixelLighting;
bool bSupportsGLSLUBO;
bool bSupportsGLSLCache;
bool bSupportsGLPinnedMemory;
@ -172,11 +172,11 @@ struct VideoConfig
bool bSupportsGLBaseVertex;
} backend_info;
// Utility
bool RealXFBEnabled() const { return bUseXFB && bUseRealXFB; }
bool VirtualXFBEnabled() const { return bUseXFB && !bUseRealXFB; }
bool EFBCopiesToTextureEnabled() const { return bEFBCopyEnable && bCopyEFBToTexture; }
bool EFBCopiesToRamEnabled() const { return bEFBCopyEnable && !bCopyEFBToTexture; }
// Utility
bool RealXFBEnabled() const { return bUseXFB && bUseRealXFB; }
bool VirtualXFBEnabled() const { return bUseXFB && !bUseRealXFB; }
bool EFBCopiesToTextureEnabled() const { return bEFBCopyEnable && bCopyEFBToTexture; }
bool EFBCopiesToRamEnabled() const { return bEFBCopyEnable && !bCopyEFBToTexture; }
};
extern VideoConfig g_Config;

View file

@ -30,33 +30,33 @@
static void DoState(PointerWrap &p)
{
// BP Memory
p.Do(bpmem);
// BP Memory
p.Do(bpmem);
p.DoMarker("BP Memory");
// CP Memory
p.DoArray(arraybases, 16);
p.DoArray(arraystrides, 16);
p.Do(MatrixIndexA);
p.Do(MatrixIndexB);
p.Do(g_VtxDesc.Hex);
p.DoArray(arraybases, 16);
p.DoArray(arraystrides, 16);
p.Do(MatrixIndexA);
p.Do(MatrixIndexB);
p.Do(g_VtxDesc.Hex);
p.DoArray(g_VtxAttr, 8);
p.DoMarker("CP Memory");
// XF Memory
p.Do(xfregs);
p.DoArray(xfmem, XFMEM_SIZE);
// XF Memory
p.Do(xfregs);
p.DoArray(xfmem, XFMEM_SIZE);
p.DoMarker("XF Memory");
// Texture decoder
p.DoArray(texMem, TMEM_SIZE);
p.DoArray(texMem, TMEM_SIZE);
p.DoMarker("texMem");
// FIFO
Fifo_DoState(p);
// FIFO
Fifo_DoState(p);
p.DoMarker("Fifo");
CommandProcessor::DoState(p);
CommandProcessor::DoState(p);
p.DoMarker("CommandProcessor");
PixelEngine::DoState(p);
@ -77,7 +77,7 @@ static void DoState(PointerWrap &p)
void VideoCommon_DoState(PointerWrap &p)
{
DoState(p);
DoState(p);
}
void VideoCommon_RunLoop(bool enable)

View file

@ -110,70 +110,70 @@
union LitChannel
{
struct
{
u32 matsource : 1;
u32 enablelighting : 1;
u32 lightMask0_3 : 4;
u32 ambsource : 1;
u32 diffusefunc : 2; // LIGHTDIF_X
u32 attnfunc : 2; // LIGHTATTN_X
u32 lightMask4_7 : 4;
};
struct
{
u32 hex : 15;
u32 unused : 17;
};
struct
{
u32 dummy0 : 7;
u32 lightparams : 4;
u32 dummy1 : 21;
};
unsigned int GetFullLightMask() const
{
return enablelighting ? (lightMask0_3 | (lightMask4_7 << 4)) : 0;
}
struct
{
u32 matsource : 1;
u32 enablelighting : 1;
u32 lightMask0_3 : 4;
u32 ambsource : 1;
u32 diffusefunc : 2; // LIGHTDIF_X
u32 attnfunc : 2; // LIGHTATTN_X
u32 lightMask4_7 : 4;
};
struct
{
u32 hex : 15;
u32 unused : 17;
};
struct
{
u32 dummy0 : 7;
u32 lightparams : 4;
u32 dummy1 : 21;
};
unsigned int GetFullLightMask() const
{
return enablelighting ? (lightMask0_3 | (lightMask4_7 << 4)) : 0;
}
};
union INVTXSPEC
{
struct
{
u32 numcolors : 2;
u32 numnormals : 2; // 0 - nothing, 1 - just normal, 2 - normals and binormals
u32 numtextures : 4;
u32 unused : 24;
};
u32 hex;
struct
{
u32 numcolors : 2;
u32 numnormals : 2; // 0 - nothing, 1 - just normal, 2 - normals and binormals
u32 numtextures : 4;
u32 unused : 24;
};
u32 hex;
};
union TexMtxInfo
{
struct
{
u32 unknown : 1;
u32 projection : 1; // XF_TEXPROJ_X
u32 inputform : 2; // XF_TEXINPUT_X
u32 texgentype : 3; // XF_TEXGEN_X
u32 sourcerow : 5; // XF_SRCGEOM_X
u32 embosssourceshift : 3; // what generated texcoord to use
u32 embosslightshift : 3; // light index that is used
};
u32 hex;
struct
{
u32 unknown : 1;
u32 projection : 1; // XF_TEXPROJ_X
u32 inputform : 2; // XF_TEXINPUT_X
u32 texgentype : 3; // XF_TEXGEN_X
u32 sourcerow : 5; // XF_SRCGEOM_X
u32 embosssourceshift : 3; // what generated texcoord to use
u32 embosslightshift : 3; // light index that is used
};
u32 hex;
};
union PostMtxInfo
{
struct
{
u32 index : 6; // base row of dual transform matrix
u32 unused : 2;
u32 normalize : 1; // normalize before send operation
};
u32 hex;
struct
{
u32 index : 6; // base row of dual transform matrix
u32 unused : 2;
u32 normalize : 1; // normalize before send operation
};
u32 hex;
};
union NumColorChannel
@ -207,25 +207,25 @@ union DualTexInfo
struct Light
{
u32 useless[3];
u32 color; //rgba
float a0; //attenuation
float a1;
float a2;
float k0; //k stuff
float k1;
float k2;
union
{
struct {
u32 useless[3];
u32 color; //rgba
float a0; //attenuation
float a1;
float a2;
float k0; //k stuff
float k1;
float k2;
union
{
struct {
float dpos[3];
float ddir[3]; // specular lights only
};
struct {
float sdir[3];
float shalfangle[3]; // specular lights only
};
};
float ddir[3]; // specular lights only
};
struct {
float sdir[3];
float shalfangle[3]; // specular lights only
};
};
};
struct Viewport
@ -246,35 +246,35 @@ struct Projection
struct XFRegisters
{
u32 error; // 0x1000
u32 diag; // 0x1001
u32 state0; // 0x1002
u32 state1; // 0x1003
u32 xfClock; // 0x1004
u32 clipDisable; // 0x1005
u32 perf0; // 0x1006
u32 perf1; // 0x1007
INVTXSPEC hostinfo; // 0x1008 number of textures,colors,normals from vertex input
NumColorChannel numChan; // 0x1009
u32 ambColor[2]; // 0x100a, 0x100b
u32 matColor[2]; // 0x100c, 0x100d
LitChannel color[2]; // 0x100e, 0x100f
LitChannel alpha[2]; // 0x1010, 0x1011
DualTexInfo dualTexTrans; // 0x1012
u32 unk3; // 0x1013
u32 unk4; // 0x1014
u32 unk5; // 0x1015
u32 unk6; // 0x1016
u32 unk7; // 0x1017
u32 MatrixIndexA; // 0x1018
u32 MatrixIndexB; // 0x1019
Viewport viewport; // 0x101a - 0x101f
Projection projection; // 0x1020 - 0x1026
u32 unk8[24]; // 0x1027 - 0x103e
NumTexGen numTexGen; // 0x103f
TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047
u32 unk9[8]; // 0x1048 - 0x104f
PostMtxInfo postMtxInfo[8]; // 0x1050 - 0x1057
u32 error; // 0x1000
u32 diag; // 0x1001
u32 state0; // 0x1002
u32 state1; // 0x1003
u32 xfClock; // 0x1004
u32 clipDisable; // 0x1005
u32 perf0; // 0x1006
u32 perf1; // 0x1007
INVTXSPEC hostinfo; // 0x1008 number of textures,colors,normals from vertex input
NumColorChannel numChan; // 0x1009
u32 ambColor[2]; // 0x100a, 0x100b
u32 matColor[2]; // 0x100c, 0x100d
LitChannel color[2]; // 0x100e, 0x100f
LitChannel alpha[2]; // 0x1010, 0x1011
DualTexInfo dualTexTrans; // 0x1012
u32 unk3; // 0x1013
u32 unk4; // 0x1014
u32 unk5; // 0x1015
u32 unk6; // 0x1016
u32 unk7; // 0x1017
u32 MatrixIndexA; // 0x1018
u32 MatrixIndexB; // 0x1019
Viewport viewport; // 0x101a - 0x101f
Projection projection; // 0x1020 - 0x1026
u32 unk8[24]; // 0x1027 - 0x103e
NumTexGen numTexGen; // 0x103f
TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047
u32 unk9[8]; // 0x1048 - 0x104f
PostMtxInfo postMtxInfo[8]; // 0x1050 - 0x1057
};

View file

@ -36,37 +36,37 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
u32 address = baseAddress;
u32 dataIndex = 0;
while (transferSize > 0 && address < 0x1058)
{
u32 newValue = pData[dataIndex];
while (transferSize > 0 && address < 0x1058)
{
u32 newValue = pData[dataIndex];
u32 nextAddress = address + 1;
switch (address)
{
case XFMEM_ERROR:
case XFMEM_DIAG:
case XFMEM_STATE0: // internal state 0
case XFMEM_STATE1: // internal state 1
case XFMEM_CLOCK:
switch (address)
{
case XFMEM_ERROR:
case XFMEM_DIAG:
case XFMEM_STATE0: // internal state 0
case XFMEM_STATE1: // internal state 1
case XFMEM_CLOCK:
case XFMEM_SETGPMETRIC:
nextAddress = 0x1007;
break;
break;
case XFMEM_CLIPDISABLE:
case XFMEM_CLIPDISABLE:
//if (data & 1) {} // disable clipping detection
//if (data & 2) {} // disable trivial rejection
//if (data & 4) {} // disable cpoly clipping acceleration
break;
break;
case XFMEM_VTXSPECS: //__GXXfVtxSpecs, wrote 0004
break;
case XFMEM_VTXSPECS: //__GXXfVtxSpecs, wrote 0004
break;
case XFMEM_SETNUMCHAN:
case XFMEM_SETNUMCHAN:
if (xfregs.numChan.numColorChans != (newValue & 3))
VertexManager::Flush();
break;
VertexManager::Flush();
break;
case XFMEM_SETCHAN0_AMBCOLOR: // Channel Ambient Color
case XFMEM_SETCHAN0_AMBCOLOR: // Channel Ambient Color
case XFMEM_SETCHAN1_AMBCOLOR:
{
u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR;
@ -75,11 +75,11 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
VertexManager::Flush();
VertexShaderManager::SetMaterialColorChanged(chan);
PixelShaderManager::SetMaterialColorChanged(chan);
}
}
break;
}
case XFMEM_SETCHAN0_MATCOLOR: // Channel Material Color
case XFMEM_SETCHAN0_MATCOLOR: // Channel Material Color
case XFMEM_SETCHAN1_MATCOLOR:
{
u8 chan = address - XFMEM_SETCHAN0_MATCOLOR;
@ -92,28 +92,28 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
break;
}
case XFMEM_SETCHAN0_COLOR: // Channel Color
case XFMEM_SETCHAN0_COLOR: // Channel Color
case XFMEM_SETCHAN1_COLOR:
case XFMEM_SETCHAN0_ALPHA: // Channel Alpha
case XFMEM_SETCHAN1_ALPHA:
case XFMEM_SETCHAN1_ALPHA:
if (((u32*)&xfregs)[address - 0x1000] != (newValue & 0x7fff))
VertexManager::Flush();
VertexManager::Flush();
break;
case XFMEM_DUALTEX:
case XFMEM_DUALTEX:
if (xfregs.dualTexTrans.enabled != (newValue & 1))
VertexManager::Flush();
break;
VertexManager::Flush();
break;
case XFMEM_SETMATRIXINDA:
//_assert_msg_(GX_XF, 0, "XF matrixindex0");
case XFMEM_SETMATRIXINDA:
//_assert_msg_(GX_XF, 0, "XF matrixindex0");
VertexShaderManager::SetTexMatrixChangedA(newValue);
break;
case XFMEM_SETMATRIXINDB:
//_assert_msg_(GX_XF, 0, "XF matrixindex1");
VertexShaderManager::SetTexMatrixChangedB(newValue);
break;
break;
case XFMEM_SETMATRIXINDB:
//_assert_msg_(GX_XF, 0, "XF matrixindex1");
VertexShaderManager::SetTexMatrixChangedB(newValue);
break;
case XFMEM_SETVIEWPORT:
case XFMEM_SETVIEWPORT+1:
@ -135,16 +135,16 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETPROJECTION+4:
case XFMEM_SETPROJECTION+5:
case XFMEM_SETPROJECTION+6:
VertexManager::Flush();
VertexManager::Flush();
VertexShaderManager::SetProjectionChanged();
nextAddress = XFMEM_SETPROJECTION + 7;
break;
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
if (xfregs.numTexGen.numTexGens != (newValue & 15))
VertexManager::Flush();
break;
break;
case XFMEM_SETTEXMTXINFO:
case XFMEM_SETTEXMTXINFO+1:
@ -178,47 +178,47 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
// Maybe these are for Normals?
case 0x1048: //xfregs.texcoords[0].nrmmtxinfo.hex = data; break; ??
case 0x1049:
case 0x104a:
case 0x104b:
case 0x104c:
case 0x104d:
case 0x104e:
case 0x104f:
case 0x1049:
case 0x104a:
case 0x104b:
case 0x104c:
case 0x104d:
case 0x104e:
case 0x104f:
DEBUG_LOG(VIDEO, "Possible Normal Mtx XF reg?: %x=%x\n", address, newValue);
break;
case 0x1013:
case 0x1014:
case 0x1015:
case 0x1016:
case 0x1017:
case 0x1014:
case 0x1015:
case 0x1016:
case 0x1017:
default:
WARN_LOG(VIDEO, "Unknown XF Reg: %x=%x\n", address, newValue);
break;
}
default:
WARN_LOG(VIDEO, "Unknown XF Reg: %x=%x\n", address, newValue);
break;
}
int transferred = nextAddress - address;
address = nextAddress;
transferSize -= transferred;
dataIndex += transferred;
}
}
}
void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
{
// do not allow writes past registers
if (baseAddress + transferSize > 0x1058)
{
INFO_LOG(VIDEO, "xf load exceeds address space: %x %d bytes\n", baseAddress, transferSize);
// do not allow writes past registers
if (baseAddress + transferSize > 0x1058)
{
INFO_LOG(VIDEO, "xf load exceeds address space: %x %d bytes\n", baseAddress, transferSize);
if (baseAddress >= 0x1058)
transferSize = 0;
else
transferSize = 0x1058 - baseAddress;
}
if (baseAddress >= 0x1058)
transferSize = 0;
else
transferSize = 0x1058 - baseAddress;
}
// write to XF mem
if (baseAddress < 0x1000 && transferSize > 0)
@ -247,11 +247,11 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
}
// write to XF regs
if (transferSize > 0)
if (transferSize > 0)
{
XFRegWritten(transferSize, baseAddress, pData);
memcpy_gc((u32*)(&xfregs) + (baseAddress - 0x1000), pData, transferSize * 4);
}
}
}
// TODO - verify that it is correct. Seems to work, though.

View file

@ -111,17 +111,17 @@ struct CachedDisplayList
u32 num_cp_reg;
u32 num_bp_reg;
u32 num_index_xf;
u32 num_draw_call;
u32 num_draw_call;
u32 pass;
u32 check;
int frame_count;
int frame_count;
u32 BufferCount;
void InsertRegion(ReferencedDataRegion* NewRegion)
{
if(LastRegion)
{
LastRegion->NextRegion = NewRegion;
LastRegion->NextRegion = NewRegion;
}
LastRegion = NewRegion;
if(!Regions)
@ -174,7 +174,7 @@ struct CachedDisplayList
Current = Current->NextRegion;
}
return true;
}
}
ReferencedDataRegion* FindOverlapingRegion(u8* RegionStart, u32 Regionsize)
{
@ -182,7 +182,7 @@ struct CachedDisplayList
while(Current)
{
if(!Current->IntersectsMemoryRange(RegionStart, Regionsize))
return Current;
return Current;
Current = Current->NextRegion;
}
return Current;
@ -330,7 +330,7 @@ u32 AnalyzeAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
u32 addr = DataReadU32();
u32 count = DataReadU32();
ExecuteDisplayList(addr, count);
}
}
break;
case GX_CMD_UNKNOWN_METRICS: // zelda 4 swords calls it and checks the metrics registers after that
DEBUG_LOG(VIDEO, "GX 0x44: %08x", cmd_byte);
@ -392,7 +392,7 @@ u32 AnalyzeAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
dl->num_draw_call = num_draw_call;
dl->num_index_xf = num_index_xf;
dl->num_xf_reg = num_xf_reg;
// reset to the old pointer
// reset to the old pointer
g_pVideoData = old_pVideoData;
return result;
}
@ -458,7 +458,7 @@ void CompileAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
NewRegion->MustClean = true;
NewRegion->size = transfer_size * 4;
NewRegion->start_address = (u8*) new u8[NewRegion->size+15+12]; // alignment and guaranteed space
NewRegion->hash = 0;
NewRegion->hash = 0;
dl->InsertRegion(NewRegion);
u32 *data_buffer = (u32*)(u8*)(((size_t)NewRegion->start_address+0xf)&~0xf);
DataReadU32xFuncs[transfer_size-1](data_buffer);
@ -539,7 +539,6 @@ void CompileAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
if (cmd_byte & 0x80)
{
// load vertices (use computed vertex size from FifoCommandRunnable above)
u16 numVertices = DataReadU16();
if(numVertices > 0)
{
@ -558,7 +557,7 @@ void CompileAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
NewRegion->MustClean = true;
NewRegion->size = Vdatasize;
NewRegion->start_address = (u8*)new u8[Vdatasize];
NewRegion->hash = 0;
NewRegion->hash = 0;
dl->InsertRegion(NewRegion);
memcpy(NewRegion->start_address, StartAddress, Vdatasize);
emitter.ABI_CallFunctionCCCP((void *)&VertexLoaderManager::RunCompiledVertices, cmd_byte & GX_VAT_MASK, (cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, numVertices, NewRegion->start_address);
@ -577,7 +576,6 @@ void CompileAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
}
}
}
}
else
{
@ -626,7 +624,7 @@ void Clear()
}
dl_map.clear();
// Reset the cache pointers.
emitter.SetCodePtr(dlcode_cache);
emitter.SetCodePtr(dlcode_cache);
}
void ProgressiveCleanup()
@ -684,14 +682,14 @@ bool HandleDisplayList(u32 address, u32 size)
{
vhash = DLCache::CreateVMapId(Parentiter->second.VATUsed);
iter = Parentiter->second.dl_map.find(vhash);
childexist = iter != Parentiter->second.dl_map.end();
childexist = iter != Parentiter->second.dl_map.end();
}
if (Parentiter != DLCache::dl_map.end() && childexist)
{
DLCache::CachedDisplayList &dl = iter->second;
if (dl.uncachable)
{
return false;
return false;
}
switch (dl.pass)
@ -700,7 +698,7 @@ bool HandleDisplayList(u32 address, u32 size)
// First, check that the hash is the same as the last time.
if (dl.dl_hash != GetHash64(Memory::GetPointer(address), size, 0))
{
dl.uncachable = true;
dl.uncachable = true;
return false;
}
DLCache::CompileAndRunDisplayList(address, size, &dl);
@ -717,7 +715,7 @@ bool HandleDisplayList(u32 address, u32 size)
if (DlistChanged)
{
dl.uncachable = true;
dl.ClearRegions();
dl.ClearRegions();
return false;
}
dl.frame_count= frameCount;
@ -764,10 +762,9 @@ bool HandleDisplayList(u32 address, u32 size)
vdl.VATUsed = dlvatused;
vdl.count = 1;
DLCache::dl_map[dl_id] = vdl;
}
return true;
}
void IncrementCheckContextId()

View file

@ -517,7 +517,7 @@ inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
dst[0] = ((src[0] & 0xFF) << 24) | ((src[0] & 0xFF00)>>8) | (src2[0] << 8);
@ -556,7 +556,7 @@ void decodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
{
int blue3 = ((blue2 - blue1) >> 1) - ((blue2 - blue1) >> 3);
int green3 = ((green2 - green1) >> 1) - ((green2 - green1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3);
colors[2] = makecol(red1 + red3, green1 + green3, blue1 + blue3, 255);
colors[3] = makecol(red2 - red3, green2 - green3, blue2 - blue3, 255);
}
@ -2140,7 +2140,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u32 base = (tBlk * widthBlks + sBlk) * blockWidth * blockHeight;
u16 blkS = s & (blockWidth - 1);
u16 blkT = t & (blockHeight - 1);
u32 blkOff = blkT * blockWidth + blkS;
u32 blkOff = blkT * blockWidth + blkS;
*/
switch (texformat)
@ -2154,9 +2154,9 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 7;
u32 blkOff = (blkT << 3) + blkS;
int rs = (blkOff & 1)?0:4;
u32 offset = base + (blkOff >> 1);
u32 offset = base + (blkOff >> 1);
u8 val = (*(src + offset) >> rs) & 0xF;
u16 *tlut = (u16*)(texMem + tlutaddr);
@ -2166,7 +2166,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -2184,9 +2184,9 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 7;
u32 blkOff = (blkT << 3) + blkS;
int rs = (blkOff & 1)?0:4;
u32 offset = base + (blkOff >> 1);
u32 offset = base + (blkOff >> 1);
u8 val = (*(src + offset) >> rs) & 0xF;
val = Convert4To8(val);
@ -2205,7 +2205,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
dst[0] = val;
dst[1] = val;
@ -2222,7 +2222,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
u16 *tlut = (u16*)(texMem + tlutaddr);
@ -2231,7 +2231,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -2249,7 +2249,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 7;
u16 blkT = t & 3;
u32 blkOff = (blkT << 3) + blkS;
u8 val = *(src + base + blkOff);
const u8 a = Convert4To8(val>>4);
const u8 l = Convert4To8(val&0xF);
@ -2268,7 +2268,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -2284,7 +2284,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -2296,7 +2296,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
case 0:
*((u32*)dst) = decodeIA8Swapped(tlut[val]);
break;
case 1:
case 1:
*((u32*)dst) = decode565RGBA(Common::swap16(tlut[val]));
break;
case 2:
@ -2314,7 +2314,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u16 blkS = s & 3;
u16 blkT = t & 3;
u32 blkOff = (blkT << 2) + blkS;
u32 offset = (base + blkOff) << 1;
const u16* valAddr = (u16*)(src + offset);
@ -2372,7 +2372,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
u32 offset = (base + blkOff) << 3;
const DXTBlock* dxtBlock = (const DXTBlock*)(src + offset);
u16 c1 = Common::swap16(dxtBlock->color1);
u16 c2 = Common::swap16(dxtBlock->color2);
int blue1 = Convert5To8(c1 & 0x1F);
@ -2391,7 +2391,7 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth
colorSel |= c1 > c2?0:4;
u32 color = 0;
switch (colorSel)
{
case 0: