Put the DirectX9 stuff into a namespace.

This makes it almost build on Windows, but not quite.  Some required files
excluded from build, still.
This commit is contained in:
Unknown W. Brackets 2013-09-15 08:53:21 -07:00
parent 301884428f
commit f55b6a0dbc
29 changed files with 211 additions and 64 deletions

View File

@ -30,6 +30,7 @@
#include "GPU/Directx9/TextureCacheDX9.h"
#include "GPU/Directx9/ShaderManagerDX9.h"
namespace DX9 {
// Aggressively delete unused FBO:s to save gpu memory.
enum {
@ -284,10 +285,10 @@ void FramebufferManagerDX9::DrawActiveTexture(float x, float y, float w, float h
pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float));
}
VirtualFramebuffer *FramebufferManagerDX9::GetDisplayFBO() {
VirtualFramebuffer *match = NULL;
VirtualFramebufferDX9 *FramebufferManagerDX9::GetDisplayFBO() {
VirtualFramebufferDX9 *match = NULL;
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *v = vfbs_[i];
VirtualFramebufferDX9 *v = vfbs_[i];
if (MaskedEqual(v->fb_address, displayFramebufPtr_) && v->format == displayFormat_ && v->width >= 480) {
// Could check w too but whatever
if (match == NULL || match->last_frame_render < v->last_frame_render) {
@ -353,7 +354,7 @@ static void DrawingSize(int &drawing_width, int &drawing_height) {
}
}
void FramebufferManagerDX9::DestroyFramebuf(VirtualFramebuffer *v) {
void FramebufferManagerDX9::DestroyFramebuf(VirtualFramebufferDX9 *v) {
textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED);
if (v->fbo) {
fbo_destroy(v->fbo);
@ -406,9 +407,9 @@ void FramebufferManagerDX9::SetRenderFrameBuffer() {
int buffer_height = drawing_height;
// Find a matching framebuffer
VirtualFramebuffer *vfb = 0;
VirtualFramebufferDX9 *vfb = 0;
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *v = vfbs_[i];
VirtualFramebufferDX9 *v = vfbs_[i];
if (MaskedEqual(v->fb_address, fb_address) && v->format == fmt) {
// Let's not be so picky for now. Let's say this is the one.
vfb = v;
@ -429,7 +430,7 @@ void FramebufferManagerDX9::SetRenderFrameBuffer() {
// None found? Create one.
if (!vfb) {
gstate_c.textureChanged = true;
vfb = new VirtualFramebuffer();
vfb = new VirtualFramebufferDX9();
vfb->fbo = 0;
vfb->fb_address = fb_address;
vfb->fb_stride = fb_stride;
@ -598,7 +599,7 @@ void FramebufferManagerDX9::CopyDisplayToOutput() {
currentRenderVfb_ = 0;
VirtualFramebuffer *vfb = GetDisplayFBO();
VirtualFramebufferDX9 *vfb = GetDisplayFBO();
if (!vfb) {
if (Memory::IsValidAddress(ramDisplayFramebufPtr_)) {
// The game is displaying something directly from RAM. In GTA, it's decoded video.
@ -644,7 +645,7 @@ void FramebufferManagerDX9::CopyDisplayToOutput() {
}
}
void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync) {
void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebufferDX9 *vfb, bool sync) {
// This only works with buffered rendering
if (!useBufferedRendering_) {
return;
@ -660,11 +661,11 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, boo
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
// For now we'll keep these on the same struct as the ones that can get displayed
// (and blatantly copy work already done above while at it).
VirtualFramebuffer *nvfb = 0;
VirtualFramebufferDX9 *nvfb = 0;
// We maintain a separate vector of framebuffer objects for blitting.
for (size_t i = 0; i < bvfbs_.size(); ++i) {
VirtualFramebuffer *v = bvfbs_[i];
VirtualFramebufferDX9 *v = bvfbs_[i];
if (MaskedEqual(v->fb_address, vfb->fb_address) && v->format == vfb->format) {
if (v->bufferWidth == vfb->bufferWidth && v->bufferHeight == vfb->bufferHeight) {
nvfb = v;
@ -678,7 +679,7 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, boo
// Create a new fbo if none was found for the size
if(!nvfb) {
nvfb = new VirtualFramebuffer();
nvfb = new VirtualFramebufferDX9();
nvfb->fbo = 0;
nvfb->fb_address = vfb->fb_address;
nvfb->fb_stride = vfb->fb_stride;
@ -749,7 +750,7 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, boo
}
}
void FramebufferManagerDX9::BlitFramebuffer_(VirtualFramebuffer *src, VirtualFramebuffer *dst, bool flip, float upscale, float vscale) {
void FramebufferManagerDX9::BlitFramebuffer_(VirtualFramebufferDX9 *src, VirtualFramebufferDX9 *dst, bool flip, float upscale, float vscale) {
// This only works with buffered rendering
if (!useBufferedRendering_ || !src->fbo) {
return;
@ -825,7 +826,7 @@ static void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, GEBuff
#include <xgraphics.h>
#endif
static void Resolve(u8* data, VirtualFramebuffer *vfb) {
static void Resolve(u8* data, VirtualFramebufferDX9 *vfb) {
#ifdef _XBOX
D3DTexture * rtt = (D3DTexture*)fbo_get_rtt(vfb->fbo);
pD3Ddevice->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, rtt, NULL, 0, 0, NULL, 0.f, 0, NULL);
@ -839,7 +840,7 @@ static void Resolve(u8* data, VirtualFramebuffer *vfb) {
#endif
}
void FramebufferManagerDX9::PackFramebufferDirectx9_(VirtualFramebuffer *vfb) {
void FramebufferManagerDX9::PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb) {
if (useBufferedRendering_ && vfb->fbo) {
fbo_bind_for_read(vfb->fbo);
} else {
@ -910,7 +911,7 @@ std::vector<FramebufferInfo> FramebufferManagerDX9::GetFramebufferList() {
std::vector<FramebufferInfo> list;
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *vfb = vfbs_[i];
VirtualFramebufferDX9 *vfb = vfbs_[i];
FramebufferInfo info;
info.fb_address = vfb->fb_address;
@ -934,7 +935,7 @@ void FramebufferManagerDX9::DecimateFBOs() {
bool useMem = g_Config.iRenderingMode == FB_READFBOMEMORY_GPU;
#endif
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *vfb = vfbs_[i];
VirtualFramebufferDX9 *vfb = vfbs_[i];
int age = frameLastFramebufUsed - std::max(vfb->last_frame_render, vfb->last_frame_used);
if(useMem && age == 0 && !vfb->memoryUpdated) {
@ -954,7 +955,7 @@ void FramebufferManagerDX9::DecimateFBOs() {
// Do the same for ReadFramebuffersToMemory's VFBs
for (size_t i = 0; i < bvfbs_.size(); ++i) {
VirtualFramebuffer *vfb = bvfbs_[i];
VirtualFramebufferDX9 *vfb = bvfbs_[i];
int age = frameLastFramebufUsed - vfb->last_frame_render;
if (age > FBO_OLD_AGE) {
INFO_LOG(SCEGE, "Decimating FBO for %08x (%i x %i x %i), age %i", vfb->fb_address, vfb->width, vfb->height, vfb->format, age)
@ -972,7 +973,7 @@ void FramebufferManagerDX9::DestroyAllFBOs() {
prevPrevDisplayFramebuf_ = 0;
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *vfb = vfbs_[i];
VirtualFramebufferDX9 *vfb = vfbs_[i];
INFO_LOG(SCEGE, "Destroying FBO for %08x : %i x %i x %i", vfb->fb_address, vfb->width, vfb->height, vfb->format);
DestroyFramebuf(vfb);
}
@ -993,7 +994,7 @@ void FramebufferManagerDX9::UpdateFromMemory(u32 addr, int size) {
bool needUnbind = false;
for (size_t i = 0; i < vfbs_.size(); ++i) {
VirtualFramebuffer *vfb = vfbs_[i];
VirtualFramebufferDX9 *vfb = vfbs_[i];
if (MaskedEqual(vfb->fb_address, addr)) {
vfb->dirtyAfterDisplay = true;
vfb->reallyDirtyAfterDisplay = true;
@ -1019,3 +1020,5 @@ void FramebufferManagerDX9::UpdateFromMemory(u32 addr, int size) {
void FramebufferManagerDX9::Resized() {
resized_ = true;
}
};

View File

@ -18,6 +18,7 @@
#pragma once
#include <list>
#include "d3d9.h"
#include "GPU/Directx9/helper/fbo.h"
// Keeps track of allocated FBOs.
@ -28,6 +29,8 @@
#include "Globals.h"
#include "GPU/GPUCommon.h"
namespace DX9 {
struct GLSLProgram;
class TextureCacheDX9;
@ -44,7 +47,7 @@ enum {
FB_READFBOMEMORY_GPU = 3,
};
struct VirtualFramebuffer {
struct VirtualFramebufferDX9 {
int last_frame_used;
int last_frame_render;
bool memoryUpdated;
@ -79,6 +82,7 @@ struct VirtualFramebuffer {
void CenterRect(float *x, float *y, float *w, float *h,
float origW, float origH, float frameW, float frameH);
class ShaderManagerDX9;
class FramebufferManagerDX9 {
@ -107,10 +111,10 @@ public:
void SetRenderFrameBuffer(); // Uses parameters computed from gstate
void UpdateFromMemory(u32 addr, int size);
void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync = true);
void ReadFramebufferToMemory(VirtualFramebufferDX9 *vfb, bool sync = true);
// TODO: Break out into some form of FBO manager
VirtualFramebuffer *GetDisplayFBO();
VirtualFramebufferDX9 *GetDisplayFBO();
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format);
size_t NumVFBs() const { return vfbs_.size(); }
@ -128,7 +132,7 @@ public:
return displayFramebuf_ ? (0x04000000 | displayFramebuf_->fb_address) : 0;
}
void DestroyFramebuf(VirtualFramebuffer *vfb);
void DestroyFramebuf(VirtualFramebufferDX9 *vfb);
private:
u32 ramDisplayFramebufPtr_; // workaround for MotoGP insanity
@ -136,20 +140,20 @@ private:
u32 displayStride_;
GEBufferFormat displayFormat_;
VirtualFramebuffer *displayFramebuf_;
VirtualFramebuffer *prevDisplayFramebuf_;
VirtualFramebuffer *prevPrevDisplayFramebuf_;
VirtualFramebufferDX9 *displayFramebuf_;
VirtualFramebufferDX9 *prevDisplayFramebuf_;
VirtualFramebufferDX9 *prevPrevDisplayFramebuf_;
int frameLastFramebufUsed;
std::vector<VirtualFramebuffer *> vfbs_;
std::vector<VirtualFramebufferDX9 *> vfbs_;
VirtualFramebuffer *currentRenderVfb_;
VirtualFramebufferDX9 *currentRenderVfb_;
// Used by ReadFramebufferToMemory
void BlitFramebuffer_(VirtualFramebuffer *src, VirtualFramebuffer *dst, bool flip = false, float upscale = 1.0f, float vscale = 1.0f);
void PackFramebufferDirectx9_(VirtualFramebuffer *vfb);
void BlitFramebuffer_(VirtualFramebufferDX9 *src, VirtualFramebufferDX9 *dst, bool flip = false, float upscale = 1.0f, float vscale = 1.0f);
void PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb);
int gpuVendor;
std::vector<VirtualFramebuffer *> bvfbs_; // blitting FBOs
std::vector<VirtualFramebufferDX9 *> bvfbs_; // blitting FBOs
// Used by DrawPixels
LPDIRECT3DTEXTURE9 drawPixelsTex_;
@ -164,4 +168,6 @@ private:
bool resized_;
bool useBufferedRendering_;
};
};
};

View File

@ -37,6 +37,8 @@
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceGe.h"
namespace DX9 {
enum {
FLAG_FLUSHBEFORE = 1,
FLAG_FLUSHBEFOREONCHANGE = 2,
@ -478,7 +480,7 @@ bool DIRECTX9_GPU::FramebufferDirty() {
// Allow it to process fully before deciding if it's dirty.
SyncThread();
}
VirtualFramebuffer *vfb = framebufferManager_.GetDisplayFBO();
VirtualFramebufferDX9 *vfb = framebufferManager_.GetDisplayFBO();
if (vfb) {
bool dirty = vfb->dirtyAfterDisplay;
vfb->dirtyAfterDisplay = false;
@ -495,7 +497,7 @@ bool DIRECTX9_GPU::FramebufferReallyDirty() {
SyncThread();
}
VirtualFramebuffer *vfb = framebufferManager_.GetDisplayFBO();
VirtualFramebufferDX9 *vfb = framebufferManager_.GetDisplayFBO();
if (vfb) {
bool dirty = vfb->reallyDirtyAfterDisplay;
vfb->reallyDirtyAfterDisplay = false;
@ -1379,3 +1381,5 @@ void DIRECTX9_GPU::DoState(PointerWrap &p) {
framebufferManager_.DestroyAllFBOs();
shaderManager_->ClearCache(true);
}
};

View File

@ -27,6 +27,8 @@
#include "GPU/Directx9/TextureCacheDX9.h"
#include "GPU/Directx9/helper/fbo.h"
namespace DX9 {
class ShaderManagerDX9;
class LinkedShaderDX9;
@ -95,3 +97,7 @@ private:
std::string reportingPrimaryInfo_;
std::string reportingFullInfo_;
};
};
typedef DX9::DIRECTX9_GPU DIRECTX9_GPU;

View File

@ -27,6 +27,8 @@
// GL_NV_shader_framebuffer_fetch looks interesting....
namespace DX9 {
static bool IsAlphaTestTriviallyTrue() {
GEComparison alphaTestFunc = gstate.getAlphaTestFunction();
int alphaTestRef = gstate.getAlphaTestRef();
@ -300,3 +302,5 @@ void GenerateFragmentShaderDX9(char *buffer) {
}
WRITE(p, "}\n");
}
};

View File

@ -19,6 +19,8 @@
#include "Globals.h"
namespace DX9 {
struct FragmentShaderIDDX9
{
FragmentShaderIDDX9() {d[0] = 0xFFFFFFFF;}
@ -50,3 +52,5 @@ struct FragmentShaderIDDX9
void ComputeFragmentShaderIDDX9(FragmentShaderIDDX9 *id);
void GenerateFragmentShaderDX9(char *buffer);
};

View File

@ -36,6 +36,8 @@
// For matrices convertions
#include <xnamath.h>
namespace DX9 {
PSShader::PSShader(const char *code, bool useHWTransform) : failed_(false), useHWTransform_(useHWTransform) {
source_ = code;
#ifdef SHADERLOG
@ -653,3 +655,5 @@ LinkedShaderDX9 *ShaderManagerDX9::ApplyShader(int prim) {
lastShader_ = ls;
return ls;
}
};

View File

@ -23,6 +23,8 @@
#include "GPU/Directx9/VertexShaderGeneratorDX9.h"
#include "GPU/Directx9/PixelShaderGeneratorDX9.h"
namespace DX9 {
class PSShader;
class VSShader;
@ -228,3 +230,5 @@ private:
VSCache vsCache_;
};
};

View File

@ -17,6 +17,9 @@
#include "Core/MemMap.h"
#include "GPU/Directx9/TransformPipelineDX9.h"
#include "Gpu/Common/VertexDecoderCommon.h"
namespace DX9 {
// Just to get something on the screen, we'll just not subdivide correctly.
void TransformDrawEngineDX9::DrawBezier(int ucount, int vcount) {
@ -191,4 +194,6 @@ void TransformDrawEngineDX9::SubmitBezier(void* control_points, void* indices, i
vdecoder.SetVertexType(vertex_type);
Flush();
}
}
};

View File

@ -28,6 +28,8 @@
#include "GPU/Directx9/TextureCacheDX9.h"
#include "GPU/Directx9/FramebufferDX9.h"
namespace DX9 {
static const D3DBLEND aLookup[11] = {
D3DBLEND_DESTCOLOR,
D3DBLEND_INVDESTCOLOR,
@ -367,3 +369,5 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
dxstate.viewport.set(vpX0 + renderX, vpY0 + renderY, vpWidth, vpHeight, depthRangeMin, depthRangeMax);
}
}
};

View File

@ -30,6 +30,8 @@
#include "math/math_util.h"
#include "native/ext/cityhash/city.h"
namespace DX9 {
#define INVALID_TEX (LPDIRECT3DTEXTURE9)(-1)
// If a texture hasn't been seen for this many frames, get rid of it.
@ -164,7 +166,7 @@ void TextureCacheDX9::ClearNextFrame() {
template <typename T>
inline void AttachFramebufferValid(T &entry, VirtualFramebuffer *framebuffer) {
inline void AttachFramebufferValid(T &entry, VirtualFramebufferDX9 *framebuffer) {
const bool hasInvalidFramebuffer = entry->framebuffer == 0 || entry->invalidHint == -1;
const bool hasOlderFramebuffer = entry->framebuffer != 0 && entry->framebuffer->last_frame_render < framebuffer->last_frame_render;
if (hasInvalidFramebuffer || hasOlderFramebuffer) {
@ -174,14 +176,14 @@ inline void AttachFramebufferValid(T &entry, VirtualFramebuffer *framebuffer) {
}
template <typename T>
inline void AttachFramebufferInvalid(T &entry, VirtualFramebuffer *framebuffer) {
inline void AttachFramebufferInvalid(T &entry, VirtualFramebufferDX9 *framebuffer) {
if (entry->framebuffer == 0 || entry->framebuffer == framebuffer) {
entry->framebuffer = framebuffer;
entry->invalidHint = -1;
}
}
inline void TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, bool exactMatch) {
inline void TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebufferDX9 *framebuffer, bool exactMatch) {
// If they match exactly, it's non-CLUT and from the top left.
if (exactMatch) {
DEBUG_LOG(G3D, "Render to texture detected at %08x!", address);
@ -220,13 +222,13 @@ inline void TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address
}
}
inline void TextureCacheDX9::DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer) {
inline void TextureCacheDX9::DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebufferDX9 *framebuffer) {
if (entry->framebuffer == framebuffer) {
entry->framebuffer = 0;
}
}
void TextureCacheDX9::NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffer, FramebufferNotification msg) {
void TextureCacheDX9::NotifyFramebuffer(u32 address, VirtualFramebufferDX9 *framebuffer, FramebufferNotification msg) {
// This is a rough heuristic, because sometimes our framebuffers are too tall.
static const u32 MAX_SUBAREA_Y_OFFSET = 32;
@ -1759,3 +1761,5 @@ bool TextureCacheDX9::DecodeTexture(u8* output, GPUgstate state)
OutputDebugStringA("TextureCache::DecodeTexture : FixMe\r\n");
return true;
}
};

View File

@ -24,7 +24,9 @@
#include "GPU/GPUState.h"
#include "GPU/Directx9/TextureScalerDX9.h"
struct VirtualFramebuffer;
namespace DX9 {
struct VirtualFramebufferDX9;
enum TextureFiltering {
AUTO = 1,
@ -56,7 +58,7 @@ public:
// FramebufferManager keeps TextureCache updated about what regions of memory
// are being rendered to. This is barebones so far.
void NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffer, FramebufferNotification msg);
void NotifyFramebuffer(u32 address, VirtualFramebufferDX9 *framebuffer, FramebufferNotification msg);
size_t NumLoadedTextures() const {
return cache.size();
@ -88,7 +90,7 @@ private:
int status;
u32 addr;
u32 hash;
VirtualFramebuffer *framebuffer; // if null, not sourced from an FBO.
VirtualFramebufferDX9 *framebuffer; // if null, not sourced from an FBO.
u32 sizeInRAM;
int lastFrame;
int numFrames;
@ -125,8 +127,8 @@ private:
const T *GetCurrentClut();
u32 GetCurrentClutHash();
void UpdateCurrentClut();
void AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, bool exactMatch);
void DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer);
void AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebufferDX9 *framebuffer, bool exactMatch);
void DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebufferDX9 *framebuffer);
void SetTextureFramebuffer(TexCacheEntry *entry);
TexCacheEntry *GetEntryAt(u32 texaddr);
@ -134,7 +136,7 @@ private:
typedef std::map<u64, TexCacheEntry> TexCache;
TexCache cache;
TexCache secondCache;
std::vector<VirtualFramebuffer *> fbCache_;
std::vector<VirtualFramebufferDX9 *> fbCache_;
bool clearCacheNextFrame_;
bool lowMemoryMode_;
@ -161,3 +163,4 @@ private:
int decimationCounter_;
};
};

View File

@ -28,6 +28,10 @@
#include <stdlib.h>
#include <math.h>
#ifndef _XBOX
#include <D3D9Types.h>
#endif
#undef min
#undef max
@ -523,6 +527,8 @@ namespace {
/////////////////////////////////////// Texture Scaler
namespace DX9 {
TextureScalerDX9::TextureScalerDX9() {
initBicubicWeights();
}
@ -677,3 +683,5 @@ void TextureScalerDX9::ConvertTo8888(u32 format, u32* source, u32* &dest, int wi
ERROR_LOG(G3D, "iXBRZTexScaling: unsupported texture format");
}
}
};

View File

@ -24,6 +24,8 @@
#include <vector>
namespace DX9 {
class TextureScalerDX9 {
public:
@ -50,3 +52,5 @@ private:
// of course, scaling factor 5 is totally silly anyway
SimpleBuf<u32> bufInput, bufDeposter, bufOutput, bufTmp1, bufTmp2, bufTmp3;
};
};

View File

@ -40,6 +40,8 @@
#include "GPU/Directx9/ShaderManagerDX9.h"
#include "GPU/Directx9/GPU_DX9.h"
namespace DX9 {
const D3DPRIMITIVETYPE glprim[8] = {
D3DPT_POINTLIST,
D3DPT_LINELIST,
@ -128,6 +130,7 @@ void TransformDrawEngineDX9::DestroyDeviceObjects() {
}
namespace {
using namespace DX9;
// Convenient way to do precomputation to save the parts of the lighting calculation
// that's common between the many vertices of a draw call.
@ -1330,3 +1333,5 @@ rotateVBO:
numDrawCalls = 0;
prevPrim_ = GE_PRIM_INVALID;
}
};

View File

@ -23,13 +23,15 @@
#include "GPU/Common/IndexGenerator.h"
#include "GPU/Directx9/VertexDecoderDX9.h"
struct DecVtxFormat;
namespace DX9 {
class LinkedShaderDX9;
class ShaderManagerDX9;
class TextureCacheDX9;
class FramebufferManagerDX9;
struct DecVtxFormat;
// States transitions:
// On creation: DRAWN_NEW
// DRAWN_NEW -> DRAWN_HASHING
@ -227,3 +229,5 @@ struct Color4 {
a = (col&0xff)/255.0f;
}
};
};

View File

@ -24,6 +24,8 @@
#include "GPU/Directx9/VertexDecoderDX9.h"
#include "GPU/Directx9/VertexShaderGeneratorDX9.h"
namespace DX9 {
// Always use float for decoding data
#define USE_WEIGHT_HACK
@ -1001,4 +1003,6 @@ int VertexDecoderDX9::ToString(char *output) const {
output += sprintf(output, " (size: %i)", VertexSize());
return output - start;
}
}
};

View File

@ -24,6 +24,8 @@
#include "GPU/Common/VertexDecoderCommon.h"
namespace DX9 {
class VertexDecoderDX9;
typedef void (VertexDecoderDX9::*StepFunction)() const;
@ -150,3 +152,4 @@ public:
int stats_[NUM_VERTEX_DECODER_STATS];
};
};

View File

@ -33,6 +33,8 @@
#define WRITE p+=sprintf
namespace DX9 {
bool CanUseHardwareTransformDX9(int prim) {
if (!g_Config.bHardwareTransform)
return false;
@ -575,3 +577,5 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform) {
}
WRITE(p, "}\n");
}
};

View File

@ -19,6 +19,8 @@
#include "Globals.h"
namespace DX9 {
// #define USE_BONE_ARRAY
struct VertexShaderIDDX9
@ -55,3 +57,5 @@ void GenerateVertexShaderDX9(int prim, char *buffer, bool useHWTransform);
// Collapse to less skinning shaders to reduce shader switching, which is expensive.
int TranslateNumBonesDX9(int bones);
};

View File

@ -1,6 +1,8 @@
#include "dx_state.h"
#include <assert.h>
namespace DX9 {
DirectxState dxstate;
GLExtensions gl_extensions;
@ -76,4 +78,6 @@ void DirectxState::SetVSyncInterval(int interval) {
wglSwapIntervalEXT(interval);
#endif
*/
}
}
};

View File

@ -4,6 +4,8 @@
#include <string.h>
#include "global.h"
namespace DX9 {
// OpenGL state cache. Should convert all code to use this instead of directly calling glEnable etc,
// as GL state changes can be expensive on some hardware.
class DirectxState
@ -297,3 +299,5 @@ struct GLExtensions {
extern GLExtensions gl_extensions;
void CheckGLExtensions();
};

View File

@ -4,6 +4,8 @@
#include <stdio.h>
#include "fbo.h"
namespace DX9 {
static LPDIRECT3DSURFACE9 currentRtt;
static LPDIRECT3DSURFACE9 workingRtt;
static LPDIRECT3DSURFACE9 deviceRTsurf;
@ -157,4 +159,6 @@ void SwapBuffer() {
// :s
//pD3Ddevice->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET |D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0 ,0), 0, 0);
}
}
};

View File

@ -4,6 +4,8 @@
// Very C-ish API because that's what I felt like, and it's cool to completely
// hide the data from callers...
namespace DX9 {
struct FBO;
enum FBOColorDepth {
@ -36,4 +38,6 @@ void fbo_resolve(FBO *fbo);
void * fbo_get_rtt(FBO *fbo);
// To get default depth and rt surface
void fbo_init();
void fbo_init();
};

View File

@ -1,6 +1,8 @@
#include "global.h"
#include "fbo.h"
namespace DX9 {
LPDIRECT3DDEVICE9 pD3Ddevice = NULL;
LPDIRECT3D9 pD3D = NULL;
@ -246,4 +248,6 @@ void DirectxInit() {
CompileShaders();
fbo_init();
}
}
};

View File

@ -1,7 +1,7 @@
#pragma once
#include "Common/CommonWindows.h"
#ifdef _XBOX
#include <xtl.h>
// Used on XBox to create a linear format
// TODO: Might actually want to use nonlinear on xbox?
#define D3DFMT(x) (D3DFORMAT)MAKELINFMT(x)
@ -9,6 +9,8 @@
#define D3DFMT(x) x
#endif
namespace DX9 {
#include <d3d9.h>
#include <d3dx9.h>
@ -23,4 +25,6 @@ extern IDirect3DVertexDeclaration9* pSoftVertexDecl;
bool CompilePixelShader(const char * code, LPDIRECT3DPIXELSHADER9 * pShader, LPD3DXCONSTANTTABLE * pShaderTable);
bool CompileVertexShader(const char * code, LPDIRECT3DVERTEXSHADER9 * pShader, LPD3DXCONSTANTTABLE * pShaderTable);
#define D3DBLEND_UNK D3DSTENCILOP_FORCE_DWORD
#define D3DBLEND_UNK D3DSTENCILOP_FORCE_DWORD
};

View File

@ -158,6 +158,9 @@
<ClInclude Include="Common\IndexGenerator.h" />
<ClInclude Include="Common\VertexDecoderCommon.h" />
<ClInclude Include="Directx9\GPU_DX9.h" />
<ClInclude Include="Directx9\helper\dx_state.h" />
<ClInclude Include="Directx9\helper\fbo.h" />
<ClInclude Include="Directx9\helper\global.h" />
<ClInclude Include="Directx9\PixelShaderGeneratorDX9.h" />
<ClInclude Include="Directx9\FramebufferDX9.h" />
<ClInclude Include="Directx9\ShaderManagerDX9.h" />
@ -196,6 +199,19 @@
<ClCompile Include="Common\IndexGenerator.cpp" />
<ClCompile Include="Common\VertexDecoderCommon.cpp" />
<ClCompile Include="Directx9\GPU_DX9.cpp" />
<ClCompile Include="Directx9\helper\dx_state.cpp" />
<ClCompile Include="Directx9\helper\fbo.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Directx9\helper\global.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Directx9\PixelShaderGeneratorDX9.cpp" />
<ClCompile Include="Directx9\FramebufferDX9.cpp" />
<ClCompile Include="Directx9\ShaderManagerDX9.cpp" />
@ -239,4 +255,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -16,6 +16,9 @@
<Filter Include="DirectX9">
<UniqueIdentifier>{88629970-4774-4122-b031-2128244b795c}</UniqueIdentifier>
</Filter>
<Filter Include="DirectX9\helper">
<UniqueIdentifier>{ba434472-5d5e-4b08-ab16-bfb7ec8e7068}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ge_constants.h">
@ -126,6 +129,15 @@
<ClInclude Include="..\ext\xbrz\xbrz.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Directx9\helper\dx_state.h">
<Filter>DirectX9\helper</Filter>
</ClInclude>
<ClInclude Include="Directx9\helper\fbo.h">
<Filter>DirectX9\helper</Filter>
</ClInclude>
<ClInclude Include="Directx9\helper\global.h">
<Filter>DirectX9\helper</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math3D.cpp">
@ -233,6 +245,15 @@
<ClCompile Include="..\ext\xbrz\xbrz.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Directx9\helper\dx_state.cpp">
<Filter>DirectX9\helper</Filter>
</ClCompile>
<ClCompile Include="Directx9\helper\fbo.cpp">
<Filter>DirectX9\helper</Filter>
</ClCompile>
<ClCompile Include="Directx9\helper\global.cpp">
<Filter>DirectX9\helper</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />

View File

@ -23,8 +23,8 @@
#endif
#include "GPU/Null/NullGpu.h"
#include "GPU/Software/SoftGpu.h"
#ifdef USE_DIRECTX
#include "Directx9/DisplayListInterpreter.h"
#if defined(_XBOX)
#include "GPU/Directx9/GPU_DX9.h"
#endif
#include "Core/CoreParameter.h"
#include "Core/System.h"
@ -39,22 +39,21 @@ bool GPU_Init() {
case GPU_NULL:
gpu = new NullGPU();
break;
#ifndef _XBOX
case GPU_GLES:
#ifndef _XBOX
gpu = new GLES_GPU();
#endif
break;
#endif
case GPU_SOFTWARE:
#if !(defined(__SYMBIAN32__) || defined(_XBOX))
gpu = new SoftGPU();
#endif
break;
#ifdef USE_DIRECTX
case GPU_DIRECTX9:
#if defined(_XBOX)
gpu = new DIRECTX9_GPU();
break;
#endif
break;
}
return gpu != NULL;