mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
D3D: Eliminate black borders, add 4:3 and 16:9 settings, and the widescreen hack. Unfortunately this temporarily breaks MSAA (in d3d only) until I have time to fix it.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4263 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -218,7 +218,7 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
|
||||
PanicAlert("Cant read from DVD_Plugin - DVD-Interface: Fatal Error");
|
||||
}
|
||||
|
||||
FileMon::CheckFile(std::string(pFilename), m_pFileSystem->GetFileSize(pFilename));
|
||||
FileMon::CheckFile(std::string(pFilename), (int)m_pFileSystem->GetFileSize(pFilename));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ void SetDitherMode(const BPCmd &bp);
|
||||
void SetLogicOpMode(const BPCmd &bp);
|
||||
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);
|
||||
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight);
|
||||
void ClearScreen(const BPCmd &bp, const EFBRectangle &rc);
|
||||
void RestoreRenderState(const BPCmd &bp);
|
||||
u8 *GetPointer(const u32 &address);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "Profiler.h"
|
||||
#include "Statistics.h"
|
||||
#include "Render.h"
|
||||
#include "VideoCommon.h"
|
||||
#include "PixelShaderManager.h"
|
||||
#include "BPFunctions.h"
|
||||
@@ -40,6 +41,12 @@ void BPInit()
|
||||
bpmem.bpMask = 0xFFFFFF;
|
||||
}
|
||||
|
||||
|
||||
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight)
|
||||
{
|
||||
Renderer::RenderToXFB(xfbAddr, dstWidth, dstHeight, rc);
|
||||
}
|
||||
|
||||
void BPWritten(const BPCmd& bp)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -67,8 +67,8 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 texturemask, u32 dstAlphaEnable)
|
||||
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC;
|
||||
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC;
|
||||
|
||||
u32 val0 = cc.hex&0xffffff;
|
||||
u32 val1 = ac.hex&0xffffff;
|
||||
u32 val0 = cc.hex & 0xffffff;
|
||||
u32 val1 = ac.hex & 0xffffff;
|
||||
val0 |= bpmem.tevksel[i / 2].getKC(i & 1) << 24;
|
||||
val1 |= bpmem.tevksel[i / 2].getKA(i & 1) << 24;
|
||||
pcurvalue[0] = val0;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// GC graphics pipeline
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
@@ -33,9 +32,13 @@
|
||||
#include "MathUtil.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
// TODO: Move these out of here.
|
||||
extern int frameCount;
|
||||
extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
|
||||
|
||||
// Renderer really isn't a very good name for this class - it's more like "Misc".
|
||||
// The long term goal is to get rid of this class and replace it with others that make
|
||||
// more sense.
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
@@ -48,8 +51,6 @@ public:
|
||||
|
||||
static void ReinitView();
|
||||
|
||||
static void SwapBuffers();
|
||||
|
||||
static void SetColorMask();
|
||||
static void SetBlendMode(bool forceUpdate);
|
||||
static bool SetScissorRect();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "CommonTypes.h"
|
||||
#include "VideoCommon.h"
|
||||
#include "Render.h" // for EFBRectangle.h, unfortunately.
|
||||
#include <vector>
|
||||
|
||||
#ifndef _STATISTICS_H
|
||||
|
||||
@@ -97,6 +97,7 @@ void VideoConfig::Load(const char *ini_file)
|
||||
iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0);
|
||||
iniFile.Get("Hardware", "VSync", &bVsync, 0);
|
||||
iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0);
|
||||
iniFile.Get("Hardware", "SimpleFB", &bSimpleFB, false);
|
||||
|
||||
// Load common settings
|
||||
iniFile.Load(CONFIG_FILE);
|
||||
@@ -175,12 +176,11 @@ void VideoConfig::Save(const char *ini_file)
|
||||
iniFile.Set("Hardware", "WindowedRes", iWindowedRes);
|
||||
iniFile.Set("Hardware", "VSync", bVsync);
|
||||
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
|
||||
iniFile.Set("Hardware", "SimpleFB", bSimpleFB);
|
||||
|
||||
iniFile.Save(ini_file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: Figure out a better place for this function.
|
||||
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
|
||||
{
|
||||
@@ -198,8 +198,8 @@ void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip
|
||||
{
|
||||
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
||||
float Ratio = (WinWidth / WinHeight) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
|
||||
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
|
||||
if (Ratio > 1)
|
||||
// Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
|
||||
if (Ratio > 1.0f)
|
||||
{
|
||||
// Scale down and center in the X direction.
|
||||
FloatGLWidth /= Ratio;
|
||||
@@ -230,12 +230,8 @@ void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip
|
||||
// Adjust the X and Y offset
|
||||
FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
|
||||
FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
|
||||
//NOTICE_LOG(OSREPORT, "Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f", Ratio, IncreasedHeight, FloatYOffset);
|
||||
//NOTICE_LOG(OSREPORT, "Crop FloatGLWidth:%1.2f FloatGLHeight:%3.0f", (float)FloatGLWidth, (float)FloatGLHeight);
|
||||
//NOTICE_LOG(OSREPORT, "");
|
||||
}
|
||||
|
||||
// round(float) = floor(float + 0.5)
|
||||
int XOffset = (int)(FloatXOffset + 0.5f);
|
||||
int YOffset = (int)(FloatYOffset + 0.5f);
|
||||
rc->left = XOffset;
|
||||
|
||||
@@ -131,9 +131,6 @@ struct VideoConfig
|
||||
// With this enabled, the plugin renders directly to the backbuffer. Many features are
|
||||
// disabled but it might be faster on really old GPUs.
|
||||
bool bSimpleFB;
|
||||
|
||||
// Runtime detection config
|
||||
bool bOldCard;
|
||||
};
|
||||
|
||||
extern VideoConfig g_Config;
|
||||
|
||||
@@ -1190,6 +1190,14 @@
|
||||
<Filter
|
||||
Name="Render"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Src\FramebufferManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\FramebufferManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\NativeVertexFormat.cpp"
|
||||
>
|
||||
|
||||
@@ -217,13 +217,6 @@ void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const
|
||||
}
|
||||
}
|
||||
|
||||
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight)
|
||||
{
|
||||
Renderer::SwapBuffers();
|
||||
PRIM_LOG("Renderer::SwapBuffers()");
|
||||
g_VideoInitialize.pCopiedToXFB(false);
|
||||
}
|
||||
|
||||
void ClearScreen(const BPCmd &bp, const EFBRectangle &rc)
|
||||
{
|
||||
// TODO: Scale EFBRectangle correctly
|
||||
@@ -306,7 +299,7 @@ void SetSamplerState(const BPCmd &bp)
|
||||
|
||||
if (g_ActiveConfig.iMaxAnisotropy > 1)
|
||||
{
|
||||
mag = D3DTEXF_ANISOTROPIC;
|
||||
mag = D3DTEXF_LINEAR;
|
||||
min = D3DTEXF_ANISOTROPIC;
|
||||
mip = D3DTEXF_LINEAR;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "Render.h"
|
||||
#include "XFStructs.h"
|
||||
|
||||
@@ -24,7 +25,8 @@ namespace D3D
|
||||
|
||||
LPDIRECT3D9 D3D = NULL; // Used to create the D3DDevice
|
||||
LPDIRECT3DDEVICE9 dev = NULL; // Our rendering device
|
||||
LPDIRECT3DSURFACE9 backBuffer;
|
||||
LPDIRECT3DSURFACE9 back_buffer;
|
||||
LPDIRECT3DSURFACE9 back_buffer_z;
|
||||
D3DCAPS9 caps;
|
||||
HWND hWnd;
|
||||
|
||||
@@ -117,7 +119,7 @@ void EnableAlphaToCoverage()
|
||||
xres = pp->BackBufferWidth = client.right - client.left;
|
||||
yres = pp->BackBufferHeight = client.bottom - client.top;
|
||||
pp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
pp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
pp->PresentationInterval = g_Config.bVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
pp->Windowed = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +253,8 @@ void EnableAlphaToCoverage()
|
||||
}
|
||||
}
|
||||
dev->GetDeviceCaps(&caps);
|
||||
dev->GetRenderTarget(0, &backBuffer);
|
||||
dev->GetRenderTarget(0, &back_buffer);
|
||||
dev->GetDepthStencilSurface(&back_buffer_z);
|
||||
|
||||
// Device state would normally be set here
|
||||
return S_OK;
|
||||
@@ -284,7 +287,12 @@ const char *PixelShaderVersionString()
|
||||
|
||||
LPDIRECT3DSURFACE9 GetBackBufferSurface()
|
||||
{
|
||||
return backBuffer;
|
||||
return back_buffer;
|
||||
}
|
||||
|
||||
LPDIRECT3DSURFACE9 GetBackBufferDepthSurface()
|
||||
{
|
||||
return back_buffer_z;
|
||||
}
|
||||
|
||||
void ShowD3DError(HRESULT err)
|
||||
@@ -305,10 +313,17 @@ void ShowD3DError(HRESULT err)
|
||||
{
|
||||
if (dev)
|
||||
{
|
||||
// Can't keep a pointer around to the backbuffer surface when resetting.
|
||||
back_buffer_z->Release();
|
||||
back_buffer->Release();
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
InitPP(cur_adapter, resolution, multisample, &d3dpp);
|
||||
|
||||
HRESULT hr = dev->Reset(&d3dpp);
|
||||
|
||||
ShowD3DError(hr);
|
||||
dev->GetRenderTarget(0, &back_buffer);
|
||||
dev->GetDepthStencilSurface(&back_buffer_z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,12 +332,12 @@ void ShowD3DError(HRESULT err)
|
||||
return fullScreen;
|
||||
}
|
||||
|
||||
int GetDisplayWidth()
|
||||
int GetBackBufferWidth()
|
||||
{
|
||||
return xres;
|
||||
}
|
||||
|
||||
int GetDisplayHeight()
|
||||
int GetBackBufferHeight()
|
||||
{
|
||||
return yres;
|
||||
}
|
||||
@@ -332,7 +347,7 @@ void ShowD3DError(HRESULT err)
|
||||
nextFullScreen = fullscreen;
|
||||
}
|
||||
|
||||
bool BeginFrame(bool clear, u32 color, float z)
|
||||
bool BeginFrame()
|
||||
{
|
||||
if (bFrameInProgress)
|
||||
{
|
||||
@@ -342,8 +357,6 @@ void ShowD3DError(HRESULT err)
|
||||
bFrameInProgress = true;
|
||||
if (dev)
|
||||
{
|
||||
if (clear)
|
||||
dev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, (DWORD)color, z, 0 );
|
||||
dev->BeginScene();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,13 +37,16 @@ void Shutdown();
|
||||
extern IDirect3DDevice9 *dev;
|
||||
|
||||
void Reset();
|
||||
bool BeginFrame(bool clear, u32 color, float z);
|
||||
bool BeginFrame();
|
||||
void EndFrame();
|
||||
void SwitchFullscreen(bool fullscreen);
|
||||
bool IsFullscreen();
|
||||
int GetDisplayWidth();
|
||||
int GetDisplayHeight();
|
||||
|
||||
int GetBackBufferWidth();
|
||||
int GetBackBufferHeight();
|
||||
LPDIRECT3DSURFACE9 GetBackBufferSurface();
|
||||
LPDIRECT3DSURFACE9 GetBackBufferDepthSurface();
|
||||
|
||||
const D3DCAPS9 &GetCaps();
|
||||
const char *PixelShaderVersionString();
|
||||
const char *VertexShaderVersionString();
|
||||
|
||||
@@ -36,21 +36,19 @@ LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
// TODO(ector): allow mipmaps for non-pow textures on newer cards?
|
||||
// TODO(ector): Allow mipmaps for non-pow textures on newer cards?
|
||||
// TODO(ector): Use the game-specified mipmaps?
|
||||
if (!isPow2)
|
||||
hr = dev->CreateTexture(width, height, 1, 0, fmt, D3DPOOL_MANAGED, &pTexture, NULL);
|
||||
else
|
||||
hr = dev->CreateTexture(width, height, 0, D3DUSAGE_AUTOGENMIPMAP, fmt, D3DPOOL_MANAGED, &pTexture, NULL);
|
||||
|
||||
if(FAILED(hr))
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
|
||||
int level = 0;
|
||||
|
||||
D3DLOCKED_RECT Lock;
|
||||
pTexture->LockRect(level, &Lock, NULL, 0 );
|
||||
|
||||
switch(fmt)
|
||||
pTexture->LockRect(level, &Lock, NULL, 0);
|
||||
switch (fmt)
|
||||
{
|
||||
case D3DFMT_L8:
|
||||
case D3DFMT_A8:
|
||||
@@ -150,26 +148,4 @@ void ReplaceTexture2D(LPDIRECT3DTEXTURE9 pTexture, const u8* buffer, const int w
|
||||
pTexture->UnlockRect(level);
|
||||
}
|
||||
|
||||
LPDIRECT3DTEXTURE9 CreateRenderTarget(const int width, const int height)
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 tex;
|
||||
HRESULT hr = dev->CreateTexture(width,height,0,D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&tex,NULL);
|
||||
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
else
|
||||
return tex;
|
||||
}
|
||||
|
||||
LPDIRECT3DSURFACE9 CreateDepthStencilSurface(const int width, const int height)
|
||||
{
|
||||
LPDIRECT3DSURFACE9 surf;
|
||||
HRESULT hr = dev->CreateDepthStencilSurface(width,height,D3DFMT_D24S8,D3DMULTISAMPLE_NONE,0,0,&surf,0);
|
||||
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
else
|
||||
return surf;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -51,11 +51,14 @@ namespace D3D
|
||||
|
||||
int CD3DFont::Init()
|
||||
{
|
||||
m_fTextScale = 1.0f; // Draw fonts into texture without scaling
|
||||
// Create a new texture for the font
|
||||
HRESULT hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, &m_pTexture, NULL);
|
||||
if (FAILED(hr))
|
||||
// Create vertex buffer for the letters
|
||||
HRESULT hr;
|
||||
if (FAILED(hr = dev->CreateVertexBuffer(MAX_NUM_VERTICES*sizeof(FONT2DVERTEX),
|
||||
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0, D3DPOOL_DEFAULT, &m_pVB, NULL)))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
m_fTextScale = 1.0f; // Draw fonts into texture without scaling
|
||||
|
||||
// Prepare to create a bitmap
|
||||
int *pBitmapBits;
|
||||
@@ -76,15 +79,13 @@ namespace D3D
|
||||
// Create a font. By specifying ANTIALIASED_QUALITY, we might get an
|
||||
// antialiased font, but this is not guaranteed.
|
||||
// We definitely don't want to get it cleartype'd, anyway.
|
||||
int m_dwFontHeight = 36;
|
||||
|
||||
int m_dwFontHeight = 24;
|
||||
int nHeight = -MulDiv(m_dwFontHeight, int(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale), 72);
|
||||
int dwBold = FW_NORMAL; ///FW_BOLD
|
||||
HFONT hFont = CreateFont(nHeight, 0, 0, 0, dwBold, 0,
|
||||
FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
|
||||
VARIABLE_PITCH, _T("Tahoma"));
|
||||
|
||||
if (NULL == hFont)
|
||||
return E_FAIL;
|
||||
|
||||
@@ -99,43 +100,48 @@ namespace D3D
|
||||
// Loop through all printable character 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";
|
||||
SIZE size;
|
||||
|
||||
for (char c=0; c<127-32; c++)
|
||||
for (int c = 0; c < 127 - 32; c++)
|
||||
{
|
||||
str[0] = c+32;
|
||||
str[0] = c + 32;
|
||||
SIZE size;
|
||||
GetTextExtentPoint32A(hDC, str, 1, &size);
|
||||
|
||||
if ((int)(x+size.cx+1) > m_dwTexWidth)
|
||||
{
|
||||
x = 0;
|
||||
y += size.cy+1;
|
||||
y += size.cy + 1;
|
||||
}
|
||||
|
||||
ExtTextOutA(hDC, x+1, y+0, ETO_OPAQUE | ETO_CLIPPED, NULL, str, 1, NULL);
|
||||
|
||||
m_fTexCoords[c][0] = ((float)(x+0))/m_dwTexWidth;
|
||||
m_fTexCoords[c][1] = ((float)(y+0))/m_dwTexHeight;
|
||||
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 avoid 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
|
||||
hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, D3DUSAGE_DYNAMIC,
|
||||
D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
PanicAlert("Failed to create font texture");
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Lock the surface and write the alpha values for the set pixels
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
m_pTexture->LockRect(0, &d3dlr, 0, 0);
|
||||
unsigned short* pDst16 = (unsigned short*)d3dlr.pBits;
|
||||
m_pTexture->LockRect(0, &d3dlr, 0, D3DLOCK_DISCARD);
|
||||
int bAlpha; // 4-bit measure of pixel intensity
|
||||
|
||||
for (y=0; y < m_dwTexHeight; y++)
|
||||
for (y = 0; y < m_dwTexHeight; y++)
|
||||
{
|
||||
for (x=0; x < m_dwTexWidth; x++)
|
||||
u16 *pDst16 = (u16*)((u8 *)d3dlr.pBits + y * d3dlr.Pitch);
|
||||
for (x = 0; x < m_dwTexWidth; x++)
|
||||
{
|
||||
bAlpha = ((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
|
||||
*pDst16++ = (bAlpha << 12) | 0x0fff;
|
||||
bAlpha = ((pBitmapBits[m_dwTexWidth * y + x] & 0xff) >> 4);
|
||||
pDst16[x] = (bAlpha << 12) | 0x0fff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,14 +154,6 @@ namespace D3D
|
||||
SelectObject(hDC, hOldFont);
|
||||
DeleteObject(hFont);
|
||||
|
||||
// Create vertex buffer for the letters
|
||||
if (FAILED(hr = dev->CreateVertexBuffer(MAX_NUM_VERTICES*sizeof(FONT2DVERTEX),
|
||||
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
|
||||
D3DPOOL_DEFAULT, &m_pVB,NULL)))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -191,13 +189,12 @@ namespace D3D
|
||||
static DWORD RS_old[6];
|
||||
static DWORD TS_old[6];
|
||||
static LPDIRECT3DBASETEXTURE9 texture_old;
|
||||
static DWORD FVF_old;
|
||||
static LPDIRECT3DVERTEXDECLARATION9 decl_old;
|
||||
static LPDIRECT3DPIXELSHADER9 ps_old;
|
||||
static LPDIRECT3DVERTEXSHADER9 vs_old;
|
||||
|
||||
void SaveRenderStates()
|
||||
{
|
||||
// TODO: Get rid of these Gets so we can potentially switch to Pure Device
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
dev->GetRenderState((_D3DRENDERSTATETYPE)RS[i][0], &(RS_old[i]));
|
||||
@@ -206,8 +203,20 @@ namespace D3D
|
||||
dev->GetTexture(0, &texture_old);
|
||||
dev->GetPixelShader(&ps_old);
|
||||
dev->GetVertexShader(&vs_old);
|
||||
dev->GetVertexDeclaration(&decl_old);
|
||||
dev->GetFVF(&FVF_old);
|
||||
}
|
||||
|
||||
void RestoreRenderStates()
|
||||
{
|
||||
D3D::SetTexture(0, texture_old);
|
||||
|
||||
dev->SetPixelShader(ps_old);
|
||||
dev->SetVertexShader(vs_old);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
D3D::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
|
||||
D3D::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CD3DFont::SetRenderStates()
|
||||
@@ -226,24 +235,12 @@ namespace D3D
|
||||
}
|
||||
}
|
||||
|
||||
void RestoreRenderStates()
|
||||
{
|
||||
D3D::SetTexture(0, texture_old);
|
||||
|
||||
dev->SetPixelShader(ps_old);
|
||||
dev->SetVertexShader(vs_old);
|
||||
|
||||
dev->SetFVF(FVF_old);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
D3D::SetRenderState((_D3DRENDERSTATETYPE)RS[i][0], RS_old[i]);
|
||||
D3D::SetTextureStageState(0, (_D3DTEXTURESTAGESTATETYPE)int(TS[i][0]), TS_old[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, float spacing, u32 dwColor, const char* strText, bool center)
|
||||
{
|
||||
if (!m_pVB)
|
||||
return 0;
|
||||
|
||||
SaveRenderStates();
|
||||
SetRenderStates();
|
||||
dev->SetStreamSource(0, m_pVB, 0, sizeof(FONT2DVERTEX));
|
||||
@@ -283,10 +280,10 @@ namespace D3D
|
||||
float w = (tx2-tx1)*m_dwTexWidth;
|
||||
w *= (fXScale*vpHeight)*invLineHeight;
|
||||
mx += w + spacing*fXScale*vpWidth;
|
||||
if (mx>maxx) maxx=mx;
|
||||
if (mx > maxx) maxx = mx;
|
||||
}
|
||||
|
||||
float offset=-maxx/2;
|
||||
float offset = -maxx/2;
|
||||
strText = oldstrText;
|
||||
//Then let's draw it
|
||||
if (center)
|
||||
@@ -295,10 +292,10 @@ namespace D3D
|
||||
fStartX+=offset;
|
||||
}
|
||||
|
||||
float wScale=(fXScale*vpHeight)*invLineHeight;
|
||||
float hScale=(fYScale*vpHeight)*invLineHeight;
|
||||
float wScale = (fXScale*vpHeight)*invLineHeight;
|
||||
float hScale = (fYScale*vpHeight)*invLineHeight;
|
||||
|
||||
while(*strText)
|
||||
while (*strText)
|
||||
{
|
||||
char c = *strText++;
|
||||
|
||||
@@ -322,28 +319,24 @@ namespace D3D
|
||||
w *= wScale;
|
||||
h *= hScale;
|
||||
|
||||
|
||||
FONT2DVERTEX v[6];
|
||||
v[0]=InitFont2DVertex(sx, sy+h, dwColor, tx1, ty2);
|
||||
v[1]=InitFont2DVertex(sx, sy, dwColor, tx1, ty1);
|
||||
v[2]=InitFont2DVertex(sx+w, sy+h, dwColor, tx2, ty2);
|
||||
v[3]=InitFont2DVertex(sx+w, sy, dwColor, tx2, ty1);
|
||||
v[4]=v[2];
|
||||
v[5]=v[1];
|
||||
v[0] = InitFont2DVertex(sx, sy+h, dwColor, tx1, ty2);
|
||||
v[1] = InitFont2DVertex(sx, sy, dwColor, tx1, ty1);
|
||||
v[2] = InitFont2DVertex(sx+w, sy+h, dwColor, tx2, ty2);
|
||||
v[3] = InitFont2DVertex(sx+w, sy, dwColor, tx2, ty1);
|
||||
v[4] = v[2];
|
||||
v[5] = v[1];
|
||||
|
||||
memcpy(pVertices,v,6*sizeof(FONT2DVERTEX));
|
||||
memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX));
|
||||
|
||||
pVertices+=6;
|
||||
dwNumTriangles += 2;
|
||||
|
||||
if (dwNumTriangles * 3 > (MAX_NUM_VERTICES-6))
|
||||
if (dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6))
|
||||
{
|
||||
// Unlock, render, and relock the vertex buffer
|
||||
m_pVB->Unlock();
|
||||
|
||||
// dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
|
||||
dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
|
||||
|
||||
m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
|
||||
dwNumTriangles = 0;
|
||||
}
|
||||
@@ -354,10 +347,7 @@ namespace D3D
|
||||
// Unlock and render the vertex buffer
|
||||
m_pVB->Unlock();
|
||||
if (dwNumTriangles > 0)
|
||||
{
|
||||
// dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
|
||||
dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
|
||||
}
|
||||
RestoreRenderStates();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ void DX9Debugger_Pause_Count_N(PauseEvent event,bool update)
|
||||
if (update)
|
||||
{
|
||||
D3D::EndFrame();
|
||||
D3D::BeginFrame(false, 0x00000000, 1.0f);
|
||||
D3D::BeginFrame();
|
||||
}
|
||||
DX9DebuggerCheckAndPause();
|
||||
}
|
||||
|
||||
@@ -86,17 +86,34 @@ struct TabDirect3D : public W32Util::Tab
|
||||
CheckDlgButton(hDlg, IDC_FULLSCREENENABLE, g_Config.bFullscreen ? TRUE : FALSE);
|
||||
CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVsync ? TRUE : FALSE);
|
||||
CheckDlgButton(hDlg, IDC_RENDER_TO_MAINWINDOW, g_Config.RenderToMainframe ? TRUE : FALSE);
|
||||
CheckDlgButton(hDlg, IDC_ASPECT_16_9, g_Config.bKeepAR169 ? TRUE : FALSE);
|
||||
CheckDlgButton(hDlg, IDC_ASPECT_4_3, g_Config.bKeepAR43 ? TRUE : FALSE);
|
||||
CheckDlgButton(hDlg, IDC_WIDESCREEN_HACK, g_Config.bWidescreenHack ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
void Command(HWND hDlg,WPARAM wParam)
|
||||
{
|
||||
/*
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_ASPECT_4_3:
|
||||
Button_SetCheck(GetDlgItem(hDlg, IDC_ASPECT_16_9), FALSE);
|
||||
g_Config.bKeepAR43 = Button_GetCheck(GetDlgItem(hDlg, IDC_ASPECT_4_3)) ? true : false;
|
||||
g_Config.bKeepAR169 = false;
|
||||
break;
|
||||
case IDC_ASPECT_16_9:
|
||||
Button_SetCheck(GetDlgItem(hDlg, IDC_ASPECT_4_3), FALSE);
|
||||
g_Config.bKeepAR169 = Button_GetCheck(GetDlgItem(hDlg, IDC_ASPECT_16_9)) ? true : false;
|
||||
g_Config.bKeepAR43 = false;
|
||||
break;
|
||||
case IDC_WIDESCREEN_HACK:
|
||||
g_Config.bWidescreenHack = Button_GetCheck(GetDlgItem(hDlg, IDC_WIDESCREEN_HACK)) ? true : false;
|
||||
break;
|
||||
case IDC_WIREFRAME:
|
||||
g_Config.bWireFrame = Button_GetCheck(GetDlgItem(hDlg,IDC_WIREFRAME)) ? true : false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Apply(HWND hDlg)
|
||||
@@ -133,9 +150,6 @@ struct TabAdvanced : public W32Util::Tab
|
||||
Button_SetCheck(GetDlgItem(hDlg,IDC_TEXFMT_OVERLAY), g_Config.bTexFmtOverlayEnable);
|
||||
Button_SetCheck(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), g_Config.bTexFmtOverlayCenter);
|
||||
Button_GetCheck(GetDlgItem(hDlg,IDC_TEXFMT_OVERLAY)) ? Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), true) : Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), false);
|
||||
|
||||
//SetWindowText(GetDlgItem(hDlg,IDC_TEXDUMPPATH),g_Config.texDumpPath.c_str()); <-- Old method
|
||||
//Edit_LimitText(GetDlgItem(hDlg,IDC_TEXDUMPPATH),255); <-- Old method
|
||||
}
|
||||
void Command(HWND hDlg,WPARAM wParam)
|
||||
{
|
||||
@@ -149,7 +163,7 @@ struct TabAdvanced : public W32Util::Tab
|
||||
// break;
|
||||
case IDC_TEXFMT_OVERLAY:
|
||||
{
|
||||
Button_GetCheck(GetDlgItem(hDlg,IDC_TEXFMT_OVERLAY)) ? Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), true) : Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), false);
|
||||
Button_GetCheck(GetDlgItem(hDlg, IDC_TEXFMT_OVERLAY)) ? Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), true) : Button_Enable(GetDlgItem(hDlg,IDC_TEXFMT_CENTER), false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -163,7 +177,6 @@ struct TabAdvanced : public W32Util::Tab
|
||||
|
||||
g_Config.bOverlayStats = Button_GetCheck(GetDlgItem(hDlg,IDC_OVERLAYSTATS)) ? true : false;
|
||||
g_Config.bOverlayProjStats = Button_GetCheck(GetDlgItem(hDlg,IDC_OVERLAYPROJSTATS)) ? true : false;
|
||||
g_Config.bWireFrame = Button_GetCheck(GetDlgItem(hDlg,IDC_WIREFRAME)) ? true : false;
|
||||
g_Config.bDumpTextures = Button_GetCheck(GetDlgItem(hDlg,IDC_TEXDUMP)) ? true : false;
|
||||
g_Config.bDumpFrames = Button_GetCheck(GetDlgItem(hDlg,IDC_DUMPFRAMES)) ? true : false;
|
||||
g_Config.bShowShaderErrors = Button_GetCheck(GetDlgItem(hDlg,IDC_SHOWSHADERERRORS)) ? true : false;
|
||||
@@ -240,7 +253,7 @@ void DlgSettings_Show(HINSTANCE hInstance, HWND _hParent)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(( tfoe != g_Config.bTexFmtOverlayEnable) ||
|
||||
if ((tfoe != g_Config.bTexFmtOverlayEnable) ||
|
||||
((g_Config.bTexFmtOverlayEnable) && ( tfoc != g_Config.bTexFmtOverlayCenter)))
|
||||
{
|
||||
TextureCache::Invalidate(false);
|
||||
|
||||
@@ -15,11 +15,18 @@ HINSTANCE m_hInstance = NULL;
|
||||
WNDCLASSEX wndClass;
|
||||
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
|
||||
int g_winstyle;
|
||||
static volatile bool s_sizing;
|
||||
|
||||
bool IsSizing()
|
||||
{
|
||||
return s_sizing;
|
||||
}
|
||||
|
||||
HWND GetWnd()
|
||||
{
|
||||
return m_hWnd;
|
||||
}
|
||||
|
||||
HWND GetParentWnd()
|
||||
{
|
||||
return m_hParent;
|
||||
@@ -38,6 +45,14 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_ENTERSIZEMOVE:
|
||||
s_sizing = true;
|
||||
break;
|
||||
|
||||
case WM_EXITSIZEMOVE:
|
||||
s_sizing = false;
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch( LOWORD( wParam ))
|
||||
{
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
|
||||
namespace EmuWindow
|
||||
{
|
||||
HWND GetWnd();
|
||||
HWND GetParentWnd();
|
||||
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
|
||||
void Show();
|
||||
void Close();
|
||||
void SetSize(int displayWidth, int displayHeight);
|
||||
|
||||
HWND GetWnd();
|
||||
HWND GetParentWnd();
|
||||
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
|
||||
void Show();
|
||||
void Close();
|
||||
void SetSize(int displayWidth, int displayHeight);
|
||||
bool IsSizing();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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 "D3DBase.h"
|
||||
#include "Render.h"
|
||||
#include "FramebufferManager.h"
|
||||
|
||||
namespace FBManager
|
||||
{
|
||||
|
||||
static LPDIRECT3DSURFACE9 s_efb_color_surface;
|
||||
static LPDIRECT3DSURFACE9 s_efb_depth_surface;
|
||||
|
||||
#undef CHECK
|
||||
#define CHECK(hr) if (FAILED(hr)) { PanicAlert("FAIL: " __FUNCTION__); }
|
||||
|
||||
LPDIRECT3DSURFACE9 GetEFBColorRTSurface() { return s_efb_color_surface; }
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthRTSurface() { return s_efb_depth_surface; }
|
||||
|
||||
void Create()
|
||||
{
|
||||
// Simplest possible setup to start with.
|
||||
int target_width = Renderer::GetTargetWidth();
|
||||
int target_height = Renderer::GetTargetHeight();
|
||||
HRESULT hr = D3D::dev->CreateRenderTarget(target_width, target_height, D3DFMT_A8R8G8B8,
|
||||
D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_color_surface, NULL);
|
||||
CHECK(hr);
|
||||
hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, D3DFMT_D24S8,
|
||||
D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL);
|
||||
CHECK(hr);
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
s_efb_depth_surface->Release();
|
||||
s_efb_depth_surface = NULL;
|
||||
s_efb_color_surface->Release();
|
||||
s_efb_color_surface = NULL;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,60 @@
|
||||
// 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/
|
||||
|
||||
#ifndef _FRAMEBUFFERMANAGER_D3D_H_
|
||||
#define _FRAMEBUFFERMANAGER_D3D_H_
|
||||
|
||||
#include <list>
|
||||
#include "D3DBase.h"
|
||||
|
||||
namespace FBManager
|
||||
{
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
// To get the EFB in texture form, these functions may have to transfer
|
||||
// the EFB to a resolved texture first.
|
||||
LPDIRECT3DTEXTURE9 GetEFBColorTexture(const EFBRectangle& sourceRc);
|
||||
LPDIRECT3DTEXTURE9 GetEFBDepthTexture(const EFBRectangle& sourceRc);
|
||||
|
||||
LPDIRECT3DSURFACE9 GetEFBColorRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthRTSurface();
|
||||
|
||||
|
||||
/*
|
||||
// Resolved framebuffer is only used in MSAA mode.
|
||||
LPDIRECT3DTEXTURE9 GetResolvedFramebuffer() const { return m_resolvedFramebuffer; }
|
||||
|
||||
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) const;
|
||||
|
||||
void SetFramebuffer(LPDIRECT3DSURFACE9 surface);
|
||||
|
||||
// If in MSAA mode, this will perform a resolve of the specified rectangle, and return the resolve target as a texture ID.
|
||||
// Thus, this call may be expensive. Don't repeat it unnecessarily.
|
||||
// If not in MSAA mode, will just return the render target texture ID.
|
||||
// After calling this, before you render anything else, you MUST bind the framebuffer you want to draw to.
|
||||
LPDIRECT3DTEXTURE9 ResolveAndGetRenderTarget(const EFBRectangle &rect);
|
||||
|
||||
// Same as above but for the depth Target.
|
||||
// After calling this, before you render anything else, you MUST bind the framebuffer you want to draw to.
|
||||
LPDIRECT3DTEXTURE9 ResolveAndGetDepthTarget(const EFBRectangle &rect);
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user