(D3D) Make renderchain_set_vertices static

This commit is contained in:
twinaphex 2015-04-05 18:52:44 +02:00
parent 6365ac2174
commit 2066396913
2 changed files with 119 additions and 126 deletions

View File

@ -785,6 +785,51 @@ void renderchain_deinit(void *data)
delete (renderchain_t *)renderchain;
}
static void renderchain_log_info(void *data, const void *info_data)
{
const LinkInfo *info = (const LinkInfo*)info_data;
RARCH_LOG("[D3D]: Render pass info:\n");
RARCH_LOG("\tTexture width: %u\n", info->tex_w);
RARCH_LOG("\tTexture height: %u\n", info->tex_h);
RARCH_LOG("\tScale type (X): ");
switch (info->pass->fbo.type_x)
{
case RARCH_SCALE_INPUT:
RARCH_LOG("Relative @ %fx\n", info->pass->fbo.scale_x);
break;
case RARCH_SCALE_VIEWPORT:
RARCH_LOG("Viewport @ %fx\n", info->pass->fbo.scale_x);
break;
case RARCH_SCALE_ABSOLUTE:
RARCH_LOG("Absolute @ %u px\n", info->pass->fbo.abs_x);
break;
}
RARCH_LOG("\tScale type (Y): ");
switch (info->pass->fbo.type_y)
{
case RARCH_SCALE_INPUT:
RARCH_LOG("Relative @ %fx\n", info->pass->fbo.scale_y);
break;
case RARCH_SCALE_VIEWPORT:
RARCH_LOG("Viewport @ %fx\n", info->pass->fbo.scale_y);
break;
case RARCH_SCALE_ABSOLUTE:
RARCH_LOG("Absolute @ %u px\n", info->pass->fbo.abs_y);
break;
}
RARCH_LOG("\tBilinear filter: %s\n",
info->pass->filter == RARCH_FILTER_LINEAR ? "true" : "false");
}
bool renderchain_init(void *data, const video_info_t *video_info,
void *dev_,
const void *final_viewport_,
@ -1052,6 +1097,80 @@ void renderchain_end_render(void *data)
chain->prev.ptr = (chain->prev.ptr + 1) & TEXTURESMASK;
}
static void renderchain_set_vertices(
void *data, void *pass_data,
unsigned width, unsigned height,
unsigned out_width, unsigned out_height,
unsigned vp_width, unsigned vp_height,
unsigned rotation)
{
Pass *pass = (Pass*)pass_data;
renderchain_t *chain = (renderchain_t*)data;
const LinkInfo *info = (const LinkInfo*)&pass->info;
if (pass->last_width != width || pass->last_height != height)
{
Vertex vert[4];
unsigned i;
void *verts = NULL;
float _u = float(width) / info->tex_w;
float _v = float(height) / info->tex_h;
pass->last_width = width;
pass->last_height = height;
for (i = 0; i < 4; i++)
{
vert[i].z = 0.5f;
vert[i].r = vert[i].g = vert[i].b = vert[i].a = 1.0f;
}
vert[0].x = 0.0f;
vert[1].x = out_width;
vert[2].x = 0.0f;
vert[3].x = out_width;
vert[0].y = out_height;
vert[1].y = out_height;
vert[2].y = 0.0f;
vert[3].y = 0.0f;
vert[0].u = 0.0f;
vert[1].u = _u;
vert[2].u = 0.0f;
vert[3].u = _u;
vert[0].v = 0.0f;
vert[1].v = 0.0f;
vert[2].v = _v;
vert[3].v = _v;
vert[0].lut_u = 0.0f;
vert[1].lut_u = 1.0f;
vert[2].lut_u = 0.0f;
vert[3].lut_u = 1.0f;
vert[0].lut_v = 0.0f;
vert[1].lut_v = 0.0f;
vert[2].lut_v = 1.0f;
vert[3].lut_v = 1.0f;
/* Align texels and vertices. */
for (i = 0; i < 4; i++)
{
vert[i].x -= 0.5f;
vert[i].y += 0.5f;
}
verts = d3d_vertex_buffer_lock(pass->vertex_buf);
memcpy(verts, vert, sizeof(vert));
d3d_vertex_buffer_unlock(pass->vertex_buf);
}
renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation);
renderchain_set_shader_params(chain, pass,
width, height,
info->tex_w, info->tex_h,
vp_width, vp_height);
}
bool renderchain_render(void *chain_data, const void *data,
unsigned width, unsigned height, unsigned pitch, unsigned rotation)
{
@ -1214,79 +1333,6 @@ bool renderchain_create_first_pass(void *data, const void *info_data,
return true;
}
void renderchain_set_vertices(
void *data, void *pass_data,
unsigned width, unsigned height,
unsigned out_width, unsigned out_height,
unsigned vp_width, unsigned vp_height,
unsigned rotation)
{
Pass *pass = (Pass*)pass_data;
renderchain_t *chain = (renderchain_t*)data;
const LinkInfo *info = (const LinkInfo*)&pass->info;
if (pass->last_width != width || pass->last_height != height)
{
Vertex vert[4];
unsigned i;
void *verts = NULL;
float _u = float(width) / info->tex_w;
float _v = float(height) / info->tex_h;
pass->last_width = width;
pass->last_height = height;
for (i = 0; i < 4; i++)
{
vert[i].z = 0.5f;
vert[i].r = vert[i].g = vert[i].b = vert[i].a = 1.0f;
}
vert[0].x = 0.0f;
vert[1].x = out_width;
vert[2].x = 0.0f;
vert[3].x = out_width;
vert[0].y = out_height;
vert[1].y = out_height;
vert[2].y = 0.0f;
vert[3].y = 0.0f;
vert[0].u = 0.0f;
vert[1].u = _u;
vert[2].u = 0.0f;
vert[3].u = _u;
vert[0].v = 0.0f;
vert[1].v = 0.0f;
vert[2].v = _v;
vert[3].v = _v;
vert[0].lut_u = 0.0f;
vert[1].lut_u = 1.0f;
vert[2].lut_u = 0.0f;
vert[3].lut_u = 1.0f;
vert[0].lut_v = 0.0f;
vert[1].lut_v = 0.0f;
vert[2].lut_v = 1.0f;
vert[3].lut_v = 1.0f;
/* Align texels and vertices. */
for (i = 0; i < 4; i++)
{
vert[i].x -= 0.5f;
vert[i].y += 0.5f;
}
verts = d3d_vertex_buffer_lock(pass->vertex_buf);
memcpy(verts, vert, sizeof(vert));
d3d_vertex_buffer_unlock(pass->vertex_buf);
}
renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation);
renderchain_set_shader_params(chain, pass,
width, height,
info->tex_w, info->tex_h,
vp_width, vp_height);
}
void renderchain_set_viewport(void *data, void *viewport_data)
{
@ -1452,48 +1498,4 @@ void renderchain_render_pass(void *data, void *pass_data, unsigned pass_index)
renderchain_unbind_all(chain);
}
void renderchain_log_info(void *data, const void *info_data)
{
const LinkInfo *info = (const LinkInfo*)info_data;
RARCH_LOG("[D3D]: Render pass info:\n");
RARCH_LOG("\tTexture width: %u\n", info->tex_w);
RARCH_LOG("\tTexture height: %u\n", info->tex_h);
RARCH_LOG("\tScale type (X): ");
switch (info->pass->fbo.type_x)
{
case RARCH_SCALE_INPUT:
RARCH_LOG("Relative @ %fx\n", info->pass->fbo.scale_x);
break;
case RARCH_SCALE_VIEWPORT:
RARCH_LOG("Viewport @ %fx\n", info->pass->fbo.scale_x);
break;
case RARCH_SCALE_ABSOLUTE:
RARCH_LOG("Absolute @ %u px\n", info->pass->fbo.abs_x);
break;
}
RARCH_LOG("\tScale type (Y): ");
switch (info->pass->fbo.type_y)
{
case RARCH_SCALE_INPUT:
RARCH_LOG("Relative @ %fx\n", info->pass->fbo.scale_y);
break;
case RARCH_SCALE_VIEWPORT:
RARCH_LOG("Viewport @ %fx\n", info->pass->fbo.scale_y);
break;
case RARCH_SCALE_ABSOLUTE:
RARCH_LOG("Absolute @ %u px\n", info->pass->fbo.abs_y);
break;
}
RARCH_LOG("\tBilinear filter: %s\n",
info->pass->filter == RARCH_FILTER_LINEAR ? "true" : "false");
}

View File

@ -78,13 +78,6 @@ bool renderchain_render(void *chain_data, const void *data,
bool renderchain_create_first_pass(void *data,
const void *info_data, unsigned fmt);
void renderchain_set_vertices(
void *data, void *pass_data,
unsigned width, unsigned height,
unsigned out_width, unsigned out_height,
unsigned vp_width, unsigned vp_height,
unsigned rotation);
void renderchain_set_viewport(void *data, void *viewport_data);
void renderchain_set_mvp(void *data, void *vertex_program,
@ -102,8 +95,6 @@ void renderchain_blit_to_texture(void *data, const void *frame,
void renderchain_render_pass(void *data, void *pass_data, unsigned pass_index);
void renderchain_log_info(void *data, const void *info_data);
bool renderchain_compile_shaders(void *data, void *fragment_data,
void *vertex_data, const std::string &shader);