diff --git a/shared/OpenglCodecCommon/GLSharedGroup.h b/shared/OpenglCodecCommon/GLSharedGroup.h index 8a35a89e194fc3b92e282c9b63bd4d8d99521372..9ef92ea9c6f5798ba64a38e497690a3295dd607c 100755 --- a/shared/OpenglCodecCommon/GLSharedGroup.h +++ b/shared/OpenglCodecCommon/GLSharedGroup.h @@ -39,7 +39,6 @@ #include <utils/threads.h> #include "FixedBuffer.h" #include "auto_goldfish_dma_context.h" -#include "goldfish_address_space.h" #include "IndexRangeCache.h" #include "SmartPtr.h" @@ -64,8 +63,6 @@ struct BufferData { // DMA support AutoGoldfishDmaContext dma_buffer; - // Direct memory access support - GoldfishAddressSpaceBlock shared_block; }; class ProgramData { diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h index ee4bd9a294175b2b29a5ba74a2d68df912daa8d7..bff33f380a188d60e3183a7d073cf81371b105ae 100644 --- a/shared/OpenglCodecCommon/gralloc_cb.h +++ b/shared/OpenglCodecCommon/gralloc_cb.h @@ -32,7 +32,6 @@ enum EmulatorFrameworkFormat { FRAMEWORK_FORMAT_GL_COMPATIBLE = 0, FRAMEWORK_FORMAT_YV12 = 1, FRAMEWORK_FORMAT_YUV_420_888 = 2, // (Y+)(U+)(V+) - FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED = 3, // (Y+)(UV)+ }; // diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp index d8ea74e29d19e77036ebf8f51b1b98ea58275410..44264d966ca58aa53e5427c45b52f99dcd22beeb 100755 --- a/system/GLESv2_enc/GL2Encoder.cpp +++ b/system/GLESv2_enc/GL2Encoder.cpp @@ -3041,42 +3041,6 @@ void* GL2Encoder::s_glMapBufferRange(void* self, GLenum target, GLintptr offset, buf->m_guest_paddr); return reinterpret_cast<void*>(buf->dma_buffer.get().mapped_addr); - } else if (ctx->hasExtension("ANDROID_EMU_direct_mem_v2")) { - GoldfishAddressSpaceBlock new_shared_block; - - if (new_shared_block.allocate(&ctx->m_goldfish_address_block_provider, length)) { - uint64_t gpu_addr = - ctx->glMapBufferRangeDirect(ctx, - target, - offset, - length, - access, - new_shared_block.physAddr()); - if (gpu_addr) { - void *user_ptr = new_shared_block.mmap(gpu_addr); - if (user_ptr) { - buf->shared_block.replace(&new_shared_block); - return user_ptr; - } else { - GLboolean host_res = GL_TRUE; - - ctx->glUnmapBufferDirect( - ctx, target, - offset, - length, - access, - new_shared_block.physAddr(), - gpu_addr, - &host_res); - - return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf); - } - } else { - return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf); - } - } else { - return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf); - } } else { return s_glMapBufferRangeAEMUImpl(ctx, target, offset, length, access, buf); } @@ -3119,23 +3083,6 @@ GLboolean GL2Encoder::s_glUnmapBuffer(void* self, GLenum target) { buf->m_mappedAccess, goldfish_dma_guest_paddr(&buf->dma_buffer.get()), &host_res); - } else if (buf->shared_block.guestPtr()) { - GoldfishAddressSpaceBlock *shared_block = &buf->shared_block; - - memcpy(static_cast<char*>(buf->m_fixedBuffer.ptr()) + buf->m_mappedOffset, - shared_block->guestPtr(), - buf->m_mappedLength); - - ctx->glUnmapBufferDirect( - ctx, target, - buf->m_mappedOffset, - buf->m_mappedLength, - buf->m_mappedAccess, - shared_block->physAddr(), - shared_block->hostAddr(), - &host_res); - - shared_block->replace(NULL); } else { ctx->glUnmapBufferAEMU( ctx, target, @@ -3176,20 +3123,12 @@ void GL2Encoder::s_glFlushMappedBufferRange(void* self, GLenum target, GLintptr buf->m_indexRangeCache.invalidateRange(totalOffset, length); - if (buf->shared_block.guestPtr()) { - ctx->glFlushMappedBufferRangeDirect( - ctx, target, - offset, - length, - buf->m_mappedAccess); - } else { - ctx->glFlushMappedBufferRangeAEMU( - ctx, target, - totalOffset, - length, - buf->m_mappedAccess, - (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset)); - } + ctx->glFlushMappedBufferRangeAEMU( + ctx, target, + totalOffset, + length, + buf->m_mappedAccess, + (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset)); } void GL2Encoder::s_glCompressedTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) { diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h index fc444c505e0224d62014579622f29007ec6e9168..c617a3663d888c631e07883668b7d760a1b0fd76 100644 --- a/system/GLESv2_enc/GL2Encoder.h +++ b/system/GLESv2_enc/GL2Encoder.h @@ -104,8 +104,6 @@ private: GLSharedGroupPtr m_shared; GLenum m_error; - GoldfishAddressSpaceBlockProvider m_goldfish_address_block_provider; - GLint *m_compressedTextureFormats; GLint m_num_compressedTextureFormats; GLint *getCompressedTextureFormats(); diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp index b0b510b70c6693b0a3dee38575e4d0ac79ab0a30..60d17e5b336a9d8991516a5121f12dd153e04c9b 100644 --- a/system/egl/egl.cpp +++ b/system/egl/egl.cpp @@ -920,7 +920,11 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) const char* eglQueryString(EGLDisplay dpy, EGLint name) { - VALIDATE_DISPLAY_INIT(dpy, NULL); + // EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is + // EGL_NO_DISPLAY and name is EGL_EXTENSIONS. + if (dpy || name != EGL_EXTENSIONS) { + VALIDATE_DISPLAY_INIT(dpy, NULL); + } return s_display.queryString(name); } diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp index d39d99ab807dcfa29d2ec17f493fd14a197f1e5d..e9140beb5a26a9eadcd66435913814ba97c5bd1d 100644 --- a/system/gralloc/gralloc.cpp +++ b/system/gralloc/gralloc.cpp @@ -479,6 +479,7 @@ static int gralloc_alloc(alloc_device_t* dev, bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK)); bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER); bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); + const bool hw_texture = usage & GRALLOC_USAGE_HW_TEXTURE; #if PLATFORM_SDK_VERSION >= 17 bool hw_cam_write = (usage & GRALLOC_USAGE_HW_CAMERA_WRITE); bool hw_cam_read = (usage & GRALLOC_USAGE_HW_CAMERA_READ); @@ -541,6 +542,15 @@ static int gralloc_alloc(alloc_device_t* dev, glFormat = GL_RGBA; glType = GL_UNSIGNED_BYTE; break; + case HAL_PIXEL_FORMAT_RGB_888: + if (hw_texture) { + return -EINVAL; // we dont support RGB_888 for HW textures + } else { + bpp = 3; + glFormat = GL_RGB; + glType = GL_UNSIGNED_BYTE; + break; + } case HAL_PIXEL_FORMAT_RGB_565: bpp = 2; // Workaround: distinguish vs the RGB8/RGBA8 @@ -613,13 +623,7 @@ static int gralloc_alloc(alloc_device_t* dev, // We are going to use RGB888 on the host glFormat = GL_RGB; glType = GL_UNSIGNED_BYTE; - - if (usage & (GRALLOC_USAGE_HW_CAMERA_READ | GRALLOC_USAGE_HW_CAMERA_WRITE)) { - // EmulatedFakeCamera3.cpp assumes it is NV21 - selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED; - } else { - selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888; - } + selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888; break; default: ALOGE("gralloc_alloc: Unknown format %d", format); @@ -1195,7 +1199,9 @@ static int gralloc_lock(gralloc_module_t const* module, return -EBUSY; } - if (sw_read) { + // camera delivers bits to the buffer directly and does not require + // an explicit read, it also writes in YUV_420 (interleaved) + if (sw_read & !(usage & GRALLOC_USAGE_HW_CAMERA_MASK)) { void* rgb_addr = cpu_addr; char* tmpBuf = 0; if (cb->frameworkFormat == HAL_PIXEL_FORMAT_YV12 || @@ -1319,8 +1325,10 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, return -EINVAL; } + usage |= (cb->usage & GRALLOC_USAGE_HW_CAMERA_MASK); + void *vaddr; - int ret = gralloc_lock(module, handle, usage | GRALLOC_USAGE_SW_WRITE_MASK, l, t, w, h, &vaddr); + int ret = gralloc_lock(module, handle, usage, l, t, w, h, &vaddr); if (ret) { return ret; } @@ -1357,7 +1365,7 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, cStep = 1; break; case HAL_PIXEL_FORMAT_YCbCr_420_888: - if (cb->emuFrameworkFormat == FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED) { + if (usage & GRALLOC_USAGE_HW_CAMERA_MASK) { yStride = cb->width; cStride = cb->width; yOffset = 0; @@ -1542,6 +1550,10 @@ struct private_module_t HAL_MODULE_INFO_SYM = { lock: gralloc_lock, unlock: gralloc_unlock, perform: NULL, +#if PLATFORM_SDK_VERSION >= 28 // In Q, we want to specify these, but SDK version is not 29 yet. do not merge this to P + validateBufferSize: NULL, + getTransportSize: NULL, +#endif // PLATFORM_VERSION > 28 #if PLATFORM_SDK_VERSION >= 18 lock_ycbcr: gralloc_lock_ycbcr, #endif // PLATFORM_SDK_VERSION >= 18