From 249a0b898d1ef6f03794133c40e2eda02737d365 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 5 Apr 2015 01:24:09 +0200 Subject: [PATCH] (D3D) Use pointer arguments instead of references --- gfx/d3d/render_chain.cpp | 16 ++++++++-------- gfx/d3d/render_chain.h | 8 ++++---- gfx/d3d/render_chain_cg.h | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gfx/d3d/render_chain.cpp b/gfx/d3d/render_chain.cpp index 2e21840cb2..2757555574 100644 --- a/gfx/d3d/render_chain.cpp +++ b/gfx/d3d/render_chain.cpp @@ -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, diff --git a/gfx/d3d/render_chain.h b/gfx/d3d/render_chain.h index b7859f4668..98c435e7a3 100644 --- a/gfx/d3d/render_chain.h +++ b/gfx/d3d/render_chain.h @@ -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, diff --git a/gfx/d3d/render_chain_cg.h b/gfx/d3d/render_chain_cg.h index 79b78c6584..b18634c99e 100644 --- a/gfx/d3d/render_chain_cg.h +++ b/gfx/d3d/render_chain_cg.h @@ -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); }