(D3D) Use pointer arguments instead of references

This commit is contained in:
twinaphex 2015-04-05 01:24:09 +02:00
parent 583855a85c
commit 249a0b898d
3 changed files with 25 additions and 25 deletions

View File

@ -85,7 +85,7 @@ bool renderchain_init(void *data, const video_info_t *video_info,
if (!renderchain_create_first_pass(chain, info, fmt))
return false;
renderchain_log_info(chain, info);
if (!renderchain_compile_shaders(chain, chain->fStock, chain->vStock, ""))
if (!renderchain_compile_shaders(chain, &chain->fStock, &chain->vStock, ""))
return false;
return true;
@ -181,8 +181,8 @@ bool renderchain_add_pass(void *data, const void *info_data)
pass.last_width = 0;
pass.last_height = 0;
renderchain_compile_shaders(chain, pass.fPrg,
pass.vPrg, info->pass->source.path);
renderchain_compile_shaders(chain, &pass.fPrg,
&pass.vPrg, info->pass->source.path);
if (!renderchain_init_shader_fvf(chain, &pass))
return false;
@ -369,7 +369,7 @@ bool renderchain_render(void *chain_data, const void *data,
back_buffer->Release();
renderchain_end_render(chain);
renderchain_set_shaders(chain, chain->fStock, chain->vStock);
renderchain_set_shaders(chain, &chain->fStock, &chain->vStock);
renderchain_set_mvp(chain, chain->vStock, chain->final_viewport->Width,
chain->final_viewport->Height, 0);
@ -435,8 +435,8 @@ bool renderchain_create_first_pass(void *data, const void *info_data,
d3d_set_texture(d3dr, 0, NULL);
}
renderchain_compile_shaders(chain, pass.fPrg,
pass.vPrg, info->pass->source.path);
renderchain_compile_shaders(chain, &pass.fPrg,
&pass.vPrg, info->pass->source.path);
if (!renderchain_init_shader_fvf(chain, &pass))
return false;
@ -553,7 +553,7 @@ void renderchain_set_mvp(void *data, void *vertex_program,
D3DXMatrixMultiply(&proj, &ortho, &rot);
D3DXMatrixTranspose(&tmp, &proj);
renderchain_set_shader_mvp(chain, vPrg, tmp);
renderchain_set_shader_mvp(chain, &vPrg, tmp);
}
void renderchain_convert_geometry(
@ -625,7 +625,7 @@ void renderchain_render_pass(void *data, void *pass_data, unsigned pass_index)
renderchain_t *chain = (renderchain_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev;
renderchain_set_shaders(chain, pass->fPrg, pass->vPrg);
renderchain_set_shaders(chain, &pass->fPrg, &pass->vPrg);
d3d_set_texture(d3dr, 0, pass->tex);
d3d_set_sampler_minfilter(d3dr, 0,

View File

@ -169,16 +169,16 @@ void renderchain_log_info(void *data, const void *info_data);
void renderchain_unbind_all(void *data);
bool renderchain_compile_shaders(void *data, CGprogram &fPrg,
CGprogram &vPrg, const std::string &shader);
bool renderchain_compile_shaders(void *data, CGprogram *fPrg,
CGprogram *vPrg, const std::string &shader);
void renderchain_set_shaders(void *data, CGprogram &fPrg, CGprogram &vPrg);
void renderchain_set_shaders(void *data, CGprogram *fPrg, CGprogram *vPrg);
void renderchain_destroy_stock_shader(void *data);
void renderchain_destroy_shader(void *data, int i);
void renderchain_set_shader_mvp(void *data, CGprogram &vPrg, D3DXMATRIX &tmp);
void renderchain_set_shader_mvp(void *data, CGprogram *vPrg, D3DXMATRIX &tmp);
void renderchain_set_shader_params(void *data, void *pass_data,
unsigned video_w, unsigned video_h,

View File

@ -88,8 +88,8 @@ static INLINE CGparameter find_param_from_semantic(CGprogram prog,
prog, CG_PROGRAM), sem);
}
bool renderchain_compile_shaders(void *data, CGprogram &fPrg,
CGprogram &vPrg, const std::string &shader)
bool renderchain_compile_shaders(void *data, CGprogram *fPrg,
CGprogram *vPrg, const std::string &shader)
{
renderchain_t *chain = (renderchain_t*)data;
CGprofile vertex_profile = cgD3D9GetLatestVertexProfile();
@ -103,13 +103,13 @@ bool renderchain_compile_shaders(void *data, CGprogram &fPrg,
if (shader.length() > 0)
{
RARCH_LOG("[D3D Cg]: Compiling shader: %s.\n", shader.c_str());
fPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
*fPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
shader.c_str(), fragment_profile, "main_fragment", fragment_opts);
if (cgGetLastListing(chain->cgCtx))
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(chain->cgCtx));
vPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
*vPrg = cgCreateProgramFromFile(chain->cgCtx, CG_SOURCE,
shader.c_str(), vertex_profile, "main_vertex", vertex_opts);
if (cgGetLastListing(chain->cgCtx))
@ -119,13 +119,13 @@ bool renderchain_compile_shaders(void *data, CGprogram &fPrg,
{
RARCH_LOG("[D3D Cg]: Compiling stock shader.\n");
fPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
*fPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
fragment_profile, "main_fragment", fragment_opts);
if (cgGetLastListing(chain->cgCtx))
RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(chain->cgCtx));
vPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
*vPrg = cgCreateProgram(chain->cgCtx, CG_SOURCE, stock_program,
vertex_profile, "main_vertex", vertex_opts);
if (cgGetLastListing(chain->cgCtx))
@ -135,15 +135,15 @@ bool renderchain_compile_shaders(void *data, CGprogram &fPrg,
if (!fPrg || !vPrg)
return false;
cgD3D9LoadProgram(fPrg, true, 0);
cgD3D9LoadProgram(vPrg, true, 0);
cgD3D9LoadProgram(*fPrg, true, 0);
cgD3D9LoadProgram(*vPrg, true, 0);
return true;
}
void renderchain_set_shaders(void *data, CGprogram &fPrg, CGprogram &vPrg)
void renderchain_set_shaders(void *data, CGprogram *fPrg, CGprogram *vPrg)
{
cgD3D9BindProgram(fPrg);
cgD3D9BindProgram(vPrg);
cgD3D9BindProgram(*fPrg);
cgD3D9BindProgram(*vPrg);
}
void renderchain_destroy_stock_shader(void *data)
@ -176,9 +176,9 @@ void renderchain_destroy_shader(void *data, int i)
#endif
}
void renderchain_set_shader_mvp(void *data, CGprogram &vPrg, D3DXMATRIX &tmp)
void renderchain_set_shader_mvp(void *data, CGprogram *vPrg, D3DXMATRIX &tmp)
{
CGparameter cgpModelViewProj = cgGetNamedParameter(vPrg, "modelViewProj");
CGparameter cgpModelViewProj = cgGetNamedParameter(*vPrg, "modelViewProj");
if (cgpModelViewProj)
cgD3D9SetUniformMatrix(cgpModelViewProj, &tmp);
}