(D3D8/D3D9) More dehardcoding

This commit is contained in:
twinaphex 2018-01-25 14:34:20 +01:00
parent 8422e44a2d
commit 8f4a1b748b
8 changed files with 164 additions and 277 deletions

View File

@ -25,6 +25,7 @@
/* Direct3D 9 */
#include <d3d9.h>
#if 0
#define LPDIRECT3D LPDIRECT3D9
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE9
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE9
@ -38,6 +39,7 @@
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE9
#define D3DVERTEXELEMENT D3DVERTEXELEMENT9
#define D3DVIEWPORT D3DVIEWPORT9
#endif
#ifndef D3DCREATE_SOFTWARE_VERTEXPROCESSING
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0
@ -51,6 +53,7 @@
#endif
/* Direct3D 8 */
#if 0
#define LPDIRECT3D LPDIRECT3D8
#define LPDIRECT3DDEVICE LPDIRECT3DDEVICE8
#define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE8
@ -62,22 +65,18 @@
#define LPDIRECT3DRESOURCE LPDIRECT3DRESOURCE8
#define D3DVERTEXELEMENT D3DVERTEXELEMENT8
#define D3DVIEWPORT D3DVIEWPORT8
#endif
#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX)
#define D3DLOCK_NOSYSLOCK (0)
#endif
#if 0
#define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU
#define D3DSAMP_ADDRESSV D3DTSS_ADDRESSV
#define D3DSAMP_MAGFILTER D3DTSS_MAGFILTER
#define D3DSAMP_MINFILTER D3DTSS_MINFILTER
#endif
#if defined(_XBOX360)
#define D3DFVF_CUSTOMVERTEX 0
#elif defined(HAVE_D3D9)
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)
#elif defined(HAVE_D3D8)
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE)
#endif
#endif

166
diff.diff
View File

