Some housecleaning around the D3D plugin, start of preparations to share even more code with the GL plugin.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4183 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2091fb3ceb
commit
562a4e25ac
|
@ -24,6 +24,7 @@ files = [
|
|||
'VertexLoader_Normal.cpp',
|
||||
'VertexLoader_Position.cpp',
|
||||
'VertexLoader_TextCoord.cpp',
|
||||
'TextureConversionShader.cpp',
|
||||
'ImageWrite.cpp',
|
||||
'NativeVertexWriter.cpp',
|
||||
'Statistics.cpp',
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "Common.h"
|
||||
|
||||
#include "TextureConversionShader.h"
|
||||
#include "TextureDecoder.h"
|
||||
#include "PixelShaderManager.h"
|
||||
#include "PixelShaderGen.h"
|
||||
#include "BPMemory.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "Common.h"
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
|
||||
static char text[16384];
|
||||
|
@ -33,7 +33,6 @@ static char text[16384];
|
|||
namespace TextureConversionShader
|
||||
{
|
||||
|
||||
|
||||
u16 GetEncodedSampleCount(u32 format)
|
||||
{
|
||||
switch (format) {
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "Common.h"
|
||||
#include "TextureDecoder.h"
|
||||
#include <Cg/cg.h>
|
||||
|
||||
namespace TextureConversionShader
|
||||
{
|
|
@ -416,6 +416,14 @@
|
|||
RelativePath=".\Src\PixelShaderGen.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConversionShader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConversionShader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\VertexShaderGen.cpp"
|
||||
>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="Plugin_VideoDX9"
|
||||
ProjectGUID="{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}"
|
||||
RootNamespace="Plugin_VideoDX9"
|
||||
|
@ -1246,14 +1246,6 @@
|
|||
RelativePath=".\Src\D3DBase.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\D3DPostprocess.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\D3DPostprocess.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\D3DShader.cpp"
|
||||
>
|
||||
|
|
|
@ -103,12 +103,12 @@ void FlushPipeline()
|
|||
void SetGenerationMode(const BPCmd &bp)
|
||||
{
|
||||
// dev->SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
|
||||
Renderer::SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
|
||||
D3D::SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
|
||||
|
||||
if (bpmem.genMode.cullmode == 3)
|
||||
{
|
||||
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ void SetGenerationMode(const BPCmd &bp)
|
|||
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||
|
||||
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,21 +132,21 @@ void SetLineWidth(const BPCmd &bp)
|
|||
{
|
||||
// We can't change line width in D3D unless we use ID3DXLine
|
||||
float psize = float(bpmem.lineptwidth.pointsize) * 6.0f;
|
||||
Renderer::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
|
||||
D3D::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
|
||||
}
|
||||
|
||||
void SetDepthMode(const BPCmd &bp)
|
||||
{
|
||||
if (bpmem.zmode.testenable)
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_ZENABLE, TRUE);
|
||||
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
|
||||
Renderer::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[bpmem.zmode.func]);
|
||||
D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
|
||||
D3D::SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
|
||||
D3D::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[bpmem.zmode.func]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
}
|
||||
|
||||
//if (!bpmem.zmode.updateenable)
|
||||
|
@ -156,44 +156,44 @@ void SetDepthMode(const BPCmd &bp)
|
|||
void SetBlendMode(const BPCmd &bp)
|
||||
{
|
||||
if (bp.changes & 1)
|
||||
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable);
|
||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable);
|
||||
|
||||
D3DBLEND src = d3dSrcFactors[bpmem.blendmode.srcfactor];
|
||||
D3DBLEND dst = d3dDestFactors[bpmem.blendmode.dstfactor];
|
||||
|
||||
if (bp.changes & 0x700)
|
||||
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
|
||||
D3D::SetRenderState(D3DRS_SRCBLEND, src);
|
||||
|
||||
if (bp.changes & 0xE0) {
|
||||
if (!bpmem.blendmode.subtract)
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||
D3D::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
D3D::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
}
|
||||
}
|
||||
if (bp.changes & 0x800)
|
||||
{
|
||||
if (bpmem.blendmode.subtract)
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
D3D::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
D3D::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
|
||||
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||
D3D::SetRenderState(D3DRS_SRCBLEND, src);
|
||||
D3D::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||
}
|
||||
|
||||
Renderer::SetRenderState(D3DRS_BLENDOP,
|
||||
D3D::SetRenderState(D3DRS_BLENDOP,
|
||||
bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
|
||||
}
|
||||
}
|
||||
void SetDitherMode(const BPCmd &bp)
|
||||
{
|
||||
Renderer::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
|
||||
D3D::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
|
||||
}
|
||||
void SetLogicOpMode(const BPCmd &bp)
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void SetColorMask(const BPCmd &bp)
|
|||
if (bpmem.blendmode.colorupdate)
|
||||
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||
|
||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
}
|
||||
|
||||
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf)
|
||||
|
|
|
@ -29,6 +29,17 @@ namespace D3D
|
|||
D3DCAPS9 caps;
|
||||
int multisample;
|
||||
int resolution;
|
||||
const int MaxTextureStages = 9;
|
||||
const int MaxRenderStates = 210;
|
||||
const DWORD MaxTextureTypes = 33;
|
||||
const DWORD MaxSamplerSize = 13;
|
||||
const DWORD MaxSamplerTypes = 15;
|
||||
|
||||
static DWORD m_RenderStates[MaxRenderStates+46];
|
||||
static DWORD m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
|
||||
static DWORD m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
|
||||
|
||||
LPDIRECT3DBASETEXTURE9 m_Textures[16];
|
||||
|
||||
#define VENDOR_NVIDIA 4318
|
||||
#define VENDOR_ATI 4098
|
||||
|
@ -76,9 +87,9 @@ namespace D3D
|
|||
void EnableAlphaToCoverage()
|
||||
{
|
||||
if (GetCurAdapter().ident.VendorId == VENDOR_ATI)
|
||||
Renderer::SetRenderState(D3DRS_POINTSIZE, (D3DFORMAT)MAKEFOURCC('A', '2', 'M', '1'));
|
||||
D3D::SetRenderState(D3DRS_POINTSIZE, (D3DFORMAT)MAKEFOURCC('A', '2', 'M', '1'));
|
||||
else
|
||||
Renderer::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
|
||||
D3D::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
|
||||
}
|
||||
|
||||
void InitPP(int adapter, int resolution, int aa_mode, D3DPRESENT_PARAMETERS *pp)
|
||||
|
@ -395,4 +406,40 @@ namespace D3D
|
|||
}
|
||||
}
|
||||
|
||||
void SetTexture(DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture)
|
||||
{
|
||||
if (m_Textures[Stage] != pTexture)
|
||||
{
|
||||
m_Textures[Stage] = pTexture;
|
||||
D3D::dev->SetTexture(Stage, pTexture);
|
||||
}
|
||||
}
|
||||
|
||||
void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
|
||||
{
|
||||
if (m_RenderStates[State] != Value)
|
||||
{
|
||||
m_RenderStates[State] = Value;
|
||||
D3D::dev->SetRenderState(State, Value);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
|
||||
{
|
||||
if (m_TextureStageStates[Stage][Type] != Value)
|
||||
{
|
||||
m_TextureStageStates[Stage][Type] = Value;
|
||||
D3D::dev->SetTextureStageState(Stage, Type, Value);
|
||||
}
|
||||
}
|
||||
|
||||
void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value)
|
||||
{
|
||||
if (m_SamplerStates[Sampler][Type] != Value)
|
||||
{
|
||||
m_SamplerStates[Sampler][Type] = Value;
|
||||
D3D::dev->SetSamplerState(Sampler, Type, Value);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -54,10 +54,17 @@ namespace D3D
|
|||
ShaderVersion GetShaderVersion();
|
||||
LPDIRECT3DSURFACE9 GetBackBufferSurface();
|
||||
const D3DCAPS9 &GetCaps();
|
||||
extern IDirect3DDevice9 *dev;
|
||||
void ShowD3DError(HRESULT err);
|
||||
void EnableAlphaToCoverage();
|
||||
|
||||
extern IDirect3DDevice9 *dev;
|
||||
|
||||
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
|
||||
void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
|
||||
void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
|
||||
void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
|
||||
void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
|
||||
|
||||
struct Resolution
|
||||
{
|
||||
char name[32];
|
||||
|
|
|
@ -1,294 +0,0 @@
|
|||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "D3DTexture.h"
|
||||
#include "D3DUtil.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "Render.h"
|
||||
|
||||
using namespace D3D;
|
||||
|
||||
namespace Postprocess
|
||||
{
|
||||
LPDIRECT3DSURFACE9 displayColorBuffer;
|
||||
LPDIRECT3DSURFACE9 displayZStencilBuffer;
|
||||
|
||||
LPDIRECT3DTEXTURE9 mainColorBufferTexture;
|
||||
LPDIRECT3DSURFACE9 mainColorBuffer;
|
||||
LPDIRECT3DSURFACE9 mainZStencilBuffer;
|
||||
|
||||
const int numScratch = 2;
|
||||
LPDIRECT3DTEXTURE9 scratch[numScratch];
|
||||
LPDIRECT3DSURFACE9 scratchSurface[numScratch];
|
||||
|
||||
const int mainWidth = 640, mainHeight=480;
|
||||
const int scratchWidth = 256, scratchHeight=256;
|
||||
|
||||
int displayWidth, displayHeight;
|
||||
|
||||
bool initialized;
|
||||
|
||||
int GetWidth() {
|
||||
return initialized ? mainWidth : displayWidth;
|
||||
}
|
||||
|
||||
int GetHeight() {
|
||||
return initialized ? mainHeight : displayHeight;
|
||||
}
|
||||
|
||||
|
||||
void CreateStuff()
|
||||
{
|
||||
mainColorBufferTexture = D3D::CreateRenderTarget(mainWidth,mainHeight);
|
||||
mainColorBufferTexture->GetSurfaceLevel(0,&mainColorBuffer);
|
||||
mainZStencilBuffer = D3D::CreateDepthStencilSurface(mainWidth,mainHeight);
|
||||
|
||||
for (int i=0; i<numScratch; i++)
|
||||
{
|
||||
scratch[i]=D3D::CreateRenderTarget(scratchWidth,scratchHeight);
|
||||
scratch[i]->GetSurfaceLevel(0,&(scratchSurface[i]));
|
||||
}
|
||||
|
||||
initialized=true;
|
||||
}
|
||||
|
||||
void DestroyStuff()
|
||||
{
|
||||
SAFE_RELEASE(mainColorBuffer);
|
||||
SAFE_RELEASE(mainColorBufferTexture);
|
||||
SAFE_RELEASE(mainZStencilBuffer);
|
||||
|
||||
for (int i=0; i<numScratch; i++)
|
||||
{
|
||||
SAFE_RELEASE(scratch[i]);
|
||||
SAFE_RELEASE(scratchSurface[i]);
|
||||
}
|
||||
initialized=false;
|
||||
}
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
dev->GetRenderTarget(0,&displayColorBuffer);
|
||||
dev->GetDepthStencilSurface(&displayZStencilBuffer);
|
||||
|
||||
D3DSURFACE_DESC desc;
|
||||
displayColorBuffer->GetDesc(&desc);
|
||||
displayWidth = desc.Width;
|
||||
displayHeight = desc.Height;
|
||||
|
||||
if (g_Config.iPostprocessEffect)
|
||||
CreateStuff();
|
||||
}
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
DestroyStuff();
|
||||
SAFE_RELEASE(displayColorBuffer);
|
||||
SAFE_RELEASE(displayZStencilBuffer);
|
||||
}
|
||||
|
||||
|
||||
void BeginFrame()
|
||||
{
|
||||
if (g_Config.iPostprocessEffect)
|
||||
{
|
||||
if (!initialized)
|
||||
CreateStuff();
|
||||
dev->SetRenderTarget(0,mainColorBuffer);
|
||||
dev->SetDepthStencilSurface(mainZStencilBuffer);
|
||||
|
||||
// dev->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
Renderer::SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
|
||||
dev->Clear(0,0,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0,1,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
dev->SetRenderTarget(0,displayColorBuffer);
|
||||
dev->SetDepthStencilSurface(displayZStencilBuffer);
|
||||
DestroyStuff();
|
||||
}
|
||||
|
||||
// dev->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
Renderer::SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int filterKernel[8] = {0x40,0x80,0xc0,0xFF,0xFF,0xc0,0x80,0x40}; //good looking almost Gaussian
|
||||
|
||||
//int filterKernel[8] = {0xFF,0xc0,0x80,0x40,0x40,0x80,0xc0,0xFF,}; //crazy filter
|
||||
|
||||
void NightGlow(bool intense, bool original)
|
||||
{
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SUBTRACT);
|
||||
// dev->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
// dev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
|
||||
// dev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
|
||||
Renderer::SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SUBTRACT );
|
||||
Renderer::SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
Renderer::SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
|
||||
Renderer::SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
|
||||
|
||||
dev->SetDepthStencilSurface(0);
|
||||
|
||||
//dev->SetTexture(0,mainColorBufferTexture);
|
||||
Renderer::SetTexture( 0, mainColorBufferTexture );
|
||||
|
||||
dev->SetRenderTarget(0,scratchSurface[0]);
|
||||
dev->SetSamplerState(0,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP);
|
||||
dev->SetSamplerState(0,D3DSAMP_ADDRESSV,D3DTADDRESS_CLAMP);
|
||||
dev->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
|
||||
dev->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
|
||||
dev->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);
|
||||
dev->Clear(0,0,D3DCLEAR_TARGET,0,0,0);
|
||||
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
|
||||
//dev->SetSamplerState(0,D3DSAMP_MIPMAPLODBIAS,1.0f);
|
||||
#define QOFF(xoff,yoff,col) quad2d(-0.0f,-0.0f,scratchWidth-0.0f,scratchHeight-0.0f,col,0+xoff,0+yoff,1+xoff,1+yoff);
|
||||
float f=0.008f;
|
||||
QOFF(0,0,0xa0a0a0a0);
|
||||
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
//dev->SetTexture(0,scratch[0]);
|
||||
Renderer::SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
Renderer::SetTexture( 0, scratch[0] );
|
||||
|
||||
dev->SetRenderTarget(0,scratchSurface[1]);
|
||||
dev->Clear(0,0,D3DCLEAR_TARGET,0,0,0);
|
||||
|
||||
float yMul = 1.33333333333f;
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
DWORD c=filterKernel[i]/2;
|
||||
c|=c<<8;
|
||||
c|=c<<16;
|
||||
QOFF(0,(i-3.5f) * f * yMul,c);
|
||||
}
|
||||
|
||||
//dev->SetTexture(0,scratch[1]);
|
||||
Renderer::SetTexture( 0, scratch[1] );
|
||||
|
||||
dev->SetRenderTarget(0,scratchSurface[0]);
|
||||
dev->Clear(0,0,D3DCLEAR_TARGET,0,0,0);
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
DWORD c=filterKernel[i]/(intense?3:2);
|
||||
c|=c<<8;
|
||||
c|=c<<16;
|
||||
QOFF((i-3.5f) * f,0,c);
|
||||
}
|
||||
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
Renderer::SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
|
||||
if (intense)
|
||||
{
|
||||
// dev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
|
||||
// dev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_SRCALPHA);
|
||||
Renderer::SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
|
||||
Renderer::SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCALPHA );
|
||||
}
|
||||
else
|
||||
{
|
||||
// dev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVDESTCOLOR);
|
||||
// dev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
|
||||
Renderer::SetRenderState( D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR );
|
||||
Renderer::SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
|
||||
}
|
||||
|
||||
// dev->SetTexture(0,scratch[0]);
|
||||
Renderer::SetTexture( 0, scratch[0] );
|
||||
|
||||
dev->SetRenderTarget(0,mainColorBuffer);
|
||||
quad2d(0,0,(float)mainWidth,(float)mainHeight,original?0xCFFFFFFF:0xFFFFFFFF,0,0,1,1);
|
||||
|
||||
// dev->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
Renderer::SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
|
||||
|
||||
dev->SetSamplerState(0,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP);
|
||||
dev->SetSamplerState(0,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP);
|
||||
//dev->SetSamplerState(0,D3DSAMP_MIPMAPLODBIAS,0);
|
||||
}
|
||||
|
||||
const char **GetPostprocessingNames()
|
||||
{
|
||||
static const char *names[] = {
|
||||
"None",
|
||||
"Night Glow 1",
|
||||
"Night Glow 2",
|
||||
"Night Glow 3",
|
||||
0,
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
void FinalizeFrame()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
// dev->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
// dev->SetRenderState(D3DRS_ZENABLE,FALSE);
|
||||
// dev->SetRenderState(D3DRS_FOGENABLE,FALSE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_DIFFUSE);
|
||||
// dev->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2);
|
||||
|
||||
Renderer::SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
|
||||
Renderer::SetRenderState( D3DRS_ZENABLE, FALSE );
|
||||
Renderer::SetRenderState( D3DRS_FOGENABLE, FALSE );
|
||||
Renderer::SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
Renderer::SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
|
||||
Renderer::SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
Renderer::SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
|
||||
Renderer::SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_DIFFUSE);
|
||||
Renderer::SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2);
|
||||
|
||||
switch(g_Config.iPostprocessEffect) {
|
||||
case 1:
|
||||
NightGlow(true,true);
|
||||
case 2:
|
||||
NightGlow(false,true);
|
||||
break;
|
||||
case 3:
|
||||
NightGlow(false,false);
|
||||
break;
|
||||
}
|
||||
|
||||
dev->SetRenderTarget(0,displayColorBuffer);
|
||||
dev->SetDepthStencilSurface(displayZStencilBuffer);
|
||||
|
||||
// dev->SetTexture(0,mainColorBufferTexture);
|
||||
Renderer::SetTexture( 0, mainColorBufferTexture );
|
||||
|
||||
quad2d(0, 0, (float)displayWidth, (float)displayHeight, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Postprocess
|
||||
{
|
||||
|
||||
void Initialize();
|
||||
void Cleanup();
|
||||
|
||||
void BeginFrame();
|
||||
void FinalizeFrame();
|
||||
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
|
||||
const char **GetPostprocessingNames();
|
||||
}
|
|
@ -211,27 +211,23 @@ namespace D3D
|
|||
|
||||
void CD3DFont::SetRenderStates()
|
||||
{
|
||||
// dev->SetTexture(0, m_pTexture);
|
||||
Renderer::SetTexture(0, m_pTexture);
|
||||
D3D::SetTexture(0, m_pTexture);
|
||||
|
||||
dev->SetPixelShader(0);
|
||||
dev->SetVertexShader(0);
|
||||
|
||||
dev->SetFVF(D3DFVF_FONT2DVERTEX);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
// dev->SetRenderState((_D3DRENDERSTATETYPE)RS[i][0],RS[i][1]);
|
||||
// dev->SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS[i][1]);
|
||||
|
||||
Renderer::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS[i][1]);
|
||||
Renderer::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS[i][1]);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
D3D::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS[i][1]);
|
||||
D3D::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
void RestoreRenderStates()
|
||||
{
|
||||
// dev->SetTexture(0, texture_old);
|
||||
Renderer::SetTexture(0, texture_old);
|
||||
D3D::SetTexture(0, texture_old);
|
||||
|
||||
dev->SetPixelShader(ps_old);
|
||||
dev->SetVertexShader(vs_old);
|
||||
|
@ -240,11 +236,8 @@ namespace D3D
|
|||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// dev->SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
|
||||
// dev->SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
|
||||
|
||||
Renderer::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
|
||||
Renderer::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
|
||||
D3D::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
|
||||
D3D::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "W32Util/ShellUtil.h"
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "D3DPostprocess.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
|
@ -179,11 +178,14 @@ struct TabEnhancements : public W32Util::Tab
|
|||
{
|
||||
void Init(HWND hDlg)
|
||||
{
|
||||
WCHAR tempwstr[2000];
|
||||
|
||||
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEFILTERING),g_Config.bForceFiltering);
|
||||
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEANISOTROPY),g_Config.bForceMaxAniso);
|
||||
HWND pp = GetDlgItem(hDlg,IDC_POSTPROCESSEFFECT);
|
||||
/*
|
||||
Temporarily disabled the old postprocessing code since it wasn't working anyway.
|
||||
New postprocessing code will come sooner or later, sharing shaders and framework with
|
||||
the GL postprocessing.
|
||||
|
||||
HWND pp = GetDlgItem(hDlg, IDC_POSTPROCESSEFFECT);
|
||||
const char **names = Postprocess::GetPostprocessingNames();
|
||||
int i = 0;
|
||||
while (true)
|
||||
|
@ -196,6 +198,7 @@ struct TabEnhancements : public W32Util::Tab
|
|||
i++;
|
||||
}
|
||||
ComboBox_SetCurSel(pp, g_Config.iPostprocessEffect);
|
||||
*/
|
||||
}
|
||||
void Command(HWND hDlg,WPARAM wParam)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "OpcodeDecoding.h"
|
||||
#include "BPStructs.h"
|
||||
#include "XFStructs.h"
|
||||
#include "D3DPostprocess.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "PixelShaderManager.h"
|
||||
|
@ -51,12 +50,6 @@ float Renderer::yScale;
|
|||
int Renderer::m_recordWidth;
|
||||
int Renderer::m_recordHeight;
|
||||
|
||||
std::vector<LPDIRECT3DBASETEXTURE9> Renderer::m_Textures;
|
||||
|
||||
DWORD Renderer::m_RenderStates[MaxRenderStates+46];
|
||||
DWORD Renderer::m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
|
||||
DWORD Renderer::m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
|
||||
|
||||
bool Renderer::m_LastFrameDumped;
|
||||
bool Renderer::m_AVIDumping;
|
||||
|
||||
|
@ -91,13 +84,12 @@ void Renderer::Init(SVideoInitialize &_VideoInitialize)
|
|||
m_LastFrameDumped = false;
|
||||
m_AVIDumping = false;
|
||||
|
||||
// We're not using much fixed function. Let's just set the matrices to identity.
|
||||
// We're not using fixed function, except for some 2D.
|
||||
// Let's just set the matrices to identity to be sure.
|
||||
D3DXMATRIX mtx;
|
||||
D3DXMatrixIdentity(&mtx);
|
||||
D3D::dev->SetTransform(D3DTS_VIEW, &mtx);
|
||||
D3D::dev->SetTransform(D3DTS_WORLD, &mtx);
|
||||
|
||||
|
||||
D3D::font.Init();
|
||||
Initialize();
|
||||
}
|
||||
|
@ -115,14 +107,9 @@ void Renderer::Shutdown()
|
|||
|
||||
void Renderer::Initialize()
|
||||
{
|
||||
m_Textures.reserve(MaxTextureStages);
|
||||
for (int i = 0; i < MaxTextureStages; i++)
|
||||
m_Textures.push_back(NULL);
|
||||
for (int i = 0; i < 8; i++)
|
||||
D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16);
|
||||
|
||||
Postprocess::Initialize();
|
||||
Postprocess::BeginFrame();
|
||||
D3D::BeginFrame(true, 0);
|
||||
VertexManager::BeginFrame();
|
||||
}
|
||||
|
@ -178,12 +165,11 @@ void dumpMatrix(D3DXMATRIX &mtx)
|
|||
}
|
||||
}
|
||||
|
||||
void formatBufferDump(char *in, char *out, int w, int h, int p)
|
||||
void formatBufferDump(const char *in, char *out, int w, int h, int p)
|
||||
{
|
||||
for(int i = 0; i < h; i++) {
|
||||
char *line = in + (h - i - 1) * p;
|
||||
|
||||
for (int j = 0; j < w; j++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
const char *line = in + (h - y - 1) * p;
|
||||
for (int x = 0; x < w; x++) {
|
||||
memcpy(out, line, 3);
|
||||
out += 3;
|
||||
line += 4;
|
||||
|
@ -231,8 +217,8 @@ void Renderer::SwapBuffers()
|
|||
GetWindowRect(EmuWindow::GetWnd(), &windowRect);
|
||||
D3DLOCKED_RECT rect;
|
||||
if (SUCCEEDED(surf->LockRect(&rect, &windowRect, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY))) {
|
||||
char *data = (char *) malloc(3 * m_recordWidth * m_recordHeight);
|
||||
formatBufferDump((char *) rect.pBits, data, m_recordWidth, m_recordHeight, rect.Pitch);
|
||||
char *data = (char *)malloc(3 * m_recordWidth * m_recordHeight);
|
||||
formatBufferDump((const char *)rect.pBits, data, m_recordWidth, m_recordHeight, rect.Pitch);
|
||||
AVIDump::AddFrame(data);
|
||||
free(data);
|
||||
surf->UnlockRect();
|
||||
|
@ -252,8 +238,7 @@ void Renderer::SwapBuffers()
|
|||
m_LastFrameDumped = false;
|
||||
}
|
||||
|
||||
//Finish up the current frame, print some stats
|
||||
Postprocess::FinalizeFrame();
|
||||
// Finish up the current frame, print some stats
|
||||
if (g_Config.bOverlayStats)
|
||||
{
|
||||
char st[2048];
|
||||
|
@ -309,7 +294,6 @@ void Renderer::SwapBuffers()
|
|||
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
|
||||
}
|
||||
|
||||
|
||||
ProcessMessages();
|
||||
|
||||
#if defined(DVPROFILE)
|
||||
|
@ -329,16 +313,13 @@ void Renderer::SwapBuffers()
|
|||
|
||||
DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(NEXT_FRAME);
|
||||
|
||||
//D3D frame is now over
|
||||
|
||||
|
||||
//clean out old stuff from caches
|
||||
// D3D frame is now over
|
||||
// Clean out old stuff from caches.
|
||||
frameCount++;
|
||||
PixelShaderCache::Cleanup();
|
||||
VertexShaderCache::Cleanup();
|
||||
TextureCache::Cleanup();
|
||||
|
||||
|
||||
//Begin new frame
|
||||
//Set default viewport and scissor, for the clear to work correctly
|
||||
stats.ResetFrame();
|
||||
|
@ -362,60 +343,18 @@ void Renderer::SwapBuffers()
|
|||
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 0, 0);
|
||||
|
||||
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||
// clearColor |= 0x003F003F;
|
||||
// D3D::BeginFrame(true,clearColor,1.0f);
|
||||
D3D::BeginFrame(false, clearColor, 1.0f);
|
||||
|
||||
// This probably causes problems, and the visual difference is tiny anyway.
|
||||
// So let's keep it commented out.
|
||||
// D3D::EnableAlphaToCoverage();
|
||||
|
||||
Postprocess::BeginFrame();
|
||||
VertexManager::BeginFrame();
|
||||
|
||||
if (g_Config.bOldCard)
|
||||
D3D::font.SetRenderStates(); //compatibility with low end cards
|
||||
}
|
||||
|
||||
/*
|
||||
void Renderer::SetViewport(float* _Viewport)
|
||||
{
|
||||
Viewport* pViewport = (Viewport*)_Viewport;
|
||||
D3DVIEWPORT9 vp;
|
||||
float x=(pViewport->xOrig-662)*2;
|
||||
float y=(pViewport->yOrig-582)*2; //something is wrong, but what??
|
||||
y-=16;
|
||||
|
||||
float w=pViewport->wd*2; //multiply up to real size
|
||||
float h=pViewport->ht*-2; //why is this negative? oh well..
|
||||
|
||||
if (x < 0.0f) x = 0.0f;
|
||||
if (y < 0.0f) y = 0.0f;
|
||||
if (x > 640.0f) x = 639.0f;
|
||||
if (y > 480.0f) y = 479.0f;
|
||||
if (w < 0) w = 0;
|
||||
if (h < 0) h = 0;
|
||||
if (x+w > 640.0f) w=640-x;
|
||||
if (y+h > 480.0f) h=480-y;
|
||||
//x=y=0;
|
||||
//if (w>0.0f) w=0.0f;
|
||||
//if (h<0.0f) h=0.0f;
|
||||
|
||||
vp.X = (DWORD)(x*xScale);
|
||||
vp.Y = (DWORD)(y*yScale);
|
||||
vp.Width = (DWORD)(w*xScale);
|
||||
vp.Height = (DWORD)(h*yScale);
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
|
||||
// char temp[256];
|
||||
// sprintf(temp,"Viewport: %i %i %i %i %f %f",vp.X,vp.Y,vp.Width,vp.Height,vp.MinZ,vp.MaxZ);
|
||||
// g_VideoInitialize.pLog(temp, FALSE);
|
||||
|
||||
D3D::dev->SetViewport(&vp);
|
||||
}
|
||||
*/
|
||||
|
||||
void Renderer::SetScissorRect()
|
||||
{
|
||||
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||
|
@ -436,136 +375,30 @@ void Renderer::SetScissorRect()
|
|||
g_VideoInitialize.pLog("SCISSOR ERROR", FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
void Renderer::SetProjection(float* pMatrix, int constantIndex)
|
||||
{
|
||||
D3DXMATRIX mtx;
|
||||
if (pMatrix[6] == 0) // Perspective
|
||||
{
|
||||
mtx.m[0][0] = pMatrix[0];
|
||||
mtx.m[0][1] = 0.0f;
|
||||
mtx.m[0][2] = pMatrix[1];
|
||||
mtx.m[0][3] = 0; // -0.5f/m_height; <-- fix d3d pixel center?
|
||||
|
||||
mtx.m[1][0] = 0.0f;
|
||||
mtx.m[1][1] = pMatrix[2];
|
||||
mtx.m[1][2] = pMatrix[3];
|
||||
mtx.m[1][3] = 0; // +0.5f/m_height; <-- fix d3d pixel center?
|
||||
|
||||
<<<<<<< .mine
|
||||
mtx.m[0][2] = 0.0f;
|
||||
mtx.m[1][2] = 0.0f;
|
||||
mtx.m[2][2] = -(1 - pMatrix[4]);
|
||||
mtx.m[3][2] = pMatrix[5];
|
||||
=======
|
||||
mtx.m[2][0] = 0.0f;
|
||||
mtx.m[2][1] = 0.0f;
|
||||
mtx.m[2][2] = -(1.0f - pMatrix[4]);
|
||||
mtx.m[2][3] = pMatrix[5]; // Problematic in OGL
|
||||
>>>>>>> .r2480
|
||||
|
||||
mtx.m[3][0] = 0.0f;
|
||||
mtx.m[3][1] = 0.0f;
|
||||
// donkopunchstania: GC GPU rounds differently?
|
||||
// -(1 + epsilon) so objects are clipped as they are on the real HW
|
||||
mtx.m[3][2] = -1.00000011921f;
|
||||
mtx.m[3][3] = 0.0f;
|
||||
}
|
||||
else // Orthographic Projection
|
||||
{
|
||||
mtx.m[0][0] = pMatrix[0];
|
||||
mtx.m[0][1] = 0.0f;
|
||||
mtx.m[0][2] = 0.0f;
|
||||
mtx.m[0][3] = pMatrix[1]; // -0.5f/m_width; <-- fix d3d pixel center?
|
||||
|
||||
mtx.m[1][0] = 0.0f;
|
||||
mtx.m[1][1] = pMatrix[2];
|
||||
mtx.m[1][2] = 0.0f;
|
||||
mtx.m[1][3] = pMatrix[3]; // +0.5f/m_height; <-- fix d3d pixel center?
|
||||
|
||||
mtx.m[2][0] = 0.0f;
|
||||
mtx.m[2][1] = 0.0f;
|
||||
mtx.m[2][2] = pMatrix[4];
|
||||
mtx.m[2][3] = -(-1.0f - pMatrix[5]);
|
||||
|
||||
mtx.m[3][0] = 0;
|
||||
mtx.m[3][1] = 0;
|
||||
mtx.m[3][2] = 0.0f;
|
||||
mtx.m[3][3] = 1.0f;
|
||||
}
|
||||
D3D::dev->SetVertexShaderConstantF(constantIndex, mtx, 4);
|
||||
}*/
|
||||
|
||||
void Renderer::SetTexture(DWORD Stage, LPDIRECT3DBASETEXTURE9 pTexture)
|
||||
{
|
||||
if (m_Textures[Stage] != pTexture)
|
||||
{
|
||||
m_Textures[Stage] = pTexture;
|
||||
D3D::dev->SetTexture(Stage, pTexture);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
|
||||
{
|
||||
if (m_RenderStates[State] != Value)
|
||||
{
|
||||
m_RenderStates[State] = Value;
|
||||
D3D::dev->SetRenderState(State, Value);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
|
||||
{
|
||||
if (m_TextureStageStates[Stage][Type] != Value)
|
||||
{
|
||||
m_TextureStageStates[Stage][Type] = Value;
|
||||
D3D::dev->SetTextureStageState(Stage, Type, Value);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value)
|
||||
{
|
||||
if (m_SamplerStates[Sampler][Type] != Value)
|
||||
{
|
||||
m_SamplerStates[Sampler][Type] = Value;
|
||||
D3D::dev->SetSamplerState(Sampler, Type, Value);
|
||||
}
|
||||
}
|
||||
|
||||
// mtx.m[0][3] = pMatrix[1]; // -0.5f/m_width; <-- fix d3d pixel center?
|
||||
// mtx.m[1][3] = pMatrix[3]; // +0.5f/m_height; <-- fix d3d pixel center?
|
||||
|
||||
// Called from VertexShaderManager
|
||||
void UpdateViewport()
|
||||
{
|
||||
// TODO : remove this HACK: Update viewport is still a bit wrong and causes the
|
||||
// image to be y-offset for some reason though.
|
||||
return;
|
||||
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
|
||||
// [0] = width/2
|
||||
// [1] = height/2
|
||||
// [2] = 16777215 *(farz - nearz)
|
||||
// [3] = xorig + width/2 + 342
|
||||
// [4] = yorig + height/2 + 342
|
||||
// [5] = 16777215 * farz
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2;
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2;
|
||||
// -------------------------------------
|
||||
|
||||
float MValueX = Renderer::GetXScale();
|
||||
float MValueY = Renderer::GetYScale();
|
||||
|
||||
/*INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",
|
||||
rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
|
||||
2 * rawViewport[0], 2 * rawViewport[1],
|
||||
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
vp.X = (int)(ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - (scissorXOff)) * MValueX);
|
||||
vp.Y = (int)(ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - (scissorYOff)) * MValueY);
|
||||
|
||||
vp.Width = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
|
||||
vp.Height = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
|
||||
|
||||
vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777215.0f;
|
||||
vp.MaxZ = xfregs.rawViewport[5] / 16777215.0f;
|
||||
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||
|
||||
vp.X = (int)((xfregs.rawViewport[3] - xfregs.rawViewport[0] - 342 - scissorXOff) * Renderer::GetXScale());
|
||||
vp.Y = (int)(Renderer::GetTargetHeight() - (xfregs.rawViewport[4] - xfregs.rawViewport[1] - 342 - scissorYOff) * Renderer::GetYScale());
|
||||
|
||||
vp.Width = (int)ceil(fabs(2 * xfregs.rawViewport[0]) * Renderer::GetXScale());
|
||||
vp.Height = (int)ceil(fabs(2 * xfregs.rawViewport[1]) * Renderer::GetYScale());
|
||||
|
||||
vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777215.0f; // NearZ
|
||||
vp.MaxZ = xfregs.rawViewport[5] / 16777215.0f; // FarZ
|
||||
|
||||
D3D::dev->SetViewport(&vp);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,27 +31,6 @@ extern CGprofile g_cgvProf, g_cgfProf;
|
|||
|
||||
class Renderer
|
||||
{
|
||||
// screen offset
|
||||
static float m_x;
|
||||
static float m_y;
|
||||
static float m_width;
|
||||
static float m_height;
|
||||
static float xScale;
|
||||
static float yScale;
|
||||
static bool m_LastFrameDumped;
|
||||
static bool m_AVIDumping;
|
||||
static int m_recordWidth;
|
||||
static int m_recordHeight;
|
||||
const static int MaxTextureStages = 9;
|
||||
const static int MaxRenderStates = 210;
|
||||
const static DWORD MaxTextureTypes = 33;
|
||||
const static DWORD MaxSamplerSize = 13;
|
||||
const static DWORD MaxSamplerTypes = 15;
|
||||
static std::vector<LPDIRECT3DBASETEXTURE9> m_Textures;
|
||||
static DWORD m_RenderStates[MaxRenderStates+46];
|
||||
static DWORD m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
|
||||
static DWORD m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
|
||||
|
||||
public:
|
||||
static void Init(SVideoInitialize &_VideoInitialize);
|
||||
static void Shutdown();
|
||||
|
@ -70,17 +49,26 @@ public:
|
|||
|
||||
static void SetScissorRect();
|
||||
// static void SetProjection(float* _pProjection, int constantIndex = -1);
|
||||
static u32 AccessEFB(EFBAccessType type, int x, int y);
|
||||
|
||||
// The little status display.
|
||||
static void AddMessage(const std::string &message, unsigned int ms);
|
||||
static void ProcessMessages();
|
||||
static void RenderText(const std::string &text, int left, int top, unsigned int color);
|
||||
|
||||
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
|
||||
static void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
|
||||
static void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
|
||||
static void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
|
||||
static void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
|
||||
private:
|
||||
// screen offset
|
||||
static float m_x;
|
||||
static float m_y;
|
||||
static float m_width;
|
||||
static float m_height;
|
||||
static float xScale;
|
||||
static float yScale;
|
||||
static bool m_LastFrameDumped;
|
||||
static bool m_AVIDumping;
|
||||
static int m_recordWidth;
|
||||
static int m_recordHeight;
|
||||
static std::vector<LPDIRECT3DBASETEXTURE9> m_Textures;
|
||||
};
|
||||
|
||||
#endif // __H_RENDER__
|
||||
|
|
|
@ -149,10 +149,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
|||
return &entry;
|
||||
}
|
||||
lastTexture[stage] = entry.texture;
|
||||
|
||||
// D3D::dev->SetTexture(stage,iter->second.texture);
|
||||
Renderer::SetTexture( stage, entry.texture );
|
||||
|
||||
D3D::SetTexture( stage, entry.texture );
|
||||
return &entry;
|
||||
}
|
||||
else
|
||||
|
@ -244,8 +241,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
|||
SETSTAT(stats.numTexturesAlive, (int)textures.size());
|
||||
|
||||
//Set the texture!
|
||||
// D3D::dev->SetTexture(stage,entry.texture);
|
||||
Renderer::SetTexture( stage, entry.texture );
|
||||
D3D::SetTexture( stage, entry.texture );
|
||||
|
||||
lastTexture[stage] = entry.texture;
|
||||
|
||||
|
|
|
@ -265,8 +265,8 @@ void Flush()
|
|||
goto shader_fail;
|
||||
|
||||
// update alpha only
|
||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
|
||||
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
|
||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
if (collection != C_POINTS)
|
||||
|
@ -299,9 +299,9 @@ void Flush()
|
|||
if (bpmem.blendmode.colorupdate)
|
||||
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
|
||||
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
||||
|
||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ GFXDebuggerDX9 *m_DebuggerFrame = NULL;
|
|||
#include "VertexShaderCache.h"
|
||||
#include "PixelShaderCache.h"
|
||||
#include "DlgSettings.h"
|
||||
#include "D3DPostprocess.h"
|
||||
#include "D3DTexture.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "W32Util/Misc.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="Plugin_VideoOGL"
|
||||
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
|
||||
RootNamespace="Plugin_VideoOGL"
|
||||
|
@ -932,14 +932,6 @@
|
|||
RelativePath=".\Src\GLWindow.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConversionShader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConversionShader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\TextureConverter.cpp"
|
||||
>
|
||||
|
|
|
@ -148,7 +148,7 @@ void ClearScreen(const BPCmd &bp, const EFBRectangle &rc)
|
|||
|
||||
void RestoreRenderState(const BPCmd &bp)
|
||||
{
|
||||
Renderer::RestoreGLState();
|
||||
Renderer::RestoreAPIState();
|
||||
}
|
||||
|
||||
bool GetConfig(const int &type)
|
||||
|
|
|
@ -362,40 +362,6 @@ bool Renderer::Init()
|
|||
cgGLSetDebugMode(GL_FALSE);
|
||||
#endif
|
||||
|
||||
if (!InitializeGL())
|
||||
return false;
|
||||
|
||||
return glGetError() == GL_NO_ERROR && bSuccess;
|
||||
}
|
||||
|
||||
void Renderer::Shutdown(void)
|
||||
{
|
||||
delete s_pfont;
|
||||
s_pfont = 0;
|
||||
|
||||
if (g_cgcontext) {
|
||||
cgDestroyContext(g_cgcontext);
|
||||
g_cgcontext = 0;
|
||||
}
|
||||
|
||||
glDeleteFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
|
||||
s_tempScreenshotFramebuffer = 0;
|
||||
|
||||
s_framebufferManager.Shutdown();
|
||||
|
||||
#ifdef _WIN32
|
||||
if(s_bAVIDumping) {
|
||||
AVIDump::Stop();
|
||||
}
|
||||
#else
|
||||
if(f_pFrameDump != NULL) {
|
||||
fclose(f_pFrameDump);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Renderer::InitializeGL()
|
||||
{
|
||||
glStencilFunc(GL_ALWAYS, 0, 0);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
|
@ -432,9 +398,34 @@ bool Renderer::InitializeGL()
|
|||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
return GL_REPORT_ERROR() == GL_NO_ERROR;
|
||||
return glGetError() == GL_NO_ERROR && bSuccess;
|
||||
}
|
||||
|
||||
void Renderer::Shutdown(void)
|
||||
{
|
||||
delete s_pfont;
|
||||
s_pfont = 0;
|
||||
|
||||
if (g_cgcontext) {
|
||||
cgDestroyContext(g_cgcontext);
|
||||
g_cgcontext = 0;
|
||||
}
|
||||
|
||||
glDeleteFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
|
||||
s_tempScreenshotFramebuffer = 0;
|
||||
|
||||
s_framebufferManager.Shutdown();
|
||||
|
||||
#ifdef _WIN32
|
||||
if(s_bAVIDumping) {
|
||||
AVIDump::Stop();
|
||||
}
|
||||
#else
|
||||
if(f_pFrameDump != NULL) {
|
||||
fclose(f_pFrameDump);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Return the rendering window width and height
|
||||
int Renderer::GetTargetWidth()
|
||||
|
@ -467,7 +458,7 @@ void Renderer::SetFramebuffer(GLuint fb)
|
|||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb != 0 ? fb : s_framebufferManager.GetEFBFramebuffer());
|
||||
}
|
||||
|
||||
void Renderer::ResetGLState()
|
||||
void Renderer::ResetAPIState()
|
||||
{
|
||||
// Gets us to a reasonably sane state where it's possible to do things like
|
||||
// image copies with textured quads, etc.
|
||||
|
@ -484,7 +475,7 @@ void Renderer::ResetGLState()
|
|||
|
||||
void UpdateViewport();
|
||||
|
||||
void Renderer::RestoreGLState()
|
||||
void Renderer::RestoreAPIState()
|
||||
{
|
||||
// Gets us back into a more game-like state.
|
||||
|
||||
|
@ -832,7 +823,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
||||
DVSTARTPROFILE();
|
||||
|
||||
ResetGLState();
|
||||
ResetAPIState();
|
||||
|
||||
TargetRectangle back_rc;
|
||||
ComputeBackbufferRectangle(&back_rc);
|
||||
|
@ -1038,7 +1029,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|||
// Why save this as s_bNativeResolution if we updated it every frame?
|
||||
s_bNativeResolution = g_Config.bNativeResolution;
|
||||
|
||||
RestoreGLState();
|
||||
RestoreAPIState();
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
g_Config.iSaveTargetId = 0;
|
||||
|
@ -1436,16 +1427,16 @@ void UpdateViewport()
|
|||
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
|
||||
// --------
|
||||
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||
int scissorXOff = bpmem.scissorOffset.x * 2; // 342
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2; // 342
|
||||
// -------------------------------------
|
||||
|
||||
float MValueX = Renderer::GetTargetScaleX();
|
||||
float MValueY = Renderer::GetTargetScaleY();
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
int GLx = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - 342 - scissorXOff) * MValueX);
|
||||
int GLy = (int)ceil(Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4] - xfregs.rawViewport[1] - 342 - scissorYOff)) * MValueY);
|
||||
int GLx = (int)ceil((xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff) * MValueX);
|
||||
int GLy = (int)ceil(Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4] - xfregs.rawViewport[1] - scissorYOff)) * MValueY);
|
||||
int GLWidth = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
|
||||
int GLHeight = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
|
||||
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777215.0f;
|
||||
|
|
|
@ -47,15 +47,12 @@ public:
|
|||
static bool Init();
|
||||
static void Shutdown();
|
||||
|
||||
// initialize opengl standard values (like viewport)
|
||||
static bool InitializeGL();
|
||||
|
||||
static void ResetGLState();
|
||||
static void RestoreGLState();
|
||||
// What's the real difference between these? Too similar names.
|
||||
static void ResetAPIState();
|
||||
static void RestoreAPIState();
|
||||
|
||||
static void SwapBuffers();
|
||||
|
||||
static bool IsBlack();
|
||||
static void SetColorMask();
|
||||
static void SetBlendMode(bool forceUpdate);
|
||||
static bool SetScissorRect();
|
||||
|
|
|
@ -23,7 +23,6 @@ files = [
|
|||
'VertexManager.cpp',
|
||||
'VertexLoaderManager.cpp',
|
||||
'XFB.cpp',
|
||||
'TextureConversionShader.cpp',
|
||||
'OnScreenDisplay.cpp',
|
||||
'PostProcessing.cpp',
|
||||
'FramebufferManager.cpp',
|
||||
|
|
|
@ -169,7 +169,7 @@ void Shutdown()
|
|||
void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const TargetRectangle& sourceRc,
|
||||
u8* destAddr, int dstWidth, int dstHeight, bool linearFilter)
|
||||
{
|
||||
Renderer::ResetGLState();
|
||||
Renderer::ResetAPIState();
|
||||
|
||||
// switch to texture converter frame buffer
|
||||
// attach render buffer as color destination
|
||||
|
@ -218,13 +218,13 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const Tar
|
|||
GL_REPORT_ERRORD();
|
||||
|
||||
Renderer::SetFramebuffer(0);
|
||||
Renderer::RestoreGLState();
|
||||
Renderer::RestoreAPIState();
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
TextureMngr::DisableStage(0);
|
||||
|
||||
Renderer::RestoreGLState();
|
||||
Renderer::RestoreAPIState();
|
||||
GL_REPORT_ERRORD();
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
|||
return;
|
||||
}
|
||||
|
||||
Renderer::ResetGLState();
|
||||
Renderer::ResetAPIState();
|
||||
|
||||
float srcFormatFactor = 0.5f;
|
||||
float srcFmtWidth = srcWidth * srcFormatFactor;
|
||||
|
@ -362,7 +362,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
|||
|
||||
Renderer::SetFramebuffer(0);
|
||||
|
||||
Renderer::RestoreGLState();
|
||||
Renderer::RestoreAPIState();
|
||||
GL_REPORT_ERRORD();
|
||||
}
|
||||
|
||||
|
|
|
@ -686,7 +686,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
GL_REPORT_ERRORD();
|
||||
|
||||
// We have to run a pixel shader, for color conversion.
|
||||
Renderer::ResetGLState(); // reset any game specific settings
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
|
||||
if (s_TempFramebuffer == 0)
|
||||
glGenFramebuffersEXT(1, (GLuint *)&s_TempFramebuffer);
|
||||
|
@ -725,7 +725,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
|
||||
// Return to the EFB.
|
||||
Renderer::SetFramebuffer(0);
|
||||
Renderer::RestoreGLState();
|
||||
Renderer::RestoreAPIState();
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
TextureMngr::DisableStage(0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue