From 32f0e6efac8b51dbdc11b390b64753227cbb6180 Mon Sep 17 00:00:00 2001 From: ImJezze Date: Wed, 13 Apr 2016 19:21:57 +0200 Subject: [PATCH] Removed hacks for vector screens from shaders (nw) - added handling of texture coordinates for vector screens to core render - added handling of orientation/rotation for vector screens to D3D renderer --- hlsl/bloom.fx | 4 +- hlsl/distortion.fx | 45 +++--------- hlsl/downsample.fx | 5 -- hlsl/post.fx | 21 ++---- hlsl/primary.fx | 2 - hlsl/vector.fx | 6 +- src/emu/render.cpp | 37 +++++++--- src/osd/modules/osdwindow.h | 3 +- src/osd/modules/render/d3d/d3dhlsl.cpp | 91 ++++++++++++------------ src/osd/modules/render/d3d/d3dhlsl.h | 3 - src/osd/modules/render/drawd3d.cpp | 95 ++++++++++++++++++++++---- 11 files changed, 177 insertions(+), 135 deletions(-) diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx index 5911e1ee8b5..db23995d55b 100644 --- a/hlsl/bloom.fx +++ b/hlsl/bloom.fx @@ -278,9 +278,7 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.TexCoord = TexCoord.xy; - TexCoord += VectorScreen - ? 0.5f / TargetDims.xy - : 0.5f / SourceDims.xy; + TexCoord += 0.5f / SourceDims; Output.BloomCoord = TexCoord.xy; diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx index 0040c76d3b0..e33b8811ba5 100644 --- a/hlsl/distortion.fx +++ b/hlsl/distortion.fx @@ -89,8 +89,6 @@ uniform float2 ScreenDims; // size of the window or fullscreen uniform float2 TargetDims; // size of the target surface uniform float2 QuadDims; // size of the screen quad -uniform bool VectorScreen; - VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; @@ -120,7 +118,6 @@ uniform float VignettingAmount = 0.0f; uniform float ReflectionAmount = 0.0f; uniform bool SwapXY = false; -uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270° float GetNoiseFactor(float3 n, float random) { @@ -146,40 +143,16 @@ float GetSpotAddend(float2 coord, float amount) { float2 SpotCoord = coord; - // hack for vector screen - if (VectorScreen) - { - // upper right quadrant - float2 spotOffset = - RotationType == 1 // 90° - ? float2(-0.25f, -0.25f) - : RotationType == 2 // 180° - ? float2(0.25f, -0.25f) - : RotationType == 3 // 270° else 0° - ? float2(0.25f, 0.25f) - : float2(-0.25f, 0.25f); + // upper right quadrant + float2 spotOffset = float2(-0.25f, 0.25f); - // normalized screen canvas ratio - float2 CanvasRatio = SwapXY - ? float2(QuadDims.x / QuadDims.y, 1.0f) - : float2(1.0f, QuadDims.y / QuadDims.x); + // normalized screen canvas ratio + float2 CanvasRatio = SwapXY + ? float2(1.0f, QuadDims.x / QuadDims.y) + : float2(1.0f, QuadDims.y / QuadDims.x); - SpotCoord += spotOffset; - SpotCoord *= CanvasRatio; - } - else - { - // upper right quadrant - float2 spotOffset = float2(-0.25f, 0.25f); - - // normalized screen canvas ratio - float2 CanvasRatio = SwapXY - ? float2(1.0f, QuadDims.x / QuadDims.y) - : float2(1.0f, QuadDims.y / QuadDims.x); - - SpotCoord += spotOffset; - SpotCoord *= CanvasRatio; - } + SpotCoord += spotOffset; + SpotCoord *= CanvasRatio; float SpotBlur = amount; @@ -201,7 +174,7 @@ float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount) smoothAmount = min(smoothAmount, radiusAmount); float2 quadDims = QuadDims; - quadDims = !VectorScreen && SwapXY + quadDims = SwapXY ? quadDims.yx : quadDims.xy; diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx index 7b4d003dd7c..c069b0ad10e 100644 --- a/hlsl/downsample.fx +++ b/hlsl/downsample.fx @@ -55,8 +55,6 @@ uniform float2 ScreenDims; uniform float2 TargetDims; uniform float2 QuadDims; -uniform bool VectorScreen; - static const float2 Coord0Offset = float2(-0.5f, -0.5f); static const float2 Coord1Offset = float2( 0.5f, -0.5f); static const float2 Coord2Offset = float2(-0.5f, 0.5f); @@ -67,9 +65,6 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; float2 HalfTargetTexelDims = 0.5f / TargetDims; - HalfTargetTexelDims *= VectorScreen - ? (ScreenDims / QuadDims) - : 1.0f; Output.Position = float4(Input.Position.xyz, 1.0f); Output.Position.xy /= ScreenDims; diff --git a/hlsl/post.fx b/hlsl/post.fx index c3966257c02..1ef59fcca39 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -175,27 +175,22 @@ float2 GetShadowCoord(float2 QuadCoord, float2 SourceCoord) float2 shadowUV = ShadowUV; float2 shadowCount = ShadowCount; - // swap x/y vector and raster in screen mode (not source mode) + // swap x/y in screen mode (not source mode) canvasCoord = ShadowTileMode == 0 && SwapXY ? canvasCoord.yx : canvasCoord.xy; - // swap x/y vector and raster in screen mode (not source mode) + // swap x/y in screen mode (not source mode) shadowCount = ShadowTileMode == 0 && SwapXY ? shadowCount.yx : shadowCount.xy; float2 shadowTile = canvasTexelDims * shadowCount; - // swap x/y vector in screen mode (not raster and not source mode) - shadowTile = VectorScreen && ShadowTileMode == 0 && SwapXY - ? shadowTile.yx - : shadowTile.xy; - float2 shadowFrac = frac(canvasCoord / shadowTile); - // swap x/y raster in screen mode (not vector and not source mode) - shadowFrac = !VectorScreen && ShadowTileMode == 0 && SwapXY + // swap x/y in screen mode (not source mode) + shadowFrac = ShadowTileMode == 0 && SwapXY ? shadowFrac.yx : shadowFrac.xy; @@ -215,12 +210,8 @@ float4 ps_main(PS_INPUT Input) : COLOR float4 BaseColor = tex2D(DiffuseSampler, TexCoord); BaseColor.a = 1.0f; - // keep border - if (!PrepareBloom) - { - // clip border - clip(TexCoord < 0.0f || TexCoord > 1.0f ? -1 : 1); - } + // clip border + clip(TexCoord < 0.0f || TexCoord > 1.0f ? -1 : 1); // Mask Simulation (may not affect bloom) if (!PrepareBloom && ShadowAlpha > 0.0f) diff --git a/hlsl/primary.fx b/hlsl/primary.fx index 9f5a3c62faf..939d37e97dd 100644 --- a/hlsl/primary.fx +++ b/hlsl/primary.fx @@ -55,8 +55,6 @@ uniform float2 ScreenDims; uniform float2 TargetDims; uniform float2 QuadDims; -uniform bool VectorScreen; - VS_OUTPUT vs_screen_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; diff --git a/hlsl/vector.fx b/hlsl/vector.fx index 13aeb943c53..d71b85ad0e1 100644 --- a/hlsl/vector.fx +++ b/hlsl/vector.fx @@ -28,7 +28,7 @@ struct PS_INPUT { float4 Color : COLOR0; float2 TexCoord : TEXCOORD0; - float2 LineInfo : TEXCOORD1; + float2 LineInfo : TEXCOORD1; // x is the line length, y is unused }; //----------------------------------------------------------------------------- @@ -47,9 +47,9 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.Position = float4(Input.Position.xyz, 1.0f); Output.Position.xy /= ScreenDims; - Output.Position.y = 1.0f - Output.Position.y; // flip y + Output.Position.y = 1.0f - Output.Position.y; Output.Position.xy -= 0.5f; // center - Output.Position.xy *= 2.0f * (ScreenDims / QuadDims); // zoom + Output.Position.xy *= 2.0f; // zoom Output.TexCoord = Input.TexCoord; 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& 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(prim->get_quad_width() + 0.5f); - int target_height = static_cast(prim->get_quad_height() + 0.5f); + bool swap_xy = d3d->window().swap_xy(); + int target_width = swap_xy + ? static_cast(prim->get_quad_height() + 0.5f) + : static_cast(prim->get_quad_width() + 0.5f); + int target_height = swap_xy + ? static_cast(prim->get_quad_width() + 0.5f) + : static_cast(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(prim->get_quad_width() + 0.5f); - int target_height = static_cast(prim->get_quad_height() + 0.5f); + bool swap_xy = d3d->window().swap_xy(); + int target_width = swap_xy + ? static_cast(prim->get_quad_height() + 0.5f) + : static_cast(prim->get_quad_width() + 0.5f); + int target_height = swap_xy + ? static_cast(prim->get_quad_width() + 0.5f) + : static_cast(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(shadersys->curr_render_target->width), + static_cast(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(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(this->get_width()); + float screen_height = static_cast(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;