am 23a491dc: Merge "emulator opengl: renderControl API encoder/decoder"

* commit '23a491dccdc8c294af2ecd0602d10da9f2707ac1':
  emulator opengl: renderControl API encoder/decoder
This commit is contained in:
David Turner
2011-04-15 07:08:25 -07:00
committed by Android Git Automerger
7 changed files with 264 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
LOCAL_PATH := $(call my-dir)
### renderControl Decoder ###########################################
include $(CLEAR_VARS)
emulatorOpengl := $(LOCAL_PATH)/../../..
EMUGEN := $(BUILD_OUT_EXECUTABLES)/emugen
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := lib_renderControl_dec
LOCAL_SRC_FILES :=
#LOCAL_CFLAGS += -DDEBUG_PRINTOUT -O0 -g
intermediates := $(local-intermediates-dir)
LOCAL_STATIC_LIBRARIES := \
libOpenglCodecCommon \
liblog
LOCAL_C_INCLUDES += $(emulatorOpengl)/shared/OpenglCodecCommon \
$(emulatorOpengl)/host/include/libOpenglRender \
$(emulatorOpengl)/system/renderControl_enc
#we use only *_dec.h as a sentinel for the other generated headers
GEN := $(intermediates)/renderControl_dec.cpp $(intermediates)/renderControl_dec.h
$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN): PRIVATE_CUSTOM_TOOL := $(EMUGEN) -D $(intermediates) -i $(emulatorOpengl)/system/renderControl_enc renderControl
$(GEN): $(EMUGEN) \
$(emulatorOpengl)/system/renderControl_enc/renderControl.attrib \
$(emulatorOpengl)/system/renderControl_enc/renderControl.in \
$(emulatorOpengl)/system/renderControl_enc/renderControl.types
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_HOST_SHARED_LIBRARY)

View File

@@ -0,0 +1,38 @@
LOCAL_PATH := $(call my-dir)
emulatorOpengl := $(LOCAL_PATH)/../..
EMUGEN := $(HOST_OUT_EXECUTABLES)/emugen
#### renderControl ####
include $(CLEAR_VARS)
LOCAL_SRC_FILES :=
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := lib_renderControl_enc
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
rc_intermediates := $(local-intermediates-dir)
LOCAL_C_INCLUDES += $(emulatorOpengl)/shared/OpenglCodecCommon \
$(emulatorOpengl)/host/include/libOpenglRender
LOCAL_STATIC_LIBRARIES := \
libOpenglCodecCommon
LOCAL_SHARED_LIBRARIES := libcutils
RC_GEN := \
$(rc_intermediates)/renderControl_enc.cpp \
$(rc_intermediates)/renderControl_enc.h
$(RC_GEN) : PRIVATE_PATH = $(LOCAL_PATH)
$(RC_GEN) : PRIVATE_CUSTOM_TOOL := \
$(EMUGEN) -i $(PRIVATE_PATH) -E $(rc_intermediates) renderControl
$(RC_GEN) : $(EMUGEN) \
$(LOCAL_PATH)/renderControl.in \
$(LOCAL_PATH)/renderControl.attrib \
$(LOCAL_PATH)/renderControl.types
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(RC_GEN)
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1,118 @@
The renderControl.in file in this directory defines an API which is decoded
on the android guest into a stream and get decoded and executed on the host.
It is used in order to query the host renderer as well as send the host renderer
control commands.
The following describes each of the entries defined by this renderControl API.
GLint rcGetRendererVersion();
This function queries the host renderer version number.
EGLint rcGetEGLVersion(EGLint* major, EGLint* minor);
This function queries the host renderer for the EGL version
it supports. returns EGL_FALSE on failure.
EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize);
This function queries the host for EGL string (.i.e EGL_EXTENSIONS).
if buffer is NULL or the bufferSize is not big enough the return value
is the negative number of bytes required to store the string value
otherwise the string value is copied to buffer and its size is
returned.
EGLint rcGetNumConfigs(uint32_t* numAttribs);
queries the host for the number of supported EGL configs.
The function returns the number of supported configs and returns in
numAttribs the number of attributes available for each config.
EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer);
This function queries the host for the all set of supported configs
with their attribute values.
bufSize is the size of buffer, the size should be at least equal to
(numConfigs + 1) * numAttribs * sizeof(GLuint)
where numConfigs and numAttribs are the values returned in
rcGetNumConfigs. if bufSize is not big enough then the negative number
of required bytes is returned otherwise the function returns the number
of configs and buffer is filled as follows: The first 'numAttribs'
integer values are filled with the EGL enumerant describing a config
attribute, next for each config there are 'numAttribs' integer values
holding the attribute values for that config, the values are specified
in the same order as the attribute vector.
EGLint rcGetFBParam(EGLint param);
queries the host for framebuffer parameter, see renderControl_types.h
for possible values of 'param'.
uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion);
This function creates a rendering context on the host and returns its
handle. config is the config index for the context, share is either zero
or a handle to a sharing context. glVersion is either 1 or 2 for GLES1
or GLES2 context respectively.
void rcDestroyContext(uint32_t context);
This function destroys a rendering context on the host.
context is a handle returned in rcCreateContext.
uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height);
This function creates a 'window' surface on the host which can be then
bind for rendering through rcMakeCurrent.
The function returns a handle to the created window surface.
void rcDestroyWindowSurface(uint32_t windowSurface);
This function destoys a window surface.
uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat);
This function creates a colorBuffer object on the host which can be then
be specified as a render target for a window surface through
rcSetWindowColorBuffer or to be displayed on the framebuffer window
through rcFBPost.
The function returns a handle to the colorBuffer object.
void rcDestroyColorBuffer(uint32_t colorbuffer);
destroyes a colorBuffer object.
void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
This set the target color buffer for a windowSurface, when set the
previous target colorBuffer gets updated before switching to the new
colorBuffer.
EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf);
Binds a windowSurface(s) and current rendering context for the
calling thread.
void rcFBPost(uint32_t colorBuffer);
This function causes the content of the colorBuffer object to be
displayed on the host framebuffer window. The function returns
immediatly, the buffer will be displayed at the next swap interval.
void rcFBSetSwapInterval(EGLint interval);
Sets the swap interval for the host framebuffer window.
void rcBindTexture(uint32_t colorBuffer);
This function instruct the host to bind the content of the specified
colorBuffer to the current binded texture object of the calling thread.
This function should be used to implement eglBindTexImage.
EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead);
This function returns only after all rendering requests for the specified
colorBuffer rendering target has been processed and after all 'postCount'
posts for the buffer requested previously through rcFBPost has been
processed.
if 'forRead' is not-zero, the function returns positive value in case
there was rendering done to the buffer since the last CacheFlush request
with non-zero 'forRead' value, otherwise the function returns zero or
negative value on failure.
void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y,
GLint width, GLint height, GLenum format,
GLenum type, void* pixels);
This function queries the host for the pixel content of a colorBuffer's
subregion. It act the same as OpenGL glReadPixels however pixels
are always packed with alignment of 1.
void rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y,
GLint width, GLint height, GLenum format,
GLenum type, void* pixels);
Updates the content of a subregion of a colorBuffer object.
pixels are always unpacked with alignment of 1.

