mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-02 02:52:30 +02:00
Migrated BPStructs to D3D, major progress, half of the stuff actually works!
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2609 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ef1b961e54
commit
0feedec14c
@ -27,6 +27,7 @@
|
|||||||
#include "VertexManager.h"
|
#include "VertexManager.h"
|
||||||
#include "PixelShaderGen.h"
|
#include "PixelShaderGen.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
|
#include "VertexShaderManager.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "main.h" //for the plugin interface
|
#include "main.h" //for the plugin interface
|
||||||
@ -136,6 +137,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||||
}
|
}
|
||||||
|
PixelShaderManager::SetGenModeChanged();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPMEM_IND_MTX+0:
|
case BPMEM_IND_MTX+0:
|
||||||
@ -207,7 +209,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
PRIM_LOG("constalpha: alp=%d, en=%d\n", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
PRIM_LOG("constalpha: alp=%d, en=%d\n", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
||||||
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
|
//PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -221,7 +223,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x43:
|
case BPMEM_PE_CONTROL: // GXSetZCompLoc, GXPixModeSync
|
||||||
if (changes) {
|
if (changes) {
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
@ -302,92 +304,23 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BPMEM_FOGRANGE:
|
case BPMEM_FOGRANGE:
|
||||||
if (changes) {
|
|
||||||
// TODO(XK): Fog range format
|
|
||||||
//Renderer::SetRenderState(D3DRS_FOGSTART, ...
|
|
||||||
//Renderer::SetRenderState(D3DRS_FOGEND, ...
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BPMEM_FOGPARAM0:
|
case BPMEM_FOGPARAM0:
|
||||||
{
|
|
||||||
// u32 fogATemp = bpmem.fog.a<<12;
|
|
||||||
// float fogA = *(float*)(&fogATemp);
|
|
||||||
VertexManager::Flush();
|
|
||||||
((u32*)&bpmem)[addr] = newval;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BPMEM_FOGBEXPONENT:
|
case BPMEM_FOGBEXPONENT:
|
||||||
case BPMEM_FOGBMAGNITUDE:
|
case BPMEM_FOGBMAGNITUDE:
|
||||||
{
|
|
||||||
VertexManager::Flush();
|
|
||||||
((u32*)&bpmem)[addr] = newval;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BPMEM_FOGPARAM3:
|
case BPMEM_FOGPARAM3:
|
||||||
//fog settings
|
|
||||||
if (changes) {
|
if (changes) {
|
||||||
static bool bFog = false;
|
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
PixelShaderManager::SetFogParamChanged();
|
||||||
if (!renderFog)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/// u32 fogCTemp = bpmem.fog.c_proj_fsel.cShifted12 << 12;
|
|
||||||
// float fogC = *(float*)(&fogCTemp);
|
|
||||||
|
|
||||||
|
|
||||||
//printf("%f %f magnitude: %x\n", bpmem.fog.a.GetA(),bpmem.fog.c_proj_fsel.GetC(), bpmem.fog.b_magnitude);
|
|
||||||
switch(bpmem.fog.c_proj_fsel.fsel)
|
|
||||||
{
|
|
||||||
case 0: // Off
|
|
||||||
if (bFog) {
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGENABLE, false);
|
|
||||||
bFog = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: // Linear
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
|
|
||||||
break;
|
|
||||||
case 4: // exp
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP);
|
|
||||||
break;
|
|
||||||
case 5: // exp2
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP2);
|
|
||||||
break;
|
|
||||||
case 6: // Backward exp
|
|
||||||
case 7: // Backward exp2
|
|
||||||
PanicAlert("Backward Exponential Fog Detected");
|
|
||||||
// TODO: Figure out how to do these in any rendering API
|
|
||||||
//TEV_FSEL_BX, TEV_FSEL_BX2?
|
|
||||||
default:
|
|
||||||
PanicAlert("Non-Emulated Fog selection %d\n", bpmem.fog.c_proj_fsel.fsel);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bpmem.fog.c_proj_fsel.fsel > 0 && !bFog) {
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGENABLE, true);
|
|
||||||
bFog = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BPMEM_FOGCOLOR:
|
case BPMEM_FOGCOLOR:
|
||||||
if (changes) {
|
if (changes)
|
||||||
|
{
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
PixelShaderManager::SetFogColorChanged();
|
||||||
if (!renderFog)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// dev->SetRenderState(D3DRS_FOGCOLOR,bpmem.fog.color);
|
|
||||||
int fogcolor[3] = { bpmem.fog.color.r, bpmem.fog.color.g, bpmem.fog.color.b };
|
|
||||||
//D3DCOLOR_RGBA(fogcolor[0], fogcolor[1], fogcolor[2], 0)
|
|
||||||
Renderer::SetRenderState(D3DRS_FOGCOLOR, bpmem.fog.color.hex);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -403,18 +336,37 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BPMEM_SCISSORTL:
|
||||||
|
case BPMEM_SCISSORBR:
|
||||||
|
|
||||||
|
if (changes)
|
||||||
|
{
|
||||||
|
VertexManager::Flush();
|
||||||
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
/*if (!Renderer::SetScissorRect())
|
||||||
|
{
|
||||||
|
if (addr == BPMEM_SCISSORBR) {
|
||||||
|
ERROR_LOG(VIDEO, "bad scissor!\n");
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case BPMEM_ZTEX1:
|
case BPMEM_ZTEX1:
|
||||||
if (changes) {
|
if (changes) {
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
//PRIM_LOG("ztex bias=0x%x\n", bpmem.ztex1.bias);
|
//PRIM_LOG("ztex bias=0x%x\n", bpmem.ztex1.bias);
|
||||||
//PixelShaderMngr::SetZTextureBias(bpmem.ztex1.bias);
|
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPMEM_ZTEX2:
|
case BPMEM_ZTEX2:
|
||||||
if (changes) {
|
if (changes) {
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
((u32*)&bpmem)[addr] = newval;
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
if (changes & 3) {
|
||||||
|
PixelShaderManager::SetZTextureTypeChanged();
|
||||||
|
}
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
const char* pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
|
const char* pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
|
||||||
const char* pztype[] = {"Z8", "Z16", "Z24", "?"};
|
const char* pztype[] = {"Z8", "Z16", "Z24", "?"};
|
||||||
@ -423,7 +375,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x45: //GXSetDrawDone
|
case BPMEM_SETDRAWDONE: //GXSetDrawDone
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
switch (newval & 0xFF)
|
switch (newval & 0xFF)
|
||||||
{
|
{
|
||||||
@ -448,7 +400,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (newval & 0xFFFF));
|
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (newval & 0xFFFF));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x67: // set gp metric?
|
case BPMEM_SETGPMETRIC: // set gp metric?
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BPMEM_TRIGGER_EFB_COPY:
|
case BPMEM_TRIGGER_EFB_COPY:
|
||||||
@ -501,6 +453,8 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
// it seems that the GC is able to alpha blend on color-fill
|
// it seems that the GC is able to alpha blend on color-fill
|
||||||
// we cant do that so if alpha is != 255 we skip it
|
// we cant do that so if alpha is != 255 we skip it
|
||||||
|
|
||||||
|
VertexShaderManager::SetViewportChanged();
|
||||||
|
|
||||||
// clear color
|
// clear color
|
||||||
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||||
if (bpmem.blendmode.colorupdate)
|
if (bpmem.blendmode.colorupdate)
|
||||||
@ -575,8 +529,17 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
switch (addr & 0xF8) //texture sampler filter
|
switch (addr & 0xFC) //texture sampler filter
|
||||||
{
|
{
|
||||||
|
case 0x28: // tevorder 0-3
|
||||||
|
case 0x2C: // tevorder 4-7
|
||||||
|
if (changes)
|
||||||
|
{
|
||||||
|
VertexManager::Flush();
|
||||||
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
PixelShaderManager::SetTevOrderChanged(addr - 0x28);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 0x80: // TEX MODE 0
|
case 0x80: // TEX MODE 0
|
||||||
case 0xA0:
|
case 0xA0:
|
||||||
if (changes)
|
if (changes)
|
||||||
@ -677,12 +640,13 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
|
|
||||||
case 0xE0:
|
case 0xE0:
|
||||||
case 0xE4:
|
case 0xE4:
|
||||||
((u32*)&bpmem)[addr] = newval;
|
|
||||||
if (addr&1) { // don't compare with changes!
|
if (addr&1) { // don't compare with changes!
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
|
((u32*)&bpmem)[addr] = newval;
|
||||||
int num = (addr >> 1) & 0x3;
|
int num = (addr >> 1) & 0x3;
|
||||||
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
|
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
|
||||||
}
|
} else
|
||||||
|
((u32*)&bpmem)[addr] = newval;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -720,6 +684,11 @@ void BPWritten(int addr, int changes, int newval)
|
|||||||
case 0xA0:
|
case 0xA0:
|
||||||
case 0xB0:
|
case 0xB0:
|
||||||
default:
|
default:
|
||||||
|
if (changes)
|
||||||
|
{
|
||||||
|
VertexManager::Flush();
|
||||||
|
((u32*)&bpmem)[addr] = newval;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user