mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
More common things moved out from the GFX plugins. No visible changes.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@27 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -279,13 +279,11 @@ union UGQR
|
||||
{
|
||||
unsigned ST_TYPE : 3;
|
||||
unsigned : 5;
|
||||
// signed ST_SCALE : 6;
|
||||
unsigned ST_SCALE : 6;
|
||||
unsigned ST_SCALE : 6;
|
||||
unsigned : 2;
|
||||
unsigned LD_TYPE : 3;
|
||||
unsigned : 5;
|
||||
// signed LD_SCALE : 6;
|
||||
unsigned LD_SCALE : 6;
|
||||
unsigned LD_SCALE : 6;
|
||||
unsigned : 2;
|
||||
};
|
||||
|
||||
|
@ -346,6 +346,7 @@ namespace Jit64
|
||||
js.blockStart = emaddress;
|
||||
js.fifoBytesThisBlock = 0;
|
||||
js.curBlock = &b;
|
||||
js.blockSetsQuantizers = false;
|
||||
|
||||
//Analyze the block, collect all instructions it is made of (including inlining,
|
||||
//if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
||||
|
@ -49,6 +49,7 @@ namespace Jit64
|
||||
int downcountAmount;
|
||||
|
||||
bool isLastInstruction;
|
||||
bool blockSetsQuantizers;
|
||||
|
||||
int fifoBytesThisBlock;
|
||||
|
||||
|
@ -95,12 +95,14 @@ const double m_dequantizeTableD[] =
|
||||
(1 << 4), (1 << 3), (1 << 2), (1 << 1),
|
||||
};
|
||||
|
||||
// The big problem is likely instructions that set the quantizers in the same block.
|
||||
// We will have to break block after quantizers are written to.
|
||||
u32 temp;
|
||||
void psq_st(UGeckoInstruction inst)
|
||||
{
|
||||
BIT32OLD;
|
||||
OLD;
|
||||
if (!Core::GetStartupParameter().bOptimizeQuantizers)
|
||||
if (js.blockSetsQuantizers || !Core::GetStartupParameter().bOptimizeQuantizers)
|
||||
{
|
||||
Default(inst);
|
||||
return;
|
||||
@ -220,7 +222,7 @@ void psq_l(UGeckoInstruction inst)
|
||||
{
|
||||
BIT32OLD;
|
||||
OLD;
|
||||
if (!Core::GetStartupParameter().bOptimizeQuantizers)
|
||||
if (js.blockSetsQuantizers || !Core::GetStartupParameter().bOptimizeQuantizers)
|
||||
{
|
||||
Default(inst);
|
||||
return;
|
||||
@ -296,6 +298,14 @@ void psq_l(UGeckoInstruction inst)
|
||||
ADD(32, gpr.R(inst.RA), Imm32(offset));
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
Dynamic quantizer. Todo when we have a test set.
|
||||
MOVZX(32, 8, EAX, M(((char *)&PowerPC::ppcState.spr[SPR_GQR0 + inst.I]) + 3)); // it's in the high byte.
|
||||
AND(32, R(EAX), Imm8(0x3F));
|
||||
MOV(32, R(ECX), Imm32((u32)&m_dequantizeTableD));
|
||||
MOVDDUP(r, MComplex(RCX, EAX, 8, 0));
|
||||
*/
|
||||
#endif
|
||||
default:
|
||||
// 4 0
|
||||
|
@ -35,15 +35,32 @@ namespace Jit64
|
||||
{
|
||||
case SPR_LR:
|
||||
case SPR_CTR:
|
||||
gpr.Lock(d);
|
||||
gpr.LoadToX64(d,true);
|
||||
MOV(32, M(&PowerPC::ppcState.spr[iIndex]), gpr.R(d));
|
||||
gpr.UnlockAll();
|
||||
// These are safe to do the easy way, see the bottom of this function.
|
||||
break;
|
||||
|
||||
case SPR_GQR0:
|
||||
case SPR_GQR0 + 1:
|
||||
case SPR_GQR0 + 2:
|
||||
case SPR_GQR0 + 3:
|
||||
case SPR_GQR0 + 4:
|
||||
case SPR_GQR0 + 5:
|
||||
case SPR_GQR0 + 6:
|
||||
case SPR_GQR0 + 7:
|
||||
js.blockSetsQuantizers = false;
|
||||
// Prevent recompiler from compiling in old quantizer values.
|
||||
// TODO - actually save the set state and use it in following quantizer ops.
|
||||
break;
|
||||
// TODO - break block if quantizers are written to.
|
||||
default:
|
||||
Default(inst);
|
||||
return;
|
||||
}
|
||||
|
||||
// OK, this is easy.
|
||||
gpr.Lock(d);
|
||||
gpr.LoadToX64(d,true);
|
||||
MOV(32, M(&PowerPC::ppcState.spr[iIndex]), gpr.R(d));
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
|
||||
void mfspr(UGeckoInstruction inst)
|
||||
|
27
Source/Core/VideoCommon/Src/LookUpTables.cpp
Normal file
27
Source/Core/VideoCommon/Src/LookUpTables.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "LookUpTables.h"
|
||||
|
||||
int lut3to8[8];
|
||||
int lut4to8[16];
|
||||
int lut5to8[32];
|
||||
int lut6to8[64];
|
||||
float lutu8tosfloat[256];
|
||||
float lutu8toufloat[256];
|
||||
float luts8tosfloat[256];
|
||||
|
||||
void InitLUTs()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
lut3to8[i] = (i*255) / 7;
|
||||
for (int i = 0; i < 16; i++)
|
||||
lut4to8[i] = (i*255) / 15;
|
||||
for (int i = 0; i < 32; i++)
|
||||
lut5to8[i] = (i*255) / 31;
|
||||
for (int i = 0; i < 64; i++)
|
||||
lut6to8[i] = (i*255) / 63;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
lutu8tosfloat[i] = (float)(i-128) / 127.0f;
|
||||
lutu8toufloat[i] = (float)(i) / 255.0f;
|
||||
luts8tosfloat[i] = ((float)(signed char)(char)i) / 127.0f;
|
||||
}
|
||||
}
|
16
Source/Core/VideoCommon/Src/LookUpTables.h
Normal file
16
Source/Core/VideoCommon/Src/LookUpTables.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LOOKUPTABLES_H
|
||||
#define _LOOKUPTABLES_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
extern int lut3to8[8];
|
||||
extern int lut4to8[16];
|
||||
extern int lut5to8[32];
|
||||
extern int lut6to8[64];
|
||||
extern float lutu8tosfloat[256];
|
||||
extern float lutu8toufloat[256];
|
||||
extern float luts8tosfloat[256];
|
||||
|
||||
void InitLUTs();
|
||||
|
||||
#endif
|
4
Source/Core/VideoCommon/Src/XFMemory.cpp
Normal file
4
Source/Core/VideoCommon/Src/XFMemory.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "XFMemory.h"
|
||||
|
||||
XFRegisters xfregs;
|
||||
u32 xfmem[XFMEM_SIZE];
|
218
Source/Core/VideoCommon/Src/XFMemory.h
Normal file
218
Source/Core/VideoCommon/Src/XFMemory.h
Normal file
@ -0,0 +1,218 @@
|
||||
#ifndef _XFMEMORY_H
|
||||
#define _XFMEMORY_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
/////////////
|
||||
// Lighting
|
||||
/////////////
|
||||
|
||||
#define XF_TEXPROJ_ST 0
|
||||
#define XF_TEXPROJ_STQ 1
|
||||
|
||||
#define XF_TEXINPUT_AB11 0
|
||||
#define XF_TEXINPUT_ABC1 1
|
||||
|
||||
#define XF_TEXGEN_REGULAR 0
|
||||
#define XF_TEXGEN_EMBOSS_MAP 1 // used when bump mapping
|
||||
#define XF_TEXGEN_COLOR_STRGBC0 2
|
||||
#define XF_TEXGEN_COLOR_STRGBC1 3
|
||||
|
||||
#define XF_SRCGEOM_INROW 0 // input is abc
|
||||
#define XF_SRCNORMAL_INROW 1 // input is abc
|
||||
#define XF_SRCCOLORS_INROW 2
|
||||
#define XF_SRCBINORMAL_T_INROW 3 // input is abc
|
||||
#define XF_SRCBINORMAL_B_INROW 4 // input is abc
|
||||
#define XF_SRCTEX0_INROW 5
|
||||
#define XF_SRCTEX1_INROW 6
|
||||
#define XF_SRCTEX2_INROW 7
|
||||
#define XF_SRCTEX3_INROW 8
|
||||
#define XF_SRCTEX4_INROW 9
|
||||
#define XF_SRCTEX5_INROW 10
|
||||
#define XF_SRCTEX6_INROW 11
|
||||
#define XF_SRCTEX7_INROW 12
|
||||
|
||||
#define GX_SRC_REG 0
|
||||
#define GX_SRC_VTX 1
|
||||
|
||||
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 {
|
||||
float dpos[3];
|
||||
float ddir[3]; // specular lights only
|
||||
};
|
||||
struct {
|
||||
float sdir[3];
|
||||
float shalfangle[3]; // specular lights only
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#define LIGHTDIF_NONE 0
|
||||
#define LIGHTDIF_SIGN 1
|
||||
#define LIGHTDIF_CLAMP 2
|
||||
|
||||
#define LIGHTATTN_SPEC 0 // specular attenuation
|
||||
#define LIGHTATTN_SPOT 1 // distance/spotlight attenuation
|
||||
#define LIGHTATTN_NONE 2
|
||||
#define LIGHTATTN_DIR 3
|
||||
|
||||
union LitChannel
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned matsource : 1;
|
||||
unsigned enablelighting : 1;
|
||||
unsigned lightMask0_3 : 4;
|
||||
unsigned ambsource : 1;
|
||||
unsigned diffusefunc : 2; // LIGHTDIF_X
|
||||
unsigned attnfunc : 2; // LIGHTATTN_X
|
||||
unsigned 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 ColorChannel
|
||||
{
|
||||
u32 ambColor;
|
||||
u32 matColor;
|
||||
LitChannel color;
|
||||
LitChannel alpha;
|
||||
};
|
||||
|
||||
union INVTXSPEC
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned numcolors : 2;
|
||||
unsigned numnormals : 2; // 0 - nothing, 1 - just normal, 2 - normals and binormals
|
||||
unsigned numtextures : 4;
|
||||
unsigned unused : 24;
|
||||
};
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
union TexMtxInfo
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned unknown : 1;
|
||||
unsigned projection : 1; // XF_TEXPROJ_X
|
||||
unsigned inputform : 2; // XF_TEXINPUT_X
|
||||
unsigned texgentype : 3; // XF_TEXGEN_X
|
||||
unsigned sourcerow : 5; // XF_SRCGEOM_X
|
||||
unsigned embosssourceshift : 3; // what generated texcoord to use
|
||||
unsigned embosslightshift : 3; // light index that is used
|
||||
};
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
union PostMtxInfo
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned index : 6; // base row of dual transform matrix
|
||||
unsigned unused : 2;
|
||||
unsigned normalize : 1; // normalize before send operation
|
||||
};
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
struct TexCoordInfo
|
||||
{
|
||||
TexMtxInfo texmtxinfo;
|
||||
PostMtxInfo postmtxinfo;
|
||||
};
|
||||
|
||||
struct XFRegisters
|
||||
{
|
||||
int numTexGens;
|
||||
int nNumChans;
|
||||
INVTXSPEC hostinfo; // number of textures,colors,normals from vertex input
|
||||
ColorChannel colChans[2]; //C0A0 C1A1
|
||||
TexCoordInfo texcoords[8];
|
||||
bool bEnableDualTexTransform;
|
||||
};
|
||||
|
||||
#define XFMEM_SIZE 0x8000
|
||||
#define XFMEM_POSMATRICES 0x000
|
||||
#define XFMEM_POSMATRICES_END 0x100
|
||||
#define XFMEM_NORMALMATRICES 0x400
|
||||
#define XFMEM_NORMALMATRICES_END 0x460
|
||||
#define XFMEM_POSTMATRICES 0x500
|
||||
#define XFMEM_POSTMATRICES_END 0x600
|
||||
#define XFMEM_LIGHTS 0x600
|
||||
#define XFMEM_LIGHTS_END 0x680
|
||||
|
||||
// Matrix indices
|
||||
union TMatrixIndexA
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned PosNormalMtxIdx : 6;
|
||||
unsigned Tex0MtxIdx : 6;
|
||||
unsigned Tex1MtxIdx : 6;
|
||||
unsigned Tex2MtxIdx : 6;
|
||||
unsigned Tex3MtxIdx : 6;
|
||||
};
|
||||
struct
|
||||
{
|
||||
u32 Hex : 30;
|
||||
u32 unused : 2;
|
||||
};
|
||||
};
|
||||
|
||||
union TMatrixIndexB
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned Tex4MtxIdx : 6;
|
||||
unsigned Tex5MtxIdx : 6;
|
||||
unsigned Tex6MtxIdx : 6;
|
||||
unsigned Tex7MtxIdx : 6;
|
||||
};
|
||||
struct
|
||||
{
|
||||
u32 Hex : 24;
|
||||
u32 unused : 8;
|
||||
};
|
||||
};
|
||||
|
||||
struct Viewport
|
||||
{
|
||||
float wd;
|
||||
float ht;
|
||||
float nearZ;
|
||||
float xOrig;
|
||||
float yOrig;
|
||||
float farZ;
|
||||
};
|
||||
|
||||
extern XFRegisters xfregs;
|
||||
extern u32 xfmem[XFMEM_SIZE];
|
||||
|
||||
#endif
|
@ -405,6 +405,22 @@
|
||||
RelativePath=".\Src\CPMemory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\LookUpTables.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\LookUpTables.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XFMemory.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XFMemory.h"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
Reference in New Issue
Block a user