nv2a: Migrate nv2a_get_offsets to new _get_params model

This commit is contained in:
Matt Borgerson 2025-01-06 04:08:41 -07:00
parent 008d848582
commit 5cb65d1791
4 changed files with 39 additions and 40 deletions

View File

@ -149,27 +149,16 @@ static int nv2a_get_bpp(VGACommonState *s)
return bpp; return bpp;
} }
static void nv2a_get_offsets(VGACommonState *s, static void nv2a_get_params(VGACommonState *s, VGADisplayParams *params)
uint32_t *pline_offset,
uint32_t *pstart_addr,
uint32_t *pline_compare)
{ {
NV2AState *d = container_of(s, NV2AState, vga); NV2AState *d = container_of(s, NV2AState, vga);
uint32_t start_addr, line_offset, line_compare; params->line_offset = (s->cr[0x13] | ((s->cr[0x19] & 0xe0) << 3) |
((s->cr[0x25] & 0x20) << 6))
line_offset = s->cr[0x13] << 3;
| ((s->cr[0x19] & 0xe0) << 3) params->start_addr = d->pcrtc.start / 4;
| ((s->cr[0x25] & 0x20) << 6); params->line_compare = s->cr[VGA_CRTC_LINE_COMPARE] |
line_offset <<= 3; ((s->cr[VGA_CRTC_OVERFLOW] & 0x10) << 4) |
*pline_offset = line_offset; ((s->cr[VGA_CRTC_MAX_SCAN] & 0x40) << 3);
start_addr = d->pcrtc.start / 4;
*pstart_addr = start_addr;
line_compare = s->cr[VGA_CRTC_LINE_COMPARE] |
((s->cr[VGA_CRTC_OVERFLOW] & 0x10) << 4) |
((s->cr[VGA_CRTC_MAX_SCAN] & 0x40) << 3);
*pline_compare = line_compare;
} }
const uint8_t *nv2a_get_dac_palette(void) const uint8_t *nv2a_get_dac_palette(void)
@ -235,7 +224,7 @@ static void nv2a_init_vga(NV2AState *d)
vga_common_init(vga, OBJECT(d), &error_fatal); vga_common_init(vga, OBJECT(d), &error_fatal);
vga->get_bpp = nv2a_get_bpp; vga->get_bpp = nv2a_get_bpp;
vga->get_offsets = nv2a_get_offsets; vga->get_params = nv2a_get_params;
// vga->overlay_draw_line = nv2a_overlay_draw_line; // vga->overlay_draw_line = nv2a_overlay_draw_line;
d->hw_ops = *vga->hw_ops; d->hw_ops = *vga->hw_ops;

View File

