diff options
| author | Matthew Parlane <parlane@gmail.com> | 2013-04-11 19:55:36 +1200 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2013-04-11 19:55:36 +1200 |
| commit | 0c9d8d34e1307433e27435c7d2f84557fd563752 (patch) | |
| tree | 70bc214fe520abc14e64d1a78cafffe178ae239c /Source/Core/VideoCommon | |
| parent | 7784fa4c67cc8d2545f45694d83805e7e89cd583 (diff) | |
| parent | 3c87512180decf6b0aae9402a2179c73674ef5d8 (diff) | |
Merge branch 'master' into wii-network
Conflicts:
Source/Core/Core/CMakeLists.txt
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/BPMemory.h | 11 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/CommandProcessor.cpp | 62 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/EmuWindow.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/HiresTextures.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelEngine.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 36 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderManager.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/RenderBase.cpp | 22 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexLoader.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexLoaderManager.cpp | 43 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexManagerBase.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 22 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderManager.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoConfig.cpp | 30 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoConfig.h | 14 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/XFStructs.cpp | 2 |
17 files changed, 162 insertions, 120 deletions
diff --git a/Source/Core/VideoCommon/Src/BPMemory.h b/Source/Core/VideoCommon/Src/BPMemory.h index 1a29439b36..f0d0a502ed 100644 --- a/Source/Core/VideoCommon/Src/BPMemory.h +++ b/Source/Core/VideoCommon/Src/BPMemory.h @@ -621,6 +621,17 @@ union X10Y10 // Framebuffer/pixel stuff (incl fog) +#define GX_BL_ZERO 0 +#define GX_BL_ONE 1 +#define GX_BL_SRCCLR 2 // for dst factor +#define GX_BL_INVSRCCLR 3 // for dst factor +#define GX_BL_SRCALPHA 4 +#define GX_BL_INVSRCALPHA 5 +#define GX_BL_DSTALPHA 6 +#define GX_BL_INVDSTALPHA 7 +#define GX_BL_DSTCLR GX_BL_SRCCLR // for src factor +#define GX_BL_INVDSTCLR GX_BL_INVSRCCLR // for src factor + union BlendMode { struct diff --git a/Source/Core/VideoCommon/Src/CommandProcessor.cpp b/Source/Core/VideoCommon/Src/CommandProcessor.cpp index dacec67823..733c99df69 100644 --- a/Source/Core/VideoCommon/Src/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/Src/CommandProcessor.cpp @@ -80,9 +80,9 @@ void UpdateInterrupts_Wrapper(u64 userdata, int cyclesLate) void DoState(PointerWrap &p) { - p.Do(m_CPStatusReg); - p.Do(m_CPCtrlReg); - p.Do(m_CPClearReg); + p.DoPOD(m_CPStatusReg); + p.DoPOD(m_CPCtrlReg); + p.DoPOD(m_CPClearReg); p.Do(m_bboxleft); p.Do(m_bboxtop); p.Do(m_bboxright); @@ -185,7 +185,7 @@ void Read16(u16& _rReturnValue, const u32 _Address) _rReturnValue = ReadLow (fifo.CPEnd - fifo.SafeCPReadPointer + fifo.CPWritePointer - fifo.CPBase + 32); else _rReturnValue = ReadLow (fifo.CPReadWriteDistance); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_RW_DISTANCE_LO : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_RW_DISTANCE_LO : %04x", _rReturnValue); return; case FIFO_RW_DISTANCE_HI: if (IsOnThread()) @@ -195,29 +195,29 @@ void Read16(u16& _rReturnValue, const u32 _Address) _rReturnValue = ReadHigh (fifo.CPEnd - fifo.SafeCPReadPointer + fifo.CPWritePointer - fifo.CPBase + 32); else _rReturnValue = ReadHigh(fifo.CPReadWriteDistance); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_RW_DISTANCE_HI : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_RW_DISTANCE_HI : %04x", _rReturnValue); return; case FIFO_WRITE_POINTER_LO: _rReturnValue = ReadLow (fifo.CPWritePointer); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_WRITE_POINTER_LO : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_WRITE_POINTER_LO : %04x", _rReturnValue); return; case FIFO_WRITE_POINTER_HI: _rReturnValue = ReadHigh(fifo.CPWritePointer); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_WRITE_POINTER_HI : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_WRITE_POINTER_HI : %04x", _rReturnValue); return; case FIFO_READ_POINTER_LO: if (IsOnThread()) _rReturnValue = ReadLow (fifo.SafeCPReadPointer); else _rReturnValue = ReadLow (fifo.CPReadPointer); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_READ_POINTER_LO : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_READ_POINTER_LO : %04x", _rReturnValue); return; case FIFO_READ_POINTER_HI: if (IsOnThread()) _rReturnValue = ReadHigh (fifo.SafeCPReadPointer); else _rReturnValue = ReadHigh (fifo.CPReadPointer); - DEBUG_LOG(COMMANDPROCESSOR, "read FIFO_READ_POINTER_HI : %04x", _rReturnValue); + DEBUG_LOG(COMMANDPROCESSOR, "Read FIFO_READ_POINTER_HI : %04x", _rReturnValue); return; case FIFO_BP_LO: _rReturnValue = ReadLow (fifo.CPBreakpoint); return; @@ -326,83 +326,83 @@ void Write16(const u16 _Value, const u32 _Address) { UCPClearReg tmpCtrl(_Value); m_CPClearReg.Hex = tmpCtrl.Hex; - DEBUG_LOG(COMMANDPROCESSOR,"\t write to CLEAR_REGISTER : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to CLEAR_REGISTER : %04x", _Value); SetCpClearRegister(); } break; case PERF_SELECT: // Seems to select which set of perf registers should be exposed. - DEBUG_LOG(COMMANDPROCESSOR, "write to PERF_SELECT: %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR, "Write to PERF_SELECT: %04x", _Value); break; // Fifo Registers case FIFO_TOKEN_REGISTER: m_tokenReg = _Value; - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_TOKEN_REGISTER : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_TOKEN_REGISTER : %04x", _Value); break; case FIFO_BASE_LO: WriteLow ((u32 &)fifo.CPBase, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_BASE_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_BASE_LO : %04x", _Value); break; case FIFO_BASE_HI: WriteHigh((u32 &)fifo.CPBase, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_BASE_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_BASE_HI : %04x", _Value); break; case FIFO_END_LO: WriteLow ((u32 &)fifo.CPEnd, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_END_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_END_LO : %04x", _Value); break; case FIFO_END_HI: WriteHigh((u32 &)fifo.CPEnd, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_END_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_END_HI : %04x", _Value); break; case FIFO_WRITE_POINTER_LO: WriteLow ((u32 &)fifo.CPWritePointer, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_WRITE_POINTER_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_WRITE_POINTER_LO : %04x", _Value); break; case FIFO_WRITE_POINTER_HI: WriteHigh((u32 &)fifo.CPWritePointer, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_WRITE_POINTER_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_WRITE_POINTER_HI : %04x", _Value); break; case FIFO_READ_POINTER_LO: WriteLow ((u32 &)fifo.CPReadPointer, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_READ_POINTER_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_READ_POINTER_LO : %04x", _Value); break; case FIFO_READ_POINTER_HI: WriteHigh((u32 &)fifo.CPReadPointer, _Value); fifo.SafeCPReadPointer = fifo.CPReadPointer; - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_READ_POINTER_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_READ_POINTER_HI : %04x", _Value); break; case FIFO_HI_WATERMARK_LO: WriteLow ((u32 &)fifo.CPHiWatermark, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_HI_WATERMARK_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_HI_WATERMARK_LO : %04x", _Value); break; case FIFO_HI_WATERMARK_HI: WriteHigh((u32 &)fifo.CPHiWatermark, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_HI_WATERMARK_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_HI_WATERMARK_HI : %04x", _Value); break; case FIFO_LO_WATERMARK_LO: WriteLow ((u32 &)fifo.CPLoWatermark, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_LO_WATERMARK_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_LO_WATERMARK_LO : %04x", _Value); break; case FIFO_LO_WATERMARK_HI: WriteHigh((u32 &)fifo.CPLoWatermark, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"\t write to FIFO_LO_WATERMARK_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"\t Write to FIFO_LO_WATERMARK_HI : %04x", _Value); break; case FIFO_BP_LO: WriteLow ((u32 &)fifo.CPBreakpoint, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"write to FIFO_BP_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"Write to FIFO_BP_LO : %04x", _Value); break; case FIFO_BP_HI: WriteHigh((u32 &)fifo.CPBreakpoint, _Value); - DEBUG_LOG(COMMANDPROCESSOR,"write to FIFO_BP_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"Write to FIFO_BP_HI : %04x", _Value); break; case FIFO_RW_DISTANCE_HI: @@ -417,11 +417,11 @@ void Write16(const u16 _Value, const u32 _Address) ResetVideoBuffer(); } IncrementCheckContextId(); - DEBUG_LOG(COMMANDPROCESSOR,"try to write to FIFO_RW_DISTANCE_HI : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"Try to write to FIFO_RW_DISTANCE_HI : %04x", _Value); break; case FIFO_RW_DISTANCE_LO: WriteLow((u32 &)fifo.CPReadWriteDistance, _Value & 0xFFE0); - DEBUG_LOG(COMMANDPROCESSOR,"try to write to FIFO_RW_DISTANCE_LO : %04x", _Value); + DEBUG_LOG(COMMANDPROCESSOR,"Try to write to FIFO_RW_DISTANCE_LO : %04x", _Value); break; default: @@ -453,7 +453,7 @@ void STACKALIGN GatherPipeBursted() RunGpu(); else { - // In multibuffer mode is not allowed write in the same fifo attached to the GPU. + // In multibuffer mode is not allowed write in the same FIFO attached to the GPU. // Fix Pokemon XD in DC mode. if((ProcessorInterface::Fifo_CPUEnd == fifo.CPEnd) && (ProcessorInterface::Fifo_CPUBase == fifo.CPBase) && fifo.CPReadWriteDistance > 0) @@ -469,7 +469,7 @@ void STACKALIGN GatherPipeBursted() if (IsOnThread()) SetCpStatus(true); - // update the fifo-pointer + // update the fifo pointer if (fifo.CPWritePointer >= fifo.CPEnd) fifo.CPWritePointer = fifo.CPBase; else @@ -481,7 +481,7 @@ void STACKALIGN GatherPipeBursted() RunGpu(); _assert_msg_(COMMANDPROCESSOR, fifo.CPReadWriteDistance <= fifo.CPEnd - fifo.CPBase, - "FIFO is overflown by GatherPipe !\nCPU thread is too fast!"); + "FIFO is overflowed by GatherPipe !\nCPU thread is too fast!"); // check if we are in sync _assert_msg_(COMMANDPROCESSOR, fifo.CPWritePointer == ProcessorInterface::Fifo_CPUWritePointer, "FIFOs linked but out of sync"); diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp index bf9da4190b..8952432789 100644 --- a/Source/Core/VideoCommon/Src/EmuWindow.cpp +++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp @@ -247,7 +247,7 @@ void OSDMenu(WPARAM wParam) OSDChoice = 1; // Toggle native resolution g_Config.iEFBScale = g_Config.iEFBScale + 1; - if (g_Config.iEFBScale > 7) g_Config.iEFBScale = 0; + if (g_Config.iEFBScale > SCALE_4X) g_Config.iEFBScale = SCALE_AUTO; break; case '4': OSDChoice = 2; diff --git a/Source/Core/VideoCommon/Src/HiresTextures.cpp b/Source/Core/VideoCommon/Src/HiresTextures.cpp index 5a3fb051c3..0207bc021c 100644 --- a/Source/Core/VideoCommon/Src/HiresTextures.cpp +++ b/Source/Core/VideoCommon/Src/HiresTextures.cpp @@ -148,7 +148,7 @@ PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned in break; } - INFO_LOG(VIDEO, "loading custom texture from %s", textureMap[key].c_str()); + INFO_LOG(VIDEO, "Loading custom texture from %s", textureMap[key].c_str()); cleanup: SOIL_free_image_data(temp); return returnTex; diff --git a/Source/Core/VideoCommon/Src/PixelEngine.cpp b/Source/Core/VideoCommon/Src/PixelEngine.cpp index b014148d8d..348b704f5b 100644 --- a/Source/Core/VideoCommon/Src/PixelEngine.cpp +++ b/Source/Core/VideoCommon/Src/PixelEngine.cpp @@ -137,7 +137,7 @@ void DoState(PointerWrap &p) p.Do(m_DstAlphaConf); p.Do(m_AlphaModeConf); p.Do(m_AlphaRead); - p.Do(m_Control); + p.DoPOD(m_Control); p.Do(g_bSignalTokenInterrupt); p.Do(g_bSignalFinishInterrupt); diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index d863a6e0a9..93f328fb61 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -390,7 +390,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 - ///aded extra values to map clamped values + ///added extra values to map clamped values "(cprev.rgb)", // CPREV, "(cprev.aaa)", // APREV, "(cc0.rgb)", // C0, @@ -598,9 +598,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType if (ApiType == API_OPENGL) { - WRITE(p, "out float4 ocol0;\n"); + WRITE(p, "COLOROUT(ocol0)\n"); if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) - WRITE(p, "out float4 ocol1;\n"); + WRITE(p, "COLOROUT(ocol1)\n"); if (per_pixel_depth) WRITE(p, "#define depth gl_FragDepth\n"); @@ -668,17 +668,20 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType per_pixel_depth ? "\n out float depth : SV_Depth," : ""); } - WRITE(p, " in float4 colors_0 : COLOR0,\n"); - WRITE(p, " in float4 colors_1 : COLOR1"); + // "centroid" attribute is only supported by D3D11 + const char* optCentroid = (ApiType == API_D3D11 ? "centroid" : ""); + + WRITE(p, " in %s float4 colors_0 : COLOR0,\n", optCentroid); + WRITE(p, " in %s float4 colors_1 : COLOR1", optCentroid); // compute window position if needed because binding semantic WPOS is not widely supported if (numTexgen < 7) { for (int i = 0; i < numTexgen; ++i) - WRITE(p, ",\n in float3 uv%d : TEXCOORD%d", i, i); - WRITE(p, ",\n in float4 clipPos : TEXCOORD%d", numTexgen); + WRITE(p, ",\n in %s float3 uv%d : TEXCOORD%d", optCentroid, i, i); + WRITE(p, ",\n in %s float4 clipPos : TEXCOORD%d", optCentroid, numTexgen); if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) - WRITE(p, ",\n in float4 Normal : TEXCOORD%d", numTexgen + 1); + WRITE(p, ",\n in %s float4 Normal : TEXCOORD%d", optCentroid, numTexgen + 1); WRITE(p, " ) {\n"); } else @@ -844,12 +847,21 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType WRITE(p, "\tocol0 = prev;\n"); } - // On D3D11, use dual-source color blending to perform dst alpha in a + // Use dual-source color blending to perform dst alpha in a // single pass if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) { - // Colors will be blended against the alpha from ocol1... - WRITE(p, "\tocol1 = prev;\n"); + if(ApiType & API_D3D9) + { + // alpha component must be 0 or the shader will not compile (Direct3D 9Ex restriction) + // Colors will be blended against the color from ocol1 in D3D 9... + WRITE(p, "\tocol1 = float4(prev.a, prev.a, prev.a, 0.0f);\n"); + } + else + { + // Colors will be blended against the alpha from ocol1... + WRITE(p, "\tocol1 = prev;\n"); + } // ...and the alpha from ocol0 will be written to the framebuffer. WRITE(p, "\tocol0.a = " I_ALPHA"[0].a;\n"); } @@ -1324,7 +1336,7 @@ static void WriteFog(char *&p) // x_adjust = sqrt((x-center)^2 + k^2)/k // ze *= x_adjust - //this is complitly teorical as the real hard seems to use a table intead of calculate the values. + //this is completely theoretical as the real hardware seems to use a table instead of calculating the values. if (bpmem.fogRange.Base.Enabled) { WRITE (p, "\tfloat x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n"); diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp index ad84f6876e..265bebf991 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp @@ -245,14 +245,14 @@ void PixelShaderManager::SetConstants() { //bpmem.fogRange.Base.Center : center of the viewport in x axis. observation: bpmem.fogRange.Base.Center = realcenter + 342; int center = ((u32)bpmem.fogRange.Base.Center) - 342; - // normalice center to make calculations easy + // normalize center to make calculations easy float ScreenSpaceCenter = center / (2.0f * xfregs.viewport.wd); ScreenSpaceCenter = (ScreenSpaceCenter * 2.0f) - 1.0f; - //bpmem.fogRange.K seems to be a table of precalculated coeficients for the adjust factor - //observations: bpmem.fogRange.K[0].LO apears to be the lowest value and bpmem.fogRange.K[4].HI the largest - // they always seems to be larger than 256 so my teory is : - // they are the coeficients from the center to th e border of the screen - // so to simplify i use the hi coeficient as K in the shader taking 256 as the scale + //bpmem.fogRange.K seems to be a table of precalculated coefficients for the adjust factor + //observations: bpmem.fogRange.K[0].LO appears to be the lowest value and bpmem.fogRange.K[4].HI the largest + // they always seems to be larger than 256 so my theory is : + // they are the coefficients from the center to the border of the screen + // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale SetPSConstant4f(C_FOG + 2, ScreenSpaceCenter, (float)Renderer::EFBToScaledX((int)(2.0f * xfregs.viewport.wd)), bpmem.fogRange.K[4].HI / 256.0f,0.0f); } else diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp index 90a09aec43..652a613b2a 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.cpp +++ b/Source/Core/VideoCommon/Src/RenderBase.cpp @@ -144,7 +144,7 @@ int Renderer::EFBToScaledX(int x) { switch (g_ActiveConfig.iEFBScale) { - case 0: // fractional + case SCALE_AUTO: // fractional return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbWidth(x, s_backbuffer_width); default: @@ -156,7 +156,7 @@ int Renderer::EFBToScaledY(int y) { switch (g_ActiveConfig.iEFBScale) { - case 0: // fractional + case SCALE_AUTO: // fractional return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbHeight(y, s_backbuffer_height); default: @@ -166,7 +166,7 @@ int Renderer::EFBToScaledY(int y) void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY) { - if (g_ActiveConfig.iEFBScale == 0 || g_ActiveConfig.iEFBScale == 1) + if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL) { scaledX = x; scaledY = y; @@ -283,28 +283,28 @@ void Renderer::DrawDebugText() const char* res_text = ""; switch (g_ActiveConfig.iEFBScale) { - case 0: + case SCALE_AUTO: res_text = "Auto (fractional)"; break; - case 1: + case SCALE_AUTO_INTEGRAL: res_text = "Auto (integral)"; break; - case 2: + case SCALE_1X: res_text = "Native"; break; - case 3: + case SCALE_1_5X: res_text = "1.5x"; break; - case 4: + case SCALE_2X: res_text = "2x"; break; - case 5: + case SCALE_2_5X: res_text = "2.5x"; break; - case 6: + case SCALE_3X: res_text = "3x"; break; - case 7: + case SCALE_4X: res_text = "4x"; break; } diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 5a81c9e7d5..314be94355 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -105,8 +105,8 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) if (ApiType == API_OPENGL) { - WRITE(p, " out float4 ocol0;\n"); - WRITE(p, " in float2 uv0;\n"); + WRITE(p, " COLOROUT(ocol0)\n"); + WRITE(p, " VARYIN float2 uv0;\n"); WRITE(p, "void main()\n"); } else @@ -187,7 +187,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) if (ApiType == API_OPENGL) { WRITE(p, " out float4 ocol0;\n"); - WRITE(p, " in float2 uv0;\n"); + WRITE(p, " VARYIN float2 uv0;\n"); WRITE(p, "void main()\n"); } else diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 5df495a44c..d1e8b14e8a 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -227,7 +227,7 @@ void VertexLoader::CompileVertexTranslator() #ifdef USE_JIT if (m_compiledCode) - PanicAlert("trying to recompile a vtx translator"); + PanicAlert("Trying to recompile a vtx translator"); m_compiledCode = GetCodePtr(); ABI_EmitPrologue(4); diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp index 153e69a8c3..01db9f647c 100644 --- a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp @@ -16,17 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include <algorithm> -#ifdef _MSC_VER -#include <hash_map> -using stdext::hash_map; -#elif defined __APPLE__ -#include <ext/hash_map> -using __gnu_cxx::hash_map; -#else #include <unordered_map> -using std::unordered_map; -#endif -#include <map> #include <vector> #include "VideoCommon.h" @@ -41,32 +31,21 @@ static int s_attr_dirty; // bitfield static VertexLoader *g_VertexLoaders[8]; -#ifdef _MSC_VER -namespace stdext { - inline size_t hash_value(const VertexLoaderUID& uid) { - return uid.GetHash(); - } -} -#else -#ifdef __APPLE__ -namespace __gnu_cxx -#else namespace std -#endif { - template<> struct hash<VertexLoaderUID> { - size_t operator()(const VertexLoaderUID& uid) const { - return uid.GetHash(); - } - }; + +template <> +struct hash<VertexLoaderUID> +{ + size_t operator()(const VertexLoaderUID& uid) const + { + return uid.GetHash(); + } +}; + } -#endif -#if defined _MSC_VER || defined __APPLE__ -typedef hash_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap; -#else -typedef unordered_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap; -#endif +typedef std::unordered_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap; namespace VertexLoaderManager { diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp index 87856b5aeb..3e2e88c55f 100644 --- a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp @@ -57,13 +57,13 @@ void VertexManager::PrepareForAdditionalData(int primitive, u32 count, u32 strid Flush(); if(count > IndexGenerator::GetRemainingIndices()) - ERROR_LOG(VIDEO, "Too less index values. Use 32bit or reset them on flush."); + ERROR_LOG(VIDEO, "Too little remaining index values. Use 32-bit or reset them on flush."); if (count > GetRemainingIndices(primitive)) ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all indices! " - "Increase MAXIBUFFERSIZE or we need primitive breaking afterall."); + "Increase MAXIBUFFERSIZE or we need primitive breaking after all."); if (needed_vertex_bytes > GetRemainingSize()) ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all vertices! " - "Increase MAXVBUFFERSIZE or we need primitive breaking afterall."); + "Increase MAXVBUFFERSIZE or we need primitive breaking after all."); } } @@ -190,7 +190,7 @@ void VertexManager::Flush() PixelShaderManager::SetTexDims(i, tentry->nativeW, tentry->nativeH, 0, 0); } else - ERROR_LOG(VIDEO, "error loading texture"); + ERROR_LOG(VIDEO, "Error loading texture"); } } diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 2c0f5676ed..e4a04102ff 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -133,30 +133,34 @@ static char text[16384]; char* GenerateVSOutputStruct(char* p, u32 components, API_TYPE ApiType) { + + // "centroid" attribute is only supported by D3D11 + const char* optCentroid = (ApiType == API_D3D11 ? "centroid" : ""); + // GLSL makes this ugly // TODO: Make pretty WRITE(p, "struct VS_OUTPUT {\n"); - WRITE(p, " float4 pos %s POSITION;\n", ApiType == API_OPENGL ? ";//" : ":"); - WRITE(p, " float4 colors_0 %s COLOR0;\n", ApiType == API_OPENGL ? ";//" : ":"); - WRITE(p, " float4 colors_1 %s COLOR1;\n", ApiType == API_OPENGL ? ";//" : ":"); + WRITE(p, " %s float4 pos %s POSITION;\n", optCentroid, ApiType == API_OPENGL ? ";//" : ":"); + WRITE(p, " %s float4 colors_0 %s COLOR0;\n", optCentroid, ApiType == API_OPENGL ? ";//" : ":"); + WRITE(p, " %s float4 colors_1 %s COLOR1;\n", optCentroid, ApiType == API_OPENGL ? ";//" : ":"); if (xfregs.numTexGen.numTexGens < 7) { for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) - WRITE(p, " float3 tex%d %s TEXCOORD%d;\n", i, ApiType == API_OPENGL ? ";//" : ":", i); - WRITE(p, " float4 clipPos %s TEXCOORD%d;\n", ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens); + WRITE(p, " %s float3 tex%d %s TEXCOORD%d;\n", optCentroid, i, ApiType == API_OPENGL ? ";//" : ":", i); + WRITE(p, " %s float4 clipPos %s TEXCOORD%d;\n", optCentroid, ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens); if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) - WRITE(p, " float4 Normal %s TEXCOORD%d;\n", ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens + 1); + WRITE(p, " %s float4 Normal %s TEXCOORD%d;\n", optCentroid, ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens + 1); } else { // clip position is in w of first 4 texcoords if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) { for (int i = 0; i < 8; ++i) - WRITE(p, " float4 tex%d %s TEXCOORD%d;\n", i, ApiType == API_OPENGL? ";//" : ":", i); + WRITE(p, " %s float4 tex%d %s TEXCOORD%d;\n", optCentroid, i, ApiType == API_OPENGL? ";//" : ":", i); } else { for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) - WRITE(p, " float%d tex%d %s TEXCOORD%d;\n", i < 4 ? 4 : 3 , i, ApiType == API_OPENGL ? ";//" : ":", i); + WRITE(p, " %s float%d tex%d %s TEXCOORD%d;\n", optCentroid, i < 4 ? 4 : 3 , i, ApiType == API_OPENGL ? ";//" : ":", i); } } WRITE(p, "};\n"); @@ -413,7 +417,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) if (components & (VB_HAS_NRM1|VB_HAS_NRM2)) { // transform the light dir into tangent space - WRITE(p, "ldir = normalize(" I_LIGHTS"[%d + 3].xyz - pos.xyz);\n", texinfo.embosslightshift); + WRITE(p, "ldir = normalize(" I_LIGHTS"[5*%d + 3].xyz - pos.xyz);\n", texinfo.embosslightshift); WRITE(p, "o.tex%d.xyz = o.tex%d.xyz + float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0f);\n", i, texinfo.embosssourceshift); } else diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp index a5e84ee69b..b8c9b7d5a3 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp @@ -122,7 +122,7 @@ void UpdateProjectionHack(int iPhackvalue[], std::string sPhackvalue[]) if (iPhackvalue[0] == 1) { - NOTICE_LOG(VIDEO, "\t\t--- Ortographic Projection Hack ON ---"); + NOTICE_LOG(VIDEO, "\t\t--- Orthographic Projection Hack ON ---"); fhacksign1 *= (iPhackvalue[1] == 1) ? -1.0f : fhacksign1; sTemp[0] = (iPhackvalue[1] == 1) ? " * (-1)" : ""; @@ -191,7 +191,7 @@ void VertexShaderManager::Dirty() } // Syncs the shader constant buffers with xfmem -// TODO: A cleaner way to control the matricies without making a mess in the parameters field +// TODO: A cleaner way to control the matrices without making a mess in the parameters field void VertexShaderManager::SetConstants() { if (g_ActiveConfig.backend_info.APIType == API_OPENGL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO) @@ -455,7 +455,7 @@ void VertexShaderManager::SetConstants() break; default: - ERROR_LOG(VIDEO, "unknown projection type: %d", xfregs.projection.type); + ERROR_LOG(VIDEO, "Unknown projection type: %d", xfregs.projection.type); } PRIM_LOG("Projection: %f %f %f %f %f %f\n", rawProjection[0], rawProjection[1], rawProjection[2], rawProjection[3], rawProjection[4], rawProjection[5]); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 60677ceeeb..ad040b9e24 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -49,7 +49,6 @@ VideoConfig::VideoConfig() void VideoConfig::Load(const char *ini_file) { - std::string temp; IniFile iniFile; iniFile.Load(ini_file); @@ -80,7 +79,7 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Settings", "HackedBufferUpload", &bHackedBufferUpload, 0); iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0); - iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native + iniFile.Get("Settings", "EFBScale", &iEFBScale, (int) SCALE_1X); // native iniFile.Get("Settings", "DstAlphaPass", &bDstAlphaPass, false); @@ -138,7 +137,32 @@ void VideoConfig::GameIniLoad(const char *ini_file) iniFile.GetIfExists("Video_Settings", "EnablePixelLighting", &bEnablePixelLighting); iniFile.GetIfExists("Video_Settings", "HackedBufferUpload", &bHackedBufferUpload); iniFile.GetIfExists("Video_Settings", "MSAA", &iMultisampleMode); - iniFile.GetIfExists("Video_Settings", "EFBScale", &iEFBScale); // integral + int tmp = -9000; + iniFile.GetIfExists("Video_Settings", "EFBScale", &tmp); // integral + if (tmp != -9000) + { + if (tmp != SCALE_FORCE_INTEGRAL) + iEFBScale = tmp; + // Round down to multiple of native IR + else + { + switch (iEFBScale) + { + case SCALE_AUTO: + iEFBScale = SCALE_AUTO_INTEGRAL; + break; + case SCALE_1_5X: + iEFBScale = SCALE_1X; + break; + case SCALE_2_5X: + iEFBScale = SCALE_2X; + break; + default: + break; + } + } + } + iniFile.GetIfExists("Video_Settings", "DstAlphaPass", &bDstAlphaPass); iniFile.GetIfExists("Video_Settings", "DisableFog", &bDisableFog); iniFile.GetIfExists("Video_Settings", "EnableOpenCL", &bEnableOpenCL); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 442e95f9bf..1670e47222 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -44,6 +44,18 @@ enum AspectMode { ASPECT_STRETCH = 3, }; +enum EFBScale { + SCALE_FORCE_INTEGRAL = -1, + SCALE_AUTO, + SCALE_AUTO_INTEGRAL, + SCALE_1X, + SCALE_1_5X, + SCALE_2X, + SCALE_2_5X, + SCALE_3X, + SCALE_4X, +}; + class IniFile; // NEVER inherit from this class. @@ -153,7 +165,7 @@ struct VideoConfig bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL bool bSupportsFormatReinterpretation; bool bSupportsPixelLighting; - + bool bSupportsSeparateAlphaFunction; bool bSupportsGLSLUBO; // needed by pixelShaderGen, so must stay in videoCommon } backend_info; diff --git a/Source/Core/VideoCommon/Src/XFStructs.cpp b/Source/Core/VideoCommon/Src/XFStructs.cpp index df9624b6f0..efbe09e4b3 100644 --- a/Source/Core/VideoCommon/Src/XFStructs.cpp +++ b/Source/Core/VideoCommon/Src/XFStructs.cpp @@ -212,7 +212,7 @@ 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); + INFO_LOG(VIDEO, "XF load exceeds address space: %x %d bytes\n", baseAddress, transferSize); if (baseAddress >= 0x1058) transferSize = 0; |
