diff options
author | yz70s <yz70s@users.noreply.github.com> | 2016-05-19 18:40:14 +0200 |
---|---|---|
committer | yz70s <yz70s@users.noreply.github.com> | 2016-05-19 18:43:59 +0200 |
commit | 18c91895bdcbbf937329d3d78d462fb059e05c45 (patch) | |
tree | 0c31285952dc7143a59a6eb9bf17a6b0b8b4acfb /src/mame | |
parent | f2c7981401e0e8816d0fbb7b5d578b47ab40a8f2 (diff) |
chihiro.cpp: since clipping is not present yet, if a trangle has at least a vertex where the w component is <= 0, don't draw it, this makes outr2 more watchable (nw)
Diffstat (limited to 'src/mame')
-rw-r--r-- | src/mame/includes/chihiro.h | 13 | ||||
-rw-r--r-- | src/mame/video/chihiro.cpp | 22 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/mame/includes/chihiro.h b/src/mame/includes/chihiro.h index 3705299c919..90757bb4cbc 100644 --- a/src/mame/includes/chihiro.h +++ b/src/mame/includes/chihiro.h @@ -356,6 +356,11 @@ public: FRONT_AND_BACK = 0x0408 }; + struct nv2avertex_t : public vertex_t + { + float w; + }; + nv2a_renderer(running_machine &machine) : poly_manager<float, nvidia_object_data, 13, 8192>(machine) { memset(channel, 0, sizeof(channel)); @@ -444,7 +449,7 @@ public: int geforce_exec_method(address_space &space, UINT32 channel, UINT32 subchannel, UINT32 method, UINT32 address, int &countlen); UINT32 texture_get_texel(int number, int x, int y); UINT8 *read_pixel(int x, int y, INT32 c[4]); - void write_pixel(int x, int y, UINT32 color, UINT32 depth); + void write_pixel(int x, int y, UINT32 color, int depth); void combiner_initialize_registers(UINT32 argb8[6]); void combiner_initialize_stage(int stage_number); void combiner_initialize_final(); @@ -483,9 +488,9 @@ public: int read_vertices_0x1808(address_space & space, vertex_nv *destination, UINT32 address, int limit); int read_vertices_0x1810(address_space & space, vertex_nv *destination, int offset, int limit); int read_vertices_0x1818(address_space & space, vertex_nv *destination, UINT32 address, int limit); - void convert_vertices_poly(vertex_nv *source, vertex_t *destination, int count); + void convert_vertices_poly(vertex_nv *source, nv2avertex_t *destination, int count); void assemble_primitive(vertex_nv *source, int count, render_delegate &renderspans); - UINT32 render_triangle_culling(const rectangle &cliprect, render_delegate callback, int paramcount, const vertex_t &_v1, const vertex_t &_v2, const vertex_t &_v3); + UINT32 render_triangle_culling(const rectangle &cliprect, render_delegate callback, int paramcount, const nv2avertex_t &_v1, const nv2avertex_t &_v2, const nv2avertex_t &_v3); void clear_render_target(int what, UINT32 value); void clear_depth_buffer(int what, UINT32 value); inline UINT8 *direct_access_ptr(offs_t address); @@ -566,7 +571,7 @@ public: unsigned int vertex_first; int vertex_accumulated; vertex_nv vertex_software[1024+2]; // vertex attributes sent by the software to the 3d accelerator - vertex_t vertex_xy[1024+2]; // vertex attributes computed by the 3d accelerator + nv2avertex_t vertex_xy[1024+2]; // vertex attributes computed by the 3d accelerator vertex_nv persistvertexattr; // persistent vertex attributes render_delegate render_spans_callback; diff --git a/src/mame/video/chihiro.cpp b/src/mame/video/chihiro.cpp index 1d6ae58bb90..4430eff2a65 100644 --- a/src/mame/video/chihiro.cpp +++ b/src/mame/video/chihiro.cpp @@ -1306,7 +1306,7 @@ inline UINT8 *nv2a_renderer::read_pixel(int x, int y, INT32 c[4]) return nullptr; } -void nv2a_renderer::write_pixel(int x, int y, UINT32 color, UINT32 depth) +void nv2a_renderer::write_pixel(int x, int y, UINT32 color, int depth) { UINT8 *addr; UINT32 *daddr32; @@ -1317,6 +1317,8 @@ void nv2a_renderer::write_pixel(int x, int y, UINT32 color, UINT32 depth) bool stencil_passed; bool depth_passed; + if ((depth > 0xffffff) || (depth < 0)) + return; fb[3] = fb[2] = fb[1] = fb[0] = 0; addr = nullptr; if (color_mask != 0) @@ -1341,8 +1343,6 @@ void nv2a_renderer::write_pixel(int x, int y, UINT32 color, UINT32 depth) dep = 0xffffff; sten = 0; } - if (depth > 0xffffff) - depth = 0xffffff; c[3] = color >> 24; c[2] = (color >> 16) & 255; c[1] = (color >> 8) & 255; @@ -1914,7 +1914,7 @@ void nv2a_renderer::render_color(INT32 scanline, const extent_t &extent, const n x = extent.stopx - extent.startx - 1; // number of pixels to draw while (x >= 0) { UINT32 a8r8g8b8; - UINT32 z; + int z; int ca, cr, cg, cb; int xp = extent.startx + x; // x coordinate of current pixel @@ -1933,7 +1933,7 @@ void nv2a_renderer::render_texture_simple(INT32 scanline, const extent_t &extent { int x; UINT32 a8r8g8b8; - UINT32 z; + int z; if (!objectdata.data->texture[0].enabled) { return; @@ -1967,8 +1967,8 @@ void nv2a_renderer::render_register_combiners(INT32 scanline, const extent_t &ex int ca, cr, cg, cb; UINT32 color[6]; UINT32 a8r8g8b8; - UINT32 z; - int n;//,m,i,j,k; + int z; + int n; color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0; @@ -2356,7 +2356,7 @@ void nv2a_renderer::compute_supersample_factors(float &horizontal, float &vertic vertical = my; } -void nv2a_renderer::convert_vertices_poly(vertex_nv *source, vertex_t *destination, int count) +void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *destination, int count) { vertex_nv vert[4]; int m, u; @@ -2384,6 +2384,7 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, vertex_t *destinati for (int i = 0; i < 3; i++) { v[i] += matrix.translate[i]; }*/ + destination[m].w = v[3]; destination[m].x = (v[0] / v[3])*supersample_factor_x; // source[m].attribute[0].fv[0]; destination[m].y = (v[1] / v[3])*supersample_factor_y; // source[m].attribute[0].fv[1]; destination[m].p[(int)VERTEX_PARAMETER::PARAM_Z] = v[2] / v[3]; @@ -2401,6 +2402,7 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, vertex_t *destinati vertexprogram.exec.process(vertexprogram.start_instruction, source, vert, count); // copy data for poly.c for (m = 0; m < count; m++) { + destination[m].w = vert[m].attribute[0].fv[3]; destination[m].x = vert[m].attribute[0].fv[0] * supersample_factor_x; destination[m].y = vert[m].attribute[0].fv[1] * supersample_factor_y; for (u = (int)VERTEX_PARAMETER::PARAM_COLOR_B; u <= (int)VERTEX_PARAMETER::PARAM_COLOR_A; u++) // 0=b 1=g 2=r 3=a @@ -2627,11 +2629,13 @@ void nv2a_renderer::clear_depth_buffer(int what, UINT32 value) } } -UINT32 nv2a_renderer::render_triangle_culling(const rectangle &cliprect, render_delegate callback, int paramcount, const vertex_t &_v1, const vertex_t &_v2, const vertex_t &_v3) +UINT32 nv2a_renderer::render_triangle_culling(const rectangle &cliprect, render_delegate callback, int paramcount, const nv2avertex_t &_v1, const nv2avertex_t &_v2, const nv2avertex_t &_v3) { float areax2; NV2A_GL_CULL_FACE face = NV2A_GL_CULL_FACE::FRONT; + if ((_v1.w <= 0) || (_v2.w <= 0) || (_v3.w <= 0)) // remove, for now + return 0; if (backface_culling_enabled == false) return render_triangle(cliprect, callback, paramcount, _v1, _v2, _v3); if (backface_culling_culled == NV2A_GL_CULL_FACE::FRONT_AND_BACK) |