Created
October 10, 2011 19:38
-
-
Save inactive123/1276312 to your computer and use it in GitHub Desktop.
GPU binding FBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/interface/PS3/vid_interface_ps3.cpp b/src/interface/PS3/vid_interface_ps3.cpp | |
index 3eda11f..4a7667e 100644 | |
--- a/src/interface/PS3/vid_interface_ps3.cpp | |
+++ b/src/interface/PS3/vid_interface_ps3.cpp | |
@@ -18,7 +18,6 @@ float vidScrnAspect = ASPECT_RATIO_4_3; // Aspect ratio | |
unsigned char* pVidImage = NULL; // Memory buffer | |
int nVidImageWidth = DEFAULT_IMAGE_WIDTH; // Memory buffer size | |
int nVidImageHeight = DEFAULT_IMAGE_HEIGHT; | |
-int nVidImageLeft = 0, nVidImageTop = 0; // Memory buffer visible area offsets | |
int nVidImagePitch = 0; // Memory buffer pitch | |
bool bVidRecalcPalette; | |
bool bVidFBOEnabled; // FBO/Dual shader mode | |
@@ -121,7 +120,8 @@ int VidExit() | |
int VidFrame_RecalcPalette() | |
{ | |
unsigned short* pSrc = (unsigned short*)pVidTransImage; | |
- unsigned char* pDest = pVidImage; | |
+ uint8_t * texture = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE); | |
+ unsigned char* pDest = texture; | |
uint64_t r = 0; | |
do{ | |
@@ -141,13 +141,16 @@ int VidFrame_RecalcPalette() | |
}while(r < 256); | |
bVidRecalcPalette = false; | |
+ glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); | |
+ glTextureReferenceSCE(GL_TEXTURE_2D, 1, nVidImageWidth, nVidImageHeight, 1, SCREEN_RENDER_TEXTURE_PIXEL_FORMAT, nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT, 0); | |
return 0; | |
} | |
int VidFrame_Recalc() | |
{ | |
unsigned short* pSrc = (unsigned short*)pVidTransImage; | |
- unsigned char* pDest = pVidImage; | |
+ uint8_t * texture = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE); | |
+ unsigned char* pDest = texture; | |
pBurnDraw = pVidTransImage; | |
nBurnPitch = nVidImageWidth << 1; | |
@@ -168,14 +171,19 @@ int VidFrame_Recalc() | |
pDest += nVidImagePitch; | |
}while(y < nVidImageHeight); | |
+ glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); | |
+ glTextureReferenceSCE(GL_TEXTURE_2D, 1, nVidImageWidth, nVidImageHeight, 1, SCREEN_RENDER_TEXTURE_PIXEL_FORMAT, nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT, 0); | |
return 0; | |
} | |
int VidFrame() | |
{ | |
- pBurnDraw = pVidImage; | |
+ uint8_t * texture = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE); | |
+ pBurnDraw = texture; | |
nBurnPitch = nVidImagePitch; | |
BurnDrvFrame(); | |
+ glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); | |
+ glTextureReferenceSCE(GL_TEXTURE_2D, 1, nVidImageWidth, nVidImageHeight, 1, SCREEN_RENDER_TEXTURE_PIXEL_FORMAT, nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT, 0); | |
psglRender(); | |
return 0; | |
diff --git a/src/interface/PS3/vid_psgl.cpp b/src/interface/PS3/vid_psgl.cpp | |
index 83cb867..5fd0117 100644 | |
--- a/src/interface/PS3/vid_psgl.cpp | |
+++ b/src/interface/PS3/vid_psgl.cpp | |
@@ -549,12 +549,7 @@ void psglRender(void) | |
{ | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | |
- uint8_t * texture = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_WRITE_ONLY); | |
- VidSCopyImage(texture); | |
- glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); | |
- | |
frame_count += 1; | |
- glTextureReferenceSCE(GL_TEXTURE_2D, 1, nVidImageWidth, nVidImageHeight, 0, SCREEN_RENDER_TEXTURE_PIXEL_FORMAT, nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT, 0); | |
set_cg_params(); | |
glDrawArrays(GL_QUADS, 0, 4); | |
@@ -628,7 +623,7 @@ void psglRenderAlpha(void) | |
} | |
} | |
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); | |
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nVidImageWidth, nVidImageHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 0); | |
+ glTextureReferenceSCE(GL_TEXTURE_2D, 1, nVidImageWidth, nVidImageHeight, 1, SCREEN_RENDER_TEXTURE_PIXEL_FORMAT, nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT, 0); | |
set_cg_params(); | |
glDrawArrays(GL_QUADS, 0, 4); | |
} | |
diff --git a/src/interface/PS3/vid_support-ps3.h b/src/interface/PS3/vid_support-ps3.h | |
index cffdc63..569f41c 100644 | |
--- a/src/interface/PS3/vid_support-ps3.h | |
+++ b/src/interface/PS3/vid_support-ps3.h | |
@@ -35,7 +35,7 @@ void VidInitInfo(); | |
#define VidSCopyImage(dst) \ | |
unsigned int pitch = nVidImageWidth * sizeof(unsigned int); \ | |
- uint8_t * ps = pVidImage + (nVidImageLeft << SCREEN_RENDER_TEXTURE_BPP_SHIFT); \ | |
+ uint8_t * ps = pVidImage; \ | |
int linesize = nVidImageWidth << SCREEN_RENDER_TEXTURE_BPP_SHIFT; \ | |
uint16_t height = nVidImageHeight; \ | |
do{ \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To my surprise, this ended up being slower than the method we do now where we render first to a buffer and then blit to GPU RAM instead of doing it directly. Seems FBA uses pBurnDraw as some sort of scratchpad for graphics.