Skip to content

Commit c387c01

Browse files
committed
Merge branch 'master' into libretro
2 parents 2b455e2 + b244864 commit c387c01

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

frontend/plugin_lib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct rearmed_cbs {
6363
void (*pl_vout_set_raw_vram)(void *vram);
6464
void (*pl_set_gpu_caps)(int caps);
6565
// emulation related
66-
void (*gpu_state_change)(int what);
66+
void (*gpu_state_change)(int what, int cycles);
6767
// some stats, for display by some plugins
6868
int flips_per_sec, cpu_usage;
6969
float vsps_cur; // currect vsync/s

libpcsxcore/gpu.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "gpu.h"
1414
#include "psxdma.h"
1515

16-
void gpu_state_change(int what)
16+
void gpu_state_change(int what, int cycles)
1717
{
1818
enum psx_gpu_state state = what;
1919
switch (state)
@@ -22,10 +22,13 @@ void gpu_state_change(int what)
2222
psxRegs.gpuIdleAfter = psxRegs.cycle + PSXCLK / 50;
2323
break;
2424
case PGS_VRAM_TRANSFER_END:
25-
psxRegs.gpuIdleAfter = psxRegs.cycle;
25+
psxRegs.gpuIdleAfter = psxRegs.cycle - 1;
2626
break;
2727
case PGS_PRIMITIVE_START:
28-
psxRegs.gpuIdleAfter = psxRegs.cycle + 200;
28+
// limit because gpulib delays things with it's buffering...
29+
if (cycles > 512)
30+
cycles = 512;
31+
psxRegs.gpuIdleAfter = psxRegs.cycle + cycles - 1;
2932
break;
3033
}
3134
}

libpcsxcore/gpu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ enum psx_gpu_state {
4949
PGS_PRIMITIVE_START, // for non-dma only
5050
};
5151

52-
void gpu_state_change(int what);
52+
void gpu_state_change(int what, int cycles);
5353

5454
#endif /* __GPU_H__ */

plugins/gpulib/gpu.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static noinline void start_vram_transfer(struct psx_gpu *gpu, uint32_t pos_word,
514514
log_io(gpu, "start_vram_transfer %c (%d, %d) %dx%d\n", is_read ? 'r' : 'w',
515515
gpu->dma.x, gpu->dma.y, gpu->dma.w, gpu->dma.h);
516516
if (gpu->gpu_state_change)
517-
gpu->gpu_state_change(PGS_VRAM_TRANSFER_START);
517+
gpu->gpu_state_change(PGS_VRAM_TRANSFER_START, 0);
518518
}
519519

520520
static void finish_vram_transfer(struct psx_gpu *gpu, int is_read)
@@ -540,7 +540,7 @@ static void finish_vram_transfer(struct psx_gpu *gpu, int is_read)
540540
gpu->dma_start.w, gpu->dma_start.h, 0);
541541
}
542542
if (gpu->gpu_state_change)
543-
gpu->gpu_state_change(PGS_VRAM_TRANSFER_END);
543+
gpu->gpu_state_change(PGS_VRAM_TRANSFER_END, 0);
544544
}
545545

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

750750
static noinline void flush_cmd_buffer(struct psx_gpu *gpu)
751751
{
752+
int cycles_last = 0;
752753
int dummy = 0, left;
753-
left = do_cmd_buffer(gpu, gpu->cmd_buffer, gpu->cmd_len, &dummy, &dummy);
754+
left = do_cmd_buffer(gpu, gpu->cmd_buffer, gpu->cmd_len, &dummy, &cycles_last);
754755
if (left > 0)
755756
memmove(gpu->cmd_buffer, gpu->cmd_buffer + gpu->cmd_len - left, left * 4);
756757
if (left != gpu->cmd_len) {
757-
if (!gpu->dma.h && gpu->gpu_state_change)
758-
gpu->gpu_state_change(PGS_PRIMITIVE_START);
759758
gpu->cmd_len = left;
759+
if (!gpu->dma.h && gpu->gpu_state_change)
760+
gpu->gpu_state_change(PGS_PRIMITIVE_START, cycles_last);
760761
}
761762
}
762763

plugins/gpulib/gpu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct psx_gpu {
117117
(int *x, int *y, int *w, int *h, int *vram_h);
118118
void *(*mmap)(unsigned int size);
119119
void (*munmap)(void *ptr, unsigned int size);
120-
void (*gpu_state_change)(int what); // psx_gpu_state
120+
void (*gpu_state_change)(int what, int cycles); // psx_gpu_state
121121
};
122122

123123
extern struct psx_gpu gpu;

0 commit comments

Comments
 (0)