remove sceGxmFinish on render swap
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
index e1d9a9b..d271743 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -980,7 +980,7 @@ VITA_GXM_RenderPresent(SDL_Renderer *renderer)
{
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
- sceGxmFinish(data->gxm_context);
+// sceGxmFinish(data->gxm_context);
data->displayData.address = data->displayBufferData[data->backBufferIndex];
@@ -994,6 +994,9 @@ VITA_GXM_RenderPresent(SDL_Renderer *renderer)
data->frontBufferIndex = data->backBufferIndex;
data->backBufferIndex = (data->backBufferIndex + 1) % VITA_GXM_BUFFERS;
data->pool_index = 0;
+
+ data->current_pool = (data->current_pool + 1) % 2;
+
data->drawing = SDL_FALSE;
}
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index f410595..12065ce 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -88,7 +88,7 @@ pool_malloc(VITA_GXM_RenderData *data, unsigned int size)
{
if ((data->pool_index + size) < VITA_GXM_POOL_SIZE) {
- void *addr = (void *)((unsigned int)data->pool_addr + data->pool_index);
+ void *addr = (void *)((unsigned int)data->pool_addr[data->current_pool] + data->pool_index);
data->pool_index += size;
return addr;
}
@@ -101,7 +101,7 @@ pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignme
{
unsigned int new_index = (data->pool_index + alignment - 1) & ~(alignment - 1);
if ((new_index + size) < VITA_GXM_POOL_SIZE) {
- void *addr = (void *)((unsigned int)data->pool_addr + new_index);
+ void *addr = (void *)((unsigned int)data->pool_addr[data->current_pool] + new_index);
data->pool_index = new_index + size;
return addr;
}
@@ -863,12 +863,20 @@ gxm_init(SDL_Renderer *renderer)
data->textureTintColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureTintFragmentProgramGxp, "uTintColor");
// Allocate memory for the memory pool
- data->pool_addr = mem_gpu_alloc(
+ data->pool_addr[0] = mem_gpu_alloc(
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW,
VITA_GXM_POOL_SIZE,
sizeof(void *),
SCE_GXM_MEMORY_ATTRIB_READ,
- &data->poolUid
+ &data->poolUid[0]
+ );
+
+ data->pool_addr[1] = mem_gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW,
+ VITA_GXM_POOL_SIZE,
+ sizeof(void *),
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->poolUid[1]
);
init_orthographic_matrix(data->ortho_matrix, 0.0f, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f);
@@ -876,6 +884,7 @@ gxm_init(SDL_Renderer *renderer)
data->backBufferIndex = 0;
data->frontBufferIndex = 0;
data->pool_index = 0;
+ data->current_pool = 0;
data->currentBlendMode = SDL_BLENDMODE_BLEND;
return 0;
@@ -949,7 +958,8 @@ void gxm_finish(SDL_Renderer *renderer)
mem_gpu_free(data->vdmRingBufferUid);
SDL_free(data->contextParams.hostMem);
- mem_gpu_free(data->poolUid);
+ mem_gpu_free(data->poolUid[0]);
+ mem_gpu_free(data->poolUid[1]);
// terminate libgxm
sceGxmTerminate();
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h
index 64a323e..fa146ac 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_types.h
+++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h
@@ -152,9 +152,10 @@ typedef struct
unsigned int backBufferIndex;
unsigned int frontBufferIndex;
- void* pool_addr;
- SceUID poolUid;
+ void* pool_addr[2];
+ SceUID poolUid[2];
unsigned int pool_index;
+ unsigned int current_pool;
float ortho_matrix[4*4];