View File

@@ -0,0 +1,29 @@
GLOBAL
base_opcode 10000
encoder_headers <stdint.h> <EGL/egl.h> "glUtils.h"
rcGetEGLVersion
dir major out
len major sizeof(EGLint)
dir minor out
len minor sizeof(EGLint)
rcQueryEGLString
dir buffer out
len buffer bufferSize
rcGetNumConfigs
dir numAttribs out
len numAttribs sizeof(uint32_t)
rcGetConfigs
dir buffer out
len buffer bufSize
rcReadColorBuffer
dir pixels out
len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
rcUpdateColorBuffer
dir pixels in
len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)

View File

@@ -0,0 +1,20 @@
GL_ENRTY(GLint, rcGetRendererVersion)
GL_ENTRY(EGLint, rcGetEGLVersion, EGLint *major, EGLint *minor)
GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize)
GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs)
GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer)
GL_ENTRY(EGLint, rcGetFBParam, EGLint param)
GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion)
GL_ENTRY(void, rcDestroyContext, uint32_t context)
GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height)
GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface)
GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat)
GL_ENTRY(void, rcDestroyColorBuffer, uint32_t colorbuffer)
GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer)
GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf)
GL_ENTRY(void, rcFBPost, uint32_t colorBuffer)
GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval)
GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer)
GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
GL_ENTRY(void, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)

View File

@@ -0,0 +1,11 @@
uint32_t 32 0x%08x false
EGLint 32 0x%08x false
GLint 32 0x%08x false
GLuint 32 0x%08x false
GLenum 32 0x%08x false
EGLenum 32 0x%08x false
uint32_t* 32 0x%08x true
EGLint* 32 0x%08x true
GLint* 32 0x%08x true
GLuint* 32 0x%08x true
void* 32 0x%08x true

View File

@@ -0,0 +1,12 @@
#include <stdint.h>
#include <EGL/egl.h>
#include "glUtils.h"
// values for 'param' argument of rcGetFBParam
#define FB_WIDTH 1
#define FB_HEIGHT 2
#define FB_XDPI 3
#define FB_YDPI 4
#define FB_FPS 5
#define FB_MIN_SWAP_INTERVAL 6
#define FB_MAX_SWAP_INTERVAL 7