summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/render.cpp37
-rw-r--r--src/osd/modules/osdwindow.h3
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp91
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h3
-rw-r--r--src/osd/modules/render/drawd3d.cpp95
5 files changed, 158 insertions, 71 deletions
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index 0af06e665b2..b2e4e02558a 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -1880,12 +1880,6 @@ void render_target::add_container_primitives(render_primitive_list &list, const
}
else
{
- if (curitem.flags() & PRIMFLAG_VECTORBUF_MASK)
- {
- // determine UV coordinates
- prim->texcoords = oriented_texcoords[0];
- }
-
// adjust the color for brightness/contrast/gamma
prim->color.r = container.apply_brightness_contrast_gamma_fp(prim->color.r);
prim->color.g = container.apply_brightness_contrast_gamma_fp(prim->color.g);
@@ -1894,12 +1888,33 @@ void render_target::add_container_primitives(render_primitive_list &list, const
// no texture
prim->texture.base = nullptr;
- // set the basic flags
- prim->flags = (curitem.flags() & ~PRIMFLAG_BLENDMODE_MASK)
- | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
+ if (PRIMFLAG_GET_VECTORBUF(curitem.flags()))
+ {
+ // determine the final orientation (textures are up-side down, so flip y-axis for vectors to immitate that behavior)
+ int finalorient = orientation_add(ORIENTATION_FLIP_Y, container_xform.orientation);
- // apply clipping
- clipped = render_clip_quad(&prim->bounds, &cliprect, nullptr);
+ // determine UV coordinates
+ prim->texcoords = oriented_texcoords[finalorient];
+
+ // apply clipping
+ clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
+
+ // apply the final orientation from the quad flags and then build up the final flags
+ prim->flags = (curitem.flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK))
+ | PRIMFLAG_TEXORIENT(finalorient);
+ prim->flags |= blendmode != -1
+ ? PRIMFLAG_BLENDMODE(blendmode)
+ : PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem.flags()));
+ }
+ else
+ {
+ // set the basic flags
+ prim->flags = (curitem.flags() & ~PRIMFLAG_BLENDMODE_MASK)
+ | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
+
+ // apply clipping
+ clipped = render_clip_quad(&prim->bounds, &cliprect, nullptr);
+ }
}
break;
}
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h
index 60d2cccc700..1361ff50c9f 100644
--- a/src/osd/modules/osdwindow.h
+++ b/src/osd/modules/osdwindow.h
@@ -134,8 +134,7 @@ public:
bool orientation_swap_xy =
(machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
bool rotation_swap_xy =
- (target()->orientation() & ROT90) == ROT90 ||
- (target()->orientation() & ROT270) == ROT270;
+ (target()->orientation() & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
return orientation_swap_xy ^ rotation_swap_xy;
};
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 4cf8c96a164..d89ead8938e 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -992,14 +992,12 @@ int shaders::create_resources(bool reset, std::vector<ui_menu_item>& sliders)
post_effect->add_uniform("ScanlineBrightOffset", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_BRIGHT_OFFSET);
post_effect->add_uniform("Power", uniform::UT_VEC3, uniform::CU_POST_POWER);
post_effect->add_uniform("Floor", uniform::UT_VEC3, uniform::CU_POST_FLOOR);
- post_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
distortion_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING);
distortion_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE);
distortion_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER);
distortion_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER);
distortion_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION);
- distortion_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
initialized = true;
@@ -1656,7 +1654,11 @@ void shaders::render_quad(poly_info *poly, int vertnum)
{
lines_pending = true;
- curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
+ bool swap_xy = d3d->window().swap_xy();
+ int source_width = swap_xy ? (float)d3d->get_height() : (float)d3d->get_width();
+ int source_height = swap_xy ? (float)d3d->get_width() : (float)d3d->get_height();
+
+ curr_render_target = find_render_target(source_width, source_height, 0, 0);
d3d_render_target *rt = curr_render_target;
if (rt == nullptr)
@@ -1679,7 +1681,11 @@ void shaders::render_quad(poly_info *poly, int vertnum)
{
curr_screen = curr_screen < num_screens ? curr_screen : 0;
- curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
+ bool swap_xy = d3d->window().swap_xy();
+ int source_width = swap_xy ? (float)d3d->get_height() : (float)d3d->get_width();
+ int source_height = swap_xy ? (float)d3d->get_width() : (float)d3d->get_height();
+
+ curr_render_target = find_render_target(source_width, source_height, 0, 0);
d3d_render_target *rt = curr_render_target;
if (rt == nullptr)
@@ -1820,14 +1826,21 @@ d3d_render_target* shaders::get_vector_target(render_primitive *prim)
return nullptr;
}
- int target_width = static_cast<int>(prim->get_quad_width() + 0.5f);
- int target_height = static_cast<int>(prim->get_quad_height() + 0.5f);
+ bool swap_xy = d3d->window().swap_xy();
+ int target_width = swap_xy
+ ? static_cast<int>(prim->get_quad_height() + 0.5f)
+ : static_cast<int>(prim->get_quad_width() + 0.5f);
+ int target_height = swap_xy
+ ? static_cast<int>(prim->get_quad_width() + 0.5f)
+ : static_cast<int>(prim->get_quad_height() + 0.5f);
+ int source_width = swap_xy ? (float)d3d->get_height() : (float)d3d->get_width();
+ int source_height = swap_xy ? (float)d3d->get_width() : (float)d3d->get_height();
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
// find render target and check of the size of the target quad has changed
- d3d_render_target *target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
+ d3d_render_target *target = find_render_target(source_width, source_height, 0, 0);
if (target != nullptr && target->target_width == target_width && target->target_height == target_height)
{
return target;
@@ -1840,14 +1853,21 @@ d3d_render_target* shaders::get_vector_target(render_primitive *prim)
void shaders::create_vector_target(render_primitive *prim)
{
- int target_width = static_cast<int>(prim->get_quad_width() + 0.5f);
- int target_height = static_cast<int>(prim->get_quad_height() + 0.5f);
+ bool swap_xy = d3d->window().swap_xy();
+ int target_width = swap_xy
+ ? static_cast<int>(prim->get_quad_height() + 0.5f)
+ : static_cast<int>(prim->get_quad_width() + 0.5f);
+ int target_height = swap_xy
+ ? static_cast<int>(prim->get_quad_width() + 0.5f)
+ : static_cast<int>(prim->get_quad_height() + 0.5f);
+ int source_width = swap_xy ? (float)d3d->get_height() : (float)d3d->get_width();
+ int source_height = swap_xy ? (float)d3d->get_width() : (float)d3d->get_height();
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
osd_printf_verbose("create_vector_target() - %d, %d\n", target_width, target_height);
- if (!add_render_target(d3d, nullptr, d3d->get_width(), d3d->get_height(), target_width, target_height))
+ if (!add_render_target(d3d, nullptr, source_width, source_height, target_width, target_height))
{
vector_enable = false;
}
@@ -2587,10 +2607,26 @@ void uniform::update()
}
case CU_SOURCE_DIMS:
{
- if (shadersys->curr_texture)
+ bool vector_screen =
+ d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR;
+ if (vector_screen)
{
- vec2f sourcedims = shadersys->curr_texture->get_rawdims();
- m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
+ if (shadersys->curr_render_target)
+ {
+ // vector screen has no source texture, so take the source dimensions of the render target
+ float sourcedims[2] = {
+ static_cast<float>(shadersys->curr_render_target->width),
+ static_cast<float>(shadersys->curr_render_target->height) };
+ m_shader->set_vector("SourceDims", 2, sourcedims);
+ }
+ }
+ else
+ {
+ if (shadersys->curr_texture)
+ {
+ vec2f sourcedims = shadersys->curr_texture->get_rawdims();
+ m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
+ }
}
break;
}
@@ -2623,35 +2659,6 @@ void uniform::update()
m_shader->set_bool("SwapXY", d3d->window().swap_xy());
break;
}
- case CU_ORIENTATION_SWAP:
- {
- bool orientation_swap_xy =
- (d3d->window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
- m_shader->set_bool("OrientationSwapXY", orientation_swap_xy);
- break;
-
- }
- case CU_ROTATION_SWAP:
- {
- bool rotation_swap_xy =
- (d3d->window().target()->orientation() & ROT90) == ROT90 ||
- (d3d->window().target()->orientation() & ROT270) == ROT270;
- m_shader->set_bool("RotationSwapXY", rotation_swap_xy);
- break;
- }
- case CU_ROTATION_TYPE:
- {
- int rotation_type =
- (d3d->window().target()->orientation() & ROT90) == ROT90
- ? 1
- : (d3d->window().target()->orientation() & ROT180) == ROT180
- ? 2
- : (d3d->window().target()->orientation() & ROT270) == ROT270
- ? 3
- : 0;
- m_shader->set_int("RotationType", rotation_type);
- break;
- }
case CU_VECTOR_SCREEN:
{
bool vector_screen =
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index e5e6ad600b7..0eddbd5cd0e 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -49,9 +49,6 @@ public:
CU_QUAD_DIMS,
CU_SWAP_XY,
- CU_ORIENTATION_SWAP,
- CU_ROTATION_SWAP,
- CU_ROTATION_TYPE,
CU_VECTOR_SCREEN,
CU_NTSC_CCFREQ,
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index 020e4ee3de5..6c7a96bbfb8 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -1398,13 +1398,13 @@ void renderer_d3d9::batch_vectors()
{
windows_options &options = downcast<windows_options &>(window().machine().options());
+ float quad_width = 0.0f;
+ float quad_height = 0.0f;
+
int vector_size = (options.antialias() ? 24 : 6);
m_vectorbatch = mesh_alloc(m_line_count * vector_size);
m_batchindex = 0;
- float width = 0.0f;
- float height = 0.0f;
-
static int start_index = 0;
int line_index = 0;
float period = options.screen_vector_time_period();
@@ -1432,8 +1432,8 @@ void renderer_d3d9::batch_vectors()
case render_primitive::QUAD:
if (PRIMFLAG_GET_VECTORBUF(prim.flags))
{
- width = prim.bounds.x1 - prim.bounds.x0;
- height = prim.bounds.y1 - prim.bounds.y0;
+ quad_width = prim.bounds.x1 - prim.bounds.x0;
+ quad_height = prim.bounds.y1 - prim.bounds.y0;
}
break;
@@ -1443,9 +1443,76 @@ void renderer_d3d9::batch_vectors()
}
}
+ // handle orientation and rotation for vectors as they were a texture
+ if (m_shaders->enabled())
+ {
+ bool orientation_swap_xy =
+ (window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
+ bool rotation_swap_xy =
+ (window().target()->orientation() & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
+ bool swap_xy = orientation_swap_xy ^ rotation_swap_xy;
+
+ bool rotation_0 = window().target()->orientation() == ROT0;
+ bool rotation_90 = window().target()->orientation() == ROT90;
+ bool rotation_180 = window().target()->orientation() == ROT180;
+ bool rotation_270 = window().target()->orientation() == ROT270;
+ bool flip_x =
+ ((rotation_0 || rotation_270) && orientation_swap_xy) ||
+ ((rotation_180 || rotation_270) && !orientation_swap_xy);
+ bool flip_y =
+ ((rotation_0 || rotation_90) && orientation_swap_xy) ||
+ ((rotation_180 || rotation_90) && !orientation_swap_xy);
+
+ float screen_width = static_cast<float>(this->get_width());
+ float screen_height = static_cast<float>(this->get_height());
+ float half_screen_width = screen_width * 0.5f;
+ float half_screen_height = screen_height * 0.5f;
+ float screen_swap_x_factor = 1.0f / screen_width * screen_height;
+ float screen_swap_y_factor = 1.0f / screen_height * screen_width;
+ float screen_quad_ratio_x = screen_width / quad_width;
+ float screen_quad_ratio_y = screen_height / quad_height;
+
+ if (swap_xy)
+ {
+ std::swap(screen_quad_ratio_x, screen_quad_ratio_y);
+ }
+
+ for (int batchindex = 0; batchindex < m_batchindex; batchindex++)
+ {
+ if (swap_xy)
+ {
+ m_vectorbatch[batchindex].x *= screen_swap_x_factor;
+ m_vectorbatch[batchindex].y *= screen_swap_y_factor;
+ std::swap(m_vectorbatch[batchindex].x, m_vectorbatch[batchindex].y);
+ }
+
+ if (flip_x)
+ {
+ m_vectorbatch[batchindex].x = screen_width - m_vectorbatch[batchindex].x;
+ }
+
+ if (flip_y)
+ {
+ m_vectorbatch[batchindex].y = screen_height - m_vectorbatch[batchindex].y;
+ }
+
+ // center
+ m_vectorbatch[batchindex].x -= half_screen_width;
+ m_vectorbatch[batchindex].y -= half_screen_height;
+
+ // correct screen/quad ratio (vectors are created in screen coordinates and have to be adjusted for texture corrdinates of the quad)
+ m_vectorbatch[batchindex].x *= screen_quad_ratio_x;
+ m_vectorbatch[batchindex].y *= screen_quad_ratio_y;
+
+ // un-center
+ m_vectorbatch[batchindex].x += half_screen_width;
+ m_vectorbatch[batchindex].y += half_screen_height;
+ }
+ }
+
// now add a polygon entry
m_poly[m_numpolys].init(D3DPT_TRIANGLELIST, m_line_count * (options.antialias() ? 8 : 2), vector_size * m_line_count, cached_flags,
- m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, width, height);
+ m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, quad_width, quad_height);
m_numpolys++;
start_index += (int)((float)line_index * period);
@@ -1470,13 +1537,22 @@ void renderer_d3d9::batch_vector(const render_primitive &prim, float line_time)
render_bounds b0, b1;
render_line_to_quad(&prim.bounds, effwidth, &b0, &b1);
+ float dx = b1.x1 - b0.x1;
+ float dy = b1.y1 - b0.y1;
+ float line_length = sqrtf(dx * dx + dy * dy);
+
+ vec2f& start = (get_vector_texture() ? get_vector_texture()->get_uvstart() : get_default_texture()->get_uvstart());
+ vec2f& stop = (get_vector_texture() ? get_vector_texture()->get_uvstop() : get_default_texture()->get_uvstop());
+
// iterate over AA steps
for (const line_aa_step *step = PRIMFLAG_GET_ANTIALIAS(prim.flags) ? line_aa_4step : line_aa_1step;
step->weight != 0; step++)
{
// get a pointer to the vertex buffer
if (m_vectorbatch == nullptr)
+ {
return;
+ }
m_vectorbatch[m_batchindex + 0].x = b0.x0 + step->xoffs;
m_vectorbatch[m_batchindex + 0].y = b0.y0 + step->yoffs;
@@ -1492,10 +1568,6 @@ void renderer_d3d9::batch_vector(const render_primitive &prim, float line_time)
m_vectorbatch[m_batchindex + 5].x = b1.x1 + step->xoffs;
m_vectorbatch[m_batchindex + 5].y = b1.y1 + step->yoffs;
- float dx = b1.x1 - b0.x1;
- float dy = b1.y1 - b0.y1;
- float line_length = sqrtf(dx * dx + dy * dy);
-
// determine the color of the line
INT32 r = (INT32)(prim.color.r * step->weight * 255.0f);
INT32 g = (INT32)(prim.color.g * step->weight * 255.0f);
@@ -1518,9 +1590,6 @@ void renderer_d3d9::batch_vector(const render_primitive &prim, float line_time)
if (a > 255) a = 255;
DWORD color = D3DCOLOR_ARGB(a, r, g, b);
- vec2f& start = (get_vector_texture() ? get_vector_texture()->get_uvstart() : get_default_texture()->get_uvstart());
- vec2f& stop = (get_vector_texture() ? get_vector_texture()->get_uvstop() : get_default_texture()->get_uvstop());
-
m_vectorbatch[m_batchindex + 0].u0 = start.c.x;
m_vectorbatch[m_batchindex + 0].v0 = start.c.y;
m_vectorbatch[m_batchindex + 1].u0 = start.c.x;