Skip to content

Commit

Permalink
Merge branch 'master' into libretro
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Dec 19, 2024
2 parents 2b455e2 + b244864 commit c387c01
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/plugin_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct rearmed_cbs {
void (*pl_vout_set_raw_vram)(void *vram);
void (*pl_set_gpu_caps)(int caps);
// emulation related
void (*gpu_state_change)(int what);
void (*gpu_state_change)(int what, int cycles);
// some stats, for display by some plugins
int flips_per_sec, cpu_usage;
float vsps_cur; // currect vsync/s
Expand Down
9 changes: 6 additions & 3 deletions libpcsxcore/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "gpu.h"
#include "psxdma.h"

void gpu_state_change(int what)
void gpu_state_change(int what, int cycles)
{
enum psx_gpu_state state = what;
switch (state)
Expand All @@ -22,10 +22,13 @@ void gpu_state_change(int what)
psxRegs.gpuIdleAfter = psxRegs.cycle + PSXCLK / 50;
break;
case PGS_VRAM_TRANSFER_END:
psxRegs.gpuIdleAfter = psxRegs.cycle;
psxRegs.gpuIdleAfter = psxRegs.cycle - 1;
break;
case PGS_PRIMITIVE_START:
psxRegs.gpuIdleAfter = psxRegs.cycle + 200;
// limit because gpulib delays things with it's buffering...
if (cycles > 512)
cycles = 512;
psxRegs.gpuIdleAfter = psxRegs.cycle + cycles - 1;
break;
}
}
2 changes: 1 addition & 1 deletion libpcsxcore/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ enum psx_gpu_state {
PGS_PRIMITIVE_START, // for non-dma only
};

void gpu_state_change(int what);
void gpu_state_change(int what, int cycles);

#endif /* __GPU_H__ */
11 changes: 6 additions & 5 deletions plugins/gpulib/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static noinline void start_vram_transfer(struct psx_gpu *gpu, uint32_t pos_word,
log_io(gpu, "start_vram_transfer %c (%d, %d) %dx%d\n", is_read ? 'r' : 'w',
gpu->dma.x, gpu->dma.y, gpu->dma.w, gpu->dma.h);
if (gpu->gpu_state_change)
gpu->gpu_state_change(PGS_VRAM_TRANSFER_START);
gpu->gpu_state_change(PGS_VRAM_TRANSFER_START, 0);
}

static void finish_vram_transfer(struct psx_gpu *gpu, int is_read)
Expand All @@ -540,7 +540,7 @@ static void finish_vram_transfer(struct psx_gpu *gpu, int is_read)
gpu->dma_start.w, gpu->dma_start.h, 0);
}
if (gpu->gpu_state_change)
gpu->gpu_state_change(PGS_VRAM_TRANSFER_END);
gpu->gpu_state_change(PGS_VRAM_TRANSFER_END, 0);
}

static void do_vram_copy(struct psx_gpu *gpu, const uint32_t *params, int *cpu_cycles)
Expand Down Expand Up @@ -749,14 +749,15 @@ static noinline int do_cmd_buffer(struct psx_gpu *gpu, uint32_t *data, int count

static noinline void flush_cmd_buffer(struct psx_gpu *gpu)
{
int cycles_last = 0;
int dummy = 0, left;
left = do_cmd_buffer(gpu, gpu->cmd_buffer, gpu->cmd_len, &dummy, &dummy);
left = do_cmd_buffer(gpu, gpu->cmd_buffer, gpu->cmd_len, &dummy, &cycles_last);
if (left > 0)
memmove(gpu->cmd_buffer, gpu->cmd_buffer + gpu->cmd_len - left, left * 4);
if (left != gpu->cmd_len) {
if (!gpu->dma.h && gpu->gpu_state_change)
gpu->gpu_state_change(PGS_PRIMITIVE_START);
gpu->cmd_len = left;
if (!gpu->dma.h && gpu->gpu_state_change)
gpu->gpu_state_change(PGS_PRIMITIVE_START, cycles_last);
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/gpulib/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct psx_gpu {
(int *x, int *y, int *w, int *h, int *vram_h);
void *(*mmap)(unsigned int size);
void (*munmap)(void *ptr, unsigned int size);
void (*gpu_state_change)(int what); // psx_gpu_state
void (*gpu_state_change)(int what, int cycles); // psx_gpu_state
};

extern struct psx_gpu gpu;
Expand Down

0 comments on commit c387c01

Please sign in to comment.