From c9f6f87fccfad5fa95230576cf393c3854926fc1 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sun, 6 Apr 2025 14:03:09 +0100 Subject: [PATCH] much less idiotic... --- src/include/86box/nv/render/vid_nv3_render.h | 1 + src/include/86box/nv/vid_nv3.h | 2 +- .../classes/nv3_class_00c_win95_gdi_text.c | 2 +- src/video/nv/nv3/classes/nv3_class_010_blit.c | 5 ++ src/video/nv/nv3/render/nv3_render_blit.c | 61 ++++++++----------- src/video/nv/nv3/render/nv3_render_core.c | 3 +- 6 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/include/86box/nv/render/vid_nv3_render.h b/src/include/86box/nv/render/vid_nv3_render.h index 00591e342..048f3089a 100644 --- a/src/include/86box/nv/render/vid_nv3_render.h +++ b/src/include/86box/nv/render/vid_nv3_render.h @@ -22,6 +22,7 @@ void nv3_render_write_pixel(nv3_position_16_t position, uint32_t color, nv3_grob uint8_t nv3_render_read_pixel_8(nv3_position_16_t position, nv3_grobj_t grobj, bool use_destination); uint16_t nv3_render_read_pixel_16(nv3_position_16_t position, nv3_grobj_t grobj, bool use_destination); uint32_t nv3_render_read_pixel_32(nv3_position_16_t position, nv3_grobj_t grobj, bool use_destination); +uint32_t nv3_render_get_vram_address(nv3_position_16_t position, nv3_grobj_t grobj, bool use_destination); uint32_t nv3_render_to_chroma(nv3_color_expanded_t expanded); nv3_color_expanded_t nv3_render_expand_color(uint32_t color, nv3_grobj_t grobj); // Convert a colour to full RGB10 format from the current working format. diff --git a/src/include/86box/nv/vid_nv3.h b/src/include/86box/nv/vid_nv3.h index 411ccdecf..dc6249346 100644 --- a/src/include/86box/nv/vid_nv3.h +++ b/src/include/86box/nv/vid_nv3.h @@ -14,7 +14,7 @@ * Also check the doc folder for some more notres * * vid_nv3.h: NV3 Architecture Hardware Reference (open-source) - * Last updated: 2 April 2025 (STILL WORKING ON IT!!!) + * Last updated: 6 April 2025 (STILL WORKING ON IT!!!) * * Authors: Connor Hyde * diff --git a/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c b/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c index e2f640fac..c1085fe89 100644 --- a/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c +++ b/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c @@ -278,7 +278,7 @@ void nv3_class_00c_method(uint32_t param, uint32_t method_id, nv3_ramin_context_ return; } - nv_log("%s: Invalid or unimplemented method 0x%04x\n", nv3_class_names[context.class_id & 0x1F], method_id); + warning("%s: Invalid or unimplemented method 0x%04x\n", nv3_class_names[context.class_id & 0x1F], method_id); nv3_pgraph_interrupt_invalid(NV3_PGRAPH_INTR_1_SOFTWARE_METHOD_PENDING); break; } diff --git a/src/video/nv/nv3/classes/nv3_class_010_blit.c b/src/video/nv/nv3/classes/nv3_class_010_blit.c index 7b752243f..6582ada13 100644 --- a/src/video/nv/nv3/classes/nv3_class_010_blit.c +++ b/src/video/nv/nv3/classes/nv3_class_010_blit.c @@ -54,6 +54,11 @@ void nv3_class_010_method(uint32_t param, uint32_t method_id, nv3_ramin_context_ && nv3->pgraph.blit.point_in.y == nv3->pgraph.blit.point_out.y) return; + /* Some of these seem to have sizes of 0, so skip */ + if (nv3->pgraph.blit.size.h == 0 + && nv3->pgraph.blit.size.w == 0) + return; + nv3_render_blit_screen2screen(grobj); break; diff --git a/src/video/nv/nv3/render/nv3_render_blit.c b/src/video/nv/nv3/render/nv3_render_blit.c index 46556f928..ad8c0e3f9 100644 --- a/src/video/nv/nv3/render/nv3_render_blit.c +++ b/src/video/nv/nv3/render/nv3_render_blit.c @@ -138,51 +138,38 @@ void nv3_render_blit_screen2screen(nv3_grobj_t grobj) uint32_t pixel_to_copy = 0x00; - /* Prevents overwriting pixels we've already modified*/ - uint32_t xdiff = 0, ydiff = 0; + /* Coordinates for copying an entire line at a time */ + uint32_t buf_position = 0, vram_position = 0, size_x = nv3->pgraph.blit.size.w; + + /* Read the old pixel into the line buffer + Assumption: All data is sent in an unpacked format. In the case of an NVIDIA GPU this means that all data is sent 32 bits at a time regardless of if + the actual source data is 32 bits in size or not. For pixel data, the upper bits are left as 0 in 8bpp/16bpp mode. For 86box purposes, the data is written + 8/16 bits at a time. + + TODO: CHECK FOR PACKED FORMAT!!!!! + */ + + if (nv3->nvbase.svga.bpp == 15 + || nv3->nvbase.svga.bpp == 16) + size_x <<= 1; + else if (nv3->nvbase.svga.bpp == 32) + size_x <<= 2; - /* Read the old pixel into the line buffer */ for (int32_t y = 0; y < nv3->pgraph.blit.size.h; y++) { old_position.y = nv3->pgraph.blit.point_in.y + y; + /* 32bit buffer */ + buf_position = (nv3->pgraph.blit.size.w * y); + vram_position = nv3_render_get_vram_address(old_position, grobj, false); - for (int32_t x = 0; x < nv3->pgraph.blit.size.w; x++) - { - old_position.x = nv3->pgraph.blit.point_in.x + x; - - switch (nv3->nvbase.svga.bpp) - { - case 8: - pixel_to_copy = nv3_render_read_pixel_8(old_position, grobj, false) & 0xFF; - break; - case 15 ... 16: //15bpp and 16bpp modes are considered as identical - pixel_to_copy = nv3_render_read_pixel_16(old_position, grobj, false) & 0xFFFF; - break; - case 32: - pixel_to_copy = nv3_render_read_pixel_32(old_position, grobj, false); - break; - } - - uint32_t buf_position = (y * nv3->pgraph.blit.size.w) + x; - nv3_s2sb_line_buffer[buf_position] = pixel_to_copy; - } - - + memcpy(&nv3_s2sb_line_buffer[buf_position], &nv3->nvbase.svga.vram[vram_position], size_x); } /* simply write it all back to vram */ for (int32_t y = 0; y < nv3->pgraph.blit.size.h; y++) - { + { + buf_position = (nv3->pgraph.blit.size.w * y); new_position.y = nv3->pgraph.blit.point_out.y + y; - - for (int32_t x = 0; x < nv3->pgraph.blit.size.w; x++) - { - new_position.x = nv3->pgraph.blit.point_out.x + x; - - uint32_t buf_position = (y * nv3->pgraph.blit.size.w) + x; - - nv3_render_write_pixel(new_position, nv3_s2sb_line_buffer[buf_position], grobj); - } + vram_position = nv3_render_get_vram_address(new_position, grobj, false); + memcpy(&nv3->nvbase.svga.vram[vram_position], &nv3_s2sb_line_buffer[buf_position], size_x); } - - } \ No newline at end of file diff --git a/src/video/nv/nv3/render/nv3_render_core.c b/src/video/nv/nv3/render/nv3_render_core.c index e9ebeb013..dca2a6a6c 100644 --- a/src/video/nv/nv3/render/nv3_render_core.c +++ b/src/video/nv/nv3/render/nv3_render_core.c @@ -212,7 +212,7 @@ uint32_t nv3_render_set_pattern_color(nv3_color_expanded_t pattern_colour, bool } -/* /* Combine the current buffer with the pitch to get the address in the framebuffer to draw from for a given position. */ +/* Combine the current buffer with the pitch to get the address in the framebuffer to draw from for a given position. */ uint32_t nv3_render_get_vram_address(nv3_position_16_t position, nv3_grobj_t grobj, bool use_destination) { uint32_t vram_x = position.x; @@ -309,7 +309,6 @@ void nv3_render_write_pixel(nv3_position_16_t position, uint32_t color, nv3_grob bool alpha_enabled = (grobj.grobj_0 >> NV3_PGRAPH_CONTEXT_SWITCH_ALPHA) & 0x01; uint32_t framebuffer_bpp = nv3->nvbase.svga.bpp; // maybe y16 too?z - uint32_t current_buffer = (nv3->pgraph.context_switch >> NV3_PGRAPH_CONTEXT_SWITCH_SRC_BUFFER) & 0x03; /* doesn't seem*/ nv3_color_argb_t color_data = *(nv3_color_argb_t*)&color;