1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Stop using predefined texture sizes introduced for Android

For Android we use EGL image for async copies and for sync copies and
devices that don't support EGL image, the fixed texture sizes don't seem
to improve performance.
This commit is contained in:
fzurita 2021-04-17 16:34:43 -04:00 committed by Sergey Lipskiy
parent 7a6289b270
commit 5f7a7cadc2
5 changed files with 17 additions and 32 deletions

View File

@ -12,17 +12,6 @@
#include "Log.h"
#include "MemoryStatus.h"
/*
#include "ColorBufferToRDRAM_GL.h"
#include "ColorBufferToRDRAM_BufferStorageExt.h"
#elif defined(OS_ANDROID) && defined (GLES2)
#include "ColorBufferToRDRAM_GL.h"
#include "ColorBufferToRDRAM_GLES.h"
#else
#include "ColorBufferToRDRAMStub.h"
#endif
*/
#include <Graphics/Context.h>
#include <Graphics/Parameters.h>
#include <Graphics/ColorBufferReader.h>
@ -165,12 +154,12 @@ bool ColorBufferToRDRAM::_prepareCopy(u32& _startAddress)
return false;
if(m_pTexture == nullptr ||
m_pTexture->width != _getRealWidth(pBuffer->m_width) ||
m_pTexture->height != VI_GetMaxBufferHeight(_getRealWidth(pBuffer->m_width)))
m_pTexture->width != pBuffer->m_width ||
m_pTexture->height != VI_GetMaxBufferHeight(pBuffer->m_width))
{
_destroyFBTexure();
m_lastBufferWidth = _getRealWidth(pBuffer->m_width);
m_lastBufferWidth = pBuffer->m_width;
_initFBTexture();
}
@ -341,18 +330,6 @@ void ColorBufferToRDRAM::_copy(u32 _startAddress, u32 _endAddress, bool _sync)
gDP.changed |= CHANGED_SCISSOR;
}
u32 ColorBufferToRDRAM::_getRealWidth(u32 _viWidth)
{
u32 index = 0;
const u32 maxIndex = static_cast<u32>(m_allowedRealWidths.size()) - 1;
while (index < maxIndex && _viWidth > m_allowedRealWidths[index])
{
++index;
}
return m_allowedRealWidths[index];
}
void ColorBufferToRDRAM::copyToRDRAM(u32 _address, bool _sync)
{
if (!isMemoryWritable(RDRAM + _address, gDP.colorImage.width << gDP.colorImage.size >> 1))

View File

@ -46,8 +46,6 @@ private:
void _copy(u32 _startAddress, u32 _endAddress, bool _sync);
u32 _getRealWidth(u32 _viWidth);
// Convert pixel from video memory to N64 buffer format.
static u8 _RGBAtoR8(u8 _c, u32 x, u32 y);
static u16 _RGBAtoRGBA16(u32 _c, u32 x, u32 y);

View File

@ -22,6 +22,8 @@ GraphicBufferWrapper::GraphicBufferWrapper() {
m_private = true;
m_privateGraphicBuffer = new GraphicBuffer();
}
m_stride = 0;
}
GraphicBufferWrapper::~GraphicBufferWrapper() {
@ -51,7 +53,6 @@ bool GraphicBufferWrapper::allocate(const AHardwareBuffer_Desc *desc) {
}
}
int GraphicBufferWrapper::lock(uint64_t usage, void **out_virtual_address) {
int returnValue = 0;
@ -64,7 +65,6 @@ int GraphicBufferWrapper::lock(uint64_t usage, void **out_virtual_address) {
return returnValue;
}
void GraphicBufferWrapper::release() {
if (!m_private) {
AndroidHardwareBufferCompat::GetInstance().Release(m_publicGraphicBuffer);
@ -81,7 +81,6 @@ void GraphicBufferWrapper::unlock() {
}
EGLClientBuffer GraphicBufferWrapper::getClientBuffer() {
EGLClientBuffer clientBuffer = nullptr;
if (m_private) {
@ -93,6 +92,15 @@ EGLClientBuffer GraphicBufferWrapper::getClientBuffer() {
return clientBuffer;
}
unsigned GraphicBufferWrapper::getStride() const {
if (m_private) {
return m_privateGraphicBuffer->getStride();
} else {
AHardwareBuffer_Desc bufferInfo;
AndroidHardwareBufferCompat::GetInstance().Describe(m_publicGraphicBuffer, &bufferInfo);
return bufferInfo.stride;
}
}
int GraphicBufferWrapper::getApiLevel()
{

View File

@ -28,6 +28,7 @@ public:
void release();
void unlock();
EGLClientBuffer getClientBuffer();
unsigned int getStride() const;
private:
@ -36,6 +37,7 @@ private:
bool m_private;
GraphicBuffer* m_privateGraphicBuffer;
AHardwareBuffer* m_publicGraphicBuffer;
unsigned int m_stride;
};

View File

@ -55,7 +55,7 @@ const u8 * ColorBufferReaderWithEGLImage::_readPixels(const ReadColorBufferParam
m_hardwareBuffer.lock(AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN, &gpuData);
m_bufferLocked = true;
_heightOffset = static_cast<u32>(_params.y0);
_stride = m_pTexture->width;
_stride = m_hardwareBuffer.getStride();
} else {
gpuData = m_pixelData.data();
glReadPixels(_params.x0, _params.y0, m_pTexture->width, _params.height, format, type, gpuData);