mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
ColorBufferReader performance improvements
This commit is contained in:
parent
4f5759ef46
commit
ebcf46e5ad
|
@ -26,8 +26,8 @@ void ColorBufferReaderWithBufferStorage::_initBuffers()
|
||||||
for (int index = 0; index < _numPBO; ++index) {
|
for (int index = 0; index < _numPBO; ++index) {
|
||||||
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[index]));
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[index]));
|
||||||
m_fence[index] = 0;
|
m_fence[index] = 0;
|
||||||
glBufferStorage(GL_PIXEL_PACK_BUFFER, m_pTexture->textureBytes, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
|
glBufferStorage(GL_PIXEL_PACK_BUFFER, m_pTexture->textureBytes, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||||
m_PBOData[index] = glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pTexture->textureBytes, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
|
m_PBOData[index] = glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pTexture->textureBytes, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle::null);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle::null);
|
||||||
|
@ -59,18 +59,17 @@ u8 * ColorBufferReaderWithBufferStorage::readPixels(s32 _x0, s32 _y0, u32 _width
|
||||||
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[m_curIndex]));
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[m_curIndex]));
|
||||||
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
||||||
|
|
||||||
//Setup a fence sync object so that we know when glReadPixels completes
|
|
||||||
glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT);
|
|
||||||
m_fence[m_curIndex] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
||||||
|
|
||||||
if (!_sync) {
|
if (!_sync) {
|
||||||
|
//Setup a fence sync object so that we know when glReadPixels completes
|
||||||
|
m_fence[m_curIndex] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
m_curIndex = (m_curIndex + 1) % _numPBO;
|
m_curIndex = (m_curIndex + 1) % _numPBO;
|
||||||
}
|
//Wait for glReadPixels to complete for the currently selected PBO
|
||||||
|
if (m_fence[m_curIndex] != 0) {
|
||||||
//Wait for glReadPixels to complete for the currently selected PBO
|
glClientWaitSync(m_fence[m_curIndex], 0, 1e8);
|
||||||
if (m_fence[m_curIndex] != 0) {
|
glDeleteSync(m_fence[m_curIndex]);
|
||||||
glClientWaitSync(m_fence[m_curIndex], 0, 1e8);
|
}
|
||||||
glDeleteSync(m_fence[m_curIndex]);
|
} else {
|
||||||
|
glFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLubyte* pixelData = reinterpret_cast<GLubyte*>(m_PBOData[m_curIndex]);
|
GLubyte* pixelData = reinterpret_cast<GLubyte*>(m_PBOData[m_curIndex]);
|
||||||
|
|
|
@ -33,7 +33,7 @@ void ColorBufferReaderWithPixelBuffer::_initBuffers()
|
||||||
|
|
||||||
// Initialize Pixel Buffer Objects
|
// Initialize Pixel Buffer Objects
|
||||||
for (u32 i = 0; i < _numPBO; ++i) {
|
for (u32 i = 0; i < _numPBO; ++i) {
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[i]);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[i]));
|
||||||
glBufferData(GL_PIXEL_PACK_BUFFER, m_pTexture->textureBytes, nullptr, GL_DYNAMIC_READ);
|
glBufferData(GL_PIXEL_PACK_BUFFER, m_pTexture->textureBytes, nullptr, GL_DYNAMIC_READ);
|
||||||
}
|
}
|
||||||
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle::null);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle::null);
|
||||||
|
@ -58,11 +58,11 @@ u8 * ColorBufferReaderWithPixelBuffer::readPixels(s32 _x0, s32 _y0, u32 _width,
|
||||||
if (!_sync) {
|
if (!_sync) {
|
||||||
m_curIndex ^= 1;
|
m_curIndex ^= 1;
|
||||||
const u32 nextIndex = m_curIndex ^ 1;
|
const u32 nextIndex = m_curIndex ^ 1;
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[m_curIndex]);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[m_curIndex]));
|
||||||
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[nextIndex]);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[nextIndex]));
|
||||||
} else {
|
} else {
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBO[_numPBO - 1]);
|
m_bindBuffer->bind(Parameter(GL_PIXEL_PACK_BUFFER), ObjectHandle(m_PBO[_numPBO -1]));
|
||||||
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ graphics::PixelReadBuffer * ContextImpl::createPixelReadBuffer(size_t _sizeInByt
|
||||||
|
|
||||||
graphics::ColorBufferReader * ContextImpl::createColorBufferReader(CachedTexture * _pTexture)
|
graphics::ColorBufferReader * ContextImpl::createColorBufferReader(CachedTexture * _pTexture)
|
||||||
{
|
{
|
||||||
if (m_glInfo.bufferStorage)
|
if (m_glInfo.bufferStorage && m_glInfo.renderer != Renderer::Intel)
|
||||||
return new ColorBufferReaderWithBufferStorage(_pTexture, m_cachedFunctions->getCachedBindBuffer());
|
return new ColorBufferReaderWithBufferStorage(_pTexture, m_cachedFunctions->getCachedBindBuffer());
|
||||||
|
|
||||||
if (!m_glInfo.isGLES2)
|
if (!m_glInfo.isGLES2)
|
||||||
|
|
|
@ -29,6 +29,8 @@ void GLInfo::init() {
|
||||||
renderer = Renderer::Adreno;
|
renderer = Renderer::Adreno;
|
||||||
else if (strstr((const char*)strRenderer, "VideoCore IV") != nullptr)
|
else if (strstr((const char*)strRenderer, "VideoCore IV") != nullptr)
|
||||||
renderer = Renderer::VideoCore;
|
renderer = Renderer::VideoCore;
|
||||||
|
else if (strstr((const char*)strRenderer, "Intel") != nullptr)
|
||||||
|
renderer = Renderer::Intel;
|
||||||
LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer);
|
LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer);
|
||||||
|
|
||||||
int numericVersion = majorVersion * 10 + minorVersion;
|
int numericVersion = majorVersion * 10 + minorVersion;
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace opengl {
|
||||||
enum class Renderer {
|
enum class Renderer {
|
||||||
Adreno,
|
Adreno,
|
||||||
VideoCore,
|
VideoCore,
|
||||||
|
Intel,
|
||||||
Other
|
Other
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user