(D3D/MSVC) Build fix and include d3d_wrapper.c for MSVC build

This commit is contained in:
twinaphex 2014-09-12 08:02:50 +02:00
parent 127441e0c6
commit 05c7d4e573
5 changed files with 521 additions and 498 deletions

View File

@ -14,10 +14,17 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "d3d.hpp"
#include "d3d_wrapper.h" #include "d3d_wrapper.h"
#include "render_chain.hpp"
void d3d_swap(d3d_video_t *d3d, LPDIRECT3DDEVICE dev) void d3d_swap(void *data, LPDIRECT3DDEVICE dev)
{ {
d3d_video_t *d3d = (d3d_video_t*)data;
if (!d3d)
return;
#if defined(_XBOX1) #if defined(_XBOX1)
D3DDevice_Swap(0); D3DDevice_Swap(0);
#elif defined(_XBOX360) #elif defined(_XBOX360)
@ -56,7 +63,7 @@ void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no,
D3DDevice_SetStreamSource_Inline(dev, stream_no, stream_vertbuf, D3DDevice_SetStreamSource_Inline(dev, stream_no, stream_vertbuf,
offset_bytes, stride); offset_bytes, stride);
#else #else
dev->SetStreamSource(steam_no, stream_vertbuf, offset_bytes, stride); dev->SetStreamSource(stream_no, stream_vertbuf, offset_bytes, stride);
#endif #endif
} }
@ -137,7 +144,7 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex,
D3DTexture_LockRect(tex, level, &lock_rect, &rect, flags); D3DTexture_LockRect(tex, level, &lock_rect, &rect, flags);
memset(lock_rect.pBits, 0, tex_height * lock_rect.Pitch); memset(lock_rect.pBits, 0, tex_height * lock_rect.Pitch);
#else #else
if (SUCCEEDED(tex->LockRect(level, &lock_rect, rect, flags))) if (SUCCEEDED(tex->LockRect(level, &lock_rect, &rect, flags)))
{ {
memset(lock_rect.pBits, level, tex_height * lock_rect.Pitch); memset(lock_rect.pBits, level, tex_height * lock_rect.Pitch);
tex->UnlockRect(0); tex->UnlockRect(0);
@ -145,12 +152,18 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex,
#endif #endif
} }
void d3d_textureblit(d3d_video_t *d3d, void d3d_textureblit(void *data, void *renderchain_data,
LPDIRECT3DTEXTURE tex, D3DSURFACE_DESC desc, LPDIRECT3DTEXTURE tex, D3DSURFACE_DESC desc,
D3DLOCKED_RECT lr, const void *frame, D3DLOCKED_RECT lr, const void *frame,
unsigned width, unsigned height, unsigned pitch) unsigned width, unsigned height, unsigned pitch)
{ {
d3d_video_t *d3d = (d3d_video_t*)d3d;
(void)desc; (void)desc;
(void)d3d;
if (!d3d)
return;
#if defined(_XBOX360) #if defined(_XBOX360)
tex->GetLevelDesc(0, &desc); tex->GetLevelDesc(0, &desc);
XGCopySurface(lr.pBits, lr.Pitch, width, height, desc.Format, NULL, XGCopySurface(lr.pBits, lr.Pitch, width, height, desc.Format, NULL,
@ -163,13 +176,18 @@ void d3d_textureblit(d3d_video_t *d3d,
memcpy(out, in, width * d3d->pixel_size); memcpy(out, in, width * d3d->pixel_size);
} }
#else #else
renderchain_t *chain = (renderchain_t*)renderchain_data;
if (!chain)
return;
if (SUCCEEDED(tex->LockRect(0, &lr, NULL, D3DLOCK_NOSYSLOCK))) if (SUCCEEDED(tex->LockRect(0, &lr, NULL, D3DLOCK_NOSYSLOCK)))
{ {
for (unsigned y = 0; y < height; y++) for (unsigned y = 0; y < height; y++)
{ {
const uint8_t *in = (const uint8_t*)frame + y * pitch; const uint8_t *in = (const uint8_t*)frame + y * pitch;
uint8_t *out = (uint8_t*)lr.pBits + y * lr.Pitch; uint8_t *out = (uint8_t*)lr.pBits + y * lr.Pitch;
memcpy(out, in, width * d3d->pixel_size); memcpy(out, in, width * chain->pixel_size);
} }
tex->UnlockRect(0); tex->UnlockRect(0);
} }

View File

@ -20,7 +20,7 @@
#include "../context/win32_common.h" #include "../context/win32_common.h"
#include "d3d_defines.h" #include "d3d_defines.h"
void d3d_swap(d3d_video_t *d3d, LPDIRECT3DDEVICE dev); void d3d_swap(void *data, LPDIRECT3DDEVICE dev);
HRESULT d3d_create_vertex_buffer(LPDIRECT3DDEVICE dev, HRESULT d3d_create_vertex_buffer(LPDIRECT3DDEVICE dev,
unsigned length, unsigned usage, unsigned fvf, unsigned length, unsigned usage, unsigned fvf,
@ -50,7 +50,7 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex,
unsigned level, D3DLOCKED_RECT lock_rect, RECT rect, unsigned level, D3DLOCKED_RECT lock_rect, RECT rect,
unsigned flags); unsigned flags);
void d3d_textureblit(d3d_video_t *d3d, void d3d_textureblit(void *data,
LPDIRECT3DTEXTURE tex, D3DSURFACE_DESC desc, LPDIRECT3DTEXTURE tex, D3DSURFACE_DESC desc,
D3DLOCKED_RECT lr, const void *frame, D3DLOCKED_RECT lr, const void *frame,
unsigned width, unsigned height, unsigned pitch); unsigned width, unsigned height, unsigned pitch);

View File

@ -161,7 +161,7 @@ bool renderchain_add_pass(void *data, const LinkInfo *info)
? D3DUSAGE_SOFTWAREPROCESSING : 0, ? D3DUSAGE_SOFTWAREPROCESSING : 0,
0, 0,
D3DPOOL_DEFAULT, D3DPOOL_DEFAULT,
&pass.vertex_buf, pass.vertex_buf,
NULL))) NULL)))
return false; return false;

View File

@ -219,6 +219,7 @@
<ClCompile Include="..\..\deps\rzlib\unzip.c" /> <ClCompile Include="..\..\deps\rzlib\unzip.c" />
<ClCompile Include="..\..\deps\rzlib\zutil.c" /> <ClCompile Include="..\..\deps\rzlib\zutil.c" />
<ClCompile Include="..\..\file_extract.c" /> <ClCompile Include="..\..\file_extract.c" />
<ClCompile Include="..\..\gfx\d3d9\d3d_wrapper.c" />
<ClCompile Include="..\..\playlist.c" /> <ClCompile Include="..\..\playlist.c" />
<ClCompile Include="..\..\file_list.c" /> <ClCompile Include="..\..\file_list.c" />
<ClCompile Include="..\..\frontend\menu\backend\menu_common_backend.c" /> <ClCompile Include="..\..\frontend\menu\backend\menu_common_backend.c" />

View File

@ -258,6 +258,10 @@
<ClCompile Include="..\..\gfx\context\win32_common.c"> <ClCompile Include="..\..\gfx\context\win32_common.c">
<Filter>gfx\context</Filter> <Filter>gfx\context</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\frontend\menu\menu_action.c" />
<ClCompile Include="..\..\gfx\d3d9\d3d_wrapper.c">
<Filter>gfx\d3d9</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />