cleanup + some eolz

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5842 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-07-06 13:14:51 +00:00
parent 5133793c6c
commit e9e12ff100
19 changed files with 1117 additions and 1141 deletions

View file

@ -357,8 +357,8 @@ void BPWritten(const BPCmd& bp)
// Bounding Box Control
// -------------------------
case BPMEM_CLEARBBOX1:
case BPMEM_CLEARBBOX2: {
case BPMEM_CLEARBBOX2:
{
#ifdef BBOX_SUPPORT
// which is which? these are GUESSES!
if (bp.address == BPMEM_CLEARBBOX1) {
@ -381,8 +381,8 @@ void BPWritten(const BPCmd& bp)
// WARN_LOG(VIDEO, "ClearBBox TB: %i, %08x - %i, %i", bp.address, bp.newvalue, top, bottom);
}
#endif
break;
}
break;
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue);
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format

View file

@ -83,7 +83,8 @@ sDecoderParameter g_DecodeParametersRGBA[] = {
bool g_Inited = false;
cl_mem g_clsrc, g_cldst; // texture buffer memory objects
void TexDecoder_OpenCL_Initialize() {
void TexDecoder_OpenCL_Initialize()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL
if(!g_Inited)
{
@ -124,7 +125,8 @@ void TexDecoder_OpenCL_Initialize() {
#endif
}
void TexDecoder_OpenCL_Shutdown() {
void TexDecoder_OpenCL_Shutdown()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL && !defined(DEBUG_OPENCL)
clReleaseProgram(g_program);

View file

@ -96,7 +96,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val0|(val1<<10); break;
case 1: pcurvalue[0] |= val0<<20; pcurvalue[1] = val1; pcurvalue++; break;
case 2: pcurvalue[1] |= (val0<<10)|(val1<<20); pcurvalue++; break;
default: PanicAlert("Uknown case for Tev Stages / 2: %08x", (i % 3));
default: PanicAlert("Unknown case for Tev Stages / 2: %08x", (i % 3));
}
}
@ -112,7 +112,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val0; break;
case 1: pcurvalue[0] |= val0 << 20; break;
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
default: PanicAlert("Uknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3);
default: PanicAlert("Unknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3);
}
}
@ -129,7 +129,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val; break;
case 1: pcurvalue[0] |= val << 21; pcurvalue[1] = val >> 11; ++pcurvalue; break;
case 2: pcurvalue[0] |= val << 10; ++pcurvalue; break;
default: PanicAlert("Uknown case for Ind Stages: %08x", (i % 3));
default: PanicAlert("Unknown case for Ind Stages: %08x", (i % 3));
}
}
@ -280,7 +280,7 @@ static const char *tevCInputTable[] = // CC
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(konsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.0f, 0.0f, 0.0f)", // ZERO
"PADERROR", "PADERROR", "PADERROR", "PADERROR",
"PADERROR", "PADERROR", "PADERROR", "PADERROR"
};
static const char *tevAInputTable[] = // CA
@ -454,18 +454,9 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
WRITE(p, "void main(\n");
if(ApiType != API_D3D11)
WRITE(p, " out float4 ocol0 : COLOR0,\n");
WRITE(p, " out float4 ocol0 : COLOR0,\n out float depth : DEPTH,\n in float4 rawpos : POSITION,\n");
else
WRITE(p, " out float4 ocol0 : SV_Target,\n");
if(ApiType != API_D3D11)
WRITE(p, " out float depth : DEPTH,\n");
else
WRITE(p, " out float depth : SV_Depth,\n");
if(ApiType != API_D3D11)
WRITE(p, " in float4 rawpos : POSITION,\n");
else
WRITE(p, " in float4 rawpos : SV_Position,\n");
WRITE(p, " out float4 ocol0 : SV_Target,\n out float depth : SV_Depth,\n in float4 rawpos : SV_Position,\n");
WRITE(p, " in float4 colors_0 : COLOR0,\n");
WRITE(p, " in float4 colors_1 : COLOR1\n");
@ -596,7 +587,6 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
WRITE(p, "zCoord = frac(zCoord);\n");
WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n");
}
WRITE(p, "depth = zCoord;\n");
if (dstAlphaEnable)
@ -608,8 +598,6 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
}
}
WRITE(p, "}\n");
if (text[sizeof(text) - 1] != 0x7C)
PanicAlert("PixelShader generator - buffer too small, canary has been eaten!");
@ -821,7 +809,6 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
RegisterStates[1].AuxStored = true;
}
if(cc.a == TEVCOLORARG_C1
|| cc.a == TEVCOLORARG_A1
|| cc.b == TEVCOLORARG_C1
@ -993,7 +980,8 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
else
WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap);
}
else {
else
{
if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy).%s;\n", destination,texmap,texmap, texcoords, texswap);
else if (ApiType == API_D3D9)
@ -1002,7 +990,8 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap);
}
}
else {
else
{
if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
else
@ -1035,7 +1024,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType)
u32 op = bpmem.alphaFunc.logic;
u32 comp[2] = {bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1};
//first kill all the simple cases
// First kill all the simple cases
switch(op)
{
case 0: // AND

View file

@ -202,9 +202,9 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n");
}
else {
else
{
WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n");
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n");
@ -224,7 +224,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
"float dist, dist2, attn;\n");
// lights/colors
for (int j = 0; j < xfregs.nNumChans; j++) {
for (int j = 0; j < xfregs.nNumChans; j++)
{
// bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused
const LitChannel& color = xfregs.colChans[j].color;
@ -268,7 +269,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
if (alpha.ambsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc.w = color%d.w;\n", j);
else WRITE(p, "lacc.w = 0;\n");
else
WRITE(p, "lacc.w = 0;\n");
}
else // from color
WRITE(p, "lacc.w = "I_MATERIALS".C%d.w;\n", j);
@ -290,6 +292,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
}
}
}
// no shared lights
for (int i = 0; i < 8; ++i)
{
@ -301,14 +304,13 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
}
else if (color.enablelighting || alpha.enablelighting)
{
//ligths are disabled in one channel so proccess only te active
// lights are disabled on one channel so process only the active ones
LitChannel workingchannel = color.enablelighting ? color : alpha;
int coloralpha = color.enablelighting ? 1 : 2;
for (int i = 0; i < 8; ++i)
{
if (workingchannel.GetFullLightMask() & (1<<i))
p = GenerateLightShader(p, i, workingchannel, "lacc", coloralpha);
}
}
@ -320,7 +322,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "o.colors[%d].xyz = mat.xyz;\n"
"o.colors[%d].w = mat.w * saturate(lacc.w);\n", j, j);
}
else {
else
{
if (alpha.enablelighting)
WRITE(p, "o.colors[%d] = mat * saturate(lacc);\n", j);
else
@ -383,7 +386,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
break;
}
// firs transformation
// first transformation
switch (texinfo.texgentype) {
case XF_TEXGEN_EMBOSS_MAP: // calculate tex coords into bump map
@ -436,7 +439,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// multiply by postmatrix
WRITE(p, "o.tex%d.xyz = float3(dot(P0.xy, o.tex%d.xy) + P0.z + P0.w, dot(P1.xy, o.tex%d.xy) + P1.z + P1.w, 0.0f);\n", i, i, i);
}
else {
else
{
if (xfregs.texcoords[i].postmtxinfo.normalize)
WRITE(p, "o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i);
@ -514,7 +518,8 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index);
}
switch (chan.diffusefunc) {
switch (chan.diffusefunc)
{
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;

View file

@ -244,7 +244,7 @@ inline void Draw(unsigned int stride, bool alphapass)
}
UINT bufoffset = 0;
UINT bufstride = (UINT)stride;
UINT bufstride = stride;
if (!alphapass) gfxstate->ApplyState();
else gfxstate->AlphaPass();

View file

@ -92,16 +92,6 @@ bool IsD3D()
return true;
}
bool IsD3D9()
{
return false;
}
bool IsD3D11()
{
return true;
}
// This is used for the functions right below here which use wxwidgets
#if defined(HAVE_WX) && HAVE_WX
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
@ -373,11 +363,6 @@ void Video_AddMessage(const char* pstr, u32 milliseconds)
OSD::AddMessage(pstr, milliseconds);
}
HRESULT ScreenShot(const char* filename)
{
return S_OK;
}
void Video_Screenshot(const char* _szFilename)
{
Renderer::SetScreenshot(_szFilename);

View file

@ -86,16 +86,19 @@ GFXConfigDialogDX::~GFXConfigDialogDX()
{
INFO_LOG(CONSOLE, "GFXConfigDialogDX Closed");
}
void GFXConfigDialogDX::OnClose(wxCloseEvent& event)
{
//INFO_LOG(CONSOLE, "OnClose");
CloseWindow();
}
void GFXConfigDialogDX::CloseClick(wxCommandEvent& WXUNUSED (event))
{
//INFO_LOG(CONSOLE, "CloseClick");
CloseWindow();
}
void GFXConfigDialogDX::InitializeGUIValues()
{
// General Display Settings
@ -151,6 +154,7 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_TexfmtCenter->SetValue(g_Config.bTexFmtOverlayCenter);
m_TexfmtCenter->Enable(m_TexfmtOverlay->IsChecked());
}
void GFXConfigDialogDX::CreateGUIControls()
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
@ -380,6 +384,7 @@ void GFXConfigDialogDX::CreateGUIControls()
Center();
UpdateGUI();
}
void GFXConfigDialogDX::DirectXSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())

