Initial work
This commit is contained in:
commit
3222551702
374 changed files with 40290 additions and 0 deletions
129
external/android-emugl/host/tools/emugen/tests/run-tests.sh
vendored
Executable file
129
external/android-emugl/host/tools/emugen/tests/run-tests.sh
vendored
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright 2014 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
PROGDIR=$(dirname "$0")
|
||||
PROGNAME=$(basename "$0")
|
||||
|
||||
fatal () {
|
||||
echo "ERROR: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
OPT_EMUGEN=
|
||||
OPT_HELP=
|
||||
OPT_OUT_DIR=
|
||||
OPT_TOOL=
|
||||
|
||||
for OPT; do
|
||||
OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
|
||||
case $OPT in
|
||||
--help|-h|-?)
|
||||
OPT_HELP=true
|
||||
;;
|
||||
--emugen=*)
|
||||
OPT_EMUGEN=$OPTARG
|
||||
;;
|
||||
--out-dir=*)
|
||||
OPT_OUT_DIR=$OPTARG
|
||||
;;
|
||||
--tool=*)
|
||||
OPT_TOOL=$OPTARG
|
||||
;;
|
||||
-*)
|
||||
fatal "Invalid option '$OPT', see --help."
|
||||
;;
|
||||
*)
|
||||
fatal "This script doesn't take arguments, see --help."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$OPT_HELP" ]; then
|
||||
cat <<EOF
|
||||
Usage: $PROGNAME [options]
|
||||
|
||||
Run the emugen test suite. This scripts looks for sub-directories
|
||||
named t.<number>/input, and uses them as input to 'emugen'. It then
|
||||
compares the output to t.<number>/expected/ content.
|
||||
|
||||
Valid options:
|
||||
--help|-h|-? Print this help.
|
||||
--out-dir=<dir> Generate outputs into <dir>.
|
||||
--emugen=<program> Emugen program path, if not in path.
|
||||
--tool=<tool> Launch visual diff tool in case of differences.
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find emugen program
|
||||
EMUGEN=
|
||||
if [ "$OPT_EMUGEN" ]; then
|
||||
EMUGEN=$OPT_EMUGEN
|
||||
else
|
||||
EMUGEN=$(which emugen 2>/dev/null || true)
|
||||
if [ -z "$EMUGEN" ]; then
|
||||
fatal "Cannot find 'emugen' program in PATH, use --emugen=<program> option."
|
||||
fi
|
||||
echo "Auto-config: --emugen=$EMUGEN"
|
||||
fi
|
||||
if [ ! -f "$EMUGEN" ]; then
|
||||
fatal "Emugen program doesn't exist: $EMUGEN"
|
||||
fi
|
||||
|
||||
# Create output directory.
|
||||
OUT_DIR=
|
||||
if [ "$OPT_OUT_DIR" ]; then
|
||||
OUT_DIR=$OPT_OUT_DIR
|
||||
else
|
||||
OUT_DIR=/tmp/$USER-emugen-testing
|
||||
echo "Auto-config: --out-dir=$OUT_DIR"
|
||||
fi
|
||||
mkdir -p "$OUT_DIR" && rm -rf "$OUT_DIR/emugen"
|
||||
|
||||
OUT_DIR=$OUT_DIR/emugen
|
||||
|
||||
# Find test directories
|
||||
TEST_DIRS=$(cd "$PROGDIR" && find . -name "t.*" | sed -e 's|^\./||')
|
||||
for TEST_DIR in $TEST_DIRS; do
|
||||
IN=$PROGDIR/$TEST_DIR/input
|
||||
PREFIXES=$(cd $IN && find . -name "*.in" | sed -e 's|^\./||g' -e 's|\.in$||g')
|
||||
OUT=$OUT_DIR/$TEST_DIR
|
||||
mkdir -p "$OUT/encoder"
|
||||
mkdir -p "$OUT/decoder"
|
||||
mkdir -p "$OUT/wrapper"
|
||||
for PREFIX in $PREFIXES; do
|
||||
echo "Processing $IN/foo.*"
|
||||
$EMUGEN -i "$PROGDIR/$TEST_DIR/input" -D "$OUT/decoder" -E "$OUT/encoder" -W "$OUT/wrapper" $PREFIX
|
||||
done
|
||||
if ! diff -qr "$PROGDIR/$TEST_DIR/expected" "$OUT"; then
|
||||
if [ "$OPT_TOOL" ]; then
|
||||
$OPT_TOOL "$PROGDIR/$TEST_DIR/expected" "$OUT"
|
||||
else
|
||||
echo "ERROR: Invalid differences between actual and expected output!"
|
||||
diff -burN "$PROGDIR/$TEST_DIR/expected" "$OUT"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All good!"
|
||||
exit 0
|
||||
128
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
vendored
Normal file
128
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "foo_opcodes.h"
|
||||
|
||||
#include "foo_dec.h"
|
||||
|
||||
|
||||
#include "ProtocolUtils.h"
|
||||
|
||||
#include "ChecksumCalculatorThreadInfo.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
|
||||
|
||||
#ifdef OPENGL_DEBUG_PRINTOUT
|
||||
# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(__VA_ARGS__); } } while(0)
|
||||
#else
|
||||
# define DEBUG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_GLERROR
|
||||
# define SET_LASTCALL(name) sprintf(lastCall, #name)
|
||||
#else
|
||||
# define SET_LASTCALL(name) ((void)0)
|
||||
#endif
|
||||
|
||||
using namespace emugl;
|
||||
|
||||
size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream)
|
||||
{
|
||||
|
||||
size_t pos = 0;
|
||||
if (len < 8) return pos;
|
||||
unsigned char *ptr = (unsigned char *)buf;
|
||||
bool unknownOpcode = false;
|
||||
#ifdef CHECK_GL_ERROR
|
||||
char lastCall[256] = {0};
|
||||
#endif
|
||||
while ((len - pos >= 8) && !unknownOpcode) {
|
||||
uint32_t opcode = *(uint32_t *)ptr;
|
||||
size_t packetLen = *(uint32_t *)(ptr + 4);
|
||||
if (len - pos < packetLen) return pos;
|
||||
bool useChecksum = ChecksumCalculatorThreadInfo::getVersion() > 0;
|
||||
size_t checksumSize = 0;
|
||||
if (useChecksum) {
|
||||
checksumSize = ChecksumCalculatorThreadInfo::checksumByteSize();
|
||||
}
|
||||
switch(opcode) {
|
||||
case OP_fooAlphaFunc: {
|
||||
FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8);
|
||||
FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4);
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + 4, ptr + 8 + 4 + 4, checksumSize,
|
||||
"8 + 4 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
|
||||
}
|
||||
DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref);
|
||||
this->fooAlphaFunc(var_func, var_ref);
|
||||
SET_LASTCALL("fooAlphaFunc");
|
||||
break;
|
||||
}
|
||||
case OP_fooIsBuffer: {
|
||||
uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
|
||||
InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff);
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_stuff, ptr + 8 + 4 + size_stuff, checksumSize,
|
||||
"8 + 4 + size_stuff::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
|
||||
}
|
||||
size_t totalTmpSize = sizeof(FooBoolean);
|
||||
totalTmpSize += checksumSize;
|
||||
unsigned char *tmpBuf = stream->alloc(totalTmpSize);
|
||||
DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff);
|
||||
*(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get()));
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::writeChecksum(&tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize);
|
||||
}
|
||||
stream->flush();
|
||||
SET_LASTCALL("fooIsBuffer");
|
||||
break;
|
||||
}
|
||||
case OP_fooUnsupported: {
|
||||
uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
|
||||
InputBuffer inptr_params(ptr + 8 + 4, size_params);
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_params, ptr + 8 + 4 + size_params, checksumSize,
|
||||
"8 + 4 + size_params::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
|
||||
}
|
||||
DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params);
|
||||
this->fooUnsupported((void*)(inptr_params.get()));
|
||||
SET_LASTCALL("fooUnsupported");
|
||||
break;
|
||||
}
|
||||
case OP_fooDoEncoderFlush: {
|
||||
FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8);
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4, ptr + 8 + 4, checksumSize,
|
||||
"8 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
|
||||
}
|
||||
DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param);
|
||||
this->fooDoEncoderFlush(var_param);
|
||||
SET_LASTCALL("fooDoEncoderFlush");
|
||||
break;
|
||||
}
|
||||
case OP_fooTakeConstVoidPtrConstPtr: {
|
||||
uint32_t size_param __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
|
||||
InputBuffer inptr_param(ptr + 8 + 4, size_param);
|
||||
if (useChecksum) {
|
||||
ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_param, ptr + 8 + 4 + size_param, checksumSize,
|
||||
"8 + 4 + size_param::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n");
|
||||
}
|
||||
DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream,(const void* const*)(inptr_param.get()), size_param);
|
||||
this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get()));
|
||||
SET_LASTCALL("fooTakeConstVoidPtrConstPtr");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
unknownOpcode = true;
|
||||
} //switch
|
||||
if (!unknownOpcode) {
|
||||
pos += packetLen;
|
||||
ptr += packetLen;
|
||||
}
|
||||
} // while
|
||||
return pos;
|
||||
}
|
||||
18
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
vendored
Normal file
18
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
#ifndef GUARD_foo_decoder_context_t
|
||||
#define GUARD_foo_decoder_context_t
|
||||
|
||||
#include "IOStream.h"
|
||||
#include "foo_server_context.h"
|
||||
|
||||
|
||||
|
||||
struct foo_decoder_context_t : public foo_server_context_t {
|
||||
|
||||
size_t decode(void *buf, size_t bufsize, IOStream *stream);
|
||||
|
||||
};
|
||||
|
||||
#endif // GUARD_foo_decoder_context_t
|
||||
14
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
vendored
Normal file
14
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __GUARD_foo_opcodes_h_
|
||||
#define __GUARD_foo_opcodes_h_
|
||||
|
||||
#define OP_fooAlphaFunc 200
|
||||
#define OP_fooIsBuffer 201
|
||||
#define OP_fooUnsupported 202
|
||||
#define OP_fooDoEncoderFlush 203
|
||||
#define OP_fooTakeConstVoidPtrConstPtr 204
|
||||
#define OP_last 205
|
||||
|
||||
|
||||
#endif
|
||||
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
vendored
Normal file
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "foo_server_context.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
|
||||
{
|
||||
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);
|
||||
fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_server_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
22
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
vendored
Normal file
22
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_server_context_t_h
|
||||
#define __foo_server_context_t_h
|
||||
|
||||
#include "foo_server_proc.h"
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
|
||||
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;
|
||||
fooTakeConstVoidPtrConstPtr_server_proc_t fooTakeConstVoidPtrConstPtr;
|
||||
virtual ~foo_server_context_t() {}
|
||||
int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
|
||||
};
|
||||
|
||||
#endif
|
||||
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
vendored
Normal file
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_server_proc_t_h
|
||||
#define __foo_server_proc_t_h
|
||||
|
||||
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
#include "emugl/common/logging.h"
|
||||
#ifndef foo_APIENTRY
|
||||
#define foo_APIENTRY
|
||||
#endif
|
||||
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);
|
||||
typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_server_proc_t) (const void* const*);
|
||||
|
||||
|
||||
#endif
|
||||
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
vendored
Normal file
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "foo_client_context.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
|
||||
{
|
||||
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);
|
||||
fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
vendored
Normal file
27
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_client_context_t_h
|
||||
#define __foo_client_context_t_h
|
||||
|
||||
#include "foo_client_proc.h"
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
|
||||
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;
|
||||
fooTakeConstVoidPtrConstPtr_client_proc_t fooTakeConstVoidPtrConstPtr;
|
||||
virtual ~foo_client_context_t() {}
|
||||
|
||||
typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
|
||||
static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
|
||||
int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
|
||||
virtual void setError(unsigned int error){ (void)error; };
|
||||
virtual unsigned int getError(){ return 0; };
|
||||
};
|
||||
|
||||
#endif
|
||||
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
vendored
Normal file
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_client_proc_t_h
|
||||
#define __foo_client_proc_t_h
|
||||
|
||||
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
#include "emugl/common/logging.h"
|
||||
#ifndef foo_APIENTRY
|
||||
#define foo_APIENTRY
|
||||
#endif
|
||||
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);
|
||||
typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_client_proc_t) (void * ctx, const void* const*);
|
||||
|
||||
|
||||
#endif
|
||||
153
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
vendored
Normal file
153
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
vendored
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <string.h>
|
||||
#include "foo_opcodes.h"
|
||||
|
||||
#include "foo_enc.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace {
|
||||
|
||||
void enc_unsupported()
|
||||
{
|
||||
ALOGE("Function is unsupported\n");
|
||||
}
|
||||
|
||||
void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref)
|
||||
{
|
||||
|
||||
foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
|
||||
IOStream *stream = ctx->m_stream;
|
||||
ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
|
||||
bool useChecksum = checksumCalculator->getVersion() > 0;
|
||||
|
||||
unsigned char *ptr;
|
||||
unsigned char *buf;
|
||||
const size_t sizeWithoutChecksum = 8 + 4 + 4;
|
||||
const size_t checksumSize = checksumCalculator->checksumByteSize();
|
||||
const size_t totalSize = sizeWithoutChecksum + checksumSize;
|
||||
buf = stream->alloc(totalSize);
|
||||
ptr = buf;
|
||||
int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4;
|
||||
memcpy(ptr, &totalSize, 4); ptr += 4;
|
||||
|
||||
memcpy(ptr, &func, 4); ptr += 4;
|
||||
memcpy(ptr, &ref, 4); ptr += 4;
|
||||
|
||||
if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
|
||||
if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
|
||||
|
||||
}
|
||||
|
||||
FooBoolean fooIsBuffer_enc(void *self , void* stuff)
|
||||
{
|
||||
|
||||
foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
|
||||
IOStream *stream = ctx->m_stream;
|
||||
ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
|
||||
bool useChecksum = checksumCalculator->getVersion() > 0;
|
||||
|
||||
const unsigned int __size_stuff = (4 * sizeof(float));
|
||||
unsigned char *ptr;
|
||||
unsigned char *buf;
|
||||
const size_t sizeWithoutChecksum = 8 + __size_stuff + 1*4;
|
||||
const size_t checksumSize = checksumCalculator->checksumByteSize();
|
||||
const size_t totalSize = sizeWithoutChecksum + checksumSize;
|
||||
buf = stream->alloc(totalSize);
|
||||
ptr = buf;
|
||||
int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
|
||||
memcpy(ptr, &totalSize, 4); ptr += 4;
|
||||
|
||||
*(unsigned int *)(ptr) = __size_stuff; ptr += 4;
|
||||
memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff;
|
||||
|
||||
if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
|
||||
if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
|
||||
|
||||
|
||||
FooBoolean retval;
|
||||
stream->readback(&retval, 1);
|
||||
if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
|
||||
if (useChecksum) {
|
||||
std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
|
||||
stream->readback(checksumBuf.get(), checksumSize);
|
||||
if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
|
||||
ALOGE("fooIsBuffer: GL communication error, please report this issue to b.android.com.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void fooDoEncoderFlush_enc(void *self , FooInt param)
|
||||
{
|
||||
|
||||
foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
|
||||
IOStream *stream = ctx->m_stream;
|
||||
ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
|
||||
bool useChecksum = checksumCalculator->getVersion() > 0;
|
||||
|
||||
unsigned char *ptr;
|
||||
unsigned char *buf;
|
||||
const size_t sizeWithoutChecksum = 8 + 4;
|
||||
const size_t checksumSize = checksumCalculator->checksumByteSize();
|
||||
const size_t totalSize = sizeWithoutChecksum + checksumSize;
|
||||
buf = stream->alloc(totalSize);
|
||||
ptr = buf;
|
||||
int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4;
|
||||
memcpy(ptr, &totalSize, 4); ptr += 4;
|
||||
|
||||
memcpy(ptr, ¶m, 4); ptr += 4;
|
||||
|
||||
if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
|
||||
if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
|
||||
|
||||
stream->flush();
|
||||
}
|
||||
|
||||
void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param)
|
||||
{
|
||||
|
||||
foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
|
||||
IOStream *stream = ctx->m_stream;
|
||||
ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
|
||||
bool useChecksum = checksumCalculator->getVersion() > 0;
|
||||
|
||||
const unsigned int __size_param = ;
|
||||
unsigned char *ptr;
|
||||
unsigned char *buf;
|
||||
const size_t sizeWithoutChecksum = 8 + __size_param + 1*4;
|
||||
const size_t checksumSize = checksumCalculator->checksumByteSize();
|
||||
const size_t totalSize = sizeWithoutChecksum + checksumSize;
|
||||
buf = stream->alloc(totalSize);
|
||||
ptr = buf;
|
||||
int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4;
|
||||
memcpy(ptr, &totalSize, 4); ptr += 4;
|
||||
|
||||
*(unsigned int *)(ptr) = __size_param; ptr += 4;
|
||||
memcpy(ptr, param, __size_param);ptr += __size_param;
|
||||
|
||||
if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
|
||||
if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
foo_encoder_context_t::foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
|
||||
{
|
||||
m_stream = stream;
|
||||
m_checksumCalculator = checksumCalculator;
|
||||
|
||||
this->fooAlphaFunc = &fooAlphaFunc_enc;
|
||||
this->fooIsBuffer = &fooIsBuffer_enc;
|
||||
this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported;
|
||||
this->fooDoEncoderFlush = &fooDoEncoderFlush_enc;
|
||||
this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc;
|
||||
}
|
||||
|
||||
23
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
vendored
Normal file
23
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
#ifndef GUARD_foo_encoder_context_t
|
||||
#define GUARD_foo_encoder_context_t
|
||||
|
||||
#include "IOStream.h"
|
||||
#include "ChecksumCalculator.h"
|
||||
#include "foo_client_context.h"
|
||||
|
||||
|
||||
#include "fooUtils.h"
|
||||
#include "fooBase.h"
|
||||
|
||||
struct foo_encoder_context_t : public foo_client_context_t {
|
||||
|
||||
IOStream *m_stream;
|
||||
ChecksumCalculator *m_checksumCalculator;
|
||||
|
||||
foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator);
|
||||
};
|
||||
|
||||
#endif // GUARD_foo_encoder_context_t
|
||||
53
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
vendored
Normal file
53
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "foo_client_context.h"
|
||||
|
||||
#ifndef GL_TRUE
|
||||
extern "C" {
|
||||
void fooAlphaFunc(FooInt func, FooFloat ref);
|
||||
FooBoolean fooIsBuffer(void* stuff);
|
||||
void fooUnsupported(void* params);
|
||||
void fooDoEncoderFlush(FooInt param);
|
||||
void fooTakeConstVoidPtrConstPtr(const void* const* param);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef GET_CONTEXT
|
||||
static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
|
||||
void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
|
||||
#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext()
|
||||
#endif
|
||||
|
||||
void fooAlphaFunc(FooInt func, FooFloat ref)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooAlphaFunc(ctx, func, ref);
|
||||
}
|
||||
|
||||
FooBoolean fooIsBuffer(void* stuff)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
|
||||
return ctx->fooIsBuffer(ctx, stuff);
|
||||
}
|
||||
|
||||
void fooUnsupported(void* params)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooUnsupported(ctx, params);
|
||||
}
|
||||
|
||||
void fooDoEncoderFlush(FooInt param)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooDoEncoderFlush(ctx, param);
|
||||
}
|
||||
|
||||
void fooTakeConstVoidPtrConstPtr(const void* const* param)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooTakeConstVoidPtrConstPtr(ctx, param);
|
||||
}
|
||||
|
||||
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
vendored
Normal file
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_client_ftable_t_h
|
||||
#define __foo_client_ftable_t_h
|
||||
|
||||
|
||||
static const struct _foo_funcs_by_name {
|
||||
const char *name;
|
||||
void *proc;
|
||||
} foo_funcs_by_name[] = {
|
||||
{"fooAlphaFunc", (void*)fooAlphaFunc},
|
||||
{"fooIsBuffer", (void*)fooIsBuffer},
|
||||
{"fooUnsupported", (void*)fooUnsupported},
|
||||
{"fooDoEncoderFlush", (void*)fooDoEncoderFlush},
|
||||
{"fooTakeConstVoidPtrConstPtr", (void*)fooTakeConstVoidPtrConstPtr},
|
||||
};
|
||||
static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name);
|
||||
|
||||
|
||||
#endif
|
||||
14
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
vendored
Normal file
14
external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __GUARD_foo_opcodes_h_
|
||||
#define __GUARD_foo_opcodes_h_
|
||||
|
||||
#define OP_fooAlphaFunc 200
|
||||
#define OP_fooIsBuffer 201
|
||||
#define OP_fooUnsupported 202
|
||||
#define OP_fooDoEncoderFlush 203
|
||||
#define OP_fooTakeConstVoidPtrConstPtr 204
|
||||
#define OP_last 205
|
||||
|
||||
|
||||
#endif
|
||||
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
vendored
Normal file
20
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "foo_wrapper_context.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
|
||||
{
|
||||
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);
|
||||
fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_wrapper_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
25
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
vendored
Normal file
25
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_wrapper_context_t_h
|
||||
#define __foo_wrapper_context_t_h
|
||||
|
||||
#include "foo_server_proc.h"
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
|
||||
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;
|
||||
fooTakeConstVoidPtrConstPtr_wrapper_proc_t fooTakeConstVoidPtrConstPtr;
|
||||
virtual ~foo_wrapper_context_t() {}
|
||||
|
||||
typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void);
|
||||
static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
|
||||
int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
|
||||
};
|
||||
|
||||
#endif
|
||||
52
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
vendored
Normal file
52
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "foo_wrapper_context.h"
|
||||
|
||||
#ifndef GL_TRUE
|
||||
extern "C" {
|
||||
void fooAlphaFunc(FooInt func, FooFloat ref);
|
||||
FooBoolean fooIsBuffer(void* stuff);
|
||||
void fooUnsupported(void* params);
|
||||
void fooDoEncoderFlush(FooInt param);
|
||||
void fooTakeConstVoidPtrConstPtr(const void* const* param);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef GET_CONTEXT
|
||||
static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
|
||||
void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
|
||||
#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext()
|
||||
#endif
|
||||
|
||||
void fooAlphaFunc(FooInt func, FooFloat ref)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooAlphaFunc( func, ref);
|
||||
}
|
||||
|
||||
FooBoolean fooIsBuffer(void* stuff)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
return ctx->fooIsBuffer( stuff);
|
||||
}
|
||||
|
||||
void fooUnsupported(void* params)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooUnsupported( params);
|
||||
}
|
||||
|
||||
void fooDoEncoderFlush(FooInt param)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooDoEncoderFlush( param);
|
||||
}
|
||||
|
||||
void fooTakeConstVoidPtrConstPtr(const void* const* param)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->fooTakeConstVoidPtrConstPtr( param);
|
||||
}
|
||||
|
||||
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
vendored
Normal file
21
external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Generated Code - DO NOT EDIT !!
|
||||
// generated by 'emugen'
|
||||
#ifndef __foo_wrapper_proc_t_h
|
||||
#define __foo_wrapper_proc_t_h
|
||||
|
||||
|
||||
|
||||
#include "foo_types.h"
|
||||
|
||||
#include "emugl/common/logging.h"
|
||||
#ifndef foo_APIENTRY
|
||||
#define foo_APIENTRY
|
||||
#endif
|
||||
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);
|
||||
typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_wrapper_proc_t) (const void* const*);
|
||||
|
||||
|
||||
#endif
|
||||
15
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib
vendored
Normal file
15
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
GLOBAL
|
||||
base_opcode 200
|
||||
encoder_headers "fooUtils.h" "fooBase.h"
|
||||
|
||||
fooIsBuffer
|
||||
dir stuff in
|
||||
len stuff (4 * sizeof(float))
|
||||
param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
|
||||
|
||||
fooUnsupported
|
||||
dir params in
|
||||
flag unsupported
|
||||
|
||||
fooDoEncoderFlush
|
||||
flag flushOnEncode
|
||||
5
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in
vendored
Normal file
5
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
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)
|
||||
FOO_ENTRY(void, fooTakeConstVoidPtrConstPtr, const void* const* param)
|
||||
10
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types
vendored
Normal file
10
external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
FooBoolean 8 %d
|
||||
FooInt 32 %d
|
||||
FooShort 16 %d
|
||||
FooFloat 32 %f
|
||||
FooEnum 32 %08x
|
||||
FooVoid 0 %x
|
||||
FooChar 8 %d
|
||||
FooChar* 32 0x%08x
|
||||
void* 32 0x%08x
|
||||
void*const* 32 0x%08x
|
||||
Loading…
Add table
Add a link
Reference in a new issue