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
#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)
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;
}
}
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)
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)
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);
}
}
(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;