mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
FIx EGL image compatibility with mali devices
This commit is contained in:
parent
4c87af5975
commit
462dd2a9bc
|
@ -81,9 +81,12 @@ void ColorBufferToRDRAM::_initFBTexture(void)
|
|||
m_pTexture->height = VI_GetMaxBufferHeight(m_lastBufferWidth);
|
||||
m_pTexture->textureBytes = m_pTexture->width * m_pTexture->height * fbTexFormat.colorFormatBytes;
|
||||
|
||||
TextureTargetParam target = Context::EglImage ? textureTarget::TEXTURE_EXTERNAL : textureTarget::TEXTURE_2D;
|
||||
|
||||
{
|
||||
Context::InitTextureParams params;
|
||||
params.handle = m_pTexture->name;
|
||||
params.target = target;
|
||||
params.width = m_pTexture->width;
|
||||
params.height = m_pTexture->height;
|
||||
params.internalFormat = fbTexFormat.colorInternalFormat;
|
||||
|
@ -94,7 +97,7 @@ void ColorBufferToRDRAM::_initFBTexture(void)
|
|||
{
|
||||
Context::TexParameters params;
|
||||
params.handle = m_pTexture->name;
|
||||
params.target = textureTarget::TEXTURE_2D;
|
||||
params.target = target;
|
||||
params.textureUnitIndex = textureIndices::Tex[0];
|
||||
params.minFilter = textureParameters::FILTER_LINEAR;
|
||||
params.magFilter = textureParameters::FILTER_LINEAR;
|
||||
|
@ -105,7 +108,7 @@ void ColorBufferToRDRAM::_initFBTexture(void)
|
|||
bufTarget.bufferHandle = ObjectHandle(m_FBO);
|
||||
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||
bufTarget.textureTarget = textureTarget::TEXTURE_2D;
|
||||
bufTarget.textureTarget = target;
|
||||
bufTarget.textureHandle = m_pTexture->name;
|
||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ bool Context::IntegerTextures = false;
|
|||
bool Context::ClipControl = false;
|
||||
bool Context::FramebufferFetch = false;
|
||||
bool Context::TextureBarrier = false;
|
||||
bool Context::EglImage = false;
|
||||
|
||||
Context::Context() {}
|
||||
|
||||
|
@ -38,6 +39,7 @@ void Context::init()
|
|||
ClipControl = m_impl->isSupported(SpecialFeatures::ClipControl);
|
||||
FramebufferFetch = m_impl->isSupported(SpecialFeatures::FramebufferFetch);
|
||||
TextureBarrier = m_impl->isSupported(SpecialFeatures::TextureBarrier);
|
||||
EglImage = m_impl->isSupported(SpecialFeatures::EglImage);
|
||||
}
|
||||
|
||||
void Context::destroy()
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace graphics {
|
|||
IntegerTextures,
|
||||
ClipControl,
|
||||
FramebufferFetch,
|
||||
TextureBarrier
|
||||
TextureBarrier,
|
||||
EglImage
|
||||
};
|
||||
|
||||
enum class ClampMode {
|
||||
|
@ -84,6 +85,7 @@ namespace graphics {
|
|||
struct InitTextureParams {
|
||||
ObjectHandle handle;
|
||||
TextureUnitParam textureUnitIndex{0};
|
||||
TextureTargetParam target = textureTarget::TEXTURE_2D;
|
||||
u32 msaaLevel = 0;
|
||||
u32 width = 0;
|
||||
u32 height = 0;
|
||||
|
@ -291,6 +293,7 @@ namespace graphics {
|
|||
static bool ClipControl;
|
||||
static bool FramebufferFetch;
|
||||
static bool TextureBarrier;
|
||||
static bool EglImage;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ContextImpl> m_impl;
|
||||
|
|
|
@ -328,6 +328,8 @@ void initGLFunctions();
|
|||
#define glDisablei(...) opengl::FunctionWrapper::wrDisablei(__VA_ARGS__)
|
||||
#define glEGLImageTargetTexture2DOES(...) opengl::FunctionWrapper::wrEGLImageTargetTexture2DOES(__VA_ARGS__)
|
||||
|
||||
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||
|
||||
#include "Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h"
|
||||
|
||||
#endif // GLFUNCTIONS_H
|
||||
|
|
|
@ -42,12 +42,12 @@ bool GraphicBufferWrapper::isPublicSupportAvailable() {
|
|||
return apiLevel >= 26;
|
||||
}
|
||||
|
||||
void GraphicBufferWrapper::allocate(const AHardwareBuffer_Desc *desc) {
|
||||
bool GraphicBufferWrapper::allocate(const AHardwareBuffer_Desc *desc) {
|
||||
|
||||
if (m_private) {
|
||||
m_privateGraphicBuffer->reallocate(desc->width, desc->height, desc->format, desc->usage);
|
||||
return m_privateGraphicBuffer->reallocate(desc->width, desc->height, desc->format, desc->usage);
|
||||
} else {
|
||||
AndroidHardwareBufferCompat::GetInstance().Allocate(desc, &m_publicGraphicBuffer);
|
||||
return AndroidHardwareBufferCompat::GetInstance().Allocate(desc, &m_publicGraphicBuffer) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
static bool isPublicSupportAvailable();
|
||||
|
||||
void allocate(const AHardwareBuffer_Desc* desc);
|
||||
bool allocate(const AHardwareBuffer_Desc* desc);
|
||||
int lock(uint64_t usage, void** out_virtual_address);
|
||||
void release();
|
||||
void unlock();
|
||||
|
|
|
@ -80,10 +80,10 @@ AndroidHardwareBufferCompat &AndroidHardwareBufferCompat::GetInstance() {
|
|||
return compat;
|
||||
}
|
||||
|
||||
void AndroidHardwareBufferCompat::Allocate(const AHardwareBuffer_Desc *desc,
|
||||
int AndroidHardwareBufferCompat::Allocate(const AHardwareBuffer_Desc *desc,
|
||||
AHardwareBuffer **out_buffer) {
|
||||
DCHECK(IsSupportAvailable());
|
||||
allocate_(desc, out_buffer);
|
||||
return allocate_(desc, out_buffer);
|
||||
}
|
||||
|
||||
void AndroidHardwareBufferCompat::Acquire(AHardwareBuffer *buffer) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "dcheck.h"
|
||||
|
||||
extern "C" {
|
||||
using PFAHardwareBuffer_allocate = void (*)(const AHardwareBuffer_Desc *desc,
|
||||
using PFAHardwareBuffer_allocate = int (*)(const AHardwareBuffer_Desc *desc,
|
||||
AHardwareBuffer **outBuffer) ;
|
||||
using PFAHardwareBuffer_acquire = void (*)(AHardwareBuffer *buffer) ;
|
||||
using PFAHardwareBuffer_describe = void (*)(const AHardwareBuffer *buffer,
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
static bool IsSupportAvailable();
|
||||
static AndroidHardwareBufferCompat& GetInstance();
|
||||
|
||||
void Allocate(const AHardwareBuffer_Desc* desc, AHardwareBuffer** outBuffer);
|
||||
int Allocate(const AHardwareBuffer_Desc* desc, AHardwareBuffer** outBuffer);
|
||||
void Acquire(AHardwareBuffer* buffer);
|
||||
void Describe(const AHardwareBuffer* buffer, AHardwareBuffer_Desc* outDesc);
|
||||
int Lock(AHardwareBuffer* buffer,
|
||||
|
|
|
@ -11,7 +11,7 @@ ColorBufferReaderWithEGLImage::ColorBufferReaderWithEGLImage(CachedTexture *_pTe
|
|||
: graphics::ColorBufferReader(_pTexture)
|
||||
, m_bindTexture(_bindTexture)
|
||||
, m_image(nullptr)
|
||||
, m_usage(AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN)
|
||||
, m_usage(AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN|AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE)
|
||||
, m_bufferLocked(false)
|
||||
{
|
||||
_initBuffers();
|
||||
|
@ -48,11 +48,10 @@ const u8 * ColorBufferReaderWithEGLImage::_readPixels(const ReadColorBufferParam
|
|||
void* gpuData = nullptr;
|
||||
|
||||
if (!_params.sync) {
|
||||
m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_2D), m_pTexture->name);
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
|
||||
m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_2D), ObjectHandle());
|
||||
|
||||
m_hardwareBuffer.lock(m_usage, &gpuData);
|
||||
m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_EXTERNAL_OES), m_pTexture->name);
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, m_image);
|
||||
m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_EXTERNAL_OES), ObjectHandle());
|
||||
m_hardwareBuffer.lock(AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN, &gpuData);
|
||||
m_bufferLocked = true;
|
||||
_heightOffset = static_cast<u32>(_params.y0);
|
||||
_stride = m_pTexture->width;
|
||||
|
|
|
@ -499,6 +499,8 @@ bool ContextImpl::isSupported(graphics::SpecialFeatures _feature) const
|
|||
return m_glInfo.ext_fetch;
|
||||
case graphics::SpecialFeatures::TextureBarrier:
|
||||
return m_glInfo.texture_barrier || m_glInfo.texture_barrierNV;
|
||||
case graphics::SpecialFeatures::EglImage:
|
||||
return m_glInfo.eglImage;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace graphics {
|
|||
TextureTargetParam TEXTURE_2D(GL_TEXTURE_2D);
|
||||
TextureTargetParam TEXTURE_2D_MULTISAMPLE(GL_TEXTURE_2D_MULTISAMPLE);
|
||||
TextureTargetParam RENDERBUFFER(GL_RENDERBUFFER);
|
||||
TextureTargetParam TEXTURE_EXTERNAL(GL_TEXTURE_EXTERNAL_OES);
|
||||
}
|
||||
|
||||
namespace bufferTarget {
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace opengl {
|
|||
void init2DTexture(const graphics::Context::InitTextureParams & _params) override
|
||||
{
|
||||
if (_params.msaaLevel == 0) {
|
||||
m_bind->bind(_params.textureUnitIndex, graphics::textureTarget::TEXTURE_2D, _params.handle);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
m_bind->bind(_params.textureUnitIndex, _params.target, _params.handle);
|
||||
glTexImage2D(GLuint(_params.target),
|
||||
_params.mipMapLevel,
|
||||
GLuint(_params.internalFormat),
|
||||
_params.width,
|
||||
|
@ -104,10 +104,10 @@ namespace opengl {
|
|||
void init2DTexture(const graphics::Context::InitTextureParams & _params) override
|
||||
{
|
||||
if (_params.msaaLevel == 0) {
|
||||
m_bind->bind(_params.textureUnitIndex, graphics::textureTarget::TEXTURE_2D, _params.handle);
|
||||
m_bind->bind(_params.textureUnitIndex, _params.target, _params.handle);
|
||||
if (m_handle != _params.handle) {
|
||||
m_handle = _params.handle;
|
||||
glTexStorage2D(GL_TEXTURE_2D,
|
||||
glTexStorage2D(GLuint(_params.target),
|
||||
_params.mipMapLevels,
|
||||
GLenum(_params.internalFormat),
|
||||
_params.width,
|
||||
|
@ -115,7 +115,7 @@ namespace opengl {
|
|||
}
|
||||
|
||||
if (_params.data != nullptr) {
|
||||
glTexSubImage2D(GL_TEXTURE_2D,
|
||||
glTexSubImage2D(GLuint(_params.target),
|
||||
_params.mipMapLevel,
|
||||
0, 0,
|
||||
_params.width,
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace graphics {
|
|||
extern TextureTargetParam TEXTURE_2D;
|
||||
extern TextureTargetParam TEXTURE_2D_MULTISAMPLE;
|
||||
extern TextureTargetParam RENDERBUFFER;
|
||||
extern TextureTargetParam TEXTURE_EXTERNAL;
|
||||
}
|
||||
|
||||
namespace bufferTarget {
|
||||
|
|
Loading…
Reference in New Issue
Block a user