mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Minor code formatting:
First step to bring a level of consistency between the video plug-ins - variable names, spacing, function names, function order, comments, file names. This will help us identify common code for VideoMerge. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6235 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -16,24 +16,26 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "BPFunctions.h"
|
||||
#include "D3DBase.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "Common.h"
|
||||
#include "D3DBase.h"
|
||||
#include "Debugger/Debugger.h"
|
||||
#include "TextureCache.h"
|
||||
#include "VertexManager.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "Debugger/Debugger.h"
|
||||
#include "TextureConverter.h"
|
||||
|
||||
#include "VideoConfig.h"
|
||||
|
||||
bool textureChanged[8];
|
||||
|
||||
const bool renderFog = false;
|
||||
|
||||
using namespace D3D;
|
||||
|
||||
namespace BPFunctions
|
||||
{
|
||||
// ----------------------------------------------
|
||||
// State translation lookup tables
|
||||
// Reference: Yet Another Gamecube Documentation
|
||||
// ----------------------------------------------
|
||||
|
||||
|
||||
void FlushPipeline()
|
||||
{
|
||||
@ -80,9 +82,10 @@ void SetColorMask(const BPCmd &bp)
|
||||
|
||||
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const int &scaleByHalf)
|
||||
{
|
||||
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
|
||||
if (!g_ActiveConfig.bEFBCopyDisable)
|
||||
{
|
||||
TextureCache::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
||||
TextureCache::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,22 +24,24 @@
|
||||
namespace D3D
|
||||
{
|
||||
|
||||
// Bytecode->shader.
|
||||
// bytecode->shader.
|
||||
LPDIRECT3DVERTEXSHADER9 CreateVertexShaderFromByteCode(const u8 *bytecode, int len)
|
||||
{
|
||||
LPDIRECT3DVERTEXSHADER9 v_shader;
|
||||
HRESULT hr = D3D::dev->CreateVertexShader((DWORD *)bytecode, &v_shader);
|
||||
if (FAILED(hr))
|
||||
v_shader = 0;
|
||||
{
|
||||
PanicAlert("CreateVertexShaderFromByteCode failed from %p (size %d) at %s %d\n", bytecode, len, __FILE__, __LINE__);
|
||||
v_shader = NULL;
|
||||
}
|
||||
return v_shader;
|
||||
}
|
||||
|
||||
// Code->bytecode.
|
||||
// code->bytecode.
|
||||
bool CompileVertexShader(const char *code, int len, u8 **bytecode, int *bytecodelen)
|
||||
{
|
||||
//try to compile
|
||||
LPD3DXBUFFER shaderBuffer = 0;
|
||||
LPD3DXBUFFER errorBuffer = 0;
|
||||
LPD3DXBUFFER shaderBuffer = NULL;
|
||||
LPD3DXBUFFER errorBuffer = NULL;
|
||||
HRESULT hr = PD3DXCompileShader(code, len, 0, 0, "main", D3D::VertexShaderVersionString(),
|
||||
0, &shaderBuffer, &errorBuffer, 0);
|
||||
if (FAILED(hr))
|
||||
@ -69,18 +71,20 @@ bool CompileVertexShader(const char *code, int len, u8 **bytecode, int *bytecode
|
||||
return SUCCEEDED(hr) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
// Bytecode->shader.
|
||||
// bytecode->shader
|
||||
LPDIRECT3DPIXELSHADER9 CreatePixelShaderFromByteCode(const u8 *bytecode, int len)
|
||||
{
|
||||
LPDIRECT3DPIXELSHADER9 p_shader;
|
||||
HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)bytecode, &p_shader);
|
||||
if (FAILED(hr))
|
||||
p_shader = 0;
|
||||
{
|
||||
PanicAlert("CreatePixelShaderFromByteCode failed at %s %d\n", __FILE__, __LINE__);
|
||||
p_shader = NULL;
|
||||
}
|
||||
return p_shader;
|
||||
}
|
||||
|
||||
|
||||
// code->bytecode
|
||||
bool CompilePixelShader(const char *code, int len, u8 **bytecode, int *bytecodelen)
|
||||
{
|
||||
LPD3DXBUFFER shaderBuffer = 0;
|
||||
@ -118,28 +122,32 @@ bool CompilePixelShader(const char *code, int len, u8 **bytecode, int *bytecodel
|
||||
return SUCCEEDED(hr) ? true : false;
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len) {
|
||||
LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len)
|
||||
{
|
||||
u8 *bytecode;
|
||||
int bytecodelen;
|
||||
if (CompileVertexShader(code, len, &bytecode, &bytecodelen)) {
|
||||
if (CompileVertexShader(code, len, &bytecode, &bytecodelen))
|
||||
{
|
||||
LPDIRECT3DVERTEXSHADER9 v_shader = CreateVertexShaderFromByteCode(bytecode, len);
|
||||
delete [] bytecode;
|
||||
return v_shader;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
PanicAlert("Failed to compile and create vertex shader from %p (size %d) at %s %d\n", code, len, __FILE__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char *code, int len) {
|
||||
LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char* code, unsigned int len)
|
||||
{
|
||||
u8 *bytecode;
|
||||
int bytecodelen;
|
||||
if (CompilePixelShader(code, len, &bytecode, &bytecodelen)) {
|
||||
if (CompilePixelShader(code, len, &bytecode, &bytecodelen))
|
||||
{
|
||||
LPDIRECT3DPIXELSHADER9 p_shader = CreatePixelShaderFromByteCode(bytecode, len);
|
||||
delete [] bytecode;
|
||||
return p_shader;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
PanicAlert("Failed to compile and create pixel shader, %s %d\n", __FILE__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -30,5 +30,5 @@ namespace D3D
|
||||
|
||||
// Utility functions
|
||||
LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len);
|
||||
LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char *code, int len);
|
||||
LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char *code, unsigned int len);
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ int CD3DFont::Init()
|
||||
m_fTextScale = 1.0f; // Draw fonts into texture without scaling
|
||||
|
||||
// Prepare to create a bitmap
|
||||
int *pBitmapBits;
|
||||
unsigned int* pBitmapBits;
|
||||
BITMAPINFO bmi;
|
||||
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
|
||||
bmi.bmiHeader.biHeight = -(int)m_dwTexHeight;
|
||||
@ -74,8 +74,8 @@ int CD3DFont::Init()
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
|
||||
// Create a DC and a bitmap for the font
|
||||
HDC hDC = CreateCompatibleDC(NULL);
|
||||
HBITMAP hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (VOID**)&pBitmapBits, NULL, 0);
|
||||
HDC hDC = CreateCompatibleDC(NULL);
|
||||
HBITMAP hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
|
||||
SetMapMode(hDC, MM_TEXT);
|
||||
|
||||
// Create a font. By specifying ANTIALIASED_QUALITY, we might get an
|
||||
@ -99,7 +99,7 @@ int CD3DFont::Init()
|
||||
SetBkColor (hDC, 0);
|
||||
SetTextAlign(hDC, TA_TOP);
|
||||
|
||||
// Loop through all printable character and output them to the bitmap..
|
||||
// Loop through all printable characters and output them to the bitmap
|
||||
// Meanwhile, keep track of the corresponding tex coords for each character.
|
||||
int x = 0, y = 0;
|
||||
char str[2] = "\0";
|
||||
@ -120,10 +120,12 @@ int CD3DFont::Init()
|
||||
m_fTexCoords[c][2] = ((float)(x+0+size.cx))/m_dwTexWidth;
|
||||
m_fTexCoords[c][3] = ((float)(y+0+size.cy))/m_dwTexHeight;
|
||||
|
||||
x += size.cx + 3; //3 to work around annoying ij conflict (part of the j ends up with the i)
|
||||
x += size.cx + 3; // 3 to work around annoying ij conflict (part of the j ends up with the i)
|
||||
}
|
||||
|
||||
// Create a new texture for the font
|
||||
// possible optimization: store the converted data in a buffer and fill the texture on creation.
|
||||
// That way, we can use a static texture
|
||||
hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, D3DUSAGE_DYNAMIC,
|
||||
D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL);
|
||||
if (FAILED(hr))
|
||||
@ -245,7 +247,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
|
||||
float invLineHeight = 1.0f / ((m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight);
|
||||
// Fill vertex buffer
|
||||
FONT2DVERTEX* pVertices;
|
||||
int dwNumTriangles = 0L;
|
||||
int dwNumTriangles = 0L;
|
||||
m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
|
||||
|
||||
const char *oldstrText=strText;
|
||||
@ -296,7 +298,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
|
||||
if (c < (' '))
|
||||
continue;
|
||||
|
||||
c-=32;
|
||||
c -= 32;
|
||||
float tx1 = m_fTexCoords[c][0];
|
||||
float ty1 = m_fTexCoords[c][1];
|
||||
float tx2 = m_fTexCoords[c][2];
|
||||
@ -329,7 +331,6 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
|
||||
m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
|
||||
dwNumTriangles = 0;
|
||||
}
|
||||
|
||||
sx += w + spacing*fXScale*vpWidth;
|
||||
}
|
||||
|
||||
|
@ -349,15 +349,15 @@ static void DX9DebuggerUpdateScreen()
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(NULL);
|
||||
|
||||
D3D::dev->StretchRect(FBManager.GetEFBColorRTSurface(), NULL,
|
||||
D3D::dev->StretchRect(g_framebufferManager.GetEFBColorRTSurface(), NULL,
|
||||
D3D::GetBackBufferSurface(), NULL,
|
||||
D3DTEXF_LINEAR);
|
||||
|
||||
D3D::dev->EndScene();
|
||||
D3D::dev->Present(NULL, NULL, NULL, NULL);
|
||||
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->BeginScene();
|
||||
}
|
||||
else
|
||||
|
@ -145,14 +145,6 @@ void OSDMenu(WPARAM wParam)
|
||||
case '3':
|
||||
OSDChoice = 1;
|
||||
// Toggle native resolution
|
||||
/*
|
||||
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
|
||||
g_Config.bNativeResolution = true;
|
||||
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
|
||||
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
|
||||
else if (Renderer::AllowCustom())
|
||||
g_Config.b2xResolution = false;
|
||||
*/
|
||||
OSDInternalW = D3D::GetBackBufferWidth();
|
||||
OSDInternalH = D3D::GetBackBufferHeight();
|
||||
break;
|
||||
@ -224,6 +216,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
|
||||
// TODO:
|
||||
// 1. Remove redundant window manipulation,
|
||||
// 2. Make DX9 in fullscreen can be overlapped by other dialogs
|
||||
// 3. Request window sizes which actually make the client area map to a common resolution
|
||||
HWND Ret;
|
||||
int x=0, y=0, width=640, height=480;
|
||||
g_VideoInitialize.pRequestWindowSize(x, y, width, height);
|
||||
|
@ -26,7 +26,7 @@
|
||||
#undef CHECK
|
||||
#define CHECK(hr, Message, ...) if (FAILED(hr)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: " Message, __FILE__, __LINE__, __VA_ARGS__); }
|
||||
|
||||
FramebufferManager FBManager;
|
||||
FramebufferManager g_framebufferManager;
|
||||
|
||||
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorRTSurface()
|
||||
{
|
||||
@ -313,7 +313,6 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
LPDIRECT3DTEXTURE9 xfbTexture;
|
||||
HRESULT hr = 0;
|
||||
|
||||
|
||||
VirtualXFBListType::iterator it = findVirtualXFB(xfbAddr, fbWidth, fbHeight);
|
||||
|
||||
if (it == m_virtualXFBList.end() && (int)m_virtualXFBList.size() >= MAX_VIRTUAL_XFB)
|
||||
@ -393,8 +392,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
m_virtualXFBList.push_front(newVirt);
|
||||
}
|
||||
|
||||
// Copy EFB to XFB texture
|
||||
|
||||
// Copy EFB data to XFB and restore render target again
|
||||
if(!xfbTexture)
|
||||
return;
|
||||
LPDIRECT3DTEXTURE9 read_texture = GetEFBColorTexture(sourceRc);
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
void Destroy();
|
||||
|
||||
void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
|
||||
const XFBSource** GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
|
||||
LPDIRECT3DTEXTURE9 GetEFBColorTexture(const EFBRectangle& sourceRc);
|
||||
@ -168,6 +167,6 @@ private:
|
||||
D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface
|
||||
};
|
||||
|
||||
extern FramebufferManager FBManager;
|
||||
extern FramebufferManager g_framebufferManager;
|
||||
|
||||
#endif
|
||||
|
@ -28,4 +28,4 @@
|
||||
// A global plugin specification
|
||||
extern PLUGIN_GLOBALS* globals;
|
||||
|
||||
#endif // _GLOBALS_H_
|
||||
#endif // _GLOBALS_H_
|
@ -27,7 +27,6 @@
|
||||
#include "CPMemory.h"
|
||||
#include "NativeVertexFormat.h"
|
||||
|
||||
|
||||
class D3DVertexFormat : public NativeVertexFormat
|
||||
{
|
||||
LPDIRECT3DVERTEXDECLARATION9 d3d_decl;
|
||||
@ -76,12 +75,13 @@ D3DDECLTYPE VarToD3D(VarType t, int size)
|
||||
D3DDECLTYPE_UNUSED, D3DDECLTYPE_UBYTE4N, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_USHORT4N, D3DDECLTYPE_FLOAT4,
|
||||
};
|
||||
D3DDECLTYPE retval = D3DDECLTYPE_UNUSED;
|
||||
switch (size) {
|
||||
switch (size)
|
||||
{
|
||||
case 1: retval = lookup1[t]; break;
|
||||
case 2: retval = lookup2[t]; break;
|
||||
case 3: retval = lookup3[t]; break;
|
||||
case 4: retval = lookup4[t]; break;
|
||||
default: PanicAlert("VarToD3D: size wrong (%i)", size); break;
|
||||
default: break;
|
||||
}
|
||||
if (retval == D3DDECLTYPE_UNUSED) {
|
||||
PanicAlert("VarToD3D: Invalid type/size combo %i , %i", (int)t, size);
|
||||
|
@ -239,14 +239,13 @@ void PixelShaderCache::Init()
|
||||
char cache_filename[MAX_PATH];
|
||||
sprintf(cache_filename, "%sdx9-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
|
||||
PixelShaderCacheInserter inserter;
|
||||
int read_items = g_ps_disk_cache.OpenAndRead(cache_filename, &inserter);
|
||||
g_ps_disk_cache.OpenAndRead(cache_filename, &inserter);
|
||||
}
|
||||
|
||||
// ONLY to be used during shutdown.
|
||||
void PixelShaderCache::Clear()
|
||||
{
|
||||
PSCache::iterator iter = PixelShaders.begin();
|
||||
for (; iter != PixelShaders.end(); ++iter)
|
||||
for (PSCache::iterator iter = PixelShaders.begin(); iter != PixelShaders.end(); iter++)
|
||||
iter->second.Destroy();
|
||||
PixelShaders.clear();
|
||||
|
||||
@ -279,19 +278,16 @@ bool PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
PIXELSHADERUID uid;
|
||||
GetPixelShaderId(&uid, dstAlpha);
|
||||
|
||||
// Is the shader already set?
|
||||
// Check if the shader is already set
|
||||
if (uid == last_pixel_shader_uid && PixelShaders[uid].frameCount == frameCount)
|
||||
{
|
||||
PSCache::const_iterator iter = PixelShaders.find(uid);
|
||||
if (iter != PixelShaders.end() && iter->second.shader)
|
||||
return true; // Sure, we're done.
|
||||
else
|
||||
return false; // ?? something is wrong.
|
||||
return (iter != PixelShaders.end() && iter->second.shader);
|
||||
}
|
||||
|
||||
memcpy(&last_pixel_shader_uid, &uid, sizeof(PIXELSHADERUID));
|
||||
|
||||
// Is the shader already in the cache?
|
||||
|
||||
// Check if the shader is already in the cache
|
||||
PSCache::iterator iter;
|
||||
iter = PixelShaders.find(uid);
|
||||
if (iter != PixelShaders.end())
|
||||
@ -311,14 +307,14 @@ bool PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
return false;
|
||||
}
|
||||
|
||||
// OK, need to generate and compile it.
|
||||
// Need to compile a new shader
|
||||
const char *code = GeneratePixelShaderCode(dstAlpha, API_D3D9,components);
|
||||
|
||||
u32 code_hash = HashAdler32((const u8 *)code, strlen(code));
|
||||
unique_shaders.insert(code_hash);
|
||||
SETSTAT(stats.numUniquePixelShaders, unique_shaders.size());
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
||||
static int counter = 0;
|
||||
char szTemp[MAX_PATH];
|
||||
@ -326,7 +322,7 @@ bool PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
|
||||
SaveData(szTemp, code);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
u8 *bytecode = 0;
|
||||
int bytecodelen = 0;
|
||||
@ -342,7 +338,7 @@ bool PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here we have the UID and the byte code. Insert it into the disk cache.
|
||||
// Insert the bytecode into the caches
|
||||
g_ps_disk_cache.Append((u8 *)&uid, sizeof(uid), bytecode, bytecodelen);
|
||||
g_ps_disk_cache.Sync();
|
||||
|
||||
@ -352,7 +348,8 @@ bool PixelShaderCache::SetShader(bool dstAlpha,u32 components)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate) {
|
||||
bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate)
|
||||
{
|
||||
LPDIRECT3DPIXELSHADER9 shader = D3D::CreatePixelShaderFromByteCode(bytecode, bytecodelen);
|
||||
|
||||
// Make an entry in the table
|
||||
@ -368,7 +365,7 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytec
|
||||
}
|
||||
|
||||
INCSTAT(stats.numPixelShadersCreated);
|
||||
SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size());
|
||||
SETSTAT(stats.numPixelShadersAlive, PixelShaders.size());
|
||||
if (activate)
|
||||
{
|
||||
D3D::SetPixelShader(shader);
|
||||
|
@ -51,7 +51,7 @@
|
||||
|
||||
#include "debugger/debugger.h"
|
||||
|
||||
int s_fps=0;
|
||||
static int s_fps = 0;
|
||||
|
||||
static bool WindowResized;
|
||||
static int s_target_width;
|
||||
@ -75,14 +75,14 @@ static float EFByScale;
|
||||
static int s_recordWidth;
|
||||
static int s_recordHeight;
|
||||
|
||||
static bool s_LastFrameDumped;
|
||||
static bool s_AVIDumping;
|
||||
static bool s_bLastFrameDumped;
|
||||
static bool s_bAVIDumping;
|
||||
|
||||
static u32 s_blendMode;
|
||||
static u32 s_LastAA;
|
||||
static u32 s_LastEFBScale;
|
||||
static bool IS_AMD;
|
||||
static bool XFBWrited;
|
||||
static bool XFBWrited = false;
|
||||
|
||||
// used extern by other files. need to clean this up at some point.
|
||||
int frameCount;
|
||||
@ -120,6 +120,24 @@ static const D3DBLEND d3dDestFactors[8] =
|
||||
D3DBLEND_INVDESTALPHA
|
||||
};
|
||||
|
||||
// 0 0x00
|
||||
// 1 Source & destination
|
||||
// 2 Source & ~destination
|
||||
// 3 Source
|
||||
// 4 ~Source & destination
|
||||
// 5 Destination
|
||||
// 6 Source ^ destination = Source & ~destination | ~Source & destination
|
||||
// 7 Source | destination
|
||||
|
||||
// 8 ~(Source | destination)
|
||||
// 9 ~(Source ^ destination) = ~Source & ~destination | Source & destination
|
||||
// 10 ~Destination
|
||||
// 11 Source | ~destination
|
||||
// 12 ~Source
|
||||
// 13 ~Source | destination
|
||||
// 14 ~(Source & destination)
|
||||
// 15 0xff
|
||||
|
||||
static const D3DBLENDOP d3dLogicOpop[16] =
|
||||
{
|
||||
D3DBLENDOP_ADD,
|
||||
@ -223,7 +241,7 @@ void SetupDeviceObjects()
|
||||
{
|
||||
D3D::font.Init();
|
||||
VertexLoaderManager::Init();
|
||||
FBManager.Create();
|
||||
g_framebufferManager.Create();
|
||||
|
||||
VertexShaderManager::Dirty();
|
||||
PixelShaderManager::Dirty();
|
||||
@ -243,7 +261,7 @@ void TeardownDeviceObjects()
|
||||
ScreenShootMEMSurface = NULL;
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
FBManager.Destroy();
|
||||
g_framebufferManager.Destroy();
|
||||
D3D::font.Shutdown();
|
||||
TextureCache::Invalidate(false);
|
||||
VertexLoaderManager::Shutdown();
|
||||
@ -252,7 +270,8 @@ void TeardownDeviceObjects()
|
||||
TextureConverter::Shutdown();
|
||||
}
|
||||
|
||||
bool Renderer::Init()
|
||||
// Init functions
|
||||
bool Renderer::Init()
|
||||
{
|
||||
st = new char[32768];
|
||||
UpdateActiveConfig();
|
||||
@ -276,6 +295,8 @@ bool Renderer::Init()
|
||||
fullScreenRes, backbuffer_ms_mode, false);
|
||||
|
||||
IS_AMD = D3D::IsATIDevice();
|
||||
|
||||
// Decide frambuffer size
|
||||
s_backbuffer_width = D3D::GetBackBufferWidth();
|
||||
s_backbuffer_height = D3D::GetBackBufferHeight();
|
||||
|
||||
@ -323,8 +344,8 @@ bool Renderer::Init()
|
||||
s_Fulltarget_width = s_target_width;
|
||||
s_Fulltarget_height = s_target_height;
|
||||
|
||||
s_LastFrameDumped = false;
|
||||
s_AVIDumping = false;
|
||||
s_bLastFrameDumped = false;
|
||||
s_bAVIDumping = false;
|
||||
|
||||
// We're not using fixed function.
|
||||
// Let's just set the matrices to identity to be sure.
|
||||
@ -348,8 +369,8 @@ bool Renderer::Init()
|
||||
D3D::dev->SetViewport(&vp);
|
||||
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 0, 0);
|
||||
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
vp.X = (s_Fulltarget_width - s_target_width) / 2;
|
||||
vp.Y = (s_Fulltarget_height - s_target_height) / 2;
|
||||
vp.Width = s_target_width;
|
||||
@ -369,28 +390,60 @@ void Renderer::Shutdown()
|
||||
D3D::Present();
|
||||
D3D::Close();
|
||||
|
||||
if (s_AVIDumping)
|
||||
if (s_bAVIDumping)
|
||||
{
|
||||
AVIDump::Stop();
|
||||
}
|
||||
delete [] st;
|
||||
}
|
||||
|
||||
int Renderer::GetTargetWidth() { return s_target_width; }
|
||||
int Renderer::GetTargetHeight() { return s_target_height; }
|
||||
int Renderer::GetFullTargetWidth() { return s_Fulltarget_width; }
|
||||
int Renderer::GetFullTargetHeight() { return s_Fulltarget_height; }
|
||||
float Renderer::GetTargetScaleX() { return EFBxScale; }
|
||||
float Renderer::GetTargetScaleY() { return EFByScale; }
|
||||
// Return the rendering target width and height
|
||||
int Renderer::GetTargetWidth()
|
||||
{
|
||||
return s_target_width;
|
||||
}
|
||||
|
||||
float Renderer::GetXFBScaleX() { return xScale; }
|
||||
float Renderer::GetXFBScaleY() { return yScale; }
|
||||
int Renderer::GetTargetHeight()
|
||||
{
|
||||
return s_target_height;
|
||||
}
|
||||
|
||||
int Renderer::GetFullTargetWidth()
|
||||
{
|
||||
return s_Fulltarget_width;
|
||||
}
|
||||
|
||||
int Renderer::GetFullTargetHeight()
|
||||
{
|
||||
return s_Fulltarget_height;
|
||||
}
|
||||
|
||||
float Renderer::GetTargetScaleX()
|
||||
{
|
||||
return EFBxScale;
|
||||
}
|
||||
|
||||
float Renderer::GetTargetScaleY()
|
||||
{
|
||||
return EFByScale;
|
||||
}
|
||||
|
||||
float Renderer::GetXFBScaleX()
|
||||
{
|
||||
return xScale;
|
||||
}
|
||||
|
||||
float Renderer::GetXFBScaleY()
|
||||
{
|
||||
return yScale;
|
||||
}
|
||||
|
||||
// Return the framebuffer size
|
||||
int Renderer::GetFrameBufferWidth()
|
||||
{
|
||||
return s_backbuffer_width;
|
||||
}
|
||||
|
||||
int Renderer::GetFrameBufferHeight()
|
||||
{
|
||||
return s_backbuffer_height;
|
||||
@ -399,7 +452,7 @@ int Renderer::GetFrameBufferHeight()
|
||||
// Create On-Screen-Messages
|
||||
void Renderer::DrawDebugText()
|
||||
{
|
||||
// OSD Menu messages
|
||||
// OSD menu messages
|
||||
if (g_ActiveConfig.bOSDHotKey)
|
||||
{
|
||||
if (OSDChoice > 0)
|
||||
@ -434,9 +487,12 @@ void Renderer::DrawDebugText()
|
||||
std::string OSDM3 = g_ActiveConfig.bEFBCopyDisable ? "Disabled" :
|
||||
g_ActiveConfig.bCopyEFBToTexture ? "To Texture" : "To RAM";
|
||||
|
||||
// If there is more text than this we will have a collission
|
||||
// If there is more text than this we will have a collision
|
||||
if (g_ActiveConfig.bShowFPS)
|
||||
{ T1 += "\n\n"; T2 += "\n\n"; }
|
||||
{
|
||||
T1 += "\n\n";
|
||||
T2 += "\n\n";
|
||||
}
|
||||
|
||||
// The rows
|
||||
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n", OSDM1.c_str()));
|
||||
@ -504,10 +560,8 @@ void formatBufferDump(const char *in, char *out, int w, int h, int p)
|
||||
void CheckForResize()
|
||||
{
|
||||
while (EmuWindow::IsSizing())
|
||||
{
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
|
||||
if (EmuWindow::GetParentWnd())
|
||||
{
|
||||
// Re-stretch window to parent window size again, if it has a parent window.
|
||||
@ -522,7 +576,8 @@ void CheckForResize()
|
||||
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
|
||||
int client_width = rcWindow.right - rcWindow.left;
|
||||
int client_height = rcWindow.bottom - rcWindow.top;
|
||||
// Sanity check.
|
||||
|
||||
// Sanity check
|
||||
if ((client_width != s_backbuffer_width ||
|
||||
client_height != s_backbuffer_height) &&
|
||||
client_width >= 4 && client_height >= 4)
|
||||
@ -539,20 +594,18 @@ void CheckForResize()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
|
||||
{
|
||||
if (!fbWidth || !fbHeight)
|
||||
return;
|
||||
VideoFifo_CheckEFBAccess();
|
||||
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
|
||||
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
|
||||
XFBWrited = true;
|
||||
// XXX: Without the VI, how would we know what kind of field this is? So
|
||||
// just use progressive.
|
||||
if (g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
FBManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
|
||||
g_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -618,7 +671,7 @@ bool Renderer::SetScissorRect()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Renderer::SetColorMask()
|
||||
void Renderer::SetColorMask()
|
||||
{
|
||||
DWORD color_mask = 0;
|
||||
if (bpmem.blendmode.alphaupdate)
|
||||
@ -644,18 +697,18 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
|
||||
// Get the working buffer
|
||||
LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ?
|
||||
FBManager.GetEFBDepthRTSurface() : FBManager.GetEFBColorRTSurface();
|
||||
g_framebufferManager.GetEFBDepthRTSurface() : g_framebufferManager.GetEFBColorRTSurface();
|
||||
// Get the temporal buffer to move 1pixel data
|
||||
LPDIRECT3DSURFACE9 RBuffer = (type == PEEK_Z || type == POKE_Z) ?
|
||||
FBManager.GetEFBDepthReadSurface() : FBManager.GetEFBColorReadSurface();
|
||||
g_framebufferManager.GetEFBDepthReadSurface() : g_framebufferManager.GetEFBColorReadSurface();
|
||||
// Get the memory buffer that can be locked
|
||||
LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ?
|
||||
FBManager.GetEFBDepthOffScreenRTSurface() : FBManager.GetEFBColorOffScreenRTSurface();
|
||||
g_framebufferManager.GetEFBDepthOffScreenRTSurface() : g_framebufferManager.GetEFBColorOffScreenRTSurface();
|
||||
// Get the buffer format
|
||||
D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ?
|
||||
FBManager.GetEFBDepthRTSurfaceFormat() : FBManager.GetEFBColorRTSurfaceFormat();
|
||||
g_framebufferManager.GetEFBDepthRTSurfaceFormat() : g_framebufferManager.GetEFBColorRTSurfaceFormat();
|
||||
D3DFORMAT ReadBufferFormat = (type == PEEK_Z || type == POKE_Z) ?
|
||||
FBManager.GetEFBDepthReadSurfaceFormat() : BufferFormat;
|
||||
g_framebufferManager.GetEFBDepthReadSurfaceFormat() : BufferFormat;
|
||||
|
||||
if (BufferFormat == D3DFMT_D24X8)
|
||||
return 0;
|
||||
@ -667,8 +720,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
PanicAlert("No %s!", (type == PEEK_Z || type == POKE_Z) ? "Z-Buffer" : "Color EFB");
|
||||
return 0;
|
||||
}
|
||||
// Get the rectangular target region covered by the EFB pixel.
|
||||
|
||||
// Get the rectangular target region covered by the EFB pixel
|
||||
EFBRectangle efbPixelRc;
|
||||
efbPixelRc.left = x;
|
||||
efbPixelRc.top = y;
|
||||
@ -700,6 +752,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
RectToLock.bottom--;
|
||||
if ((RectToLock.right - RectToLock.left) > 4)
|
||||
RectToLock.left++;
|
||||
|
||||
ResetAPIState(); // Reset any game specific settings
|
||||
hr = D3D::dev->SetDepthStencilSurface(NULL);
|
||||
hr = D3D::dev->SetRenderTarget(0, RBuffer);
|
||||
@ -727,7 +780,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
colmat[0] = colmat[5] = colmat[10] = 1.0f;
|
||||
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
|
||||
EFBRectangle source_rect;
|
||||
LPDIRECT3DTEXTURE9 read_texture = FBManager.GetEFBDepthTexture(source_rect);
|
||||
LPDIRECT3DTEXTURE9 read_texture = g_framebufferManager.GetEFBDepthTexture(source_rect);
|
||||
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
|
||||
@ -742,8 +795,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
|
||||
hr = D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
hr = D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
hr = D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
hr = D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
RestoreAPIState();
|
||||
RectToLock.bottom = 4;
|
||||
RectToLock.left = 0;
|
||||
@ -771,8 +824,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
PanicAlert("Unable to copy data to mem buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// The surface is good.. lock it
|
||||
if ((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
|
||||
@ -780,37 +832,48 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PEEK_Z:
|
||||
{
|
||||
switch (ReadBufferFormat)
|
||||
{
|
||||
case D3DFMT_R32F:
|
||||
val = ((float*)drect.pBits)[6];
|
||||
break;
|
||||
default:
|
||||
float ffrac = 1.0f/255.0f;
|
||||
z = ((u32*)drect.pBits)[6];
|
||||
val = ((float)((z>>16) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)((z>>8) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)(z & 0xFF)) * ffrac;
|
||||
break;
|
||||
};
|
||||
z = ((u32)(val * 0xffffff));
|
||||
}
|
||||
break;
|
||||
|
||||
case PEEK_COLOR:
|
||||
z = ((u32 *)drect.pBits)[0];
|
||||
break;
|
||||
case POKE_COLOR:
|
||||
switch (type)
|
||||
{
|
||||
case PEEK_Z:
|
||||
{
|
||||
switch (ReadBufferFormat)
|
||||
{
|
||||
case D3DFMT_R32F:
|
||||
val = ((float*)drect.pBits)[6];
|
||||
break;
|
||||
default:
|
||||
float ffrac = 1.0f/255.0f;
|
||||
z = ((u32*)drect.pBits)[6];
|
||||
val = ((float)((z>>16) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)((z>>8) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)(z & 0xFF)) * ffrac;
|
||||
break;
|
||||
};
|
||||
z = ((u32)(val * 0xffffff));
|
||||
}
|
||||
break;
|
||||
|
||||
case POKE_Z:
|
||||
// TODO: Implement
|
||||
break;
|
||||
|
||||
case PEEK_COLOR:
|
||||
z = ((u32*)drect.pBits)[0];
|
||||
break;
|
||||
|
||||
case POKE_COLOR:
|
||||
// TODO: Implement. One way is to draw a tiny pixel-sized rectangle at
|
||||
// the exact location. Note: EFB pokes are susceptible to Z-buffering
|
||||
// and perhaps blending.
|
||||
//WARN_LOG(VIDEOINTERFACE, "This is probably some kind of software rendering");
|
||||
break;
|
||||
|
||||
// TODO: Implement POKE_Z and POKE_COLOR
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pOffScreenBuffer->UnlockRect();
|
||||
@ -905,10 +968,10 @@ void UpdateViewport()
|
||||
{
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
FBManager.Destroy();
|
||||
FBManager.Create();
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
g_framebufferManager.Destroy();
|
||||
g_framebufferManager.Create();
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
}
|
||||
}
|
||||
vp.X = X;
|
||||
@ -978,7 +1041,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
}
|
||||
|
||||
static bool RightFrame = false;
|
||||
|
||||
// This function has the final picture. We adjust the aspect ratio here.
|
||||
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc)
|
||||
{
|
||||
if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.bUseRealXFB) || !fbWidth || !fbHeight)
|
||||
@ -989,10 +1052,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
// this function is called after the XFB field is changed, not after
|
||||
// EFB is copied to XFB. In this way, flickering is reduced in games
|
||||
// and seems to also give more FPS in ZTP
|
||||
|
||||
|
||||
if (field == FIELD_LOWER) xfbAddr -= fbWidth * 2;
|
||||
u32 xfbCount = 0;
|
||||
const XFBSource** xfbSourceList = FBManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
const XFBSource** xfbSourceList = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
|
||||
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
|
||||
{
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
@ -1019,7 +1082,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
RightFrame = true;
|
||||
}
|
||||
}
|
||||
// Set the backbuffer as the rendering target
|
||||
|
||||
// Prepare to copy the XFBs to our backbuffer
|
||||
D3D::dev->SetDepthStencilSurface(NULL);
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
|
||||
@ -1068,13 +1132,13 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
// draw each xfb source
|
||||
for (u32 i = 0; i < xfbCount; ++i)
|
||||
{
|
||||
xfbSource = xfbSourceList[i];
|
||||
xfbSource = xfbSourceList[i];
|
||||
MathUtil::Rectangle<float> sourceRc;
|
||||
|
||||
sourceRc.left = 0;
|
||||
sourceRc.top = 0;
|
||||
sourceRc.right = xfbSource->texWidth;
|
||||
sourceRc.bottom = xfbSource->texHeight;
|
||||
sourceRc.bottom = xfbSource->texHeight;
|
||||
|
||||
MathUtil::Rectangle<float> drawRc;
|
||||
|
||||
@ -1085,11 +1149,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
int xfbWidth = xfbSource->srcWidth;
|
||||
int hOffset = ((s32)xfbSource->srcAddr - (s32)xfbAddr) / ((s32)fbWidth * 2);
|
||||
|
||||
drawRc.bottom = 1.0f - 2.0f * ((hOffset) / (float)fbHeight);
|
||||
drawRc.top = 1.0f - 2.0f * ((hOffset + xfbHeight) / (float)fbHeight);
|
||||
drawRc.bottom = 1.0f - (2.0f * (hOffset) / (float)fbHeight);
|
||||
drawRc.top = 1.0f - (2.0f * (hOffset + xfbHeight) / (float)fbHeight);
|
||||
drawRc.left = -(xfbWidth / (float)fbWidth);
|
||||
drawRc.right = (xfbWidth / (float)fbWidth);
|
||||
|
||||
|
||||
if (!g_ActiveConfig.bAutoScale)
|
||||
{
|
||||
@ -1117,7 +1180,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
else
|
||||
{
|
||||
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
|
||||
LPDIRECT3DTEXTURE9 read_texture = FBManager.GetEFBColorTexture(rc);
|
||||
LPDIRECT3DTEXTURE9 read_texture = g_framebufferManager.GetEFBColorTexture(rc);
|
||||
D3D::drawShadedTexQuad(read_texture,targetRc.AsRECT(),Renderer::GetFullTargetWidth(),Renderer::GetFullTargetHeight(),Width,Height,PixelShaderCache::GetColorCopyProgram(g_Config.iMultisampleMode),VertexShaderCache::GetSimpleVertexShader(g_Config.iMultisampleMode));
|
||||
}
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
@ -1134,7 +1197,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
D3D::dev->SetViewport(&vp);
|
||||
if(s_bScreenshot)
|
||||
if (s_bScreenshot)
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
HRESULT hr = D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
|
||||
@ -1153,12 +1216,12 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
if (g_ActiveConfig.bDumpFrames)
|
||||
{
|
||||
HRESULT hr = D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
|
||||
if (!s_LastFrameDumped)
|
||||
if (!s_bLastFrameDumped)
|
||||
{
|
||||
s_recordWidth = dst_rect.GetWidth();
|
||||
s_recordHeight = dst_rect.GetHeight();
|
||||
s_AVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||
if (!s_AVIDumping)
|
||||
s_bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||
if (!s_bAVIDumping)
|
||||
{
|
||||
PanicAlert("Error dumping frames to AVI.");
|
||||
}
|
||||
@ -1169,7 +1232,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
OSD::AddMessage(msg, 2000);
|
||||
}
|
||||
}
|
||||
if (s_AVIDumping)
|
||||
if (s_bAVIDumping)
|
||||
{
|
||||
D3DLOCKED_RECT rect;
|
||||
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, dst_rect.AsRECT(), D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
|
||||
@ -1181,16 +1244,17 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
ScreenShootMEMSurface->UnlockRect();
|
||||
}
|
||||
}
|
||||
s_LastFrameDumped = true;
|
||||
s_bLastFrameDumped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_LastFrameDumped && s_AVIDumping)
|
||||
if (s_bLastFrameDumped && s_bAVIDumping)
|
||||
{
|
||||
AVIDump::Stop();
|
||||
s_AVIDumping = false;
|
||||
s_bAVIDumping = false;
|
||||
OSD::AddMessage("Stop dumping frames to AVI", 2000);
|
||||
}
|
||||
s_LastFrameDumped = false;
|
||||
s_bLastFrameDumped = false;
|
||||
}
|
||||
|
||||
// Finish up the current frame, print some stats
|
||||
@ -1213,22 +1277,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false);
|
||||
}
|
||||
|
||||
|
||||
OSD::DrawMessages();
|
||||
|
||||
D3D::EndFrame();
|
||||
|
||||
frameCount++;
|
||||
DLCache::ProgressiveCleanup();
|
||||
TextureCache::Cleanup();
|
||||
|
||||
// Make any new configuration settings active.
|
||||
// Enable any configuration changes
|
||||
UpdateActiveConfig();
|
||||
WindowResized = false;
|
||||
CheckForResize();
|
||||
|
||||
|
||||
bool xfbchanged = false;
|
||||
|
||||
|
||||
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
|
||||
{
|
||||
xfbchanged = true;
|
||||
@ -1288,13 +1349,14 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
}
|
||||
else
|
||||
{
|
||||
FBManager.Destroy();
|
||||
FBManager.Create();
|
||||
g_framebufferManager.Destroy();
|
||||
g_framebufferManager.Create();
|
||||
}
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
}
|
||||
|
||||
// Place messages on the picture, then copy it to the screen
|
||||
// ---------------------------------------------------------------------
|
||||
// Count FPS.
|
||||
// -------------
|
||||
@ -1311,20 +1373,26 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
|
||||
// Begin new frame
|
||||
// Set default viewport and scissor, for the clear to work correctly
|
||||
// New frame
|
||||
stats.ResetFrame();
|
||||
|
||||
// Flip/present backbuffer to frontbuffer here
|
||||
D3D::Present();
|
||||
D3D::BeginFrame();
|
||||
Renderer::RestoreAPIState();
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
UpdateViewport();
|
||||
VertexShaderManager::SetViewportChanged();
|
||||
// For testing zbuffer targets.
|
||||
// Renderer::SetZBufferRender();
|
||||
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget,
|
||||
// GetTargetWidth(), GetTargetHeight());
|
||||
g_VideoInitialize.pCopiedToXFB(XFBWrited || g_ActiveConfig.bUseRealXFB);
|
||||
XFBWrited = false;
|
||||
}
|
||||
|
||||
// ALWAYS call RestoreAPIState for each ResetAPIState call you're doing
|
||||
void Renderer::ResetAPIState()
|
||||
{
|
||||
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
@ -1365,6 +1433,7 @@ void Renderer::SetDepthMode()
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the test is disabled write is disabled too
|
||||
D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE); // ??
|
||||
}
|
||||
|
@ -79,6 +79,30 @@ void TextureCache::Invalidate(bool shutdown)
|
||||
HiresTextures::Shutdown();
|
||||
}
|
||||
|
||||
void TextureCache::Shutdown()
|
||||
{
|
||||
Invalidate(true);
|
||||
FreeMemoryPages(temp, TEMP_SIZE);
|
||||
temp = NULL;
|
||||
}
|
||||
|
||||
void TextureCache::Cleanup()
|
||||
{
|
||||
TexCache::iterator iter = textures.begin();
|
||||
while (iter != textures.end())
|
||||
{
|
||||
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
|
||||
{
|
||||
iter->second.Destroy(false);
|
||||
iter = textures.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache::InvalidateRange(u32 start_address, u32 size)
|
||||
{
|
||||
TexCache::iterator iter = textures.begin();
|
||||
@ -90,9 +114,9 @@ void TextureCache::InvalidateRange(u32 start_address, u32 size)
|
||||
iter->second.Destroy(false);
|
||||
textures.erase(iter++);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,53 +144,54 @@ int TextureCache::TCacheEntry::IntersectsMemoryRange(u32 range_address, u32 rang
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextureCache::Shutdown()
|
||||
{
|
||||
Invalidate(true);
|
||||
FreeMemoryPages(temp, TEMP_SIZE);
|
||||
temp = NULL;
|
||||
}
|
||||
|
||||
void TextureCache::Cleanup()
|
||||
{
|
||||
TexCache::iterator iter = textures.begin();
|
||||
while (iter != textures.end())
|
||||
{
|
||||
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
|
||||
{
|
||||
iter->second.Destroy(false);
|
||||
textures.erase(iter++);
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, int height, int tex_format, int tlutaddr, int tlutfmt,bool UseNativeMips, int maxlevel)
|
||||
{
|
||||
// notes (about "UNsafe texture cache"):
|
||||
// Have to be removed soon.
|
||||
// But we keep it until the "safe" way became rock solid
|
||||
// pros: it has an unique ID held by the texture data itself (@address) once cached.
|
||||
// cons: it writes this unique ID in the gc RAM <- very dangerous (break MP1) and ugly
|
||||
|
||||
// notes (about "safe texture cache"):
|
||||
// Metroids text issue (character table):
|
||||
// Same addr, same GX_TF_C4 texture data but different TLUT (hence different outputs).
|
||||
// That's why we have to hash the TLUT too for TLUT tex_format dependent textures (ie. GX_TF_C4, GX_TF_C8, GX_TF_C14X2).
|
||||
// And since the address and tex data don't change, the key index in the cacheEntry map can't be the address but
|
||||
// have to be a real unique ID.
|
||||
// DONE but not satifiying yet -> may break copyEFBToTexture sometimes.
|
||||
|
||||
// Pokemon Colosseum text issue (plain text):
|
||||
// Use a GX_TF_I4 512x512 text-flush-texture at a const address.
|
||||
// The problem here was just the sparse hash on the texture. This texture is partly overwrited (what is needed only)
|
||||
// so lot's of remaning old text. Thin white chars on black bg too.
|
||||
|
||||
// TODO: - clean this up when ready to kill old "unsafe texture cache"
|
||||
// - fix the key index situation with CopyRenderTargetToTexture.
|
||||
// Could happen only for GX_TF_C4, GX_TF_C8 and GX_TF_C14X2 fmt.
|
||||
// Wonder if we can't use tex width&height to know if EFB might be copied to it...
|
||||
// raw idea: TOCHECK if addresses are aligned we have few bits left...
|
||||
|
||||
if (address == 0)
|
||||
return NULL;
|
||||
|
||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1; //TexelSizeInNibbles(format)*width*height/16;
|
||||
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1; //TexelSizeInNibbles(format)*width*height/16;
|
||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1; // TexelSizeInNibbles(format)*width*height/16;
|
||||
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1; // TexelSizeInNibbles(format)*width*height/16;
|
||||
int bsdepth = TexDecoder_GetTexelSizeInNibbles(tex_format);
|
||||
int expandedWidth = (width + bsw) & (~bsw);
|
||||
int expandedWidth = (width + bsw) & (~bsw);
|
||||
int expandedHeight = (height + bsh) & (~bsh);
|
||||
|
||||
u64 hash_value;
|
||||
u64 hash_value = 0;
|
||||
u32 texID = address;
|
||||
u64 texHash;
|
||||
u64 texHash = 0;
|
||||
u32 FullFormat = tex_format;
|
||||
bool TextureisDynamic = false;
|
||||
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
||||
u32 FullFormat = (tex_format | (tlutfmt << 16));
|
||||
FullFormat = (tex_format | (tlutfmt << 16));
|
||||
|
||||
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
|
||||
{
|
||||
texHash = GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||
texHash = GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
||||
{
|
||||
// WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up)
|
||||
@ -325,7 +350,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
bool isPow2 = !((width & (width - 1)) || (height & (height - 1)));
|
||||
entry.isNonPow2 = false;
|
||||
int TexLevels = (width > height)?width:height;
|
||||
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : ((isPow2)? 0 : 1);
|
||||
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : (isPow2? 0 : 1);
|
||||
if(TexLevels > (maxlevel + 1) && maxlevel > 0)
|
||||
TexLevels = (maxlevel + 1);
|
||||
entry.MipLevels = maxlevel;
|
||||
@ -364,14 +389,14 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
entry.Scaledw = width;
|
||||
entry.Scaledh = height;
|
||||
entry.fmt = FullFormat;
|
||||
|
||||
|
||||
if (g_ActiveConfig.bDumpTextures)
|
||||
{
|
||||
// dump texture to file
|
||||
char szTemp[MAX_PATH];
|
||||
char szDir[MAX_PATH];
|
||||
const char* uniqueId = globals->unique_id;
|
||||
bool bCheckedDumpDir = false;
|
||||
static bool bCheckedDumpDir = false;
|
||||
|
||||
sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), uniqueId);
|
||||
|
||||
@ -390,7 +415,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
}
|
||||
|
||||
INCSTAT(stats.numTexturesCreated);
|
||||
SETSTAT(stats.numTexturesAlive, (int)textures.size());
|
||||
SETSTAT(stats.numTexturesAlive, textures.size());
|
||||
|
||||
//Set the texture!
|
||||
D3D::SetTexture(stage, entry.texture);
|
||||
@ -434,12 +459,12 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
textures.erase(iter);
|
||||
}
|
||||
}
|
||||
if(TextureisDynamic)
|
||||
if (TextureisDynamic)
|
||||
{
|
||||
Scaledtex_w = tex_w;
|
||||
Scaledtex_h = tex_h;
|
||||
}
|
||||
if(!tex)
|
||||
if (!tex)
|
||||
{
|
||||
TCacheEntry entry;
|
||||
entry.addr = address;
|
||||
@ -459,7 +484,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
}
|
||||
|
||||
// Make sure to resolve anything we need to read from.
|
||||
LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source_rect) : FBManager.GetEFBColorTexture(source_rect);
|
||||
LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? g_framebufferManager.GetEFBDepthTexture(source_rect) : g_framebufferManager.GetEFBColorTexture(source_rect);
|
||||
|
||||
// We have to run a pixel shader, for color conversion.
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
@ -625,7 +650,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
}
|
||||
|
||||
|
||||
D3DFORMAT bformat = FBManager.GetEFBDepthRTSurfaceFormat();
|
||||
D3DFORMAT bformat = g_framebufferManager.GetEFBDepthRTSurfaceFormat();
|
||||
int SSAAMode = g_ActiveConfig.iMultisampleMode;
|
||||
D3D::drawShadedTexQuad(
|
||||
read_texture,
|
||||
@ -660,9 +685,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
|
||||
D3D::SetTexture(0,NULL);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,6 @@ void Init()
|
||||
}
|
||||
CreateRgbToYuyvProgram();
|
||||
CreateYuyvToRgbProgram();
|
||||
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
@ -242,7 +241,7 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
||||
|
||||
if (linearFilter)
|
||||
{
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -256,7 +255,7 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
||||
vp.Height = dstHeight;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
hr = D3D::dev->SetViewport(&vp);
|
||||
hr = D3D::dev->SetViewport(&vp);
|
||||
RECT SrcRect;
|
||||
SrcRect.top = sourceRc.top;
|
||||
SrcRect.left = sourceRc.left;
|
||||
@ -277,40 +276,31 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
||||
|
||||
D3DLOCKED_RECT drect;
|
||||
|
||||
|
||||
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface);
|
||||
if((hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY)) != D3D_OK)
|
||||
hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY);
|
||||
int writeStride = bpmem.copyMipMapStrideChannels * 32;
|
||||
|
||||
if (writeStride != readStride && toTexture)
|
||||
{
|
||||
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
|
||||
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
|
||||
|
||||
// writing to a texture of a different size
|
||||
|
||||
int readHeight = readStride / dstWidth;
|
||||
|
||||
int readStart = 0;
|
||||
int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel
|
||||
u8 *Source = (u8*)drect.pBits;
|
||||
for (int i = 0; i < readLoops; i++)
|
||||
{
|
||||
int readDist = dstWidth*readHeight;
|
||||
memcpy(destAddr,Source,readDist);
|
||||
Source += readDist;
|
||||
destAddr += writeStride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int writeStride = bpmem.copyMipMapStrideChannels * 32;
|
||||
|
||||
if (writeStride != readStride && toTexture)
|
||||
{
|
||||
// writing to a texture of a different size
|
||||
|
||||
int readHeight = readStride / dstWidth;
|
||||
|
||||
int readStart = 0;
|
||||
int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel
|
||||
u8 *Source = (u8*)drect.pBits;
|
||||
for (int i = 0; i < readLoops; i++)
|
||||
{
|
||||
int readDist = dstWidth*readHeight;
|
||||
memcpy(destAddr,Source,readDist);
|
||||
Source += readDist;
|
||||
destAddr += writeStride;
|
||||
}
|
||||
}
|
||||
else
|
||||
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
|
||||
|
||||
hr = s_texConvReadSurface->UnlockRect();
|
||||
}
|
||||
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
|
||||
|
||||
hr = s_texConvReadSurface->UnlockRect();
|
||||
}
|
||||
|
||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
||||
@ -335,7 +325,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
|
||||
|
||||
u8 *dest_ptr = Memory_GetPtr(address);
|
||||
|
||||
LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source) : FBManager.GetEFBColorTexture(source);
|
||||
LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? g_framebufferManager.GetEFBDepthTexture(source) : g_framebufferManager.GetEFBColorTexture(source);
|
||||
int width = (source.right - source.left) >> bScaleByHalf;
|
||||
int height = (source.bottom - source.top) >> bScaleByHalf;
|
||||
|
||||
@ -343,7 +333,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
|
||||
|
||||
// Invalidate any existing texture covering this memory range.
|
||||
// TODO - don't delete the texture if it already exists, just replace the contents.
|
||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
||||
|
||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
||||
@ -383,9 +373,9 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
|
||||
|
||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
||||
Renderer::ResetAPIState();
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight,readStride, true, bScaleByHalf > 0);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
}
|
||||
|
||||
@ -454,8 +444,7 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture,u32 Sou
|
||||
return Hashvalue;
|
||||
}
|
||||
|
||||
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,u8* destAddr, int dstWidth, int dstHeight)
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc, u8* destAddr, int dstWidth, int dstHeight)
|
||||
{
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)dstWidth,
|
||||
@ -468,9 +457,9 @@ void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourc
|
||||
(float)Renderer::GetFullTargetHeight());
|
||||
Renderer::ResetAPIState();
|
||||
EncodeToRamUsingShader(s_rgbToYuyvProgram, srcTexture, sourceRc, destAddr, dstWidth / 2, dstHeight, 0, false, false);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
}
|
||||
|
||||
|
||||
@ -491,7 +480,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
destTexture->GetSurfaceLevel(0,&Rendersurf);
|
||||
D3D::dev->SetDepthStencilSurface(NULL);
|
||||
D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
@ -535,17 +524,17 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
s_yuyvToRgbProgram,
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
|
||||
D3D::SetTexture(0,NULL);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
D3D::dev->SetRenderTarget(0, g_framebufferManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(g_framebufferManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
Rendersurf->Release();
|
||||
s_srcTexture->Release();
|
||||
s_srcTexture->Release();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -81,26 +81,24 @@ void Shutdown()
|
||||
delete [] LocalVBuffer;
|
||||
delete [] TIBuffer;
|
||||
delete [] LIBuffer;
|
||||
delete [] PIBuffer;
|
||||
delete [] PIBuffer;
|
||||
ResetBuffer();
|
||||
}
|
||||
|
||||
void AddIndices(int _primitive, int _numVertices)
|
||||
void AddIndices(int primitive, int numVertices)
|
||||
{
|
||||
switch (_primitive)
|
||||
switch (primitive)
|
||||
{
|
||||
case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break;
|
||||
case GX_DRAW_TRIANGLES: IndexGenerator::AddList(_numVertices); break;
|
||||
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break;
|
||||
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break;
|
||||
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break;
|
||||
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
|
||||
case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break;
|
||||
case GX_DRAW_QUADS: IndexGenerator::AddQuads(numVertices); break;
|
||||
case GX_DRAW_TRIANGLES: IndexGenerator::AddList(numVertices); break;
|
||||
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(numVertices); break;
|
||||
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(numVertices); break;
|
||||
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(numVertices); break;
|
||||
case GX_DRAW_LINES: IndexGenerator::AddLineList(numVertices); break;
|
||||
case GX_DRAW_POINTS: IndexGenerator::AddPoints(numVertices); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int GetRemainingSize()
|
||||
{
|
||||
return MAXVBUFFERSIZE - (int)(s_pCurBufferPointer - LocalVBuffer);
|
||||
@ -110,53 +108,54 @@ int GetRemainingVertices(int primitive)
|
||||
{
|
||||
switch (primitive)
|
||||
{
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen())/3;
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
case GX_DRAW_LINES:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen())/2;
|
||||
case GX_DRAW_POINTS:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
|
||||
default: return 0;
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen())/3;
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
case GX_DRAW_LINES:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen())/2;
|
||||
case GX_DRAW_POINTS:
|
||||
return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void AddVertices(int _primitive, int _numVertices)
|
||||
void AddVertices(int primitive, int numVertices)
|
||||
{
|
||||
if (_numVertices <= 0)
|
||||
if (numVertices <= 0)
|
||||
return;
|
||||
switch (_primitive)
|
||||
|
||||
switch (primitive)
|
||||
{
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
if(MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen() < 3 * _numVertices)
|
||||
case GX_DRAW_QUADS:
|
||||
case GX_DRAW_TRIANGLES:
|
||||
case GX_DRAW_TRIANGLE_STRIP:
|
||||
case GX_DRAW_TRIANGLE_FAN:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen() < 3 * numVertices)
|
||||
Flush();
|
||||
break;
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
case GX_DRAW_LINES:
|
||||
if(MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen() < 2 * _numVertices)
|
||||
break;
|
||||
case GX_DRAW_LINE_STRIP:
|
||||
case GX_DRAW_LINES:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen() < 2 * numVertices)
|
||||
Flush();
|
||||
break;
|
||||
case GX_DRAW_POINTS:
|
||||
if(MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen() < _numVertices)
|
||||
break;
|
||||
case GX_DRAW_POINTS:
|
||||
if (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen() < numVertices)
|
||||
Flush();
|
||||
break;
|
||||
default: return;
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
if(Flushed)
|
||||
if (Flushed)
|
||||
{
|
||||
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
|
||||
Flushed=false;
|
||||
}
|
||||
lastPrimitive = _primitive;
|
||||
ADDSTAT(stats.thisFrame.numPrims, _numVertices);
|
||||
lastPrimitive = primitive;
|
||||
ADDSTAT(stats.thisFrame.numPrims, numVertices);
|
||||
INCSTAT(stats.thisFrame.numPrimitiveJoins);
|
||||
AddIndices(_primitive, _numVertices);
|
||||
AddIndices(primitive, numVertices);
|
||||
}
|
||||
|
||||
inline void DumpBadShaders()
|
||||
@ -179,7 +178,7 @@ inline void DumpBadShaders()
|
||||
|
||||
inline void Draw(int stride)
|
||||
{
|
||||
if(IndexGenerator::GetNumTriangles() > 0)
|
||||
if (IndexGenerator::GetNumTriangles() > 0)
|
||||
{
|
||||
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
||||
D3DPT_TRIANGLELIST,
|
||||
@ -193,7 +192,7 @@ inline void Draw(int stride)
|
||||
}
|
||||
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
||||
}
|
||||
if(IndexGenerator::GetNumLines() > 0)
|
||||
if (IndexGenerator::GetNumLines() > 0)
|
||||
{
|
||||
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
||||
D3DPT_LINELIST,
|
||||
@ -207,7 +206,7 @@ inline void Draw(int stride)
|
||||
}
|
||||
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
|
||||
}
|
||||
if(IndexGenerator::GetNumPoints() > 0)
|
||||
if (IndexGenerator::GetNumPoints() > 0)
|
||||
{
|
||||
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
|
||||
D3DPT_POINTLIST,
|
||||
@ -226,47 +225,43 @@ inline void Draw(int stride)
|
||||
void Flush()
|
||||
{
|
||||
if (LocalVBuffer == s_pCurBufferPointer) return;
|
||||
if(Flushed) return;
|
||||
if (Flushed) return;
|
||||
Flushed=true;
|
||||
VideoFifo_CheckEFBAccess();
|
||||
|
||||
DVSTARTPROFILE();
|
||||
|
||||
|
||||
u32 usedtextures = 0;
|
||||
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
|
||||
if (bpmem.tevorders[i/2].getEnable(i & 1))
|
||||
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i)
|
||||
if (bpmem.tevorders[i / 2].getEnable(i & 1))
|
||||
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
|
||||
}
|
||||
|
||||
if (bpmem.genMode.numindstages > 0) {
|
||||
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
|
||||
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) {
|
||||
if (bpmem.genMode.numindstages > 0)
|
||||
for (unsigned int i = 0; i < bpmem.genMode.numtevstages + 1; ++i)
|
||||
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
|
||||
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (unsigned int i = 0; i < 8; i++)
|
||||
{
|
||||
if (usedtextures & (1 << i)) {
|
||||
if (usedtextures & (1 << i))
|
||||
{
|
||||
Renderer::SetSamplerState(i & 3, i >> 2);
|
||||
FourTexUnits &tex = bpmem.tex[i >> 2];
|
||||
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
|
||||
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
||||
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
|
||||
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
||||
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
|
||||
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
||||
tex.texTlut[i&3].tlut_format,
|
||||
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
||||
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
||||
(tex.texMode1[i&3].max_lod >> 4));
|
||||
|
||||
if (tentry) {
|
||||
if (tentry)
|
||||
{
|
||||
// 0s are probably for no manual wrapping needed.
|
||||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to load texture\n");});
|
||||
ERROR_LOG(VIDEO, "error loading texture");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +306,5 @@ void Flush()
|
||||
|
||||
shader_fail:
|
||||
ResetBuffer();
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -84,16 +84,19 @@ void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const
|
||||
D3D::dev->SetVertexShaderConstantF(const_number, f, count);
|
||||
}
|
||||
|
||||
// this class will load the precompiled shaders into our cache
|
||||
class VertexShaderCacheInserter : public LinearDiskCacheReader {
|
||||
public:
|
||||
void Read(const u8 *key, int key_size, const u8 *value, int value_size)
|
||||
{
|
||||
VERTEXSHADERUID uid;
|
||||
if (key_size != sizeof(uid)) {
|
||||
if (key_size != sizeof(uid))
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Wrong key size in vertex shader cache");
|
||||
return;
|
||||
}
|
||||
memcpy(&uid, key, key_size);
|
||||
|
||||
VertexShaderCache::InsertByteCode(uid, value, value_size, false);
|
||||
}
|
||||
};
|
||||
@ -179,13 +182,12 @@ void VertexShaderCache::Init()
|
||||
char cache_filename[MAX_PATH];
|
||||
sprintf(cache_filename, "%sdx9-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id);
|
||||
VertexShaderCacheInserter inserter;
|
||||
int read_items = g_vs_disk_cache.OpenAndRead(cache_filename, &inserter);
|
||||
g_vs_disk_cache.OpenAndRead(cache_filename, &inserter);
|
||||
}
|
||||
|
||||
void VertexShaderCache::Clear()
|
||||
{
|
||||
VSCache::iterator iter = vshaders.begin();
|
||||
for (; iter != vshaders.end(); ++iter)
|
||||
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); ++iter)
|
||||
iter->second.Destroy();
|
||||
vshaders.clear();
|
||||
|
||||
@ -217,16 +219,11 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||
VERTEXSHADERUID uid;
|
||||
GetVertexShaderId(&uid, components);
|
||||
if (uid == last_vertex_shader_uid && vshaders[uid].frameCount == frameCount)
|
||||
{
|
||||
if (vshaders[uid].shader)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return (vshaders[uid].shader != NULL);
|
||||
|
||||
memcpy(&last_vertex_shader_uid, &uid, sizeof(VERTEXSHADERUID));
|
||||
|
||||
VSCache::iterator iter;
|
||||
iter = vshaders.find(uid);
|
||||
VSCache::iterator iter = vshaders.find(uid);
|
||||
if (iter != vshaders.end())
|
||||
{
|
||||
iter->second.frameCount = frameCount;
|
||||
|
@ -100,7 +100,7 @@ void *DllDebugger(void *_hParent, bool Show)
|
||||
return true;
|
||||
}
|
||||
};
|
||||
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
||||
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||
#endif
|
||||
|
||||
@ -148,18 +148,16 @@ void UpdateFPSDisplay(const char *text)
|
||||
SetWindowText(EmuWindow::GetWnd(), temp);
|
||||
}
|
||||
|
||||
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
|
||||
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
||||
{
|
||||
_PluginInfo->Version = 0x0100;
|
||||
_PluginInfo->Type = PLUGIN_TYPE_VIDEO;
|
||||
#ifdef DEBUGFAST
|
||||
sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (DebugFast)");
|
||||
#else
|
||||
#ifndef _DEBUG
|
||||
sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9");
|
||||
#else
|
||||
#elif defined _DEBUG
|
||||
sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (Debug)");
|
||||
#endif
|
||||
#else
|
||||
sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -197,14 +195,15 @@ void Initialize(void *init)
|
||||
{
|
||||
frameCount = 0;
|
||||
SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init;
|
||||
g_VideoInitialize = *_pVideoInitialize;
|
||||
// Create a shortcut to _pVideoInitialize that can also update it
|
||||
g_VideoInitialize = *(_pVideoInitialize);
|
||||
InitXFBConvTables();
|
||||
|
||||
g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
|
||||
g_Config.GameIniLoad(globals->game_ini);
|
||||
UpdateProjectionHack(g_Config.iPhackvalue); // DX9 projection hack could be disabled by commenting out this line
|
||||
UpdateActiveConfig();
|
||||
|
||||
|
||||
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Loading - Please wait."));
|
||||
if (g_VideoInitialize.pWindowHandle == NULL)
|
||||
{
|
||||
@ -222,6 +221,8 @@ void Initialize(void *init)
|
||||
|
||||
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
|
||||
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
|
||||
|
||||
// Now the window handle is written
|
||||
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
|
||||
|
||||
OSD::AddMessage("Dolphin Direct3D9 Video Plugin.", 5000);
|
||||
@ -234,10 +235,13 @@ void Video_Prepare()
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
|
||||
// internal interfaces
|
||||
Renderer::Init();
|
||||
TextureCache::Init();
|
||||
BPInit();
|
||||
VertexManager::Init();
|
||||
// VideoCommon
|
||||
BPInit();
|
||||
Fifo_Init();
|
||||
VertexLoaderManager::Init();
|
||||
OpcodeDecoder_Init();
|
||||
@ -246,36 +250,45 @@ void Video_Prepare()
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
DLCache::Init();
|
||||
// Tell the host the window is ready
|
||||
|
||||
// Notify the core that the video plugin is ready
|
||||
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
s_PluginInitialized = false;
|
||||
|
||||
s_efbAccessRequested = FALSE;
|
||||
s_FifoShuttingDown = FALSE;
|
||||
s_swapRequested = FALSE;
|
||||
|
||||
// VideoCommon
|
||||
DLCache::Shutdown();
|
||||
Fifo_Shutdown();
|
||||
CommandProcessor::Shutdown();
|
||||
VertexManager::Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
TextureCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
OpcodeDecoder_Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
|
||||
// internal interfaces
|
||||
PixelShaderCache::Shutdown();
|
||||
VertexShaderCache::Shutdown();
|
||||
VertexManager::Shutdown();
|
||||
TextureCache::Shutdown();
|
||||
Renderer::Shutdown();
|
||||
D3D::Shutdown();
|
||||
EmuWindow::Close();
|
||||
s_PluginInitialized = false;
|
||||
}
|
||||
|
||||
void DoState(unsigned char **ptr, int mode) {
|
||||
void DoState(unsigned char **ptr, int mode)
|
||||
{
|
||||
// Clear texture cache because it might have written to RAM
|
||||
CommandProcessor::FifoCriticalEnter();
|
||||
TextureCache::Invalidate(false);
|
||||
CommandProcessor::FifoCriticalLeave();
|
||||
// No need to clear shader caches.
|
||||
// No need to clear shader caches
|
||||
PointerWrap p(ptr, mode);
|
||||
VideoCommon_DoState(p);
|
||||
}
|
||||
@ -285,6 +298,7 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
|
||||
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
|
||||
}
|
||||
|
||||
// Enter and exit the video loop
|
||||
void Video_EnterLoop()
|
||||
{
|
||||
Fifo_EnterLoop(g_VideoInitialize);
|
||||
@ -293,11 +307,11 @@ void Video_EnterLoop()
|
||||
void Video_ExitLoop()
|
||||
{
|
||||
Fifo_ExitLoop();
|
||||
|
||||
s_FifoShuttingDown = TRUE;
|
||||
}
|
||||
|
||||
void Video_SetRendering(bool bEnabled) {
|
||||
void Video_SetRendering(bool bEnabled)
|
||||
{
|
||||
Fifo_SetRendering(bEnabled);
|
||||
}
|
||||
|
||||
@ -315,7 +329,7 @@ void VideoFifo_CheckSwapRequest()
|
||||
}
|
||||
}
|
||||
|
||||
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
||||
static inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
||||
{
|
||||
return !((aLower >= bUpper) || (bLower >= aUpper));
|
||||
}
|
||||
@ -335,14 +349,14 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
|
||||
if (addrRangesOverlap(aLower, aUpper, bLower, bUpper))
|
||||
VideoFifo_CheckSwapRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run from the CPU thread (from VideoInterface.cpp)
|
||||
void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
{
|
||||
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
|
||||
{
|
||||
{
|
||||
if (g_VideoInitialize.bOnThread)
|
||||
{
|
||||
while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown)
|
||||
@ -350,7 +364,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
Common::YieldCPU();
|
||||
}
|
||||
else
|
||||
VideoFifo_CheckSwapRequest();
|
||||
VideoFifo_CheckSwapRequest();
|
||||
s_beginFieldArgs.xfbAddr = xfbAddr;
|
||||
s_beginFieldArgs.field = field;
|
||||
s_beginFieldArgs.fbWidth = fbWidth;
|
||||
@ -360,30 +374,20 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
}
|
||||
}
|
||||
|
||||
// Run from the CPU thread (from VideoInterface.cpp)
|
||||
void Video_EndField()
|
||||
{
|
||||
}
|
||||
|
||||
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||
{
|
||||
OSD::AddMessage(pstr,milliseconds);
|
||||
}
|
||||
|
||||
HRESULT ScreenShot(const char *File)
|
||||
{
|
||||
Renderer::SetScreenshot(File);
|
||||
return S_OK;
|
||||
OSD::AddMessage(pstr, milliseconds);
|
||||
}
|
||||
|
||||
// Screenshot
|
||||
void Video_Screenshot(const char *_szFilename)
|
||||
{
|
||||
if (ScreenShot(_szFilename) != S_OK)
|
||||
PanicAlert("Error while capturing screen");
|
||||
else {
|
||||
std::string message = "Saved ";
|
||||
message += _szFilename;
|
||||
OSD::AddMessage(message.c_str(), 2000);
|
||||
}
|
||||
Renderer::SetScreenshot(_szFilename);
|
||||
}
|
||||
|
||||
static struct
|
||||
@ -406,7 +410,7 @@ void VideoFifo_CheckEFBAccess()
|
||||
}
|
||||
}
|
||||
|
||||
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y,u32 InputData)
|
||||
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
||||
{
|
||||
if (s_PluginInitialized)
|
||||
{
|
||||
|
@ -15,4 +15,4 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
@ -23,4 +23,3 @@
|
||||
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
Reference in New Issue
Block a user