Skip to content

Commit

Permalink
Create d3d_device_create_offscreen_plain_surface
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Oct 1, 2017
1 parent 95ca5a3 commit 0559be4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
17 changes: 17 additions & 0 deletions gfx/common/d3d_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no,
#endif
}

bool d3d_device_create_offscreen_plain_surface(
LPDIRECT3DDEVICE dev,
unsigned width,
unsigned height,
unsigned format,
unsigned pool,
void **surf_data,
void *data)
{
if (FAILED(dev->CreateOffscreenPlainSurface(width, height,
(D3DFORMAT)format, (D3DPOOL)pool,
(LPDIRECT3DSURFACE*)surf_data,
(HANDLE*)data)))
return false;
return true;
}

static void d3d_set_texture_stage_state(LPDIRECT3DDEVICE dev,
unsigned sampler, unsigned value, unsigned type)
{
Expand Down
9 changes: 9 additions & 0 deletions gfx/common/d3d_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value);
void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data);

bool d3d_device_create_offscreen_plain_surface(
LPDIRECT3DDEVICE dev,
unsigned width,
unsigned height,
unsigned format,
unsigned pool,
void **surf_data,
void *data);

bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp);

void d3d_device_free(LPDIRECT3DDEVICE dev, LPDIRECT3D pd3d);
Expand Down
23 changes: 7 additions & 16 deletions gfx/drivers_renderchain/d3d9_cg_renderchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,25 +1547,16 @@ static bool d3d9_cg_renderchain_read_viewport(

video_driver_get_size(&width, &height);

(void)d3d;
(void)data;
(void)buffer;

if (!d3d_device_get_render_target(d3dr, 0, (void**)&target))
{
ret = false;
goto end;
}

if (FAILED(d3d->d3d_err = d3dr->CreateOffscreenPlainSurface(
width, height,
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM,
&dest, NULL)))
{
ret = false;
goto end;
}

if (!d3d_device_get_render_target_data(d3dr, (void*)target, (void*)dest))
if (
!d3d_device_get_render_target(d3dr, 0, (void**)&target) ||
!d3d_device_create_offscreen_plain_surface(d3dr, width, height,
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, (void**)&dest, NULL) ||
!d3d_device_get_render_target_data(d3dr, (void*)target, (void*)dest)
)
{
ret = false;
goto end;
Expand Down

0 comments on commit 0559be4

Please sign in to comment.