diff options
author | David 'Digit' Turner <digit@google.com> | 2014-10-31 11:16:11 +0100 |
---|---|---|
committer | bohu <bohu@google.com> | 2014-11-25 12:31:48 -0800 |
commit | c8f4ebe81beb0ee0a10d466bc5559fc0d9c783e8 (patch) | |
tree | 4239198280df6b6898e6cedd7028b407abf705ae | |
parent | 4425a99e305e9bd4a64a46ed7ce91396619e090e (diff) | |
download | sdk-c8f4ebe81beb0ee0a10d466bc5559fc0d9c783e8.zip sdk-c8f4ebe81beb0ee0a10d466bc5559fc0d9c783e8.tar.gz sdk-c8f4ebe81beb0ee0a10d466bc5559fc0d9c783e8.tar.bz2 |
emulator/opengl/emugen: Add new 'flushOnEncode' entry point flag.
This adds a new flag that can be applied to entry points for 'emugen',
named 'flushOnEncode'. When used, the generated encoder will call
stream->flush() just after adding bytes to the stream.
This is needed to match the manual change that was performed in
the renderControl encoder in the following patch:
https://android-review.googlesource.com/#/c/95864/
Change-Id: I8cc8fdb0d38ef27e8ba646c83d717166400babfd
22 files changed, 71 insertions, 2 deletions
diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib b/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib index 8b9972f..0afa9d3 100644 --- a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib +++ b/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib @@ -39,3 +39,6 @@ rcUpdateColorBuffer dir pixels in len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) var_flag pixels isLarge + +rcCloseColorBuffer + flag flushOnEncode diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp index b3e4c34..8be0270 100644 --- a/emulator/opengl/host/tools/emugen/ApiGen.cpp +++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp @@ -630,15 +630,21 @@ int ApiGen::genEncoderImpl(const std::string &filename) } } //XXX fprintf(fp, "\n\tDBG(\"<<<< %s\\n\");\n", e->name().c_str()); + // todo - return value for pointers if (e->retval().isPointer()) { fprintf(stderr, "WARNING: %s : return value of pointer is unsupported\n", e->name().c_str()); + if (e->flushOnEncode()) { + fprintf(fp, "\tstream->flush();\n"); + } fprintf(fp, "\t return NULL;\n"); } else if (e->retval().type()->name() != "void") { fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str()); fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes()); fprintf(fp, "\treturn retval;\n"); + } else if (e->flushOnEncode()) { + fprintf(fp, "\tstream->flush();\n"); } fprintf(fp, "}\n\n"); } diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.cpp b/emulator/opengl/host/tools/emugen/EntryPoint.cpp index 43b904b..55b30cf 100644 --- a/emulator/opengl/host/tools/emugen/EntryPoint.cpp +++ b/emulator/opengl/host/tools/emugen/EntryPoint.cpp @@ -35,6 +35,7 @@ void EntryPoint::reset() m_unsupported = false; m_customDecoder = false; m_notApi = false; + m_flushOnEncode = false; m_vars.empty(); } @@ -365,6 +366,8 @@ int EntryPoint::setAttribute(const std::string &line, size_t lc) setCustomDecoder(true); } else if (flag == "not_api") { setNotApi(true); + } else if (flag == "flushOnEncode") { + setFlushOnEncode(true); } else { fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str()); } diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.h b/emulator/opengl/host/tools/emugen/EntryPoint.h index 77b8a7f..1061d25 100644 --- a/emulator/opengl/host/tools/emugen/EntryPoint.h +++ b/emulator/opengl/host/tools/emugen/EntryPoint.h @@ -47,6 +47,8 @@ public: void setCustomDecoder(bool state) { m_customDecoder = state; } bool notApi() const { return m_notApi; } void setNotApi(bool state) { m_notApi = state; } + bool flushOnEncode() const { return m_flushOnEncode; } + void setFlushOnEncode(bool state) { m_flushOnEncode = state; } int setAttribute(const std::string &line, size_t lc); private: @@ -57,6 +59,7 @@ private: bool m_unsupported; bool m_customDecoder; bool m_notApi; + bool m_flushOnEncode; void err(unsigned int lc, const char *msg) { fprintf(stderr, "line %d: %s\n", lc, msg); diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp index 1f904cf..d56653f 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp @@ -70,6 +70,13 @@ size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream) SET_LASTCALL("fooUnsupported"); break; } + case OP_fooDoEncoderFlush: { + FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8); + DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param); + this->fooDoEncoderFlush(var_param); + SET_LASTCALL("fooDoEncoderFlush"); + break; + } default: unknownOpcode = true; } //switch diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h index 8a73ca7..154f2e1 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h @@ -6,7 +6,8 @@ #define OP_fooAlphaFunc 200 #define OP_fooIsBuffer 201 #define OP_fooUnsupported 202 -#define OP_last 203 +#define OP_fooDoEncoderFlush 203 +#define OP_last 204 #endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp index 7258565..e310e2f 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp @@ -13,6 +13,7 @@ int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData); fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData); fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData); return 0; } diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h index 666143a..3cc0fd5 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h @@ -11,6 +11,7 @@ struct foo_server_context_t { fooAlphaFunc_server_proc_t fooAlphaFunc; fooIsBuffer_server_proc_t fooIsBuffer; fooUnsupported_server_proc_t fooUnsupported; + fooDoEncoderFlush_server_proc_t fooDoEncoderFlush; virtual ~foo_server_context_t() {} int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); }; diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h index 2444068..e67ea2a 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h @@ -12,6 +12,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat); typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*); typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt); #endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp index 1bc2e1e..70a5f64 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp @@ -13,6 +13,7 @@ int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData); fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData); fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData); return 0; } diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h index bf98845..2dfc76a 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h @@ -11,6 +11,7 @@ struct foo_client_context_t { fooAlphaFunc_client_proc_t fooAlphaFunc; fooIsBuffer_client_proc_t fooIsBuffer; fooUnsupported_client_proc_t fooUnsupported; + fooDoEncoderFlush_client_proc_t fooDoEncoderFlush; virtual ~foo_client_context_t() {} typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void); diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h index 6b8f211..d39b73a 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h @@ -12,6 +12,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat); typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*); typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt); #endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp index a87c3d8..5e1758e 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp @@ -54,6 +54,22 @@ FooBoolean fooIsBuffer_enc(void *self , void* stuff) return retval; } +void fooDoEncoderFlush_enc(void *self , FooInt param) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + + unsigned char *ptr; + const size_t packetSize = 8 + 4; + ptr = stream->alloc(packetSize); + int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &packetSize, 4); ptr += 4; + + memcpy(ptr, ¶m, 4); ptr += 4; + stream->flush(); +} + } // namespace foo_encoder_context_t::foo_encoder_context_t(IOStream *stream) @@ -63,5 +79,6 @@ foo_encoder_context_t::foo_encoder_context_t(IOStream *stream) this->fooAlphaFunc = &fooAlphaFunc_enc; this->fooIsBuffer = &fooIsBuffer_enc; this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported; + this->fooDoEncoderFlush = &fooDoEncoderFlush_enc; } diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp index 78b78ba..697f143 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp @@ -9,6 +9,7 @@ extern "C" { void fooAlphaFunc(FooInt func, FooFloat ref); FooBoolean fooIsBuffer(void* stuff); void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); }; #endif @@ -37,3 +38,9 @@ void fooUnsupported(void* params) ctx->fooUnsupported(ctx, params); } +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush(ctx, param); +} + diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h index abf16ad..cba476b 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h @@ -11,6 +11,7 @@ static const struct _foo_funcs_by_name { {"fooAlphaFunc", (void*)fooAlphaFunc}, {"fooIsBuffer", (void*)fooIsBuffer}, {"fooUnsupported", (void*)fooUnsupported}, + {"fooDoEncoderFlush", (void*)fooDoEncoderFlush}, }; static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name); diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h index 8a73ca7..154f2e1 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h @@ -6,7 +6,8 @@ #define OP_fooAlphaFunc 200 #define OP_fooIsBuffer 201 #define OP_fooUnsupported 202 -#define OP_last 203 +#define OP_fooDoEncoderFlush 203 +#define OP_last 204 #endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp index 7e2d3f0..46eb6ce 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp @@ -13,6 +13,7 @@ int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, voi fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData); fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData); fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData); return 0; } diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h index 047b686..166be44 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h @@ -11,6 +11,7 @@ struct foo_wrapper_context_t { fooAlphaFunc_wrapper_proc_t fooAlphaFunc; fooIsBuffer_wrapper_proc_t fooIsBuffer; fooUnsupported_wrapper_proc_t fooUnsupported; + fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush; virtual ~foo_wrapper_context_t() {} typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void); diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp index 8edf677..2e32e9c 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp @@ -9,6 +9,7 @@ extern "C" { void fooAlphaFunc(FooInt func, FooFloat ref); FooBoolean fooIsBuffer(void* stuff); void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); }; #endif @@ -36,3 +37,9 @@ void fooUnsupported(void* params) ctx->fooUnsupported( params); } +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush( param); +} + diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h index 8c707d0..2fafa24 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h +++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h @@ -12,6 +12,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat); typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*); typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt); #endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib index 14715ed..80644d8 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib +++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib @@ -10,3 +10,6 @@ fooIsBuffer fooUnsupported dir params in flag unsupported + +fooDoEncoderFlush + flag flushOnEncode diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in index 178a6b4..e61fe57 100644 --- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in +++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in @@ -1,3 +1,4 @@ FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref) FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff) FOO_ENTRY(void, fooUnsupported, void* params) +FOO_ENTRY(void, fooDoEncoderFlush, FooInt param) |