mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Direct3D9 plugin now uses BPFunctions and removed its BPStructs. Some cleanup and commenting in BPStructs.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2897 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -15,6 +15,8 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "Profiler.h"
|
||||
#include "Statistics.h"
|
||||
#include "VideoCommon.h"
|
||||
@ -46,27 +48,28 @@ void BPInit()
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
void BPWritten(const BreakPoint& bp)
|
||||
{
|
||||
// If nothing changed, return
|
||||
//if ((bp.changes == 0 ? false : true))
|
||||
// return;
|
||||
|
||||
// Flush the pipeline then update the BreakPoint Memory
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// First the pipeline is flushed then update the bpmem with the new value.
|
||||
// Some of the BP cases have to call certain functions while others just update the bpmem.
|
||||
// some bp cases check the changes variable, because they might not have to be updated all the time
|
||||
// NOTE: it seems not all bp cases like checking changes, so calling if (bp.changes == 0 ? false : true)
|
||||
// had to be ditched and the games seem to work fine with out it.
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
FlushPipeline();
|
||||
((u32*)&bpmem)[bp.address] = bp.newvalue;
|
||||
|
||||
switch (bp.address)
|
||||
{
|
||||
// -----------------------------------------------------
|
||||
// BPs that calls other code besides updating the memory
|
||||
// -----------------------------------------------------
|
||||
case BPMEM_GENMODE:
|
||||
case BPMEM_GENMODE: // Set the Generation Mode
|
||||
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d",
|
||||
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
|
||||
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
|
||||
bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
|
||||
SetGenerationMode();
|
||||
SetGenerationMode(bp);
|
||||
break;
|
||||
case BPMEM_IND_MTXA:
|
||||
case BPMEM_IND_MTXA: // Index Matrix Changed
|
||||
case BPMEM_IND_MTXB:
|
||||
case BPMEM_IND_MTXC:
|
||||
case BPMEM_IND_MTXA+3:
|
||||
@ -83,17 +86,18 @@ void BPWritten(const BreakPoint& bp)
|
||||
break;
|
||||
case BPMEM_SCISSORTL: // Scissor Rectable Top, Left
|
||||
case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right
|
||||
case BPMEM_SCISSOROFFSET: // Scissor Offset
|
||||
SetScissor(bp);
|
||||
break;
|
||||
case BPMEM_LINEPTWIDTH:
|
||||
SetLineWidth();
|
||||
case BPMEM_LINEPTWIDTH: // Line Width
|
||||
SetLineWidth(bp);
|
||||
break;
|
||||
case BPMEM_ZMODE:
|
||||
case BPMEM_ZMODE: // Depth Control
|
||||
PRIM_LOG("zmode: test=%d, func=%d, upd=%d", bpmem.zmode.testenable, bpmem.zmode.func,
|
||||
bpmem.zmode.updateenable);
|
||||
SetDepthMode();
|
||||
SetDepthMode(bp);
|
||||
break;
|
||||
case BPMEM_BLENDMODE:
|
||||
case BPMEM_BLENDMODE: // Blending Control
|
||||
if (bp.changes & 0xFFFF)
|
||||
{
|
||||
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
|
||||
@ -103,37 +107,37 @@ void BPWritten(const BreakPoint& bp)
|
||||
if (bp.changes & 2)
|
||||
{
|
||||
SETSTAT(stats.logicOpMode, bpmem.blendmode.logicopenable != 0 ? bpmem.blendmode.logicmode : stats.logicOpMode);
|
||||
SetLogicOpMode();
|
||||
SetLogicOpMode(bp);
|
||||
}
|
||||
// Set Dithering Mode
|
||||
if (bp.changes & 4)
|
||||
{
|
||||
SETSTAT(stats.dither, bpmem.blendmode.dither);
|
||||
SetDitherMode();
|
||||
SetDitherMode(bp);
|
||||
}
|
||||
// Set Blending Mode
|
||||
if (bp.changes & 0xFE1)
|
||||
{
|
||||
SETSTAT(stats.srcFactor, bpmem.blendmode.srcfactor);
|
||||
SETSTAT(stats.dstFactor, bpmem.blendmode.dstfactor);
|
||||
SetBlendMode();
|
||||
SetBlendMode(bp);
|
||||
}
|
||||
// Set Color Mask
|
||||
if (bp.changes & 0x18)
|
||||
{
|
||||
SETSTAT(stats.alphaUpdate, bpmem.blendmode.alphaupdate);
|
||||
SETSTAT(stats.colorUpdate, bpmem.blendmode.colorupdate);
|
||||
SetColorMask();
|
||||
SetColorMask(bp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BPMEM_CONSTANTALPHA:
|
||||
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
|
||||
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
||||
SETSTAT(stats.dstAlphaEnable, bpmem.dstalpha.enable);
|
||||
SETSTAT_UINT(stats.dstAlpha, bpmem.dstalpha.alpha);
|
||||
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
|
||||
break;
|
||||
case BPMEM_SETDRAWDONE:
|
||||
case BPMEM_SETDRAWDONE: // This is called when the game is done drawing (eg: like in DX: Begin(); Draw(); End();)
|
||||
switch (bp.newvalue & 0xFF)
|
||||
{
|
||||
case 0x02:
|
||||
@ -146,18 +150,18 @@ void BPWritten(const BreakPoint& bp)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BPMEM_PE_TOKEN_ID:
|
||||
case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID
|
||||
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), FALSE);
|
||||
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
|
||||
break;
|
||||
case BPMEM_PE_TOKEN_INT_ID:
|
||||
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
|
||||
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), TRUE);
|
||||
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
|
||||
break;
|
||||
// ------------------------
|
||||
// EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to XFB as YUYV.
|
||||
// It can also optionally clear the EFB while copying from it. To emulate this, we of course copy first and clear afterwards.
|
||||
case BPMEM_TRIGGER_EFB_COPY:
|
||||
case BPMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen.
|
||||
{
|
||||
DVSTARTSUBPROFILE("LoadBPReg:swap");
|
||||
// The bottom right is within the rectangle
|
||||
@ -171,6 +175,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
|
||||
float MValueX = GetRendererTargetScaleX();
|
||||
float MValueY = GetRendererTargetScaleY();
|
||||
|
||||
// Need another rc here to get it to scale.
|
||||
// Here the bottom right is the out of the rectangle.
|
||||
TRectangle multirc = {
|
||||
@ -188,38 +193,35 @@ void BPWritten(const BreakPoint& bp)
|
||||
{
|
||||
if (GetConfig(CONFIG_SHOWEFBREGIONS))
|
||||
stats.efb_regions.push_back(rc);
|
||||
u32 address = bpmem.copyTexDest << 5;
|
||||
bool fromZBuffer = (bpmem.zcontrol.pixel_format == PIXELFMT_Z24);
|
||||
bool isIntensity = (PE_copy.intensity_fmt > 0);
|
||||
u32 copyFormat = ((PE_copy.target_pixel_format / 2) + ((PE_copy.target_pixel_format & 1) * 8));
|
||||
bool scaleByHalf = (PE_copy.half_scale > 0);
|
||||
CopyEFB(rc, address, fromZBuffer, isIntensity, copyFormat, scaleByHalf);
|
||||
|
||||
CopyEFB(bp, rc, bpmem.copyTexDest << 5,
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_Z24,
|
||||
PE_copy.intensity_fmt > 0,
|
||||
((PE_copy.target_pixel_format / 2) + ((PE_copy.target_pixel_format & 1) * 8)),
|
||||
PE_copy.half_scale > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the number of lines copied is determined by the y scale * source efb height
|
||||
float yScale = bpmem.dispcopyyscale / 256.0f;
|
||||
float xfbLines = bpmem.copyTexSrcWH.y + 1.0f * yScale;
|
||||
u8* pXFB = Memory_GetPtr(bpmem.copyTexDest << 5);
|
||||
u32 dstWidth = (bpmem.copyMipMapStrideChannels << 4);
|
||||
u32 dstHeight = (u32)xfbLines;
|
||||
RenderToXFB(multirc, yScale, xfbLines, pXFB, dstWidth, dstHeight);
|
||||
const float yScale = bpmem.dispcopyyscale / 256.0f;
|
||||
const float xfbLines = ((bpmem.copyTexSrcWH.y + 1.0f) * yScale);
|
||||
RenderToXFB(bp, multirc, yScale, xfbLines,
|
||||
Memory_GetPtr(bpmem.copyTexDest << 5),
|
||||
bpmem.copyMipMapStrideChannels << 4,
|
||||
(u32)ceil(xfbLines));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Clear the picture after it's done and submitted, to prepare for the next picture
|
||||
// ----------------------------------------------------------------------------------
|
||||
if (PE_copy.clear)
|
||||
ClearScreen(multirc);
|
||||
ClearScreen(bp, multirc);
|
||||
|
||||
RestoreRenderState();
|
||||
RestoreRenderState(bp);
|
||||
|
||||
break;
|
||||
}
|
||||
case BPMEM_SCISSOROFFSET:
|
||||
SetScissorRectangle();
|
||||
break;
|
||||
case BPMEM_LOADTLUT0:
|
||||
case BPMEM_LOADTLUT0: // Load the Texture Look Up Table
|
||||
case BPMEM_LOADTLUT1:
|
||||
{
|
||||
DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut");
|
||||
@ -244,7 +246,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
// Not sure if it's a good idea, though. For now, we hash texture palettes
|
||||
}
|
||||
break;
|
||||
case BPMEM_FOGRANGE:
|
||||
case BPMEM_FOGRANGE: // Fog Settings Control
|
||||
case BPMEM_FOGPARAM0:
|
||||
case BPMEM_FOGBMAGNITUDE:
|
||||
case BPMEM_FOGBEXPONENT:
|
||||
@ -252,7 +254,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
if(!GetConfig(CONFIG_DISABLEFOG))
|
||||
PixelShaderManager::SetFogParamChanged();
|
||||
break;
|
||||
case BPMEM_FOGCOLOR:
|
||||
case BPMEM_FOGCOLOR: // Fog Color
|
||||
PixelShaderManager::SetFogColorChanged();
|
||||
break;
|
||||
case BPMEM_ALPHACOMPARE:
|
||||
@ -264,7 +266,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias);
|
||||
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
|
||||
break;
|
||||
case BPMEM_ZTEX2:
|
||||
case BPMEM_ZTEX2: // Z Texture type
|
||||
{
|
||||
if (bp.changes & 3)
|
||||
PixelShaderManager::SetZTextureTypeChanged();
|
||||
@ -276,36 +278,40 @@ void BPWritten(const BreakPoint& bp)
|
||||
break;
|
||||
}
|
||||
|
||||
// --------------------------------------
|
||||
// BPs that only flush and update memory
|
||||
// --------------------------------------
|
||||
case BPMEM_DISPLAYCOPYFILER:
|
||||
case BPMEM_DISPLAYCOPYFILER: // Display Filtering Control
|
||||
case BPMEM_DISPLAYCOPYFILER+1:
|
||||
case BPMEM_DISPLAYCOPYFILER+2:
|
||||
case BPMEM_DISPLAYCOPYFILER+3:
|
||||
case BPMEM_IND_IMASK:
|
||||
case BPMEM_SU_COUNTER:
|
||||
case BPMEM_RAS_COUNTER:
|
||||
case BPMEM_IREF:
|
||||
case BPMEM_PE_CONTROL:
|
||||
case BPMEM_FIELDMASK:
|
||||
case BPMEM_CLOCK0:
|
||||
case BPMEM_EFB_TL: // EFB Source Rect. Top, Left
|
||||
case BPMEM_EFB_BR: // EFB Source Rect. Bottom, Right (w, h - 1)
|
||||
case BPMEM_EFB_ADDR: // EFB Target Address
|
||||
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
|
||||
case BPMEM_COPYYSCALE: // Display Copy Y Scale
|
||||
case BPMEM_CLEAR_AR: // Set Clear Alpha and Red Components
|
||||
case BPMEM_CLEAR_GB: // Green and Blue
|
||||
case BPMEM_CLEAR_Z: // Clear Z, 24-bit Z Value
|
||||
case BPMEM_COPYFILTER0:
|
||||
case BPMEM_COPYFILTER1:
|
||||
break;
|
||||
case BPMEM_SU_COUNTER: // Counters
|
||||
case BPMEM_RAS_COUNTER:
|
||||
break;
|
||||
case BPMEM_FIELDMASK: // Field Control
|
||||
case BPMEM_FIELDMODE:
|
||||
break;
|
||||
case BPMEM_CLOCK0: // Debugging info
|
||||
case BPMEM_CLOCK1:
|
||||
case BPMEM_SETGPMETRIC:
|
||||
break;
|
||||
case BPMEM_EFB_TL: // EFB Source Rect. Top, Left
|
||||
case BPMEM_EFB_BR: // EFB Source Rect. Bottom, Right (w, h - 1)
|
||||
case BPMEM_EFB_ADDR: // EFB Target Address
|
||||
break;
|
||||
case BPMEM_CLEAR_AR: // Set Clear Alpha and Red Components
|
||||
case BPMEM_CLEAR_GB: // Green and Blue
|
||||
case BPMEM_CLEAR_Z: // Clear Z, 24-bit Z Value
|
||||
break;
|
||||
case BPMEM_CLEARBBOX1: // let's hope not many games use bboxes..
|
||||
case BPMEM_CLEARBBOX2: // TODO(ector): add something that watches bboxes
|
||||
case BPMEM_TEXINVALIDATE:
|
||||
case BPMEM_SETGPMETRIC: // Debugging info
|
||||
case BPMEM_FIELDMODE:
|
||||
case BPMEM_CLOCK1:
|
||||
break;
|
||||
case BPMEM_IREF:
|
||||
case BPMEM_PE_CONTROL: // Pixel Engine Control (GXSetZCompLoc, GXPixModeSync)
|
||||
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
|
||||
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
|
||||
case BPMEM_COPYYSCALE: // Display Copy Y Scale
|
||||
break;
|
||||
case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
|
||||
case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1
|
||||
case BPMEM_TEV_KSEL+2:// Texture Environment Swap Mode Table 2
|
||||
@ -314,7 +320,9 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_TEV_KSEL+5:// Texture Environment Swap Mode Table 5
|
||||
case BPMEM_TEV_KSEL+6:// Texture Environment Swap Mode Table 6
|
||||
case BPMEM_TEV_KSEL+7:// Texture Environment Swap Mode Table 7
|
||||
case BPMEM_BP_MASK:
|
||||
break;
|
||||
case BPMEM_BP_MASK: // Masks
|
||||
case BPMEM_IND_IMASK:
|
||||
break;
|
||||
|
||||
// ------------------------------------------------
|
||||
@ -332,6 +340,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_TREF+5:
|
||||
case BPMEM_TREF+6:
|
||||
case BPMEM_TREF+7:
|
||||
break;
|
||||
case BPMEM_SU_SSIZE: // Texture Wrap Size U?
|
||||
case BPMEM_SU_TSIZE: // Texture Wrap Size V?
|
||||
case BPMEM_SU_SSIZE+2:
|
||||
@ -348,6 +357,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_SU_TSIZE+12:
|
||||
case BPMEM_SU_SSIZE+14:
|
||||
case BPMEM_SU_TSIZE+14:
|
||||
break;
|
||||
case BPMEM_TX_SETMODE0: // 0x90 for Linear, Index 0
|
||||
case BPMEM_TX_SETMODE0+1:
|
||||
case BPMEM_TX_SETMODE0+2:
|
||||
@ -356,6 +366,8 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_TX_SETMODE1+1:
|
||||
case BPMEM_TX_SETMODE1+2:
|
||||
case BPMEM_TX_SETMODE1+3:
|
||||
SetSamplerState(bp);
|
||||
break;
|
||||
case BPMEM_TX_SETIMAGE0: // Texture Size ?
|
||||
case BPMEM_TX_SETIMAGE0+1:
|
||||
case BPMEM_TX_SETIMAGE0+2:
|
||||
@ -372,18 +384,21 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_TX_SETIMAGE3+1:
|
||||
case BPMEM_TX_SETIMAGE3+2:
|
||||
case BPMEM_TX_SETIMAGE3+3:
|
||||
break;
|
||||
case BPMEM_TX_LOADTLUT_0: // wtf? Load TLUT 0 here ?? (THIS HAS TO BE SET TLUT NOT LOAD TLUT !! :P, mistake found in YAGD!)
|
||||
case BPMEM_TX_LOADTLUT_0+1:
|
||||
case BPMEM_TX_LOADTLUT_0+2:
|
||||
case BPMEM_TX_LOADTLUT_0+3:
|
||||
case BPMEM_TX_SETMODE0_4: // This is Mode 0 for Index 5 to 8
|
||||
break;
|
||||
case BPMEM_TX_SETMODE0_4: // This is Mode 0 for Index 5 to 8
|
||||
case BPMEM_TX_SETMODE0_4+1:
|
||||
case BPMEM_TX_SETMODE0_4+2:
|
||||
case BPMEM_TX_SETMODE0_4+3:
|
||||
case BPMEM_TX_SETMODE1_4: // This is Mode 1 for Index 5 to 8
|
||||
case BPMEM_TX_SETMODE1_4: // This is Mode 1 for Index 5 to 8
|
||||
case BPMEM_TX_SETMODE1_4+1:
|
||||
case BPMEM_TX_SETMODE1_4+2:
|
||||
case BPMEM_TX_SETMODE1_4+3:
|
||||
break;
|
||||
case BPMEM_TX_SETIMAGE0_4: // This is Image 0 for Index 5 to 8
|
||||
case BPMEM_TX_SETIMAGE0_4+1:
|
||||
case BPMEM_TX_SETIMAGE0_4+2:
|
||||
@ -400,7 +415,8 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_TX_SETIMAGE3_4+1:
|
||||
case BPMEM_TX_SETIMAGE3_4+2:
|
||||
case BPMEM_TX_SETIMAGE3_4+3:
|
||||
case BPMEM_TX_SETLUT_4: // This is Setting TLUT for Index 5 to 8
|
||||
break;
|
||||
case BPMEM_TX_SETLUT_4: // This is Setting TLUT for Index 5 to 8
|
||||
case BPMEM_TX_SETLUT_4+1:
|
||||
case BPMEM_TX_SETLUT_4+2:
|
||||
case BPMEM_TX_SETLUT_4+3:
|
||||
@ -444,6 +460,7 @@ void BPWritten(const BreakPoint& bp)
|
||||
case BPMEM_IND_CMD+13:
|
||||
case BPMEM_IND_CMD+14:
|
||||
case BPMEM_IND_CMD+15:
|
||||
break;
|
||||
case BPMEM_TEV_COLOR_ENV: // Texture Environment 1
|
||||
case BPMEM_TEV_ALPHA_ENV:
|
||||
case BPMEM_TEV_COLOR_ENV+2: // Texture Environment 2
|
||||
|
Reference in New Issue
Block a user