@ -1,166 +0,0 @@
diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp
index fc6132d..6c81bcb 100644
--- a/gfx/drivers_context/wgl_ctx.cpp
+++ b/gfx/drivers_context/wgl_ctx.cpp
@@ -81,6 +81,20 @@
#endif
#if defined(HAVE_OPENGL)
+typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC)(HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC)(HDC hdc, INT32 *numerator, INT32 *denominator);
+typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC)(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
+typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC)(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC)(HDC hdc, INT64 traget_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
+
+static PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
+static PFNWGLGETSYNCVALUESOMLPROC wglGetSyncValuesOML;
+static PFNWGLGETMSCRATEOMLPROC wglGetMscRateOML;
+static PFNWGLSWAPBUFFERSMSCOMLPROC wglSwapBuffersMscOML;
+static PFNWGLWAITFORMSCOMLPROC wglWaitForMscOML;
+static PFNWGLWAITFORSBCOMLPROC wglWaitForSbcOML;
+
typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*);
static wglCreateContextAttribsProc pcreate_context;
#endif
@@ -91,6 +105,13 @@ static HGLRC win32_hw_hrc;
static HDC win32_hdc;
static bool win32_use_hw_ctx = false;
static bool win32_core_hw_context_enable = false;
+static unsigned g_wgl_swap_mode = 0;
+
+static int g_wgl_divisor = 0;
+static int g_wgl_remainder = 0;
+static int64_t g_wgl_ust = 0;
+static int64_t g_wgl_msc = 0;
+static int64_t g_wgl_sbc = 0;
#ifdef HAVE_VULKAN
static gfx_ctx_vulkan_data_t win32_vk;
@@ -103,6 +124,44 @@ static enum gfx_ctx_api win32_api = GFX_CTX_NONE;
static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */
+static unsigned strclen(const unsigned char *s, unsigned char c)
+{
+ unsigned i = 0;
+ while (s + i != NULL && s[i] != '\0' && s[i] != c)
+ i++;
+ return i;
+}
+
+static bool strsame(const unsigned char *a, const unsigned char *b, unsigned n)
+{
+ unsigned i = 0;
+ while (i < n && a + i != NULL && b + i != NULL && a[i] == b[i])
+ i++;
+ return i == n;
+}
+
+static bool wgl_has_extension(HDC hdc, const char *ext)
+{
+ char *end;
+ int len = strlen(ext);
+ char *p = (char*)wglGetExtensionsStringARB(hdc);
+
+ if (p == 0)
+ return false;
+
+ end = p + strlen(p);
+
+ while (p < end)
+ {
+ int n = strclen((const unsigned char*)p, ' ');
+ if (len == n && strsame((const unsigned char*)ext, (const unsigned char*)p, n))
+ return true;
+ p += n+1;
+ }
+
+ return false;
+}
+
static void setup_pixel_format(HDC hdc)
{
PIXELFORMATDESCRIPTOR pfd = {0};
@@ -282,9 +341,7 @@ static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval)
case GFX_CTX_OPENGL_API:
#ifdef HAVE_OPENGL
win32_interval = interval;
- if (!win32_hrc)
- return;
- if (!p_swap_interval)
+ if (!win32_hrc || !p_swap_interval)
return;
RARCH_LOG("[WGL]: wglSwapInterval(%u)\n", win32_interval);
@@ -339,7 +396,19 @@ static void gfx_ctx_wgl_swap_buffers(void *data, video_frame_info_t video_info)
{
case GFX_CTX_OPENGL_API:
#ifdef HAVE_OPENGL
- SwapBuffers(win32_hdc);
+ if (g_wgl_swap_mode)
+ {
+ if (win32_interval)
+ {
+ wglWaitForMscOML(win32_hdc, g_wgl_msc + win32_interval,
+ 0, 0, &g_wgl_ust, &g_wgl_msc, &g_wgl_sbc);
+ wglSwapBuffersMscOML(win32_hdc, 0, 0, 0);
+ }
+ else
+ wglSwapBuffersMscOML(win32_hdc, 0, g_wgl_divisor, g_wgl_remainder);
+ }
+ else
+ SwapBuffers(win32_hdc);
#endif
break;
@@ -439,11 +508,35 @@ static void *gfx_ctx_wgl_init(video_frame_info_t video_info, void *video_driver)
win32_monitor_init();
wndclass.lpfnWndProc = WndProcGL;
+ g_wgl_swap_mode = 0;
if (!win32_window_init(&wndclass, true, NULL))
return NULL;
switch (win32_api)
{
+ case GFX_CTX_OPENGL_API:
+ RARCH_LOG("Testing if extension WGL_OML_sync_control is available...\n");
+ wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
+
+ if (wgl_has_extension(win32_hdc, "WGL_OML_sync_control"))
+ {
+ RARCH_LOG("WGL_OML_sync_control supported, using better swap control method...\n");
+
+ g_wgl_swap_mode = 1;
+ wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)
+ wglGetProcAddress("wglGetSyncValuesOML");
+ wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)
+ wglGetProcAddress("wglGetMscRateOML");
+ wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)
+ wglGetProcAddress("wglSwapBuffersMscOML");
+ wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)
+ wglGetProcAddress("wglWaitForMscOML");
+ wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)
+ wglGetProcAddress("wglWaitForSbcOML");
+
+ wglGetSyncValuesOML(win32_hdc, &g_wgl_ust, &g_wgl_msc, &g_wgl_sbc);
+ }
+ break;
case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
if (!vulkan_context_init(&win32_vk, VULKAN_WSI_WIN32))
@@ -522,6 +615,13 @@ static void gfx_ctx_wgl_destroy(void *data)
win32_major = 0;
win32_minor = 0;
p_swap_interval = NULL;
+
+ g_wgl_swap_mode = 0;
+ g_wgl_divisor = 0;
+ g_wgl_remainder = 0;
+ g_wgl_ust = 0;
+ g_wgl_msc = 0;
+ g_wgl_sbc = 0;
}
static bool gfx_ctx_wgl_set_video_mode(void *data,

View File

@ -786,38 +786,43 @@ void d3d_texture_free(void *_tex)
bool d3d_surface_lock_rect(void *data, void *data2)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
if (!surf)
return false;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data;
if (!surf)
return false;
#ifdef __cplusplus
if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#else
#if defined(_XBOX)
IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY);
IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY);
#else
if (FAILED(IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
if (FAILED(IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#endif
#endif
#endif
}
break;
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DSURFACE8 surf = (LPDIRECT3DSURFACE8)data;
if (!surf)
return false;
#ifdef __cplusplus
if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#else
if (FAILED(IDirect3DSurface8_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
if (FAILED(IDirect3DSurface8_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#endif
#endif
}
break;
case GFX_CTX_NONE:
default:
@ -829,29 +834,36 @@ bool d3d_surface_lock_rect(void *data, void *data2)
void d3d_surface_unlock_rect(void *data)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
if (!surf)
return;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data;
if (!surf)
return;
#ifdef __cplusplus
surf->UnlockRect();
surf->UnlockRect();
#else
IDirect3DSurface9_UnlockRect(surf);
IDirect3DSurface9_UnlockRect(surf);
#endif
#endif
}
break;
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DSURFACE8 surf = (LPDIRECT3DSURFACE8)data;
if (!surf)
return;
#ifdef __cplusplus
surf->UnlockRect();
surf->UnlockRect();
#else
IDirect3DSurface8_UnlockRect(surf);
IDirect3DSurface8_UnlockRect(surf);
#endif
#endif
}
break;
case GFX_CTX_NONE:
default:
@ -861,28 +873,35 @@ void d3d_surface_unlock_rect(void *data)
void d3d_surface_free(void *data)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
if (!surf)
return;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data;
if (!surf)
return;
#ifdef __cplusplus
surf->Release();
surf->Release();
#else
IDirect3DSurface9_Release(surf);
IDirect3DSurface9_Release(surf);
#endif
#endif
}
break;
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DSURFACE8 surf = (LPDIRECT3DSURFACE8)data;
if (!surf)
return;
#ifdef __cplusplus
surf->Release();
surf->Release();
#else
IDirect3DSurface8_Release(surf);
IDirect3DSurface8_Release(surf);
#endif
#endif
}
break;
case GFX_CTX_NONE:
default:
@ -901,13 +920,13 @@ void d3d_vertex_declaration_free(void *data)
#ifdef HAVE_D3D9
#ifdef __cplusplus
{
LPDIRECT3DVERTEXDECLARATION vertex_decl =
(LPDIRECT3DVERTEXDECLARATION)data;
LPDIRECT3DVERTEXDECLARATION9 vertex_decl =
(LPDIRECT3DVERTEXDECLARATION9)data;
if (vertex_decl)
vertex_decl->Release();
}
#else
IDirect3DVertexDeclaration9_Release((LPDIRECT3DVERTEXDECLARATION)data);
IDirect3DVertexDeclaration9_Release((LPDIRECT3DVERTEXDECLARATION9)data);
#endif
#endif
break;
@ -926,9 +945,9 @@ bool d3d_vertex_declaration_new(void *_dev,
case GFX_CTX_DIRECT3D9_API:
#ifdef HAVE_D3D9
{
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
const D3DVERTEXELEMENT *vertex_elements = (const D3DVERTEXELEMENT*)vertex_data;
LPDIRECT3DVERTEXDECLARATION **vertex_decl = (LPDIRECT3DVERTEXDECLARATION**)decl_data;
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
const D3DVERTEXELEMENT9 *vertex_elements = (const D3DVERTEXELEMENT9*)vertex_data;
LPDIRECT3DVERTEXDECLARATION9 **vertex_decl = (LPDIRECT3DVERTEXDECLARATION9**)decl_data;
#if defined(__cplusplus)
if (SUCCEEDED(dev->CreateVertexDeclaration(vertex_elements, (IDirect3DVertexDeclaration9**)vertex_decl)))
@ -949,12 +968,12 @@ bool d3d_vertex_declaration_new(void *_dev,
return false;
}
LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(void *_dev,
void *d3d_vertex_buffer_new(void *_dev,
unsigned length, unsigned usage,
unsigned fvf, D3DPOOL pool, void *handle)
{
HRESULT hr = S_OK;
LPDIRECT3DVERTEXBUFFER buf = NULL;
HRESULT hr = S_OK;
void *buf = NULL;
switch (d3d_common_api)
{
@ -976,10 +995,10 @@ LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(void *_dev,
}
#ifdef __cplusplus
hr = dev->CreateVertexBuffer(length, usage, fvf, pool, &buf, NULL);
hr = dev->CreateVertexBuffer(length, usage, fvf, pool, (LPDIRECT3DVERTEXBUFFER9*)&buf, NULL);
#else
hr = IDirect3DDevice9_CreateVertexBuffer(dev, length, usage, fvf, pool,
&buf, NULL);
(LPDIRECT3DVERTEXBUFFER9*)&buf, NULL);
#endif
#endif
@ -1011,30 +1030,37 @@ LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(void *_dev,
void d3d_vertex_buffer_unlock(void *vertbuf_ptr)
{
LPDIRECT3DVERTEXBUFFER vertbuf = (LPDIRECT3DVERTEXBUFFER)vertbuf_ptr;
if (!vertbuf)
return;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DVERTEXBUFFER9 vertbuf = (LPDIRECT3DVERTEXBUFFER9)vertbuf_ptr;
if (!vertbuf)
return;
#ifdef __cplusplus
vertbuf->Unlock();
vertbuf->Unlock();
#else
IDirect3DVertexBuffer9_Unlock(vertbuf);
IDirect3DVertexBuffer9_Unlock(vertbuf);
#endif
#endif
}
break;
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DVERTEXBUFFER8 vertbuf = (LPDIRECT3DVERTEXBUFFER8)vertbuf_ptr;
if (!vertbuf)
return;
#ifdef __cplusplus
vertbuf->Unlock();
vertbuf->Unlock();
#else
IDirect3DVertexBuffer8_Unlock(vertbuf);
IDirect3DVertexBuffer8_Unlock(vertbuf);
#endif
#endif
}
break;
case GFX_CTX_NONE:
default:
@ -1045,28 +1071,37 @@ void d3d_vertex_buffer_unlock(void *vertbuf_ptr)
void *d3d_vertex_buffer_lock(void *vertbuf_ptr)
{
void *buf = NULL;
LPDIRECT3DVERTEXBUFFER vertbuf = (LPDIRECT3DVERTEXBUFFER)vertbuf_ptr;
void *buf = NULL;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DVERTEXBUFFER9 vertbuf = (LPDIRECT3DVERTEXBUFFER9)vertbuf_ptr;
if (!vertbuf)
return NULL;
#ifdef __cplusplus
vertbuf->Lock(0, 0, &buf, 0);
vertbuf->Lock(0, 0, &buf, 0);
#else
IDirect3DVertexBuffer9_Lock(vertbuf, 0, 0, &buf, 0);
IDirect3DVertexBuffer9_Lock(vertbuf, 0, 0, &buf, 0);
#endif
#endif
}
break;
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DVERTEXBUFFER8 vertbuf = (LPDIRECT3DVERTEXBUFFER8)vertbuf_ptr;
if (!vertbuf)
return NULL;
#ifdef __cplusplus
vertbuf->Lock(0, 0, &buf, 0);
vertbuf->Lock(0, 0, &buf, 0);
#else
IDirect3DVertexBuffer8_Lock(vertbuf, 0, 0, (BYTE**)&buf, 0);
IDirect3DVertexBuffer8_Lock(vertbuf, 0, 0, (BYTE**)&buf, 0);
#endif
#endif
}
break;
case GFX_CTX_NONE:
default:
@ -1087,7 +1122,7 @@ void d3d_vertex_buffer_free(void *vertex_data, void *vertex_declaration)
#ifdef HAVE_D3D9
if (vertex_data)
{
LPDIRECT3DVERTEXBUFFER buf = (LPDIRECT3DVERTEXBUFFER)vertex_data;
LPDIRECT3DVERTEXBUFFER9 buf = (LPDIRECT3DVERTEXBUFFER9)vertex_data;
#ifdef __cplusplus
buf->Release();
#else
@ -1098,7 +1133,7 @@ void d3d_vertex_buffer_free(void *vertex_data, void *vertex_declaration)
if (vertex_declaration)
{
LPDIRECT3DVERTEXDECLARATION vertex_decl = (LPDIRECT3DVERTEXDECLARATION)vertex_declaration;
LPDIRECT3DVERTEXDECLARATION9 vertex_decl = (LPDIRECT3DVERTEXDECLARATION9)vertex_declaration;
d3d_vertex_declaration_free(vertex_decl);
vertex_decl = NULL;
}
@ -1128,10 +1163,6 @@ void d3d_set_stream_source(void *_dev, unsigned stream_no,
void *stream_vertbuf_ptr, unsigned offset_bytes,
unsigned stride)
{
LPDIRECT3DVERTEXBUFFER stream_vertbuf = (LPDIRECT3DVERTEXBUFFER)stream_vertbuf_ptr;
if (!stream_vertbuf)
return;
switch (d3d_common_api)
{
@ -1139,6 +1170,9 @@ void d3d_set_stream_source(void *_dev, unsigned stream_no,
{
#ifdef HAVE_D3D9
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DVERTEXBUFFER9 stream_vertbuf = (LPDIRECT3DVERTEXBUFFER9)stream_vertbuf_ptr;
if (!stream_vertbuf)
return;
#ifdef __cplusplus
dev->SetStreamSource(stream_no, stream_vertbuf, offset_bytes, stride);
#else
@ -1153,6 +1187,9 @@ void d3d_set_stream_source(void *_dev, unsigned stream_no,
{
#ifdef HAVE_D3D8
LPDIRECT3DDEVICE8 dev = (LPDIRECT3DDEVICE8)_dev;
LPDIRECT3DVERTEXBUFFER8 stream_vertbuf = (LPDIRECT3DVERTEXBUFFER8)stream_vertbuf_ptr;
if (!stream_vertbuf)
return;
#ifdef __cplusplus
dev->SetStreamSource(stream_no, stream_vertbuf, offset_bytes, stride);
#else
@ -1186,14 +1223,14 @@ bool d3d_device_create_offscreen_plain_surface(
#ifdef __cplusplus
if (SUCCEEDED(dev->CreateOffscreenPlainSurface(width, height,
(D3DFORMAT)format, (D3DPOOL)pool,
(LPDIRECT3DSURFACE*)surf_data,
(LPDIRECT3DSURFACE9*)surf_data,
(HANDLE*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice9_CreateOffscreenPlainSurface(dev,
width, height,
(D3DFORMAT)format, (D3DPOOL)pool,
(LPDIRECT3DSURFACE*)surf_data,
(LPDIRECT3DSURFACE9*)surf_data,
(HANDLE*)data)))
return true;
#endif
@ -1585,8 +1622,6 @@ void d3d_clear(void *_dev,
bool d3d_device_get_render_target_data(void *_dev,
void *_src, void *_dst)
{
LPDIRECT3DSURFACE src = (LPDIRECT3DSURFACE)_src;
LPDIRECT3DSURFACE dst = (LPDIRECT3DSURFACE)_dst;
switch (d3d_common_api)
{
@ -1594,7 +1629,9 @@ bool d3d_device_get_render_target_data(void *_dev,
{
#ifndef _XBOX
#ifdef HAVE_D3D9
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DSURFACE9 src = (LPDIRECT3DSURFACE9)_src;
LPDIRECT3DSURFACE9 dst = (LPDIRECT3DSURFACE9)_dst;
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
if (!dev)
return false;
#ifdef __cplusplus
@ -1631,11 +1668,11 @@ bool d3d_device_get_render_target(void *_dev,
return false;
#ifdef __cplusplus
if (SUCCEEDED(dev->GetRenderTarget(idx,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE9*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice9_GetRenderTarget(dev,
idx, (LPDIRECT3DSURFACE*)data)))
idx, (LPDIRECT3DSURFACE9*)data)))
return true;
#endif
#endif
@ -1649,11 +1686,11 @@ bool d3d_device_get_render_target(void *_dev,
return false;
#ifdef __cplusplus
if (SUCCEEDED(dev->GetRenderTarget(
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE8*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice8_GetRenderTarget(dev,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE8*)data)))
return true;
#endif
#endif
@ -1918,7 +1955,7 @@ bool d3d_create_vertex_shader(void *_dev, const DWORD *a, void **b)
return true;
#else
if (IDirect3DDevice9_CreateVertexShader(dev, a,
(LPDIRECT3DVERTEXSHADER*)b) == D3D_OK)
(LPDIRECT3DVERTEXSHADER9*)b) == D3D_OK)
return true;
#endif
#endif
@ -1949,7 +1986,7 @@ bool d3d_create_pixel_shader(void *_dev, const DWORD *a, void **b)
return true;
#else
if (IDirect3DDevice9_CreatePixelShader(dev, a,
(LPDIRECT3DPIXELSHADER*)b) == D3D_OK)
(LPDIRECT3DPIXELSHADER9*)b) == D3D_OK)
return true;
#endif
#endif
@ -1971,8 +2008,8 @@ bool d3d_set_pixel_shader(void *_dev, void *data)
case GFX_CTX_DIRECT3D9_API:
#ifdef HAVE_D3D9
{
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DPIXELSHADER d3dps = (LPDIRECT3DPIXELSHADER)data;
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DPIXELSHADER9 d3dps = (LPDIRECT3DPIXELSHADER9)data;
if (!dev || !d3dps)
return false;
#if defined(__cplusplus)
@ -2008,8 +2045,8 @@ bool d3d_set_vertex_shader(void *_dev, unsigned index,
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DVERTEXSHADER shader = (LPDIRECT3DVERTEXSHADER)data;
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DVERTEXSHADER9 shader = (LPDIRECT3DVERTEXSHADER9)data;
#ifdef __cplusplus
if (dev->SetVertexShader(shader) != D3D_OK)
return false;
@ -2027,9 +2064,9 @@ bool d3d_set_vertex_shader(void *_dev, unsigned index,
case GFX_CTX_DIRECT3D8_API:
#ifdef HAVE_D3D8
{
LPDIRECT3DDEVICE8 dev = (LPDIRECT3DDEVICE8)_dev;
LPDIRECT3DDEVICE8 dev = (LPDIRECT3DDEVICE8)_dev;
#ifdef __cplusplus
LPDIRECT3DVERTEXSHADER shader = (LPDIRECT3DVERTEXSHADER)data;
LPDIRECT3DVERTEXSHADER8 shader = (LPDIRECT3DVERTEXSHADER8)data;
if (dev->SetVertexShader(shader) != D3D_OK)
return false;
@ -2202,14 +2239,14 @@ void d3d_enable_blend_func(void *data)
void d3d_device_set_render_target(void *_dev, unsigned idx,
void *data)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
switch (d3d_common_api)
{
case GFX_CTX_DIRECT3D9_API:
{
#ifdef HAVE_D3D9
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
LPDIRECT3DSURFACE9 surf = (LPDIRECT3DSURFACE9)data;
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
if (!dev)
return;
#ifdef __cplusplus
@ -2223,6 +2260,7 @@ void d3d_device_set_render_target(void *_dev, unsigned idx,
case GFX_CTX_DIRECT3D8_API:
{
#ifdef HAVE_D3D8
LPDIRECT3DSURFACE8 surf = (LPDIRECT3DSURFACE8)data;
LPDIRECT3DDEVICE8 dev = (LPDIRECT3DDEVICE8)_dev;
if (!dev)
return;
@ -2296,9 +2334,9 @@ void d3d_set_vertex_declaration(void *data, void *vertex_data)
if (!dev)
return;
#ifdef __cplusplus
dev->SetVertexDeclaration((LPDIRECT3DVERTEXDECLARATION)vertex_data);
dev->SetVertexDeclaration((LPDIRECT3DVERTEXDECLARATION9)vertex_data);
#else
IDirect3DDevice9_SetVertexDeclaration(dev, (LPDIRECT3DVERTEXDECLARATION)vertex_data);
IDirect3DDevice9_SetVertexDeclaration(dev, (LPDIRECT3DVERTEXDECLARATION9)vertex_data);
#endif
#endif
}
@ -2546,13 +2584,13 @@ bool d3d_device_get_backbuffer(void *_dev,
if (SUCCEEDED(dev->GetBackBuffer(
swapchain_idx, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE9*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice9_GetBackBuffer(dev,
swapchain_idx, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE9*)data)))
return true;
#endif
#endif
@ -2567,12 +2605,12 @@ bool d3d_device_get_backbuffer(void *_dev,
#ifdef __cplusplus
if (SUCCEEDED(dev->GetBackBuffer(idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE8*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice8_GetBackBuffer(dev, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
(LPDIRECT3DSURFACE8*)data)))
return true;
#endif
#endif
@ -2874,7 +2912,7 @@ void d3dx_font_draw_text(void *data, void *sprite_data, void *string_data,
ID3DXFont *font = (ID3DXFont*)data;
if (!font)
return;
return font->lpVtbl->DrawText(font, (LPD3DXSPRITE)sprite_data,
font->lpVtbl->DrawText(font, (LPD3DXSPRITE)sprite_data,
(LPCTSTR)string_data, count, (LPRECT)rect_data,
(DWORD)format, (D3DCOLOR)color);
#else

View File

@ -32,7 +32,7 @@ typedef struct d3d_texture
bool d3d_swap(void *data, void *dev);
LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(void *dev,
void *d3d_vertex_buffer_new(void *dev,
unsigned length, unsigned usage, unsigned fvf,
D3DPOOL pool, void *handle);

View File

@ -100,7 +100,9 @@ static bool d3d8_renderchain_create_first_pass(void *data,
d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data;
chain->vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED,
D3DUSAGE_WRITEONLY,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
D3DPOOL_MANAGED,
NULL);
if (!chain->vertex_buf)
@ -271,7 +273,9 @@ static void d3d8_renderchain_render_pass(
D3DTEXF_LINEAR : D3DTEXF_POINT);
d3d_set_viewports(chain->dev, (D3DVIEWPORT8*)&d3d->final_viewport);
d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL);
d3d_set_vertex_shader(d3dr,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
NULL);
d3d_set_stream_source(d3dr, 0, chain->vertex_buf, 0, sizeof(Vertex));
d3d8_renderchain_set_mvp(d3d, chain, NULL, &d3d->mvp_rotate);
d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2);
@ -439,7 +443,9 @@ static void d3d8_overlay_render(d3d_video_t *d3d,
if (!overlay->vert_buf)
{
overlay->vert_buf = d3d_vertex_buffer_new(
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL);
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
D3DPOOL_MANAGED, NULL);
if (!overlay->vert_buf)
return;
@ -476,7 +482,9 @@ static void d3d8_overlay_render(d3d_video_t *d3d,
d3d_vertex_buffer_unlock(overlay->vert_buf);
d3d_enable_blend_func(d3d->dev);
d3d_set_vertex_shader(d3d->dev, D3DFVF_CUSTOMVERTEX, NULL);
d3d_set_vertex_shader(d3d->dev,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
NULL);
d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf,
0, sizeof(*vert));
@ -885,7 +893,9 @@ static bool d3d8_initialize(d3d_video_t *d3d, const video_info_t *info)
d3d->menu_display.size = 1024;
d3d->menu_display.buffer = d3d_vertex_buffer_new(
d3d->dev, d3d->menu_display.size * sizeof(Vertex),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT,
D3DUSAGE_WRITEONLY,
D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE,
D3DPOOL_DEFAULT,
NULL);
if (!d3d->menu_display.buffer)

View File

@ -340,12 +340,12 @@ static void d3d9_overlay_render(d3d_video_t *d3d,
video_frame_info_t *video_info,
overlay_t *overlay)
{
LPDIRECT3DVERTEXDECLARATION vertex_decl;
LPDIRECT3DVERTEXDECLARATION9 vertex_decl;
struct video_viewport vp;
void *verts;
unsigned i;
Vertex vert[4];
D3DVERTEXELEMENT vElems[4] = {
D3DVERTEXELEMENT9 vElems[4] = {
{0, offsetof(Vertex, x), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_POSITION, 0},
{0, offsetof(Vertex, u), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
@ -363,7 +363,9 @@ static void d3d9_overlay_render(d3d_video_t *d3d,
if (!overlay->vert_buf)
{
overlay->vert_buf = d3d_vertex_buffer_new(
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL);
d3d->dev, sizeof(vert), D3DUSAGE_WRITEONLY,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED, NULL);
if (!overlay->vert_buf)
return;
@ -805,7 +807,7 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
FONT_DRIVER_RENDER_DIRECT3D_API);
{
static const D3DVERTEXELEMENT VertexElements[4] = {
static const D3DVERTEXELEMENT9 VertexElements[4] = {
{0, offsetof(Vertex, x), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_POSITION, 0},
{0, offsetof(Vertex, u), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
@ -823,7 +825,9 @@ static bool d3d9_initialize(d3d_video_t *d3d, const video_info_t *info)
d3d->menu_display.size = 1024;
d3d->menu_display.buffer = d3d_vertex_buffer_new(
d3d->dev, d3d->menu_display.size * sizeof(Vertex),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT,
D3DUSAGE_WRITEONLY,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_DEFAULT,
NULL);
if (!d3d->menu_display.buffer)

View File

@ -1483,7 +1483,7 @@ static bool d3d9_cg_renderchain_render(
unsigned width, unsigned height,
unsigned pitch, unsigned rotation)
{
LPDIRECT3DSURFACE back_buffer, target;
LPDIRECT3DSURFACE9 back_buffer, target;
unsigned i, current_width, current_height, out_width = 0, out_height = 0;
struct Pass *last_pass = NULL;
d3d_video_t *d3d = (d3d_video_t*)data;
@ -1624,11 +1624,11 @@ static bool d3d9_cg_renderchain_read_viewport(
{
unsigned width, height;
D3DLOCKED_RECT rect;
LPDIRECT3DSURFACE target = NULL;
LPDIRECT3DSURFACE dest = NULL;
bool ret = true;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE9 d3dr = (LPDIRECT3DDEVICE9)d3d->dev;
LPDIRECT3DSURFACE9 target = NULL;
LPDIRECT3DSURFACE9 dest = NULL;
bool ret = true;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE9 d3dr = (LPDIRECT3DDEVICE9)d3d->dev;
video_driver_get_size(&width, &height);

View File

@ -95,7 +95,9 @@ static bool hlsl_d3d9_renderchain_create_first_pass(void *data,
chain->vertex_buf = d3d_vertex_buffer_new(
d3d->dev, 4 * sizeof(Vertex),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED,
D3DUSAGE_WRITEONLY,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
NULL);
if (!chain->vertex_buf)