C codepath for D3D9 works now

This commit is contained in:
twinaphex 2017-10-02 03:52:53 +02:00
parent 22b14142b6
commit 5ef6de4d4e
5 changed files with 41 additions and 21 deletions

View File

@ -31,10 +31,10 @@ bool d3d_swap(void *data, LPDIRECT3DDEVICE dev)
#elif defined(_XBOX360)
D3DDevice_Present(dev);
#elif defined(HAVE_D3D9) && !defined(__cplusplus)
if (IDirect3DDevice9_Present(dev, NULL, NULL, NULL, NULL) == D3DERR_DEVICE_LOST)
if (IDirect3DDevice9_Present(dev, NULL, NULL, NULL, NULL) == D3DERR_DEVICELOST)
return false;
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (IDirect3DDevice8_Present(dev, NULL, NULL, NULL, NULL) == D3DERR_DEVICE_LOST)
if (IDirect3DDevice8_Present(dev, NULL, NULL, NULL, NULL) == D3DERR_DEVICELOST)
return false;
#else
if (dev->Present(NULL, NULL, NULL, NULL) != D3D_OK)
@ -523,10 +523,10 @@ bool d3d_lock_rectangle(LPDIRECT3DTEXTURE tex,
#if defined(_XBOX)
D3DTexture_LockRect(tex, level, lock_rect, rect, flags);
#elif defined(HAVE_D3D9) && !defined(__cplusplus)
if (IDirect3DSurface9_LockRect(tex, lock_rect, (D3DLOCKED_RECT*)rect, flags) != D3D_OK)
if (IDirect3DTexture9_LockRect(tex, level, lock_rect, (const RECT*)rect, flags) != D3D_OK)
return false;
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (IDirect3DSurface8_LockRect(tex, lock_rect, rect, flags) != D3D_OK)
if (IDirect3DTexture8_LockRect(tex, lock_rect, rect, flags) != D3D_OK)
return false;
#else
if (FAILED(tex->LockRect(level, lock_rect, rect, flags)))
@ -540,9 +540,9 @@ void d3d_unlock_rectangle(LPDIRECT3DTEXTURE tex)
#ifdef _XBOX
D3DTexture_UnlockRect(tex, 0);
#elif defined(HAVE_D3D9) && !defined(__cplusplus)
IDirect3DSurface9_UnlockRect(tex);
IDirect3DTexture9_UnlockRect(tex, 0);
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
IDirect3DSurface8_UnlockRect(tex);
IDirect3DTexture8_UnlockRect(tex);
#else
tex->UnlockRect(0);
#endif
@ -775,6 +775,23 @@ static bool d3d_create_device_internal(LPDIRECT3DDEVICE *dev,
unsigned cur_mon_id,
DWORD behavior_flags)
{
#if defined(HAVE_D3D9) && !defined(__cplusplus)
if (FAILED(IDirect3D9_CreateDevice(d3d,
cur_mon_id,
D3DDEVTYPE_HAL,
focus_window,
behavior_flags,
d3dpp,
dev)))
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (FAILED(IDirect3D8_CreateDevice(d3d,
cur_mon_id,
D3DDEVTYPE_HAL,
focus_window,
behavior_flags,
d3dpp,
dev)))
#else
if (FAILED(d3d->CreateDevice(
cur_mon_id,
D3DDEVTYPE_HAL,
@ -782,6 +799,7 @@ static bool d3d_create_device_internal(LPDIRECT3DDEVICE *dev,
behavior_flags,
d3dpp,
dev)))
#endif
return false;
return true;
}

View File

@ -79,10 +79,8 @@ namespace
typedef struct cg_renderchain
{
LPDIRECT3DDEVICE dev;
unsigned pixel_size;
const video_info_t *video_info;
state_tracker_t *state_tracker;
unsigned frame_count;
struct
{
LPDIRECT3DTEXTURE tex[TEXTURES];
@ -91,14 +89,17 @@ typedef struct cg_renderchain
unsigned last_width[TEXTURES];
unsigned last_height[TEXTURES];
} prev;
std::vector<Pass> passes;
CGprogram vStock, fStock;
std::vector<lut_info> luts;
CGprogram vStock;
CGprogram fStock;
LPDIRECT3DDEVICE dev;
const video_info_t *video_info;
state_tracker_t *state_tracker;
D3DVIEWPORT *final_viewport;
unsigned frame_count;
CGcontext cgCtx;
std::vector<Pass> passes;
std::vector<lut_info> luts;
std::vector<unsigned> bound_tex;
std::vector<unsigned> bound_vert;
CGcontext cgCtx;
} cg_renderchain_t;
static INLINE bool d3d9_cg_validate_param_name(const char *name)

View File

@ -29,16 +29,16 @@
typedef struct hlsl_d3d9_renderchain
{
unsigned pixel_size;
LPDIRECT3DDEVICE dev;
const video_info_t *video_info;
LPDIRECT3DTEXTURE tex;
LPDIRECT3DVERTEXBUFFER vertex_buf;
unsigned last_width;
unsigned last_height;
LPDIRECT3DVERTEXDECLARATION vertex_decl;
unsigned tex_w;
unsigned tex_h;
uint64_t frame_count;
LPDIRECT3DDEVICE dev;
LPDIRECT3DTEXTURE tex;
LPDIRECT3DVERTEXBUFFER vertex_buf;
LPDIRECT3DVERTEXDECLARATION vertex_decl;
const video_info_t *video_info;
} hlsl_d3d9_renderchain_t;
/* TODO/FIXME - this forward declaration should not be necesary */

View File

@ -309,6 +309,9 @@ VIDEO IMAGE
/*============================================================
VIDEO DRIVER
============================================================ */
#if defined(HAVE_D3D)
#include "../gfx/common/d3d_common.c"
#endif
#if defined(GEKKO)
#ifdef HW_RVL

View File

@ -142,10 +142,8 @@ VIDEO DRIVER
#endif
#if defined(HAVE_D3D)
#include "../gfx/common/d3d_common.cpp"
#include "../gfx/drivers/d3d.cpp"
#if defined(HAVE_D3D8)
#include "../gfx/drivers_renderchain/d3d8_renderchain.cpp"
#elif defined(HAVE_D3D9)