(D3D) Rewrite create_vertex_buffer wrapper function

This commit is contained in:
twinaphex 2014-09-13 17:56:33 +02:00
parent 0de251079a
commit c4b35fb00d
4 changed files with 28 additions and 20 deletions

View File

@ -1239,10 +1239,12 @@ static void d3d_overlay_render(void *data, overlay_t *overlay)
if (!overlay->vert_buf)
{
D3DDevice_CreateVertexBuffers(d3d->dev, sizeof(vert),
d3d->dev->GetSoftwareVertexProcessing() ?
D3DUSAGE_SOFTWAREPROCESSING : 0, 0, D3DPOOL_MANAGED,
&overlay->vert_buf, NULL);
overlay->vert_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new(
d3d->dev, sizeof(vert), d3d->dev->GetSoftwareVertexProcessing() ?
D3DUSAGE_SOFTWAREPROCESSING : 0, 0, D3DPOOL_MANAGED, NULL);
if (!overlay->vert_buf)
return;
}
for (i = 0; i < 4; i++)

View File

@ -40,19 +40,27 @@ void d3d_swap(void *data, LPDIRECT3DDEVICE dev)
#endif
}
HRESULT d3d_create_vertex_buffer(LPDIRECT3DDEVICE dev,
LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev,
unsigned length, unsigned usage, unsigned fvf,
D3DPOOL pool, LPDIRECT3DVERTEXBUFFER vert_buf, void *handle)
D3DPOOL pool, void *handle)
{
HRESULT hr;
LPDIRECT3DVERTEXBUFFER buf;
#if defined(_XBOX1)
return IDirect3DDevice8_CreateVertexBuffer(dev, length, usage, fvf, pool,
&vert_buf);
hr = IDirect3DDevice8_CreateVertexBuffer(dev, length, usage, fvf, pool,
&buf);
#elif defined(_XBOX360)
return IDirect3DDevice9_CreateVertexBuffer(dev, length, usage, fvf, pool,
&vert_buf, NULL);
hr = IDirect3DDevice9_CreateVertexBuffer(dev, length, usage, fvf, pool,
&buf, NULL);
#else
return dev->CreateVertexBuffer(length, usage, fvf, pool, &vert_buf, NULL);
hr = dev->CreateVertexBuffer(length, usage, fvf, pool, &buf, NULL);
#endif
if (FAILED(hr))
return NULL;
return buf;
}
void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no,

View File

@ -22,9 +22,9 @@
void d3d_swap(void *data, LPDIRECT3DDEVICE dev);
HRESULT d3d_create_vertex_buffer(LPDIRECT3DDEVICE dev,
LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev,
unsigned length, unsigned usage, unsigned fvf,
D3DPOOL pool, LPDIRECT3DVERTEXBUFFER vert_buf, void *handle);
D3DPOOL pool, void *handle);
void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no,
LPDIRECT3DVERTEXBUFFER stream_vertbuf, unsigned offset_bytes,

View File

@ -156,13 +156,11 @@ bool renderchain_add_pass(void *data, const LinkInfo *info)
if (!renderchain_init_shader_fvf(chain, &pass))
return false;
if (FAILED(D3DDevice_CreateVertexBuffers(d3dr, 4 * sizeof(Vertex),
d3dr->GetSoftwareVertexProcessing()
? D3DUSAGE_SOFTWAREPROCESSING : 0,
0,
D3DPOOL_DEFAULT,
&pass.vertex_buf,
NULL)))
pass.vertex_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex),
d3dr->GetSoftwareVertexProcessing() ? D3DUSAGE_SOFTWAREPROCESSING : 0,
0, D3DPOOL_DEFAULT, NULL);
if (!pass.vertex_buf)
return false;
if (FAILED(d3dr->CreateTexture(info->tex_w, info->tex_h, 1,