Create d3d_translate_filter and get rid of duplicate functions

This commit is contained in:
twinaphex 2018-04-22 15:45:11 +02:00
parent 88387ccbde
commit 04fa4871f0
7 changed files with 34 additions and 57 deletions

View File

@ -26,7 +26,6 @@
#include <dynamic/dylib.h>
#endif
#include "../../configuration.h"
#include "../../verbosity.h"
#ifdef HAVE_D3DX
@ -326,26 +325,6 @@ bool d3d8_reset(void *dev, void *d3dpp)
return false;
}
INT32 d3d8_translate_filter(unsigned type)
{
switch (type)
{
case RARCH_FILTER_UNSPEC:
{
settings_t *settings = config_get_ptr();
if (!settings->bools.video_smooth)
break;
}
/* fall-through */
case RARCH_FILTER_LINEAR:
return D3DTEXF_LINEAR;
case RARCH_FILTER_NEAREST:
break;
}
return D3DTEXF_POINT;
}
bool d3d8x_create_font_indirect(LPDIRECT3DDEVICE8 dev,
void *desc, void **font_data)
{

View File

@ -446,8 +446,6 @@ void d3d8x_font_get_text_metrics(void *data, void *metrics);
void d3d8x_font_release(void *data);
INT32 d3d8_translate_filter(unsigned type);
static INLINE INT32 d3d8_get_rgb565_format(void)
{
#ifdef _XBOX

View File

@ -489,26 +489,6 @@ void d3d9_device_free(void *_dev, void *_pd3d)
IDirect3D9_Release(pd3d);
}
INT32 d3d9_translate_filter(unsigned type)
{
switch (type)
{
case RARCH_FILTER_UNSPEC:
{
settings_t *settings = config_get_ptr();
if (!settings->bools.video_smooth)
break;
}
/* fall-through */
case RARCH_FILTER_LINEAR:
return D3DTEXF_LINEAR;
case RARCH_FILTER_NEAREST:
break;
}
return D3DTEXF_POINT;
}
bool d3d9x_create_font_indirect(void *_dev,
void *desc, void **font_data)
{

View File

@ -602,8 +602,6 @@ void d3dxbuffer_release(void *data);
void d3d9x_font_release(void *data);
INT32 d3d9_translate_filter(unsigned type);
bool d3d9x_compile_shader(
const char *src,
unsigned src_data_len,

View File

@ -129,3 +129,23 @@ void *d3d_matrix_rotation_z(void *_pout, float angle)
pout->m[1][0] = -sin(angle);
return pout;
}
int32_t d3d_translate_filter(unsigned type)
{
switch (type)
{
case RARCH_FILTER_UNSPEC:
{
settings_t *settings = config_get_ptr();
if (!settings->bools.video_smooth)
break;
}
/* fall-through */
case RARCH_FILTER_LINEAR:
return (int32_t)D3DTEXF_LINEAR;
case RARCH_FILTER_NEAREST:
break;
}
return (int32_t)D3DTEXF_POINT;
}

View File

@ -52,6 +52,8 @@ void *d3d_matrix_multiply(void *_pout,
void *d3d_matrix_rotation_z(void *_pout, float angle);
int32_t d3d_translate_filter(unsigned type);
RETRO_END_DECLS
#endif

View File

@ -465,9 +465,9 @@ static void d3d9_cg_renderchain_bind_orig(cg_renderchain_t *chain,
index = cgGetParameterResourceIndex(param);
d3d9_set_texture(chain->dev, index, chain->passes->data[0].tex);
d3d9_set_sampler_magfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
d3d9_set_sampler_minfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
unsigned_vector_list_append(chain->bound_tex, index);
@ -541,9 +541,9 @@ static void d3d9_cg_renderchain_bind_prev(void *data, const void *pass_data)
unsigned_vector_list_append(chain->bound_tex, index);
d3d9_set_sampler_magfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
d3d9_set_sampler_minfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[0].info.pass->filter));
d3d_translate_filter(chain->passes->data[0].info.pass->filter));
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
}
@ -572,9 +572,9 @@ static void d3d9_cg_renderchain_add_lut_internal(void *data,
d3d9_set_texture(chain->dev, index, chain->luts->data[i].tex);
d3d9_set_sampler_magfilter(chain->dev, index,
d3d9_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
d3d_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
d3d9_set_sampler_minfilter(chain->dev, index,
d3d9_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
d3d_translate_filter(chain->luts->data[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST));
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
unsigned_vector_list_append(chain->bound_tex, index);
@ -625,9 +625,9 @@ static void d3d9_cg_renderchain_bind_pass(
d3d9_set_texture(chain->dev, index, chain->passes->data[i].tex);
d3d9_set_sampler_magfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[i].info.pass->filter));
d3d_translate_filter(chain->passes->data[i].info.pass->filter));
d3d9_set_sampler_minfilter(chain->dev, index,
d3d9_translate_filter(chain->passes->data[i].info.pass->filter));
d3d_translate_filter(chain->passes->data[i].info.pass->filter));
d3d9_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER);
d3d9_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER);
}
@ -889,9 +889,9 @@ static bool d3d9_cg_renderchain_create_first_pass(
d3d9_set_texture(chain->dev, 0, chain->prev.tex[i]);
d3d9_set_sampler_minfilter(chain->dev, 0,
d3d9_translate_filter(info->pass->filter));
d3d_translate_filter(info->pass->filter));
d3d9_set_sampler_magfilter(chain->dev, 0,
d3d9_translate_filter(info->pass->filter));
d3d_translate_filter(info->pass->filter));
d3d9_set_sampler_address_u(chain->dev, 0, D3DTADDRESS_BORDER);
d3d9_set_sampler_address_v(chain->dev, 0, D3DTADDRESS_BORDER);
d3d9_set_texture(chain->dev, 0, NULL);
@ -1428,9 +1428,9 @@ static void cg_d3d9_renderchain_render_pass(
d3d9_set_texture(chain->dev, 0, pass->tex);
d3d9_set_sampler_minfilter(chain->dev, 0,
d3d9_translate_filter(pass->info.pass->filter));
d3d_translate_filter(pass->info.pass->filter));
d3d9_set_sampler_magfilter(chain->dev, 0,
d3d9_translate_filter(pass->info.pass->filter));
d3d_translate_filter(pass->info.pass->filter));
d3d9_set_vertex_declaration(chain->dev, pass->vertex_decl);
for (i = 0; i < 4; i++)