mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Implement generic copy color to RDRAM for GLES2 devices
Async copy is not supported for GLES2 devices unless using EGL Image extension which has platform independent implementations
This commit is contained in:
parent
2483903b74
commit
0e8e71639b
|
@ -308,6 +308,7 @@
|
|||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_CachedFunctions.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithBufferStorage.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithPixelBuffer.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithReadPixels.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ContextImpl.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.cpp" />
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_Parameters.cpp" />
|
||||
|
@ -441,6 +442,7 @@
|
|||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_CachedFunctions.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithBufferStorage.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithPixelBuffer.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithReadPixels.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ContextImpl.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GLInfo.h" />
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GraphicsDrawer.h" />
|
||||
|
|
|
@ -332,6 +332,9 @@
|
|||
<ClCompile Include="..\..\src\TextDrawer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithReadPixels.cpp">
|
||||
<Filter>Source Files\Graphics\OpenGL</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\3DMath.h">
|
||||
|
@ -622,5 +625,8 @@
|
|||
<ClInclude Include="..\..\src\TextDrawer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_ColorBufferReaderWithReadPixels.h">
|
||||
<Filter>Header Files\Graphics\OpenGL</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,43 @@
|
|||
#include <Graphics/Context.h>
|
||||
#include "opengl_ColorBufferReaderWithReadPixels.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace graphics;
|
||||
using namespace opengl;
|
||||
|
||||
ColorBufferReaderWithReadPixels::ColorBufferReaderWithReadPixels(CachedTexture *_pTexture)
|
||||
: ColorBufferReader(_pTexture)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 * ColorBufferReaderWithReadPixels::readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync)
|
||||
{
|
||||
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
||||
GLenum colorFormat, colorType, colorFormatBytes;
|
||||
if (_size > G_IM_SIZ_8b) {
|
||||
colorFormat = GLenum(fbTexFormat.colorFormat);
|
||||
colorType = GLenum(fbTexFormat.colorType);
|
||||
colorFormatBytes = GLenum(fbTexFormat.colorFormatBytes);
|
||||
} else {
|
||||
colorFormat = GLenum(fbTexFormat.monochromeFormat);
|
||||
colorType = GLenum(fbTexFormat.monochromeType);
|
||||
colorFormatBytes = GLenum(fbTexFormat.monochromeFormatBytes);
|
||||
}
|
||||
|
||||
// No async pixel buffer copies are supported in this class, this is a last resort fallback
|
||||
auto pixelData = std::unique_ptr<GLubyte[]>(new GLubyte[m_pTexture->realWidth * _height * colorFormatBytes]) ;
|
||||
glReadPixels(_x0, _y0, m_pTexture->realWidth, _height, colorFormat, colorType, pixelData.get());
|
||||
|
||||
int widthBytes = _width*colorFormatBytes;
|
||||
int strideBytes = m_pTexture->realWidth * colorFormatBytes;
|
||||
|
||||
for (unsigned int lnIndex = 0; lnIndex < _height; ++lnIndex) {
|
||||
std::copy_n(pixelData.get() + (lnIndex*strideBytes), widthBytes, m_pixelData.data() + lnIndex*widthBytes);
|
||||
}
|
||||
return m_pixelData.data();
|
||||
}
|
||||
|
||||
void ColorBufferReaderWithReadPixels::cleanUp()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include <Graphics/ColorBufferReader.h>
|
||||
#include "opengl_CachedFunctions.h"
|
||||
|
||||
namespace opengl {
|
||||
|
||||
class ColorBufferReaderWithReadPixels :
|
||||
public graphics::ColorBufferReader
|
||||
{
|
||||
public:
|
||||
ColorBufferReaderWithReadPixels(CachedTexture * _pTexture);
|
||||
~ColorBufferReaderWithReadPixels() = default;
|
||||
|
||||
u8 * readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) override;
|
||||
void cleanUp() override;
|
||||
};
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
#include "opengl_ColorBufferReaderWithPixelBuffer.h"
|
||||
#include "opengl_ColorBufferReaderWithBufferStorage.h"
|
||||
//#include "opengl_ColorBufferReaderWithEGLImage.h"
|
||||
#include "opengl_ColorBufferReaderWithReadPixels.h"
|
||||
#include "opengl_Utils.h"
|
||||
#include "GLSL/glsl_CombinerProgramBuilder.h"
|
||||
#include "GLSL/glsl_SpecialShadersFactory.h"
|
||||
|
@ -297,14 +298,17 @@ graphics::PixelReadBuffer * ContextImpl::createPixelReadBuffer(size_t _sizeInByt
|
|||
graphics::ColorBufferReader * ContextImpl::createColorBufferReader(CachedTexture * _pTexture)
|
||||
{
|
||||
/*
|
||||
#ifdef EGL
|
||||
#if defined(EGL) && defined(OS_ANDROID)
|
||||
return new ColorBufferReaderWithEGLImage(_pTexture, m_cachedFunctions->getCachedBindTexture());
|
||||
#endif*/
|
||||
|
||||
if (m_glInfo.bufferStorage)
|
||||
return new ColorBufferReaderWithBufferStorage(_pTexture, m_cachedFunctions->getCachedBindBuffer());
|
||||
|
||||
return new ColorBufferReaderWithPixelBuffer(_pTexture, m_cachedFunctions->getCachedBindBuffer());
|
||||
if (!m_glInfo.isGLES2)
|
||||
return new ColorBufferReaderWithPixelBuffer(_pTexture, m_cachedFunctions->getCachedBindBuffer());
|
||||
|
||||
return new ColorBufferReaderWithReadPixels(_pTexture);
|
||||
}
|
||||
|
||||
/*---------------Shaders-------------*/
|
||||
|
|
|
@ -90,6 +90,7 @@ MY_LOCAL_SRC_FILES := \
|
|||
$(SRCDIR)/Graphics/OpenGLContext/opengl_CachedFunctions.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_ColorBufferReaderWithBufferStorage.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_ColorBufferReaderWithPixelBuffer.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_ColorBufferReaderWithReadPixels.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_ContextImpl.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_GLInfo.cpp \
|
||||
$(SRCDIR)/Graphics/OpenGLContext/opengl_Parameters.cpp \
|
||||
|
|
Loading…
Reference in New Issue
Block a user