@ -19,6 +19,8 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "qemu/osdep.h"
#include "hw/display/vga_int.h"
#include "hw/xbox/nv2a/nv2a_int.h" #include "hw/xbox/nv2a/nv2a_int.h"
#include "hw/xbox/nv2a/pgraph/util.h" #include "hw/xbox/nv2a/pgraph/util.h"
#include "renderer.h" #include "renderer.h"
@ -284,10 +286,10 @@ static void render_display(NV2AState *d, SurfaceBinding *surface)
PGRAPHGLState *r = pg->gl_renderer_state; PGRAPHGLState *r = pg->gl_renderer_state;
unsigned int width, height; unsigned int width, height;
uint32_t pline_offset, pstart_addr, pline_compare; VGADisplayParams vga_display_params;
d->vga.get_resolution(&d->vga, (int*)&width, (int*)&height); d->vga.get_resolution(&d->vga, (int*)&width, (int*)&height);
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); d->vga.get_params(&d->vga, &vga_display_params);
int line_offset = pline_offset ? surface->pitch / pline_offset : 1; int line_offset = vga_display_params.line_offset ? surface->pitch / vga_display_params.line_offset : 1;
/* Adjust viewport height for interlaced mode, used only in 1080i */ /* Adjust viewport height for interlaced mode, used only in 1080i */
if (d->vga.cr[NV_PRMCIO_INTERLACE_MODE] != NV_PRMCIO_INTERLACE_MODE_DISABLED) { if (d->vga.cr[NV_PRMCIO_INTERLACE_MODE] != NV_PRMCIO_INTERLACE_MODE_DISABLED) {
@ -376,9 +378,10 @@ static void gl_fence(void)
void pgraph_gl_sync(NV2AState *d) void pgraph_gl_sync(NV2AState *d)
{ {
uint32_t pline_offset, pstart_addr, pline_compare; VGADisplayParams vga_display_params;
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); d->vga.get_params(&d->vga, &vga_display_params);
SurfaceBinding *surface = pgraph_gl_surface_get_within(d, d->pcrtc.start + pline_offset);
SurfaceBinding *surface = pgraph_gl_surface_get_within(d, d->pcrtc.start + vga_display_params.line_offset);
if (surface == NULL) { if (surface == NULL) {
qemu_event_set(&d->pgraph.sync_complete); qemu_event_set(&d->pgraph.sync_complete);
return; return;
@ -411,9 +414,12 @@ int pgraph_gl_get_framebuffer_surface(NV2AState *d)
qemu_mutex_lock(&d->pfifo.lock); qemu_mutex_lock(&d->pfifo.lock);
// FIXME: Possible race condition with pgraph, consider lock // FIXME: Possible race condition with pgraph, consider lock
uint32_t pline_offset, pstart_addr, pline_compare;
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); VGADisplayParams vga_display_params;
SurfaceBinding *surface = pgraph_gl_surface_get_within(d, d->pcrtc.start + pline_offset); d->vga.get_params(&d->vga, &vga_display_params);
SurfaceBinding *surface = pgraph_gl_surface_get_within(
d, d->pcrtc.start + vga_display_params.line_offset);
if (surface == NULL || !surface->color) { if (surface == NULL || !surface->color) {
qemu_mutex_unlock(&d->pfifo.lock); qemu_mutex_unlock(&d->pfifo.lock);
return 0; return 0;

View File

@ -870,9 +870,11 @@ static void update_uniforms(PGRAPHState *pg, SurfaceBinding *surface)
int display_size_loc = uniform_index(l, "display_size"); // FIXME: Cache int display_size_loc = uniform_index(l, "display_size"); // FIXME: Cache
uniform2f(l, display_size_loc, r->display.width, r->display.height); uniform2f(l, display_size_loc, r->display.width, r->display.height);
uint32_t pline_offset, pstart_addr, pline_compare; VGADisplayParams vga_display_params;
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); d->vga.get_params(&d->vga, &vga_display_params);
int line_offset = pline_offset ? surface->pitch / pline_offset : 1; int line_offset = vga_display_params.line_offset ?
surface->pitch / vga_display_params.line_offset :
1;
int line_offset_loc = uniform_index(l, "line_offset"); int line_offset_loc = uniform_index(l, "line_offset");
uniform1f(l, line_offset_loc, line_offset); uniform1f(l, line_offset_loc, line_offset);
@ -1065,11 +1067,11 @@ void pgraph_vk_render_display(PGRAPHState *pg)
NV2AState *d = container_of(pg, NV2AState, pgraph); NV2AState *d = container_of(pg, NV2AState, pgraph);
PGRAPHVkState *r = pg->vk_renderer_state; PGRAPHVkState *r = pg->vk_renderer_state;
uint32_t pline_offset, pstart_addr, pline_compare; VGADisplayParams vga_display_params;
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); d->vga.get_params(&d->vga, &vga_display_params);
SurfaceBinding *surface = SurfaceBinding *surface = pgraph_vk_surface_get_within(
pgraph_vk_surface_get_within(d, d->pcrtc.start + pline_offset); d, d->pcrtc.start + vga_display_params.line_offset);
if (surface == NULL || !surface->color) { if (surface == NULL || !surface->color) {
return; return;
} }

View File

@ -173,10 +173,12 @@ static int pgraph_vk_get_framebuffer_surface(NV2AState *d)
PGRAPHVkState *r = pg->vk_renderer_state; PGRAPHVkState *r = pg->vk_renderer_state;
qemu_mutex_lock(&d->pfifo.lock); qemu_mutex_lock(&d->pfifo.lock);
// FIXME: Possible race condition with pgraph, consider lock
uint32_t pline_offset, pstart_addr, pline_compare; VGADisplayParams vga_display_params;
d->vga.get_offsets(&d->vga, &pline_offset, &pstart_addr, &pline_compare); d->vga.get_params(&d->vga, &vga_display_params);
SurfaceBinding *surface = pgraph_vk_surface_get_within(d, d->pcrtc.start + pline_offset);
SurfaceBinding *surface = pgraph_vk_surface_get_within(
d, d->pcrtc.start + vga_display_params.line_offset);
if (surface == NULL || !surface->color) { if (surface == NULL || !surface->color) {
qemu_mutex_unlock(&d->pfifo.lock); qemu_mutex_unlock(&d->pfifo.lock);
return 0; return 0;