View file

@ -162,8 +162,6 @@ class GFXConfigDialogDX : public wxDialog
ID_SHADERERRORS,
ID_TEXFMT_OVERLAY,
ID_TEXFMT_CENTER,
ID_CHECK1,
ID_LIST1,
ID_DEBUGSTEP,
ID_REGISTERS,
ID_ENABLEDEBUGGING,

View file

@ -231,7 +231,6 @@ void SetupDeviceObjects()
// To avoid shader compilation stutters, read back all shaders from cache.
VertexShaderCache::Init();
PixelShaderCache::Init();
// Texture cache will recreate themselves over time.
}
@ -516,7 +515,7 @@ void CheckForResize()
int width = rcParentWindow.right - rcParentWindow.left;
int height = rcParentWindow.bottom - rcParentWindow.top;
if (width != s_backbuffer_width || height != s_backbuffer_height)
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
}
RECT rcWindow;
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
@ -611,7 +610,6 @@ bool Renderer::SetScissorRect()
rc.right = Xstride + s_target_width;
rc.bottom = Ystride + s_target_height;
D3D::dev->SetScissorRect(&rc);
return false;
}
return false;
}
@ -634,13 +632,13 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// Get the working buffer
LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurface() : FBManager.GetEFBColorRTSurface();
//get the temporal buffer to move 1pixel data
// Get the temporal buffer to move 1pixel data
LPDIRECT3DSURFACE9 RBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthReadSurface() : FBManager.GetEFBColorReadSurface();
//get the memory buffer that can be locked
// Get the memory buffer that can be locked
LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthOffScreenRTSurface() : FBManager.GetEFBColorOffScreenRTSurface();
//get the buffer format
// Get the buffer format
D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurfaceFormat() : FBManager.GetEFBColorRTSurfaceFormat();
D3DFORMAT ReadBufferFormat = (type == PEEK_Z || type == POKE_Z) ?
@ -689,7 +687,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.bottom--;
if ((RectToLock.right - RectToLock.left) > 4)
RectToLock.left++;
ResetAPIState(); // reset any game specific settings
ResetAPIState(); // Reset any game specific settings
hr = D3D::dev->SetDepthStencilSurface(NULL);
hr = D3D::dev->SetRenderTarget(0, RBuffer);
if (FAILED(hr))
@ -738,7 +736,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.left = 0;
RectToLock.right = 4;
RectToLock.top = 0;
}
else
{
@ -754,7 +751,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
PanicAlert("Unable to stretch data to buffer");
return 0;
}
//retriebe the pixel data to the local memory buffer
// Retrieve the pixel data to the local memory buffer
D3D::dev->GetRenderTargetData(RBuffer, pOffScreenBuffer);
if (FAILED(hr))
{
@ -764,12 +761,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
//the surface is good.. lock it
// The surface is good.. lock it
if ((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
{
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
return 0;
}
@ -810,11 +805,9 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
break;
}
pOffScreenBuffer->UnlockRect();
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
return z;
}
// Called from VertexShaderManager
@ -893,7 +886,7 @@ void UpdateViewport()
vp.Width = Width;
vp.Height = Height;
//some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
// Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = 0.0f; // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f; // xfregs.rawViewport[5] / 16777216.0f;
D3D::dev->SetViewport(&vp);
@ -913,12 +906,12 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
D3D::dev->SetViewport(&vp);
// Always set the scissor in case it was set by the game and has not been reset
RECT sirc;
sirc.left = targetRc.left;
sirc.top = targetRc.top;
sirc.right = targetRc.right;
sirc.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sirc);
RECT sicr;
sicr.left = targetRc.left;
sicr.top = targetRc.top;
sicr.right = targetRc.right;
sicr.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sicr);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
if (zEnable)
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
@ -1147,7 +1140,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_LastFrameDumped = false;
}
// Finish up the current frame, print some stats
if (g_ActiveConfig.bShowFPS)
{
@ -1192,7 +1184,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
if (s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH;
if (s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT;
if (s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT;
}
u32 newAA = g_ActiveConfig.iMultisampleMode;
@ -1248,7 +1239,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
}
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
}
// ---------------------------------------------------------------------
@ -1298,8 +1288,10 @@ void Renderer::RestoreAPIState()
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
UpdateViewport();
SetScissorRect();
if (bpmem.zmode.testenable) D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable) D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
if (bpmem.zmode.testenable)
D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable)
D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
SetColorMask();
SetLogicOpMode();
}
@ -1368,13 +1360,13 @@ void Renderer::SetSamplerState(int stage, int texindex)
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mip = (tm0.min_filter == 8) ? D3DTEXF_NONE : d3dMipFilters[tm0.min_filter & 3];
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE;
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0))
mip = D3DTEXF_NONE;
}
if (texindex)
stage += 4;
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR &&
g_ActiveConfig.iMaxAnisotropy > 1)
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR && g_ActiveConfig.iMaxAnisotropy > 1)
{
min = D3DTEXF_ANISOTROPIC;
}