2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
// 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 _D3DBASE_H
|
|
|
|
#define _D3DBASE_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
|
2009-09-13 02:21:35 -06:00
|
|
|
#include <d3d9.h>
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
|
|
|
namespace D3D
|
|
|
|
{
|
2009-09-13 02:21:35 -06:00
|
|
|
|
2009-09-16 14:12:14 -06:00
|
|
|
// From http://developer.amd.com/gpu_assets/Advanced%20DX9%20Capabilities%20for%20ATI%20Radeon%20Cards.pdf
|
|
|
|
// Magic FourCC's to unlock undocumented D3D9 features:
|
|
|
|
|
|
|
|
// Z texture formats
|
|
|
|
#define FOURCC_INTZ ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')))
|
|
|
|
#define FOURCC_RAWZ ((D3DFORMAT)(MAKEFOURCC('R','A','W','Z')))
|
|
|
|
|
|
|
|
// Depth buffer resolve:
|
|
|
|
#define FOURCC_RESZ ((D3DFORMAT)(MAKEFOURCC('R','E','S','Z')))
|
|
|
|
#define RESZ_CODE 0x7fa05000
|
|
|
|
|
|
|
|
// Null render target to do Z-only shadow maps: (probably not useful for Dolphin)
|
|
|
|
#define FOURCC_NULL ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')))
|
|
|
|
|
2009-09-13 02:21:35 -06:00
|
|
|
HRESULT Init();
|
2009-09-15 13:53:22 -06:00
|
|
|
HRESULT Create(int adapter, HWND wnd, bool fullscreen, int resolution, int aa_mode, bool auto_depth);
|
2009-09-13 02:21:35 -06:00
|
|
|
void Close();
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
// Direct access to the device.
|
|
|
|
extern IDirect3DDevice9 *dev;
|
2009-09-17 20:03:56 -06:00
|
|
|
extern bool bFrameInProgress;
|
2009-09-13 02:21:35 -06:00
|
|
|
|
|
|
|
void Reset();
|
2009-09-13 11:46:33 -06:00
|
|
|
bool BeginFrame();
|
2009-09-13 02:21:35 -06:00
|
|
|
void EndFrame();
|
|
|
|
void SwitchFullscreen(bool fullscreen);
|
|
|
|
bool IsFullscreen();
|
2009-09-16 14:12:14 -06:00
|
|
|
bool CanUseINTZ();
|
2009-09-13 11:46:33 -06:00
|
|
|
|
|
|
|
int GetBackBufferWidth();
|
|
|
|
int GetBackBufferHeight();
|
2009-09-13 02:21:35 -06:00
|
|
|
LPDIRECT3DSURFACE9 GetBackBufferSurface();
|
2009-09-13 11:46:33 -06:00
|
|
|
LPDIRECT3DSURFACE9 GetBackBufferDepthSurface();
|
|
|
|
|
2009-09-13 02:21:35 -06:00
|
|
|
const D3DCAPS9 &GetCaps();
|
|
|
|
const char *PixelShaderVersionString();
|
|
|
|
const char *VertexShaderVersionString();
|
|
|
|
void ShowD3DError(HRESULT err);
|
|
|
|
|
|
|
|
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
|
|
|
|
void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
|
|
|
|
void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
|
|
|
|
void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
|
|
|
|
void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
|
2009-09-19 04:46:25 -06:00
|
|
|
void SetVertexDeclaration(LPDIRECT3DVERTEXDECLARATION9 decl);
|
2009-09-16 14:12:14 -06:00
|
|
|
void ApplyCachedState();
|
2009-09-13 02:21:35 -06:00
|
|
|
|
|
|
|
// Utility functions for vendor specific hacks. So far, just the one.
|
|
|
|
void EnableAlphaToCoverage();
|
|
|
|
|
|
|
|
struct Resolution
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
int xres;
|
|
|
|
int yres;
|
|
|
|
std::set<D3DFORMAT> bitdepths;
|
|
|
|
std::set<int> refreshes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AALevel
|
|
|
|
{
|
|
|
|
AALevel(const char *n, D3DMULTISAMPLE_TYPE m, int q) {strcpy(name, n); ms_setting=m; qual_setting=q;}
|
|
|
|
char name[32];
|
|
|
|
D3DMULTISAMPLE_TYPE ms_setting;
|
|
|
|
int qual_setting;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Adapter
|
|
|
|
{
|
|
|
|
D3DADAPTER_IDENTIFIER9 ident;
|
|
|
|
std::vector<Resolution> resolutions;
|
|
|
|
std::vector<AALevel> aa_levels;
|
|
|
|
bool supports_alpha_to_coverage;
|
2009-09-16 14:12:14 -06:00
|
|
|
|
|
|
|
// Magic render targets, see the top of this file.
|
|
|
|
bool supports_intz;
|
|
|
|
bool supports_rawz;
|
|
|
|
bool supports_resz;
|
|
|
|
bool supports_null;
|
2009-09-13 02:21:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
const Adapter &GetAdapter(int i);
|
|
|
|
const Adapter &GetCurAdapter();
|
|
|
|
int GetNumAdapters();
|
|
|
|
|
|
|
|
} // namespace
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
#endif
|